Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: lib/survey.js

Issue 8382011: Applied changes from emailed code review (Closed)
Left Patch Set: Created Sept. 18, 2012, 2:06 p.m.
Right Patch Set: Created Sept. 28, 2012, 1:40 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « lib/rules.js ('k') | lib/typedItCollector.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* This Source Code Form is subject to the terms of the Mozilla Public 1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
4 4
5 Cu.import("resource://gre/modules/Services.jsm"); 5 Cu.import("resource://gre/modules/Services.jsm");
6 6
7 let {Prefs} = require("prefs"); 7 let {Prefs} = require("prefs");
8 8
9 let surveyLang = null; 9 let surveyLang = null;
10 let surveyUrl = "http://urlfixer.org"; //"http://adblockplus.org/usersurvey/inde x.php?sid=68316"; 10 let surveyUrl = null; //"http://urlfixer.org/usersurvey/...";
11 11
12 exports.incrementCorrectionsCounter = incrementCorrectionsCounter; 12 exports.incrementCorrectionsCounter = incrementCorrectionsCounter;
13 function incrementCorrectionsCounter() 13 function incrementCorrectionsCounter()
14 { 14 {
15 // Only if survey exists
16 if (!surveyUrl)
17 return;
18
15 // Only users with 5 URL corrections 19 // Only users with 5 URL corrections
16 if (++Prefs.corrections_count == 5) 20 if (++Prefs.corrections_count == 5)
17 { 21 {
18 initSurvey(); 22 initSurvey();
19 } 23 }
20 } 24 }
21 25
22 function initSurvey() 26 function initSurvey()
23 { 27 {
24 // Don't ask after 2012-10-15 28 // Don't ask after 2012-10-15
(...skipping 14 matching lines...) Expand all
39 return; 43 return;
40 surveyLang = RegExp.$1; 44 surveyLang = RegExp.$1;
41 45
42 // Delay survey question by 5 seconds 46 // Delay survey question by 5 seconds
43 surveyTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); 47 surveyTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
44 surveyTimer.initWithCallback(runSurvey, 5000, Ci.nsITimer.TYPE_ONE_SHOT); 48 surveyTimer.initWithCallback(runSurvey, 5000, Ci.nsITimer.TYPE_ONE_SHOT);
45 } 49 }
46 50
47 function runSurvey() 51 function runSurvey()
48 { 52 {
49 Services.wm.getMostRecentWindow("navigator:browser").openDialog("chrome://url- fixer/content/survey.xul", "survey", "top=100,left=300,chrome,dialog,dependent") ; 53 //open panel
Wladimir Palant 2012/09/21 14:40:25 a) I'm not insisting on using 80 characters as lin
54 let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci. nsIXMLHttpRequest);
55 request.open("GET", "chrome://url-fixer/content/survey.xul");
56 request.addEventListener("load", function(event)
57 {
58 let window = Services.wm.getMostRecentWindow("navigator:browser");
59 let document = window.document;
60
61 let style = document.createProcessingInstruction('xml-stylesheet', 'href="ch rome://url-fixer/skin/survey.css" type="text/css"');
62 document.insertBefore(style, document.firstChild);
63
64 let panel = new window.DOMParser().parseFromString(request.responseText, "te xt/xml").documentElement;
65 let oldPanel = document.getElementById(panel.id);
66 if (oldPanel)
67 oldPanel.parentNode.removeChild(oldPanel);
68 document.getElementById("mainPopupSet").appendChild(panel);
69 document.getElementById("url-fixer-icon").setAttribute("src", require("info" ).addonRoot + "icon64.png");
70 document.getElementById("url-fixer-accept-button").addEventListener("command ", function()
71 {
72 openSurvey();
73 panel.hidePopup();
74 });
75 document.getElementById("url-fixer-cancel-button").addEventListener("command ", function()
76 {
77 panel.hidePopup();
78 });
79 panel.addEventListener("popuphidden", function()
80 {
81 panel.parentNode.removeChild(panel);
82 style.parentNode.removeChild(style);
83 });
84
85 let anchor = document.getElementById("identity-box");
86 panel.openPopup(anchor, "after_start", 0, 0, false, true);
87 }, false);
88 request.send(null);
50 } 89 }
51 90
52 exports.openSurvey = openSurvey;
53 function openSurvey() 91 function openSurvey()
54 { 92 {
55 require("appIntegration").getBrowser(Services.wm.getMostRecentWindow("navigato r:browser")).loadOneTab(surveyUrl + "&lang=" + surveyLang, { 93 let window = Services.wm.getMostRecentWindow("navigator:browser");
Wladimir Palant 2012/09/21 14:40:25 Same here - line too long and result of getMostRec
56 referrerURI: Services.io.newURI("http://url.fixer/", null, null), 94 if (window)
57 inBackground: false 95 {
58 }); 96 let browser = require("appIntegration").getBrowser(window);
97 browser.loadOneTab(surveyUrl + "&lang=" + surveyLang, {
98 referrerURI: Services.io.newURI("http://url.fixer/", null, null),
99 inBackground: false
100 });
101 }
59 } 102 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld