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

Unified Diff: lib/typedItCollector.js

Issue 8382011: Applied changes from emailed code review (Closed)
Patch Set: Applied remaining changes Created Sept. 26, 2012, 9:02 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lib/typedItCollector.js
===================================================================
--- a/lib/typedItCollector.js
+++ b/lib/typedItCollector.js
@@ -148,46 +148,28 @@
{
if (!Prefs.domainOptIn || (domains.length == 0 && falsePositives.length == 0 && userCorrections.length == 0) || privateBrowsingEnabled())
return;
-
- let args = [];
+
+ let postData = {};
let savedDomains = domains;
let savedFalsePositives = falsePositives;
let savedUserCorrections = userCorrections;
if(domains.length > 0)
{
- args.push(domains.map(function(d) "domains[]=" + encodeURIComponent(d)).join("&"));
+ postData.domains = domains;
domains = [];
}
if(falsePositives.length > 0)
{
- args.push(
- falsePositives.map(
- function(fp)
- {
- return "falsePositives[]=" + encodeURIComponent(
- encodeURIComponent(fp[0]) + ((fp[1]) ? "&" + encodeURIComponent(fp[1]) : "")
- );
- }
- ).join("&")
- );
+ postData.falsePositives = falsePositives;
falsePositives = [];
}
if(userCorrections.length > 0)
{
- args.push(
- userCorrections.map(
- function(uc)
- {
- return "userCorrections[]=" + encodeURIComponent(
- encodeURIComponent(uc[0]) + ((uc[1]) ? "&" + encodeURIComponent(uc[1]) : "")
- );
- }
- ).join("&")
- );
+ postData.userCorrections = userCorrections;
userCorrections = [];
}
-
+
let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest);
request.open("POST", "http://typed.it/submitData");
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
@@ -200,7 +182,7 @@
userCorrections = userCorrections.concat(savedUserCorrections);
}
}, false);
- request.send(args.join("&"));
+ request.send("data=" + JSON.stringify(postData));
}
function initWebUI(event)

Powered by Google App Engine
This is Rietveld