aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bugzillaBugTriage.js88
1 files changed, 46 insertions, 42 deletions
diff --git a/bugzillaBugTriage.js b/bugzillaBugTriage.js
index e524fe7..6233db1 100644
--- a/bugzillaBugTriage.js
+++ b/bugzillaBugTriage.js
@@ -121,7 +121,7 @@ filterByRegexp = function(list, chosingMark) {
});
}
if (chosenPair.length > 0) {
- return $.trim(chosenPair[0].addr);
+ return chosenPair[0].addr.trim();
} else {
return "";
}
@@ -391,7 +391,7 @@ Color.prototype.lightColor = function() {
* @return Boolean
*/
bzPage.prototype.hasKeyword = function (str) {
- var kwd = $.trim($('#keywords', this.doc).val());
+ var kwd = $('#keywords', this.doc).val().trim();
return (new RegExp(str).test(kwd));
};
@@ -402,8 +402,10 @@ bzPage.prototype.hasKeyword = function (str) {
* @return none
*/
bzPage.prototype.setKeyword = function (str) {
+ // Could be probably rewrote to use this.addTextToTextBox, but
+ // it would be too complicated with a little gain.
var keywordInput = $('#keywords', this.doc);
- var kwd = $.trim(keywordInput.val());
+ var kwd = keywordInput.val().trim();
var strRE = new RegExp(str);
if (!strRE.test(kwd)) {
keywordInput.val(kwd ? kwd + ", " + str : str);
@@ -433,7 +435,7 @@ bzPage.prototype.getVersion = function () {
* @return None
*/
bzPage.prototype.clickMouse = function(target) {
- var localEvent = this.doc.get(0).createEvent("MouseEvents");
+ var localEvent = this.dok.createEvent("MouseEvents");
localEvent.initMouseEvent("click", true, true,
this.doc.defaultView,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
@@ -627,7 +629,7 @@ bzPage.prototype.fillInWhiteBoard = function (iLine, driverStr) {
break chipSwitchboard;
}
// cardIDArr [0] = RE, [1] = ("RADEON","INTEL","NOUVEAU"), [2] = manu PCIID
- iLine = $.trim(iLine.replace(new RegExp(cardIDArr[0],"i")));
+ iLine = iLine.replace(new RegExp(cardIDArr[0],"i")).trim();
// nVidia developers opted-out from grouping
if (driverStr === "INTEL") {
outStr = this.groupIDs(cardIDArr[1],iLine);
@@ -635,13 +637,7 @@ bzPage.prototype.fillInWhiteBoard = function (iLine, driverStr) {
outStr = iLine;
}
}
- var whiteboardInput = $("#status_whiteboard",this.doc);
- var oldWhiteboard = whiteboardInput.val();
- var attachedText = $.trim("card_"+outStr);
- if (oldWhiteboard) {
- attachedText += ", " + oldWhiteboard;
- }
- whiteboardInput.val(attachedText);
+ this.addTextToTextBox("status_whiteboard",("card_"+outStr).trim());
$("#chipmagic", this.doc).css("display","none");
};
@@ -726,7 +722,7 @@ bzPage.prototype.fillInChipMagic = function () {
});
if (interestingLineArr.length >0) {
interestingArray = ChipsetRE.exec(interestingLineArr[0]);
- interestingLine = $.trim(interestingArray[2].replace(/[\s"]+/g," "));
+ interestingLine = interestingArray[2].replace(/[\s"]+/g," ").trim();
var whiteboardInput = $("#status_whiteboard",that.doc);
that.addNewButton(whiteboardInput,"chipmagic","Fill In",
"","CHIPMAGIC",
@@ -756,13 +752,13 @@ bzPage.prototype.queryInNewTab = function(text,component,product) {
}
var url = "https://bugzilla.redhat.com/buglist.cgi?query_format=advanced";
if (product) {
- url += "&product="+$.trim(product);
+ url += "&product="+product.trim();
}
if (component) {
- url += "&field0-0-0=component&type0-0-0=substring&value0-0-0="+$.trim(component);
+ url += "&field0-0-0=component&type0-0-0=substring&value0-0-0="+component.trim();
}
if (text) {
- text = $.trim(text);
+ text = text.trim();
url += "&field1-0-0=longdesc&type1-0-0=substring&value1-0-0="+text+
"&field1-0-1=attach_data.thedata&type1-0-1=substring&value1-0-1="+text+
"&field1-0-2=status_whiteboard&type1-0-2=substring&value1-0-2="+text;
@@ -805,7 +801,7 @@ bzPage.prototype.parseAttachmentLine = function (inElem,idx) {
}
// getting name of the attachment
- var attName = $.trim($("b:first", inElem).text());
+ var attName = $("b:first", inElem).text().trim();
// getting id
var aHrefs = $("a:contains('Details')", inElem);
@@ -847,7 +843,7 @@ bzPage.prototype.selectOption = function(id,label) {
*
*/
bzPage.prototype.hasKeyword = function(str) {
- var kwd = $.trim($('#keywords',this.doc).val());
+ var kwd = $('#keywords',this.doc).val().trim();
return (new RegExp(str).test(kwd));
};
@@ -902,20 +898,26 @@ bzPage.prototype.setNeedinfoReporter = function() {
};
/**
- * Add text to the comment.
+ * 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.addTextToComment = function(string2BAdded) {
- var commentTextarea = $("#comment",this.doc);
+bzPage.prototype.addTextToTextBox = function(id,string2BAdded) {
+ var textBox = $("#"+id,this.doc);
+ var separator = ", "
+ if (textBox.get(0).tagName.toLowerCase() == "textarea") {
+ separator = "\n\n";
+ }
// don't remove the current content of the comment box,
// just behave accordingly
- if (commentTextarea.val().length > 0) {
- commentTextarea.val(commentTextarea.val() + "\n\n");
+ if (textBox.val().length > 0) {
+ textBox.val(textBox.val() + separator);
}
- commentTextarea.val(commentTextarea.val() + string2BAdded);
+ textBox.val(textBox.val() + string2BAdded);
};
/**
@@ -1070,7 +1072,7 @@ bzPage.prototype.fixAllAttachments = function(list) {
*/
bzPage.prototype.createFixAllButton = function (list) {
var that = this;
- var elem = this.doc.get(0).createElement("a");
+ var elem = this.dok.createElement("a");
var jQelem = $(elem).attr({
href:"",
accesskey:"f"
@@ -1112,7 +1114,7 @@ bzPage.prototype.addClosingUpstream = function() {
$("select[name='external_id']:first",this.doc).attr("id","external_id");
if (inputBox.val().match(/^http.*/)) {
- var helpAElem = this.doc.get(0).createElement("a");
+ var helpAElem = this.dok.createElement("a");
wholeURL = inputBox.val();
helpAElem.href = wholeURL;
var paramsArr = helpAElem.search.replace(/^\?/,'').split('&');
@@ -1141,7 +1143,8 @@ bzPage.prototype.addClosingUpstream = function() {
// It is not good to close bug as UPSTREAM, if there is no reference
// to the upstream bug.
if ((externalBugID > 0) || (refs.length > 2)) {
- this.addTextToComment(msgStrs.sentUpstreamString.replace("§§§",wholeURL));
+ this.addTextToTextBox("comment",
+ msgStrs.sentUpstreamString.replace("§§§",wholeURL));
this.selectOption("bug_status", "CLOSED");
this.selectOption("resolution", "UPSTREAM");
} else {
@@ -1179,7 +1182,7 @@ bzPage.prototype.generalPurposeCureForAllDisease = function
var verNo = 1;
if (addString.length >0) {
- this.addTextToComment(addString);
+ this.addTextToTextBox("comment",addString);
}
if (nextState === "CLOSED") {
@@ -1193,7 +1196,7 @@ bzPage.prototype.generalPurposeCureForAllDisease = function
// otherwise -> NEXTRELEASE
verNo = this.getVersion();
this.selectOption("bug_status", nextState);
- var text = $.trim(jetpack.selection.text);
+ var text = jetpack.selection.text.trim();
if (text.length > 0) {
this.selectOption("resolution","CURRENTRELEASE");
$("#cf_fixed_in",this.doc).val(text);
@@ -1280,7 +1283,7 @@ bzPage.prototype.parseBacktrace = function (ret) {
endLineNo = lineCounter + NumberOfFrames;
curLine = splitArray[i];
while ((lineCounter < endLineNo) &&
- ($.trim(curLine).length >0) && (i < ii)) {
+ (curLine.trim().length >0) && (i < ii)) {
outStr += curLine + '\n';
numStr = frameNoRE.exec(curLine);
if (numStr) {
@@ -1317,7 +1320,7 @@ bzPage.prototype.buildButtons = function (above,below) {
// Add query search button
// Apparently there is a bug in jQuery, we have to use plain DOM
//newPosition = $("#newcommentprivacy ~ br", this.doc);
- newPosition = $(this.doc.get(0).querySelector("#newcommentprivacy ~ br"));
+ newPosition = $(this.dok.querySelector("#newcommentprivacy ~ br"));
newPosition.css("border","solid blue");
this.addNewButton(newPosition,"newqueryintab","Query for string",
"","QUERYSEL","",false);
@@ -1344,19 +1347,20 @@ bzPage.prototype.buildButtons = function (above,below) {
///////////////////////////////////////////////////////////////////////////////
function bzPage(doc) {
this.doc = $(doc);
+ this.dok = doc;
var that = this;
this.originalButton = $("#commit", this.doc);
var loginArr = $("#header ul:first li:last", this.doc).text().split("\n");
- this.login = $.trim(loginArr[loginArr.length-1]);
+ this.login = loginArr[loginArr.length-1].trim();
this.password = "";
if (myConfig.BZpassword) {
this.password = myConfig.BZpassword;
} else {
- this.password = this.doc.get(0).defaultView.prompt("Enter your Bugzilla password","");
+ this.password = this.dok.defaultView.prompt("Enter your Bugzilla password","");
myConfig.BZpassword = this.password;
}
- var bugNoTitle = $.trim($("#title > p:first", this.doc).text());
+ 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",
@@ -1364,7 +1368,7 @@ function bzPage(doc) {
this.product = $("#product option:selected:first", this.doc).text();
this.component = $("#component option:selected:first", this.doc).text();
this.version = this.getVersion();
- this.its = $.trim($("#cf_issuetracker", this.doc).val());
+ this.its = $("#cf_issuetracker", this.doc).val().trim();
this.CCList = $.makeArray($("#cc", this.doc).val());
this.owner = $("#bz_assignee_edit_container .fn:first", this.doc).text();
this.defaultAssignee = filterByRegexp(defAssigneeList,
@@ -1397,7 +1401,8 @@ function bzPage(doc) {
this.btSnippet = "";
var bugTitle = $("#short_desc_nonedit_display", this.doc).text();
- if (AbrtRE.test(bugTitle)) {
+ if (AbrtRE.test(bugTitle) &&
+ !(/btparsed/.test($("#cf_devel_whiteboard",this.doc)))) {
$(".bz_alias_short_desc_container:first", this.doc).
append("\u00A0<a href=''>Abrt bugs</a>").click(function() {
that.doc.location = abrtQueryURL;
@@ -1418,7 +1423,8 @@ function bzPage(doc) {
that.btSnippet = that.parseBacktrace(ret);
console.log("btSnippet = " + that.btSnippet.length);
if (that.btSnippet) {
- that.addTextToComment(that.btSnippet);
+ that.addTextToTextBox("comment",that.btSnippet);
+ that.addTextToTextBox("cf_devel_whiteboard","btparsed");
}
});
}
@@ -1432,8 +1438,8 @@ function bzPage(doc) {
$("form:nth-child(2)", this.doc).submit(function () {
var cmntText = $("#comment", this.doc);
if ((signatureFedoraString.length > 0) &&
- ($.trim(cmntText.text()).length > 0)) {
- cmntText.text($.trim(cmntText.text()) + signatureFedoraString);
+ (cmntText.text().trim().length > 0)) {
+ cmntText.text(cmntText.text().trim() + signatureFedoraString);
}
});
}
@@ -1442,10 +1448,8 @@ function bzPage(doc) {
this.checkComments();
this.buildButtons(topRow,bottomRow);
- // FIXME this doesn't work as it should.
- // Shouldn't we use .val() again instead of .text()?
$("#component",this.doc).change(function (){
- that.component = $("#component option:selected:first", this.doc).text();
+ that.component = $("#component option:selected:first", this.doc).val();
that.changeOwner(filterByRegexp(defAssigneeList, that.component).
toLowerCase());
});