aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bugzillaBugTriage.js185
1 files changed, 108 insertions, 77 deletions
diff --git a/bugzillaBugTriage.js b/bugzillaBugTriage.js
index d3ef752..41ce1fc 100644
--- a/bugzillaBugTriage.js
+++ b/bugzillaBugTriage.js
@@ -7,6 +7,7 @@
- password dialog for password prompt
*/
+"use strict";
jetpack.future.import("pageMods");
jetpack.future.import("storage.simple");
jetpack.future.import("selection");
@@ -417,6 +418,23 @@ bzPage.prototype.setKeyword = function (str) {
}
};
+bzPage.prototype.getOptionValue = function (id) {
+ return this.dok.getElementById(id).value;
+}
+
+/* Bugzilla functions.*/
+
+/**
+ * Get the current email of the reporter of the bug.
+ *
+ * @return string
+ */
+bzPage.prototype.getReporter = function () {
+ return this.dok.
+ querySelector("#bz_show_bug_column_2 > table .vcard:first-of-type > a").
+ textContent;
+};
+
/**
* Get the current version of the Fedora release ... even if changed
* meanwhile by bug triager.
@@ -424,7 +442,7 @@ bzPage.prototype.setKeyword = function (str) {
* @return string (integer for released Fedora, float for RHEL, rawhide)
*/
bzPage.prototype.getVersion = function () {
- var verStr = $("#version option:selected:first", this.doc).text().toLowerCase();
+ var verStr = this.getOptionValue("version").toLowerCase();
var verNo = 0;
if (/rawhide/.test(verStr)) {
verNo = 999;
@@ -459,7 +477,28 @@ bzPage.prototype.addKeyword = function (str) {
this.addTextToTextBox("keywords",str);
};
-/* Bugzilla functions.*/
+/**
+ * Add text to the text box (comment box or status whiteboard)
+ *
+ * @param id string with the id of the element
+ * @param string2BAdded string to be added to the comment box
+ *
+ * @return none
+ */
+bzPage.prototype.addTextToTextBox = function(id,string2BAdded) {
+ var textBox = this.dok.getElementById(id);
+ var separator = ", "
+ if (textBox.tagName.toLowerCase() == "textarea") {
+ separator = "\n\n";
+ }
+
+ // don't remove the current content of the comment box,
+ // just behave accordingly
+ if (textBox.value.length > 0) {
+ textBox.value = textBox.value + separator;
+ }
+ textBox.value = textBox.value + string2BAdded;
+};
/**
* Set background color of all comments made by reporter in ReporterColor color
@@ -467,12 +506,16 @@ bzPage.prototype.addKeyword = function (str) {
*/
bzPage.prototype.checkComments = function () {
var that = this;
- $("#comments .bz_comment", this.doc).each(function (i) {
- var email = $(".vcard a", this).text();
- if (new RegExp(that.reporter).test(email)) {
- $(this).css("background-color", ReporterColor.toString());
+ var comments = this.dok.getElementById("comments").getElementsByClassName("bz_comment");
+// comments.forEach(function (el, idx, arr) {
+ for (var i = 0, ii = comments.length; i < ii; i++) {
+ var email = comments[i].getElementsByClassName("vcard")[0].
+ getElementsByTagName("a")[0].textContent;
+ if (new RegExp(this.reporter).test(email)) {
+ comments[i].style.backgroundColor = ReporterColor.toString();
}
- });
+ }
+// });
};
/**
@@ -825,13 +868,15 @@ bzPage.prototype.parseAttachmentLine = function (inElem,idx) {
* @return none
*/
bzPage.prototype.selectOption = function(id,label) {
- var selectElement = $("#"+id,this.doc);
- var theOption = $("option:contains('"+label+"'):first",selectElement);
- theOption.attr("selected","selected");
- var intEvent = $(this.doc).get(0).createEvent("HTMLEvents");
+ var sel = this.dok.getElementById(id);
+ var options = Array.filter(sel.getElementsByTagName("option"),
+ function (x){ return x.value == label; }
+ );
+ theOption = options.length ? options[0] : [];
+ theOption.selected = true;
+ var intEvent = this.dok.createEvent("HTMLEvents");
intEvent.initEvent("change", true, true);
- selectElement.get(0).dispatchEvent(intEvent);
-// $("#"+id,this.doc).value(label).change();
+ theOption.dispatchEvent(intEvent);
};
/**
@@ -896,29 +941,6 @@ bzPage.prototype.setNeedinfoReporter = function() {
};
/**
- * Add text to the text box (comment box or status whiteboard)
- *
- * @param id string with the id of the element
- * @param string2BAdded string to be added to the comment box
- *
- * @return none
- */
-bzPage.prototype.addTextToTextBox = function(id,string2BAdded) {
- var textBox = this.dok.getElementById(id);
- var separator = ", "
- if (textBox.tagName.toLowerCase() == "textarea") {
- separator = "\n\n";
- }
-
- // don't remove the current content of the comment box,
- // just behave accordingly
- if (textBox.value.length > 0) {
- textBox.value = textBox.value + separator;
- }
- textBox.value = textBox.value + string2BAdded;
-};
-
-/**
* Return string with the ID for the external_id SELECT for
* external bugzilla
*
@@ -1072,13 +1094,13 @@ bzPage.prototype.fixAllAttachments = function(list) {
bzPage.prototype.createFixAllButton = function (list) {
var that = this;
var elem = this.dok.createElement("a");
- var jQelem = $(elem).attr({
- href:"",
- accesskey:"f"
- }).append("<b>F</b>ix all").click(function() {
+ elem.setAttribute("href","");
+ elem.setAttribute("accesskey","f");
+ elem.innerHTML = "<b>F</b>ix all";
+ elem.addEventListener("click", function() {
that.fixAllAttachments(list);
- });
- return jQelem.get(0);
+ },true);
+ return elem;
};
/**
@@ -1089,11 +1111,12 @@ bzPage.prototype.createFixAllButton = function (list) {
*/
bzPage.prototype.addTextLink = function (row) {
var that = this;
- $("td:last", row).append("<br/>").
- append("<a href=''>Text</a>").
- click(function (event) {
- that.fixAttachById(row[1],"text/plain");
- });
+ var elemS = row.getElementsByTagName("td");
+ var elem = elemS[elemS.length-1];
+ elem.innerHTML = "<br/><a href=''>Text</a>";
+ elem.addEventListener("click",function (x) {
+ that.fixAttachById(row[1],"text/plain");
+ }, true);
};
/**
@@ -1103,19 +1126,20 @@ bzPage.prototype.addTextLink = function (row) {
* @return none
*/
bzPage.prototype.addClosingUpstream = function() {
- var refs = $("#external_bugs_table tr",this.doc);
+ var refs = this.dok.getElementById("external_bugs_table").
+ getElementsByTagName("tr");
// that's a bad id, if there is a one. :)
- var inputBox = $("#inputbox",this.doc);
+ var inputBox = this.dok.getElementById("inputbox");
var externalBugID = 0;
var wholeURL = "";
// Fix missing ID on the external_id SELECT
- $("select[name='external_id']:first",this.doc).attr("id","external_id");
+ this.dok.getElementsByName("external_id")[0].setAttribute("id","external_id");
- if (inputBox.val().match(/^http.*/)) {
+ if (inputBox.value.match(/^http.*/)) {
var helpAElem = this.dok.createElement("a");
- wholeURL = inputBox.val();
- helpAElem.href = wholeURL;
+ wholeURL = inputBox.value;
+ helpAElem.setAttribute("href",wholeURL);
var paramsArr = helpAElem.search.replace(/^\?/,'').split('&');
// get ID#
var params = {}, s = [];
@@ -1125,14 +1149,14 @@ bzPage.prototype.addClosingUpstream = function() {
});
if (params.id) {
externalBugID = parseInt(params.id,10);
- inputBox.val(externalBugID);
+ inputBox.value = externalBugID;
}
// get host and bugzillaName
var bugzillaName = this.getBugzillaName(helpAElem.hostname);
this.selectOption("external_id", bugzillaName);
- } else if (!isNaN(inputBox.val())) {
- externalBugID = parseInt(inputBox.val(),10);
- var bugzillaID = $("#external_id",this.doc).val();
+ } else if (!isNaN(inputBox.value)) {
+ externalBugID = parseInt(inputBox.value,10);
+ var bugzillaID = this.dok.getElementById("external_id").value;
wholeURL = this.getWholeURL(bugzillaID,externalBugID);
} else {
// no inputBox.value -- maybe there is an external bug from
@@ -1197,7 +1221,7 @@ bzPage.prototype.generalPurposeCureForAllDisease = function
var text = jetpack.selection.text.trim();
if (text.length > 0) {
this.selectOption("resolution","CURRENTRELEASE");
- $("#cf_fixed_in",this.doc).val(text);
+ this.dok.getElementById("cf_fixed_in").value = text;
} else if (verNo === 999) {
this.selectOption("resolution","RAWHIDE");
} else {
@@ -1234,7 +1258,7 @@ bzPage.prototype.generalPurposeCureForAllDisease = function
// for F13 and later, ASSIGNED is "add Triaged keyword" (as well)
// for <F13 it is "add both" (ASSIGNED status and Triaged keyword)
if (!isInList(this.maintCCAddr, this.CCList)) {
- $("#newcc",this.doc).text(this.maintCCAddr);
+ this.dok.getElementById("newcc").textContent = this.maintCCAddr;
}
if ((!this.isRHEL()) && (verNo < TriagedDistro)) {
this.selectOption("bug_status", nextState);
@@ -1254,9 +1278,10 @@ bzPage.prototype.generalPurposeCureForAllDisease = function
}
if (secondParameter === "ADDSELFCC") {
- $("#addselfcc", this.doc).attr("checked","checked");
+ this.dok.getElementById("addselfcc").checked = true;
} else if (secondParameter === "NODEFAULTASSIGNEE") {
- $("#set_default_assignee", this.doc).removeAttr("checked");
+ this.dok.getElementById("set_default_assignee").
+ .removeAttribute("checked");
}
};
@@ -1335,7 +1360,7 @@ bzPage.prototype.buildButtons = function (above,below) {
// Add setting default assignee
if ((this.defaultAssignee.length > 0) &&
(this.defaultAssignee !== this.owner)) {
- this.addNewButton($("#bz_assignee_edit_container", this.doc),
+ this.addNewButton(this.dok.getElementById("bz_assignee_edit_container"),
"setdefaultassigneebutton","Def. Assignee",
"","SETDEFASS",this.defaultAssignee,false,true);
}
@@ -1346,7 +1371,7 @@ function bzPage(doc) {
this.doc = $(doc);
this.dok = doc;
var that = this;
- this.originalButton = $("#commit", this.doc);
+ this.originalButton = this.doc.getElementById("commit");
var loginArr = $("#header ul:first li:last", this.doc).text().split("\n");
this.login = loginArr[loginArr.length-1].trim();
this.password = "";
@@ -1360,15 +1385,19 @@ function bzPage(doc) {
var bugNoTitle = $("#title > p:first", this.doc).text().trim();
this.bugNo = new RegExp("[0-9]+").exec(bugNoTitle)[0];
- this.reporter = $("#bz_show_bug_column_2 > table .vcard:first > a",
- this.doc).attr("title");
- this.product = $("#product option:selected:first", this.doc).text();
- this.component = $("#component option:selected:first", this.doc).text();
+ this.reporter = this.getReporter();
+ this.product = this.getOptionValue("product");
+ this.component = this.getOptionValue("component");
this.version = this.getVersion();
var ITbutton = this.dok.getElementById("cf_issuetracker");
this.its = ITbutton ? ITbutton.value.trim() : "";
- this.CCList = $.makeArray($("#cc", this.doc).val());
- // TODO be careful about this,seems breaking for non-RH BugZappers, but I cannot see why
+ this.CCList = [];
+ var CCListHTMLColl = this.dok.getElementById("cc");
+ for (let i = 0, ii = CCListHTMLColl.length; i < ii; i++) {
+ this.CCList.push(CCListHTMLColl[i].value);
+ }
+ // TODO be careful about this, seems breaking for non-RH BugZappers,
+ // but I cannot see why
this.owner = this.dok.getElementById("bz_assignee_edit_container").
getElementsByClassName("fn")[0].textContent;
this.defaultAssignee = filterByRegexp(defAssigneeList,
@@ -1379,19 +1408,21 @@ function bzPage(doc) {
this.XorgLogAttListIndex = 0;
this.attachments = [];
this.reqCounter=0;
- atts = $.makeArray($(("#attachment_table tr"),this.doc).slice(1,-1));
- atts.forEach(function (val,idx,arr) {
- that.attachments.push(that.parseAttachmentLine(val,idx));
- });
+ var atts = this.dok.getElementById("attachment_table").
+ getElementsByTagName("tr");
+ for (let i = 1, ii = atts.length-1; i < ii; i++) {
+ this.attachments.push(this.parseAttachmentLine(atts[i],i));
+ }
var badAttachments = this.attachments.filter(function (att,idx,arr) {
return (isInList(att[2],badMIMEArray));
});
if (badAttachments.length > 0) {
- var titleElement = $(".bz_alias_short_desc_container:first",this.doc).
- css("background-color","olive").
- append($(this.createFixAllButton(badAttachments)));
+ var titleElement = this.dok.
+ getElementsByClassName("bz_alias_short_desc_container")[0];
+ titleElement.style.backgroundColor = "olive";
+ titleElement.appendChild(this.createFixAllButton(badAttachments));
badAttachments.forEach(function (x,i,a) {
that.addTextLink(x);
});
@@ -1400,7 +1431,7 @@ function bzPage(doc) {
// Dig out backtrace
this.btSnippet = "";
- var bugTitle = $("#short_desc_nonedit_display", this.doc).text();
+ var bugTitle = this.dok.getElementById("short_desc_nonedit_display").textContent;
if (AbrtRE.test(bugTitle)) {
var notedLabel = $("label[for='newcc']", this.doc);