|
|
| Line 1: |
Line 1: |
| * [http://people.mozilla.org/~jdicarlo/tpm.xpi Install the Extension on your Mobile Firefox] | | * [http://people.mozilla.org/~jdicarlo/tpm.xpi Install the Extension on your Mobile Firefox] |
|
| |
|
| {{{
| | * Copy the sample code from [https://testpilot.mozillalabs.com/testcases/mobile/mobile-example-study.js the mobile example study]. |
| MobileBase = require("mobile-base.js");
| |
| | |
| var things = MobileBase.makeStudy({
| |
| testName: "Mobile Example 2",
| |
| summary: "This study simply counts the times you hit the forward and back buttons.",
| |
| dataPlotExplanation: "This is an example study that simply counts the times you hit the"
| |
| + " forward and back buttons.",
| |
| databaseColumns: [
| |
| {property: "elem", type: MobileBase.TYPE_STRING, displayName: "What you did"},
| |
| {property: "timestamp", type: MobileBase.TYPE_DOUBLE, displayName: "When you did it"}],
| |
| | |
| onExperimentStartup: function(testPilot) {
| |
| testPilot.watch("tool-back", "click", {elem: "Back"});
| |
| testPilot.watch("tool-forward", "click", {elem: "Forward"});
| |
| },
| |
| | |
| drawDataPlot: function(rawData, callback) {
| |
| //initialize counts
| |
| let counts = {};
| |
| counts["Back"] = 0;
| |
| counts["Forward"] = 0;
| |
| for each (let row in rawData) {
| |
| counts[row.elem]++;
| |
| }
| |
| | |
| let elemData = [];
| |
| let axisLabels = [];
| |
| let i = 0;
| |
| for(let e in counts) {
| |
| elemData.push([i, counts[e]]);
| |
| axisLabels.push([i+0.5, e]);
| |
| i += 1;
| |
| }
| |
| | |
| callback([{data: elemData}],
| |
| {series: {bars: {show: true}},
| |
| xaxis: {ticks: axisLabels},
| |
| yaxis: {tickDecimals: 0}});
| |
| }
| |
| | |
| });
| |
| | |
| exports.experimentInfo = things.experimentInfo;
| |
| exports.dataStoreInfo = things.dataStoreInfo;
| |
| exports.webContent = things.webContent;
| |
| exports.handlers = things.handlers;
| |
| }}}
| |