diff options
author | Matěj Cepl <mcepl@redhat.com> | 2010-01-01 17:04:12 +0100 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2010-01-01 17:04:12 +0100 |
commit | 64692372e6f70a0225e32b606c093f4cacbf347b (patch) | |
tree | ab0799f7fe0d7edbfd7eaad0a559dae2e577e4a0 /bugzillaBugTriage.js | |
parent | 33df5f4a8b7846ff1da6550fa7e10735acfa5746 (diff) | |
download | bugzilla-triage-64692372e6f70a0225e32b606c093f4cacbf347b.tar.gz |
Final dejQuerization!!!
Diffstat (limited to 'bugzillaBugTriage.js')
-rw-r--r-- | bugzillaBugTriage.js | 69 |
1 files changed, 48 insertions, 21 deletions
diff --git a/bugzillaBugTriage.js b/bugzillaBugTriage.js index 63b17ae..6a4089a 100644 --- a/bugzillaBugTriage.js +++ b/bugzillaBugTriage.js @@ -1,5 +1,5 @@ -/*jslint onevar: false, browser: true, evil: true, laxbreak: true, undef: true, nomen: true, eqeqeq: true, bitwise: true, maxerr: 1000, immed: false, white: false, plusplus: false, regexp: false, undef: false */ -/*global jQuery, $, jetpack */ +f/*jslint onevar: false, browser: true, evil: true, laxbreak: true, undef: true, nomen: true, eqeqeq: true, bitwise: true, maxerr: 1000, immed: false, white: false, plusplus: false, regexp: false, undef: false */ +/*global jetpack */ // Released under the MIT/X11 license // http://www.opensource.org/licenses/mit-license.php @@ -125,14 +125,17 @@ loadJSON(PCIIDsURL, //============================================================== -loadJSON = function(URL, cb_function) { +loadText = function(URL, cb_function,what) { + if (what === undefined) { // missing optional argument + what = this; + } + var req = new XMLHTTPRequest(); req.open("GET",URL,true); req.onreadystatechange = function (aEvt) { if (req.readyState == 4) { if (req.status == 200) { - var data = JSON.parse(req.responseText); - cb_function(data); + cb_function.apply(req.responseText,what); } else { throw "Getting " + URL + "failed!" ; } @@ -141,6 +144,17 @@ loadJSON = function(URL, cb_function) { req.send(""); }; +loadJSON = function(URL, cb_function) { + if (what === undefined) { // missing optional argument + what = this; + } + + loadText(URL,function (text) { + var data = JSON.parse(req.responseText); + cb_function.apply(data,what); + }); +}; + /** * select element of the array where regexp in the first element matches second parameter * of this function @@ -490,7 +504,7 @@ BzPage.prototype.getVersion = function () { BzPage.prototype.clickMouse = function(target) { var localEvent = this.dok.createEvent("MouseEvents"); localEvent.initMouseEvent("click", true, true, - this.doc.defaultView, + this.dok.defaultView, 0, 0, 0, 0, 0, false, false, false, false, 0, null); target.dispatchEvent(localEvent); }; @@ -929,11 +943,12 @@ BzPage.prototype.parseAttachmentLine = function (inElem) { var attName = inElem.getElementsByTagName("b")[0].textContent.trim(); // getting id + // $("a:contains('Details')", inElem); + // FIXME isn't there more simple way to replace above? querySelector? var aHrefsArr = inElem.getElementsByTagName("a"); var aHref = Array.filter(aHrefsArr,function (x) { return x.textContent.trim() == "Details"; }); -// $("a:contains('Details')", inElem); //FIXME isn't there more simple way? var id = parseInt(aHrefs.attr("href").replace(/^.*attachment.cgi\?id=/, ""),10); //getting MIME type and size @@ -1151,16 +1166,21 @@ BzPage.prototype.createXMLRPCMessage = function(login,password,attachId,mimeType */ BzPage.prototype.fixAttachById = function(id,type) { var msg = this.createXMLRPCMessage(this.login,this.password,id,type); - var ret = $.ajax({ // FIXME jQuery - type: "POST", - url: XMLRPCurl, - success: this.callBack, - contentType: "text/xml", - data: msg, - processData: false, - dataType: "xml" - }); - + var req = new XMLHTTPRequest(); + req.open("POST",XMLRPCurl,true); + req.overrideMimeType("text/xml"); + req.setRequestHeader("Content-type","text/xml"); + req.onreadystatechange = function (aEvt) { + if (req.readyState == 4) { + if (req.status == 200) { + console.log("Fixing attachment MIME type success!"); + that.callBack(); + } else { + console.error("Fixing MIME type attachment failed!"); + } + } + }; + req.send(msg); this.reqCounter++; }; @@ -1466,11 +1486,18 @@ BzPage.prototype.buildButtons = function (above,below) { /////////////////////////////////////////////////////////////////////////////// function BzPage(doc) { - this.doc = $(doc); this.dok = doc; var that = this; this.originalButton = this.dok.getElementById("commit"); - var loginArr = $("#header ul:first li:last", this.doc).text().split("\n"); + + // FIXME more elegant way to do this with querySelector? + // var loginArr = $("#header ul:first li:last", this.doc). + // text().split("\n"); + var loginArrLiElements = this.dok.getElementById("header"). + getElementsByTagName("ul")[0]. + getElementsByTagName("li"); + var loginArr = loginArrLiElements[loginArrLiElements.length-1]. + textContent.split("\n"); this.login = loginArr[loginArr.length-1].trim(); this.password = ""; if (myConfig.BZpassword) { @@ -1491,7 +1518,7 @@ function BzPage(doc) { } } - var bugNoTitle = $("#title > p:first", this.doc).text().trim(); + var bugNoTitle = this.dok.querySelector("#title > p").textContent.trim(); this.bugNo = new RegExp("[0-9]+").exec(bugNoTitle)[0]; this.reporter = this.getReporter(); @@ -1569,7 +1596,7 @@ function BzPage(doc) { console.log("attURL = " + attURL); console.log("btSnippet = " + this.btSnippet); if (!this.btSnippet) { - var btRaw = $.get(attURL,function (ret) { + var btRaw = loadText(attURL,function (ret) { this.btSnippet = this.parseBacktrace(ret); if (this.btSnippet) { this.addTextToTextBox("comment",this.btSnippet); |