aboutsummaryrefslogtreecommitdiffstats
path: root/bugzillaBugTriage.js
diff options
context:
space:
mode:
Diffstat (limited to 'bugzillaBugTriage.js')
-rw-r--r--bugzillaBugTriage.js230
1 files changed, 120 insertions, 110 deletions
diff --git a/bugzillaBugTriage.js b/bugzillaBugTriage.js
index bef3df1..1c1db65 100644
--- a/bugzillaBugTriage.js
+++ b/bugzillaBugTriage.js
@@ -1,3 +1,5 @@
+/*jslint onevar: false, browser: true, evil: true, laxbreak: true, undef: true, nomen: true, eqeqeq: true, bitwise: true, maxerr: 100, immed: false, white: false, plusplus: false, regexp: false, undef: false */
+/*global jQuery, $, jetpack */
// Released under the MIT/X11 license
// http://www.opensource.org/licenses/mit-license.php
@@ -20,7 +22,7 @@ var Desaturated = 0.4;
var XMLRPCurl = "https://bugzilla.redhat.com/xmlrpc.cgi";
var myConfig = jetpack.storage.simple;
var badMIMEArray = ["application/octet-stream","text/x-log","undefined"];
-var TriagedDistro = 12
+var TriagedDistro = 12;
//==============================================================
// CONFIGURE: The easiest method how to set up the configuration
@@ -117,7 +119,7 @@ filterByRegexp = function(list, chosingMark) {
} else {
return "";
}
-}
+};
/**
* Converts attributes value of the given list of elements to the
@@ -134,7 +136,7 @@ valuesToList = function(list) {
}
});
return outL;
-}
+};
/**
* Check whether an item is member of the list. Idea is just to
@@ -146,7 +148,7 @@ valuesToList = function(list) {
*/
isInList = function(mbr, list) {
return (list.indexOf(mbr) !== -1);
-}
+};
/**
* This function creates a new anchor element and uses location properties (inherent)
@@ -178,10 +180,10 @@ function parseURL(url) {
}
return ret;
})(),
- file: (a.pathname.match(/\/([^\/?#]+)$/i) || [,''])[1],
+ file: a.pathname.match(/\/([^\/?#]+)$/i || ['',''])[1],
hash: a.hash.replace('#',''),
path: a.pathname.replace(/^([^\/])/,'/$1'),
- relative: (a.href.match(/tp:\/\/[^\/]+(.+)/) || [,''])[1],
+ relative: (a.href.match(/tp:\/\/[^\/]+(.+)/) || ['',''])[1],
segments: a.pathname.replace(/^\//,'').split('/')
};
}
@@ -194,13 +196,15 @@ function parseURL(url) {
function Color(r,g,b) {
if (r instanceof Array) {
- this.r, this.g, this.b = r;
+ this.r = r[0];
+ this.g = r[1];
+ this.b = r[2];
} else {
this.r = r;
this.g = g;
this.b = b;
}
-};
+}
Color.prototype.update = function(r,g,b) {
this.r = r;
@@ -209,14 +213,14 @@ Color.prototype.update = function(r,g,b) {
};
Color.prototype.hs = function(nStr) {
- if (nStr == 0) {
+ if (Number(nStr) === 0) {
return "00";
} else if (nStr.length < 2) {
return "0" + nStr;
} else {
return nStr;
}
-}
+};
Color.prototype.hex = function() {
var rH = Number(this.r.toFixed()).toString(16);
@@ -237,11 +241,13 @@ Color.prototype.hex = function() {
* @return Array The HSL representation
*/
Color.prototype.hsl = function (){
- r = this.r / 255, g = this.g / 255, b = this.b / 255;
+ var r = this.r / 255;
+ var g = this.g / 255;
+ var b = this.b / 255;
var max = Math.max(r, g, b), min = Math.min(r, g, b);
var h, s, l = (max + min) / 2;
- if(max == min){
+ if(max === min){
h = s = 0; // achromatic
}else{
var d = max - min;
@@ -269,20 +275,30 @@ Color.prototype.hsl = function (){
* @return Array The RGB representation
*/
Color.prototype.hslToRgb = function (h, s, l){
+ function hue2rgb(p, q, t){
+ if (t < 0) {
+ t += 1;
+ }
+ if (t > 1) {
+ t -= 1;
+ }
+ if (t < 1/6) {
+ return p + (q - p) * 6 * t;
+ }
+ if (t < 1/2) {
+ return q;
+ }
+ if (t < 2/3) {
+ return p + (q - p) * (2/3 - t) * 6;
+ }
+ return p;
+ }
+
var r, g, b;
- if(s == 0){
+ if(s === 0){
r = g = b = l; // achromatic
}else{
- function hue2rgb(p, q, t){
- if(t < 0) t += 1;
- if(t > 1) t -= 1;
- if(t < 1/6) return p + (q - p) * 6 * t;
- if(t < 1/2) return q;
- if(t < 2/3) return p + (q - p) * (2/3 - t) * 6;
- return p;
- }
-
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
var p = 2 * l - q;
r = hue2rgb(p, q, h + 1/3);
@@ -305,14 +321,16 @@ Color.prototype.hslToRgb = function (h, s, l){
* @return Array The HSV representation
*/
Color.prototype.hsv = function (){
- r = this.r/255, g = this.g/255, b = this.b/255;
+ var r = this.r/255;
+ var g = this.g/255;
+ var b = this.b/255;
var max = Math.max(r, g, b), min = Math.min(r, g, b);
var h, s, v = max;
var d = max - min;
- s = max == 0 ? 0 : d / max;
+ s = max === 0 ? 0 : d / max;
- if(max == min){
+ if(max === min){
h = 0; // achromatic
}else{
switch(max){
@@ -347,12 +365,36 @@ Color.prototype.hsvToRgb = function (h, s, v){
var t = v * (1 - (1 - f) * s);
switch(i % 6){
- case 0: r = v, g = t, b = p; break;
- case 1: r = q, g = v, b = p; break;
- case 2: r = p, g = v, b = t; break;
- case 3: r = p, g = q, b = v; break;
- case 4: r = t, g = p, b = v; break;
- case 5: r = v, g = p, b = q; break;
+ case 0:
+ r = v;
+ g = t;
+ b = p;
+ break;
+ case 1:
+ r = q;
+ g = v;
+ b = p;
+ break;
+ case 2:
+ r = p;
+ g = v;
+ b = t;
+ break;
+ case 3:
+ r = p;
+ g = q;
+ b = v;
+ break;
+ case 4:
+ r = t;
+ g = p;
+ b = v;
+ break;
+ case 5:
+ r = v;
+ g = p;
+ b = q;
+ break;
}
return [r * 255, g * 255, b * 255];
@@ -366,7 +408,7 @@ Color.prototype.lightColor = function() {
var h = Number(hslArray[0]);
var s = Number(hslArray[1]) * Desaturated;
var l = Luminosity;
- var desA = this.hslToRgb(h, s, l)
+ var desA = this.hslToRgb(h, s, l);
return new Color(desA[0],desA[1],desA[2]);
};
@@ -396,7 +438,7 @@ bzPage.prototype.setKeyword = function (str) {
var kwd = $.trim(keywordInput.val());
if (!/str/.test(kwd)) {
keywordInput.val(kwd ? kwd + ", " + str : str);
- };
+ }
};
/**
@@ -407,7 +449,7 @@ bzPage.prototype.setKeyword = function (str) {
*/
bzPage.prototype.getVersion = function () {
var verStr = $("#version option:selected:first", this.doc).text().toLowerCase();
- var verNo = new Number();
+ var verNo = 0;
if (/rawhide/.test(verStr)) {
verNo = 999;
} else {
@@ -440,7 +482,7 @@ bzPage.prototype.clickMouse = function(target) {
*/
bzPage.prototype.addKeyword = function (str) {
var kwd = $('#keywords',this.doc);
- if (kwd.text().length == 0) {
+ if (kwd.text().length === 0) {
kwd.text(str);
}else{
kwd.text(kwd.text() + ", " + str);
@@ -469,7 +511,7 @@ bzPage.prototype.checkComments = function () {
* @return Boolean true if it is a RHEL bug
*/
bzPage.prototype.isRHEL = function() {
- return /Red Hat Enterprise Linux/.test(this.product);
+ return (/Red Hat Enterprise Linux/).test(this.product);
};
@@ -477,9 +519,9 @@ bzPage.prototype.isTriaged = function() {
if (this.version > 11) {
return this.hasKeyword("Triaged");
} else {
- return $("#bug_status", this.doc).val().toUpperCase() != "NEW";
+ return $("#bug_status", this.doc).val().toUpperCase() !== "NEW";
}
-}
+};
/**
* Set branding colours to easily distinguish between Fedora and RHEL bugs
@@ -554,7 +596,7 @@ bzPage.prototype.setBranding = function () {
*/
bzPage.prototype.groupIDs = function (manStr,cardStrID) {
var outStr = filterByRegexp(chipIDsGroupings,manStr+","+cardStrID);
- if (outStr.length == 0) {
+ if (outStr.length === 0) {
outStr = "UNGROUPED_" + manStr+"/"+cardStrID;
}
return outStr;
@@ -596,7 +638,7 @@ bzPage.prototype.fillInWhiteBoard = function (iLine, driverStr) {
console.log("iLine: " + iLine);
chipSwitchboard:
- if (driverStr == "RADEON") {
+ if (driverStr === "RADEON") {
var cardID = iLine.replace(ATIgetIDRE,"$1");
cardIDArr = this.checkChipStringFromID("1002",cardID);
if (cardIDArr.length > 0) {
@@ -616,7 +658,7 @@ bzPage.prototype.fillInWhiteBoard = function (iLine, driverStr) {
} else {
// Intel Corporation, NVIDIA
cardIDArr = manuChipStrs.filter(function (el, ind, arr) {
- return RegExp(el[0],"i").test(iLine);
+ return new RegExp(el[0],"i").test(iLine);
});
console.log("cardIDArr = " + cardIDArr.toSource());
if (cardIDArr && (cardIDArr.length > 0)) {
@@ -626,11 +668,11 @@ bzPage.prototype.fillInWhiteBoard = function (iLine, driverStr) {
break chipSwitchboard;
}
// cardIDArr [0] = RE, [1] = ("RADEON","INTEL","NOUVEAU"), [2] = manu PCIID
- iLine = $.trim(iLine.replace(RegExp(cardIDArr[0],"i")));
+ iLine = $.trim(iLine.replace(new RegExp(cardIDArr[0],"i")));
// FIXME is this necessary? Let's try without it
// outStr = iLine.replace(/^\W*(\w*).*$/,"$1");
// nVidia developers opted-out from grouping
- if (driverStr == "INTEL") {
+ if (driverStr === "INTEL") {
outStr = this.groupIDs(cardIDArr[1],iLine);
} else {
outStr = iLine;
@@ -682,7 +724,7 @@ bzPage.prototype.addNewButton = function (originalLocation,newId,newLabel,
}).click(function (evt) {
that.generalPurposeCureForAllDisease(commStr,nState, secPar);
});
- newButton;
+// FIXME why is this here? newButton;
if (after) {
$(originalLocation, this.doc).after(newButton).after("\u00A0");
} else {
@@ -713,12 +755,12 @@ bzPage.prototype.fillInChipMagic = function () {
// Xorg.0.log must be text, otherwise we cannot parse it
return (/[xX].*log/.test(value[0]) && /text/.test(value[2]));
});
- if (this.XorgLogAttList.length == 0) {
- console.log("No Xorg.0.log attachments found.")
+ if (this.XorgLogAttList.length === 0) {
+ console.log("No Xorg.0.log attachments found.");
return;
}
- var XorgLogAttID = this.XorgLogAttList[this.XorgLogAttListIndex][1];
+ XorgLogAttID = this.XorgLogAttList[this.XorgLogAttListIndex][1];
attURL = "https://bugzilla.redhat.com/attachment.cgi?id="+XorgLogAttID;
that = this;
$.get(attURL,function (ret){
@@ -754,7 +796,7 @@ bzPage.prototype.fillInChipMagic = function () {
*/
bzPage.prototype.queryInNewTab = function(text,component,product) {
// Optional parameter
- if (product == undefined) {
+ if (product === undefined) {
product = "Fedora";
}
var url = "https://bugzilla.redhat.com/buglist.cgi?query_format=advanced";
@@ -780,7 +822,7 @@ bzPage.prototype.queryForSelection = function() {
var text = $.trim(jetpack.selection.text);
if (text.length < 1) {
text = jetpack.clipboard.get();
- };
+ }
if (text.length > 0) {
this.queryInNewTab(text, this.component);
}
@@ -850,7 +892,7 @@ bzPage.prototype.selectOption = function(id,label) {
bzPage.prototype.hasKeyword = function(str) {
var kwd = $.trim($('#keywords',this.doc).val());
console.log("Keywords = " + kwd);
- return (RegExp(str).test(kwd));
+ return (new RegExp(str).test(kwd));
};
/**
@@ -953,29 +995,6 @@ bzPage.prototype.getWholeURL = function(selectValue,bugID) {
};
/**
- * Sends XMLRPC request
- *
- * @param url string with URL of the XML-RPC interface
- * @param data string with XML of the data to be sent
- * @param method string -- either 'post' or 'get'
- * @param callback function catching callback
- */
-bzPage.prototype.sendRequest = function(url,data,method,callback) {
- //$.rpc(url, dataType, onLoadCallback, version);
- GM_xmlhttpRequest({
- method: method,
- url: url,
- headers: {
- 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey fixAttType XMLRPC',
- 'Accept': 'application/atom+xml,application/xml,text/xml',
- 'Content-type': 'text/xml'
- },
- data: data,
- onload: callback
- });
-};
-
-/**
* Callback function for the XMLRPC request
*
* @param ret object with xmlhttprequest response
@@ -986,10 +1005,6 @@ bzPage.prototype.sendRequest = function(url,data,method,callback) {
* + responseText
*/
bzPage.prototype.callBack = function(data,textStatus) {
-// if (ret.status != 200) {
-// alert([ret.status,ret.statusText,ret.responseHeaders,
-// ret.responseText]);
-// }
if (--this.reqCounter <= 0) {
setTimeout(document.location.reload,1000);
}
@@ -1026,7 +1041,7 @@ bzPage.prototype.createXMLRPCMessage = function(login,password,attachId,mimeType
}
if (email === undefined) {
email = false;
- };
+ }
var emailStr = email ? "0" : "1";
var msg = <methodCall>
@@ -1116,9 +1131,10 @@ bzPage.prototype.createFixAllButton = function (list) {
};
/**
+ * Add a link to the bad attachment for fixing it.
*
- *
- * CURRENTLY BROKEN
+ * @param <TR> DOM jQuery element with a bad attachment
+ * @return none
*/
bzPage.prototype.addTextLink = function (row) {
var that = this;
@@ -1130,13 +1146,6 @@ bzPage.prototype.addTextLink = function (row) {
};
/**
- *
- */
-bzPage.prototype.isOctetStream = function (element, index, array) {
- return(badMIMEArray.indexOf(element[2]) != -1);
-};
-
-/**
* Add information about the upstream bug upstream, and closing it.
* @param evt event which called this handler
*
@@ -1155,25 +1164,24 @@ bzPage.prototype.addClosingUpstream = function() {
if (inputBox.text().match(/^http.*/)) {
var IBURLArr = parseURL(inputBox.text());
console.log("IBURLArr = " + IBURLArr.toSource());
- externalBugID = parseInt(IBURLArr.params["id"]);
+ externalBugID = parseInt(IBURLArr.params.id,10);
inputBox.text(externalBugID);
var bugzillaName = getBugzillaName(IBURLArr.host);
this.selectOption("external_id", bugzillaName);
console.log("externalBugID = " + externalBugID);
} else if (!isNaN(inputBox.text())) {
- externalBugID = parseInt(inputBox.text());
+ externalBugID = parseInt(inputBox.text(),10);
var bugzillaID = $("#external_id").text();
wholeURL = getWholeURL(bugzillaID,externalBugID);
} else {
// no inputBox.value -- maybe there is an external bug from
// the previous commit?
- ;
}
// It is not good to close bug as UPSTREAM, if there is no reference
// to the upstream bug.
if ((refs.length > 2) || (externalBugID > 0)) {
- this.addTextToComment(msgStrs['sentUpstreamString'].replace("§§§",wholeURL));
+ this.addTextToComment(msgStrs.sentUpstreamString.replace("§§§",wholeURL));
this.selectOption("bug_status", "CLOSED");
this.selectOption("resolution", "UPSTREAM");
} else {
@@ -1190,9 +1198,9 @@ bzPage.prototype.addClosingUpstream = function() {
bzPage.prototype.generateToolBar = function(anchor,array) {
for (var i=0; i<array.length; i++) {
var butt = array[i];
- this.addNewButton(anchor, butt['idx'],
- butt['msg'], butt['string'], butt['state'], butt['parameter'],
- butt['submit']);
+ this.addNewButton(anchor, butt.idx,
+ butt.msg, butt.string, butt.state, butt.parameter,
+ butt.submit);
}
};
@@ -1212,8 +1220,8 @@ bzPage.prototype.generalPurposeCureForAllDisease = function
this.addTextToComment(addString);
}
- if (nextState == "CLOSED") {
- if (secondParameter == "UPSTREAM") {
+ if (nextState === "CLOSED") {
+ if (secondParameter === "UPSTREAM") {
this.addClosingUpstream();
} else if (secondParameter.length > 0) {
this.selectOption("bug_status", nextState);
@@ -1225,14 +1233,14 @@ bzPage.prototype.generalPurposeCureForAllDisease = function
}
// Now closing bugs is done, what about the rest?
- if (nextState == "NEEDINFO") {
+ if (nextState === "NEEDINFO") {
this.setNeedinfoReporter();
- } else if (nextState == "ADDKEYWORD") {
- if (secondParameter.length == 0) {
+ } else if (nextState === "ADDKEYWORD") {
+ if (secondParameter.length === 0) {
throw "Keyword has to be defined";
}
this.addKeyword(secondParameter);
- } else if (nextState == "ASSIGNED") {
+ } else if (nextState === "ASSIGNED") {
// We lie, this is not just plain ASSIGNED, but
// modified according to
// https://fedoraproject.org/wiki/BugZappers/Meetings/Minutes-2009-Oct-27
@@ -1247,22 +1255,22 @@ bzPage.prototype.generalPurposeCureForAllDisease = function
} else {
this.setKeyword("Triaged");
}
- } else if (nextState == "QUERYSEL") {
+ } else if (nextState === "QUERYSEL") {
this.queryForSelection();
- } else if (nextState == "SETDEFASS") {
+ } else if (nextState === "SETDEFASS") {
if (secondParameter.length > 0) {
this.changeOwner(secondParameter);
}
- } else if (nextState == "CHIPMAGIC") {
+ } else if (nextState === "CHIPMAGIC") {
var splitArr = secondParameter.split("\t");
this.fillInWhiteBoard(splitArr[0],splitArr[1]);
} else if (nextState.length >0) {
this.selectOption("bug_status", nextState);
}
- if (secondParameter == "ADDSELFCC") {
+ if (secondParameter === "ADDSELFCC") {
$("#addselfcc", this.doc).attr("checked","checked");
- } else if (secondParameter == "NODEFAULTASSIGNEE") {
+ } else if (secondParameter === "NODEFAULTASSIGNEE") {
$("#set_default_assignee", this.doc).removeAttr("checked");
}
};
@@ -1296,16 +1304,18 @@ bzPage.prototype.buildButtons = function (above,below) {
this.addNewButton(newPosition,"newqueryintab","Query for string",
"","QUERYSEL","",false);
}
- if ((chipIDsGroupings.length >0) && this.maintCCAddr == "xgl-maint@redhat.com") {
+ if ((chipIDsGroupings.length >0) &&
+ this.maintCCAddr === "xgl-maint@redhat.com") {
// Add find chip magic button
var whiteboard_string = $("#status_whiteboard", this.doc).val();
- if (whiteboard_string.indexOf("card_") == -1) {
+ if (isInList("card_",whiteboard_string)) {
this.fillInChipMagic();
}
}
// Add setting default assignee
console.log("defaultAssignee = " + this.defaultAssignee + ", owner = " + this.owner);
- if ((this.defaultAssignee.length > 0) && (this.defaultAssignee != this.owner)) {
+ if ((this.defaultAssignee.length > 0) &&
+ (this.defaultAssignee !== this.owner)) {
this.addNewButton($("#bz_assignee_edit_container", this.doc),
"setdefaultassigneebutton","Def. Assignee",
"","SETDEFASS",this.defaultAssignee,false,true);
@@ -1351,7 +1361,7 @@ function bzPage(doc) {
});
var badAttachments = this.attachments.filter(function (att,idx,arr) {
- return (badMIMEArray.indexOf(att[2]) != -1);
+ return (isInList(att[2],badMIMEArray));
});
if (badAttachments.length > 0) {
@@ -1390,6 +1400,6 @@ var callback = function (doc) {
var options = {};
options.matches = [
- "https://bugzilla.redhat.com/show_bug.cgi",
+ "https://bugzilla.redhat.com/show_bug.cgi"
];
jetpack.pageMods.add(callback, options);