How does the 'new' messages concept work? - client-side

On a forum or email client you can see the difference between the old and the new messages by style (the new messages from the last visit are bold for example).
Can you tell me - How is that implemented?

This is not a straightforward question... it depends on the e-mail client you are using.
In the case of Mozilla Thunderbird, we can easily view the source online to check it out. The way they do it is by applying a different style in their stylesheet for read vs. unread messages:
47 treechildren::-moz-tree-cell-text(read) {
48 font-weight: normal;
49 }
50
51 treechildren::-moz-tree-cell-text(unread) {
52 font-weight: bold;
53 }
Somehow they get the "unread" flag from the data store up to the UI presentation layer and apply the correct style based on if the message is read or unread. How they do that is left as an exercise to the reader. ;-)

Related

How to analyze weird Goal Flow results? Is it possible to view specific users' journeys?

To help analyzing a site's user flow, I wrote a test bed in JavaScript, creating a new fake tracker, sending a few fake pageviews in like 1-2 second intervals according to a pretty extensive, randomized graph of expected views. I then set up goals in GA, containing funnels through certain pages. Then I left it running for a few hours, accumulating a few hundreds fake users.
Raw goal conversion percentages look good, page content flows too, BUT... when I'm looking at Goal Flow, some of the connections in the funnels don't make sense. For example 80% of my fake users seem to go from step "about" directly to step "success", skipping "product" and "payment", while - according to my test setup - that can't ever happen. (Step names used are examples to match the code below.)
I'd like to see exactly what paths did these particular users take - did some pages just not register, or did they register out of order, or what? Is there any way I can view RAW user journeys in GA, page by page?
For those interested, the testing code is basically like this:
ga("create","UA-0000000-2", "auto", "testtracker", {
'cookieName':"_ga_test_"+Date.now(),
'cookieExpires':120,
'clientId': 'cid-'+Date.now(),
});
var spd=1500;
var delay=0;
function pageview(page) {
setTimeout(function() {
ga("testtracker.send","pageview",page);
console.log("Sending: "+page);
},delay+=spd);
}
pageview("start");
if (Math.random()<.60) pageview("about");
if (Math.random()<.30) {
pageview("product");
if (Math.random()<.20) {
pageview("payment");
if (Math.random()<.70) {
pageview("success");
}
}
}
Apparently, I still have a lot to learn about GA.
The solution is to use Audience -> User Explorer and defining a very specific Section based on the suspicious sequence of pages does show individual users matching that pattern. And indeed somehow GA logged a pretty large number of such odd users for me, perhaps failing to register pages visited in too narrow time intervals.
I'm leaving the question for posterity, and perhaps for those who can find my code snippet useful.

What is the value of ul (User Language) in Google Analytics Measurement protocol

I am building a server side application that needs to report data to GA via Measurement Protocol.
I want to fill the languages that the user have, from the documentation:
https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#ul
It seems the right parameter is called ul and an example value is en-us.
My questions are:
which kind of langague identifier it accepts? the documentation isn't clear on that. My guess is that following the "en-us" example suggests it is based on Accept-Language header so probably ISO-639-1 +ISO-3166)
It only has space for 20 bytes, so does it means you can't send multiple langagues?
Does the reporting show multiple languages?
If you goto Google Analytics Dashboard -> Audience -> Geo -> Language and hover over the help icon next to language column you get this popup -
It apparently uses ISO 639 language codes.
Only one language can be sent per hit. It is not a multi value property.
(2) above makes it obvious what reports can show
In the documentation (as of aug '18), the following is shown:
Optional. Specifies the language.
Parameter Value | Type | Default Value | Max Length | Supported Hit Types
ul text None 20 Bytes all
Example value: en-us
Example usage: ul=en-us

Run Javascript on the body of a Gmail message

I want to display LaTeX math in the gmail messages that I receive, so that for example $\mathbb P^2$ would show as a nice formula. Now, there are several Javascripts available (for example, this one, or MathJax which would do the job, I just need to call them at the right time to manipulate the gmail message.
I know that this is possible to do in "basic HTML" and "print" views. Is it possible to do in the standard Gmail view? I tried to insert a call to the javascript right before the "canvas_frame" iframe, but that did not work.
My suspicion is that manipulating a Gmail message by any Javascript would be a major security flaw (think of all the malicious links one could insert) and that Google does everything to prevent this. And so the answer to my question is probably 'no'. Am I right in this?
Of course, it would be very easy for Google to implement viewing of LaTeX and MathML math simply by using MathJax on their servers. I made the corresponding Gmail Lab request, but no answer, and no interest from Google apparently.
So, again: is this possible to do without Google's cooperation, on the client side?
I think one of the better ways to do this might be to embed images using the Google Charts API.
<img src="http://chart.apis.google.com/chart?cht=tx&chl=x=\frac{-b%20\pm%20\sqrt{b^2-4ac}}{2a}">
To Learn more: https://developers.google.com/chart/image/ [note, the API has been officially deprecated, but will work until April 2015]
If you really must use LaTeX and some js library, I think one way you could accomplish this is by injecting a script tag into the iframe.
I hope this is a good starting point.
Example:
// ==UserScript==
// #name Test Gmail Alterations
// #version 1
// #author Justen
// #description Test Alter Email
// #include https://mail.google.com/mail/*
// #include http://mail.google.com/mail/*
// #license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
// ==/UserScript==
(function GmailIframeInject() {
GM_log('Starting GMail iFrame Injection');
var GmailCode = function() {
// Your code here;
// The ':pd' (div id) changes, so you might have to do some extra work
var mail = document.getElementById(':pd');
mail.innerHTML = '<h1>Hello, World!</h1>';
};
var iframe = document.getElementById('canvas_frame');
var doc = null;
if( iframe ) {
GM_log('Got iFrame');
doc = iframe.contentDocument;
} else {
GM_log('ERROR: Could not get iframe with id canvas_frame');
return
}
if( doc ) {
GM_log('Injecting GmailCode');
var code = "(" + GmailCode + ")();"
doc.body.appendChild(doc.createElement('script')).innerHTML=code;
} else {
GM_log('ERROR: Could not get iframe content document');
return;
}
})();
Well, there are already greasemonkey scripts that do things to GMail as far as i know (like this one). Is this a possible security hole? Of course, anything you'd do with executable code has that risk. Google seems to move a glacial speeds on things they're not interested in. They really do seem to function based on internal championing of ideas, so best way forward is to go find sympathetic googlers, if you want them to include something into GMail. Otherwise stick to Greasemonkey, at least you'll have an easy install path for other people who'd like to see the same functionality.

When listening for keypress in Flash Lite should I be listening for Key.Down or the numeric code for this key?

The adobe documentation says that when listening for a keypress event from a phone you should listen for Key.Down, however when I trace the Key.getCode() of keypresses I see a number not the string "Key.Down". I am tesing this locally in device central and do not have a phone to test this with at present. Here is my code -
keyListener = new Object();
keyListener.onKeyDown = function() {
switch (Key.getCode()) {
trace(Key.getCode()) // outputs 40
case (Key.DOWN) : // according to the docs
pressDown();
break;
}
}
My question is - is this simply because Im testing in device central and when I run it on the phone I will need to be listening for Key.Down? or is the documentation wrong? Also is the numeric code (40) consistent across all devices? What gives adobe?
thanks all
Key.Down is equal to 40 so it will recognize it as the same. So you can use whichever one you prefer, however, I would recommend using Key.Down because it will be easily recognizeable for those who dont have Key Codes memorized (most of us).
These are the Key Code Values for Javascript. However, I think they are pretty much universal

Making mixed numeric and alpha entry easier for mobile browers

I'm refurbishing a simple web-app that our field techs use. One of my goals is to make it Blackberry-friendly, as all of the techs are now using those. This app accepts basic information about a job and stores it. Among that info are times, telephone numbers, and a street address.
I have the time fields and telephone fields figured out with the following CSS:
input.time { -wap-input-format: "NN\\:NN"; }
input.phone { -wap-input-format: "\\(nnn\\)\\ nnn\\-nnnn" }
What I'm trying to do is determine how I can have the phone default to numeric input on an address field, then go alpha once a space has been inserted. I'm assuming that this can't be done with the -wap-input-format property above.
Is there another way--even if it's only for the Blackberry Browser--to do this without resorting to JavaScript? (Not that there's anything wrong with that :-) )
Thanks.
Have you considered a "Street Number" field followed by a separate "Street Name" field? There is no way to have a variable number of digits at the start of this sort WAP input field without using JavaScript.
I've found that javascript alone is the only way to do a decent job of subtle user input validation. Markup creates more challenges than it solves. With js you can let whatever keystrokes mean whatever you want, customized to any context.

Resources