← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~imbrandon/js-oopsd/jspost into lp:js-oopsd

 

Brandon Holtsclaw has proposed merging lp:~imbrandon/js-oopsd/jspost into lp:js-oopsd.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~imbrandon/js-oopsd/jspost/+merge/123442

change from http GET to POST in jsoops.js
-- 
https://code.launchpad.net/~imbrandon/js-oopsd/jspost/+merge/123442
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~imbrandon/js-oopsd/jspost into lp:js-oopsd.
=== modified file 'js/jsoops.js'
--- js/jsoops.js	2012-08-10 05:53:08 +0000
+++ js/jsoops.js	2012-09-09 12:13:20 +0000
@@ -6,25 +6,16 @@
   REPORTER : '',
   EndPoint : 'https://js-oopsd-endpoint.example.com/',
   handle: function (msg,url,line) {
-    var request = document.createElement('iframe');
-    request.style.width   = '1px';
-    request.style.height  = '1px';
-    request.style.display = 'none';
     var data = new Object();;
     data.msg = msg;
     data.url = url;
     data.line = line;
     data.lang = "js";
     data.reporter = jsoops.REPORTER;
-    var api_url = jsoops.EndPoint + '?' + jsoops.customEscape(data);
-    request.src = api_url;
-    if (document.body) {
-      document.body.appendChild(request);
-    } else{
-      addLoadEvent(function() {
-        document.body.appendChild(request);
-      });
-    };
+    var xhr = new XMLHttpRequest();
+    xhr.open("POST", jsoops.EndPoint);
+    xhr.setRequestHeader('Content-Type', 'application/json');
+    xhr.send(JSON.stringify(data));
     return api_url;
   },
   setEndPoint: function (host) {
@@ -46,20 +37,6 @@
   jsoops.handle(msg,url,line);
 };
 
-function addLoadEvent(func) {
-  var oldonload = window.onload;
-  if (typeof window.onload != 'function') {
-    window.onload = func;
-  } else {
-    window.onload = function() {
-      if (oldonload) {
-        oldonload();
-      }
-      func();
-    };
-  }
-}
-
 // add JSON support - from here https://github.com/douglascrockford/JSON-js (Public domain)
 if(!this.JSON)this.JSON={};
 (function(){function k(a){return a<10?"0"+a:a}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+k(this.getUTCMonth()+1)+"-"+k(this.getUTCDate())+"T"+k(this.getUTCHours())+":"+k(this.getUTCMinutes())+":"+k(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()}}var n=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,o=