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

Proposed by Brandon Holtsclaw
Status: Needs review
Proposed branch: lp:~imbrandon/js-oopsd/jspost
Merge into: lp:js-oopsd
Diff against target: 56 lines (+5/-28)
1 file modified
js/jsoops.js (+5/-28)
To merge this branch: bzr merge lp:~imbrandon/js-oopsd/jspost
Reviewer Review Type Date Requested Status
Richard Harding (community) Approve
Review via email: mp+123442@code.launchpad.net

Description of the change

change from http GET to POST in jsoops.js

To post a comment you must log in.
lp:~imbrandon/js-oopsd/jspost updated
14. By Brandon Holtsclaw

typo

Revision history for this message
Richard Harding (rharding) wrote :

Thanks for the update to POST. It'd be nice to have tests to go with this, but as this is it looks ok.

review: Approve

Unmerged revisions

14. By Brandon Holtsclaw

typo

13. By Brandon Holtsclaw

cleanup of unused code

12. By Brandon Holtsclaw

adding xhr post to jsoops.js

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'js/jsoops.js'
2--- js/jsoops.js 2012-08-10 05:53:08 +0000
3+++ js/jsoops.js 2012-09-10 19:50:22 +0000
4@@ -6,26 +6,17 @@
5 REPORTER : '',
6 EndPoint : 'https://js-oopsd-endpoint.example.com/',
7 handle: function (msg,url,line) {
8- var request = document.createElement('iframe');
9- request.style.width = '1px';
10- request.style.height = '1px';
11- request.style.display = 'none';
12 var data = new Object();;
13 data.msg = msg;
14 data.url = url;
15 data.line = line;
16 data.lang = "js";
17 data.reporter = jsoops.REPORTER;
18- var api_url = jsoops.EndPoint + '?' + jsoops.customEscape(data);
19- request.src = api_url;
20- if (document.body) {
21- document.body.appendChild(request);
22- } else{
23- addLoadEvent(function() {
24- document.body.appendChild(request);
25- });
26- };
27- return api_url;
28+ var xhr = new XMLHttpRequest();
29+ xhr.open("POST", jsoops.EndPoint);
30+ xhr.setRequestHeader('Content-Type', 'application/json');
31+ xhr.send(JSON.stringify(data));
32+ return url;
33 },
34 setEndPoint: function (host) {
35 jsoops.EndPoint = host;
36@@ -46,20 +37,6 @@
37 jsoops.handle(msg,url,line);
38 };
39
40-function addLoadEvent(func) {
41- var oldonload = window.onload;
42- if (typeof window.onload != 'function') {
43- window.onload = func;
44- } else {
45- window.onload = function() {
46- if (oldonload) {
47- oldonload();
48- }
49- func();
50- };
51- }
52-}
53-
54 // add JSON support - from here https://github.com/douglascrockford/JSON-js (Public domain)
55 if(!this.JSON)this.JSON={};
56 (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=

Subscribers

People subscribed via source and target branches

to all changes: