From 3984d5d9da633979c8771fc815fe8fe8782d8163 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Fri, 1 Jan 2010 14:18:57 +0100 Subject: Further dejquerization. --- bugzillaBugTriage.js | 105 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 74 insertions(+), 31 deletions(-) diff --git a/bugzillaBugTriage.js b/bugzillaBugTriage.js index 43c27b5..39ec625 100644 --- a/bugzillaBugTriage.js +++ b/bugzillaBugTriage.js @@ -100,7 +100,7 @@ var topRow = {}; var bottomRow = {}; // Get JSON configuration data -$.getJSON(jsonDataURL, function (response) { +loadJSON(jsonDataURL, function (response) { msgStrs = response.strings; signatureFedoraString = response.signature; suspiciousComponents = response.suspiciousComponents; @@ -118,13 +118,29 @@ $.getJSON(jsonDataURL, function (response) { }); // Get card translation table -$.getJSON(PCIIDsURL, +loadJSON(PCIIDsURL, function (response) { PCI_ID_Array = response; }); //============================================================== +loadJSON = function(URL, cb_function) { + 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); + } else { + throw "Getting " + URL + "failed!" ; + } + } + }; + req.send(""); +}; + /** * select element of the array where regexp in the first element matches second parameter * of this function @@ -741,20 +757,28 @@ BzPage.prototype.addNewButton = function (originalLocation,newId,newLabel, if (msgStrs[commentString]) { commStr = msgStrs[commentString]; } - var newButton = $(this.originalButton,this.doc).clone(true).attr({ - "id":newId, - "value":newLabel - }).click(function (evt) { - that.generalPurposeCureForAllDisease(commStr,nState, secPar); - }); + var newButton = this.dok.createElement("input"); + newButton.setAttribute("id",newId); + if (doSubmit) { + newButton.setAttribute("type","submit"); + } else { + newButton.setAttribute("type","button"); + } + newButton.value = newLabel; + newButton.addEventListener("click",function (evt) { + that.generalPurposeCureForAllDisease(commStr,nState, secPar); + },true); if (after) { - $(originalLocation, this.doc).after(newButton).after("\u00A0"); + originalLocation.parentNode.insertBefore(newButton, + originalLocation.nextSibling); + originalLocation.parentNode. + insertBefore(this.dok.createTextNode("\u00A0"),newButton); } else { - $(originalLocation, this.doc).before(newButton).before("\u00A0"); - } - if (!doSubmit) { - newButton.get(0).setAttribute("type","button"); + originalLocation.parentNode.insertBefore(newButton, + originalLocation); + originalLocation.parentNode. + insertBefore(this.dok.createTextNode("\u00A0"),originalLocation); } }; @@ -786,20 +810,35 @@ BzPage.prototype.fillInChipMagic = function () { XorgLogAttID = this.XorgLogAttList[this.XorgLogAttListIndex][1]; attURL = "https://bugzilla.redhat.com/attachment.cgi?id="+XorgLogAttID; that = this; - $.get(attURL,function (ret) { - var interestingLineArr = ret.split("\n").filter(function (v,i,a) { - return ChipsetRE.test(v); - }); - if (interestingLineArr.length >0) { - interestingArray = ChipsetRE.exec(interestingLineArr[0]); - interestingLine = interestingArray[2].replace(/[\s"]+/g," ").trim(); - var whiteboardInput = this.dok.getElementById("status_whiteboard"); - that.addNewButton(whiteboardInput,"chipmagic","Fill In", - "","CHIPMAGIC", - interestingLine+"\t"+interestingArray[1].toUpperCase(), - false,true); + + var req = new XMLHTTPRequest(); + req.open("GET",attURL,true); + req.onreadystatechange = function (aEvt) { + if (req.readyState == 4) { + if (req.status == 200) { + var ret = req.responseText; + var interestingLineArr = ret.split("\n"). + filter(function (v,i,a) { + return ChipsetRE.test(v); + }); + if (interestingLineArr.length >0) { + interestingArray = ChipsetRE.exec(interestingLineArr[0]); + interestingLine = interestingArray[2]. + replace(/[\s"]+/g," ").trim(); + var whiteboardInput = this.dok. + getElementById("status_whiteboard"); + that.addNewButton(whiteboardInput,"chipmagic","Fill In", + "","CHIPMAGIC", + interestingLine+"\t"+interestingArray[1].toUpperCase(), + false,true); + } + } else { + throw "Getting attachment " + attURL + "failed!"; + } } - }); + }; + req.send(""); + this.XorgLogAttListIndex++; }; @@ -850,7 +889,7 @@ BzPage.prototype.queryForSelection = function() { }; /** - * + * */ BzPage.prototype.sendBugUpstream = function() { var url = filterByRegexp(upstreamBugzillasArray, @@ -890,7 +929,11 @@ BzPage.prototype.parseAttachmentLine = function (inElem) { var attName = inElem.getElementsByTagName("b")[0].textContent.trim(); // getting id - var aHrefs = $("a:contains('Details')", inElem); //FIXME + 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 @@ -921,7 +964,7 @@ BzPage.prototype.selectOption = function(id,label) { theOption.selected = true; var intEvent = this.dok.createEvent("HTMLEvents"); intEvent.initEvent("change", true, true); - theOption.dispatchEvent(intEvent); + theOption.dispatchEvent(intEvent); } }; @@ -1108,7 +1151,7 @@ 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({ + var ret = $.ajax({ // FIXME jQuery type: "POST", url: XMLRPCurl, success: this.callBack, @@ -1279,7 +1322,7 @@ BzPage.prototype.generalPurposeCureForAllDisease = function this.selectOption("resolution",secondParameter); return 0; } else { - throw("Missing resolution for CLOSED status."); + throw "Missing resolution for CLOSED status."; } } -- cgit