aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2009-11-25 00:45:32 +0100
committerMatěj Cepl <mcepl@redhat.com>2009-11-25 00:45:32 +0100
commite26c2feb787f1421b64c88dd106a0cdc0b327af9 (patch)
tree9b9188cfb3ad0ffe527fc020a14f1c7b222463b5
parent0fcb34de5aa72cbb46e5a38400782c7131fc35c5 (diff)
downloadbugzilla-triage-e26c2feb787f1421b64c88dd106a0cdc0b327af9.tar.gz
Upstreaming works and a little cleanups.
-rw-r--r--bugzillaBugTriage.js119
1 files changed, 52 insertions, 67 deletions
diff --git a/bugzillaBugTriage.js b/bugzillaBugTriage.js
index 731ca7d..0058531 100644
--- a/bugzillaBugTriage.js
+++ b/bugzillaBugTriage.js
@@ -109,7 +109,7 @@ $.getJSON(PCIIDsURL,
filterByRegexp = function(list, chosingMark) {
var chosenPair = [];
if (list.length > 0) {
- chosenPair = list.filter(
+ chosenPair = list.filter (
function (pair) {
return new RegExp(pair.regexp, "i").test(chosingMark);
});
@@ -150,44 +150,6 @@ isInList = function(mbr, list) {
return (list.indexOf(mbr) !== -1);
};
-/**
- * This function creates a new anchor element and uses location properties (inherent)
- * to get the desired URL data. Some String operations are used (to normalize results
- * across browsers).
- * originally from http://snipplr.com/view.php?codeview&id=12659
- *
- * @param url String with URL
- * @return object with parameters set
- *
- */
-function parseURL(url) {
- var a = $('a',this.doc).get(0);
- a.href = url;
- return {
- source: url,
- protocol: a.protocol.replace(':',''),
- host: a.hostname,
- port: a.port,
- query: a.search,
- params: (function(){
- var ret = {},
- seg = a.search.replace(/^\?/,'').split('&'),
- len = seg.length, i = 0, s;
- for (;i<len;i++) {
- if (!seg[i]) { continue; }
- s = seg[i].split('=');
- ret[s[0]] = s[1];
- }
- return ret;
- })(),
- file: a.pathname.match(/\/([^\/?#]+)$/i || ['',''])[1],
- hash: a.hash.replace('#',''),
- path: a.pathname.replace(/^([^\/])/,'/$1'),
- relative: (a.href.match(/tp:\/\/[^\/]+(.+)/) || ['',''])[1],
- segments: a.pathname.replace(/^\//,'').split('/')
- };
-}
-
// ============================================================================
// Color management methods
// originally from
@@ -222,7 +184,7 @@ Color.prototype.hs = function(nStr) {
}
};
-Color.prototype.hex = function() {
+Color.prototype.toString = function() {
var rH = Number(this.r.toFixed()).toString(16);
var gH = Number(this.g.toFixed()).toString(16);
var bH = Number(this.b.toFixed()).toString(16);
@@ -436,9 +398,10 @@ bzPage.prototype.hasKeyword = function (str) {
bzPage.prototype.setKeyword = function (str) {
var keywordInput = $('#keywords', this.doc);
var kwd = $.trim(keywordInput.val());
- if (!/str/.test(kwd)) {
- keywordInput.val(kwd ? kwd + ", " + str : str);
- }
+ var strRE = new RegExp(str);
+ if (!strRE.test(kwd)) {
+ keywordInput.val(kwd ? kwd + ", " + str : str);
+ }
};
/**
@@ -500,7 +463,7 @@ bzPage.prototype.checkComments = function () {
$("#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.hex());
+ $(this).css("background-color", ReporterColor.toString());
}
});
};
@@ -552,15 +515,15 @@ bzPage.prototype.setBranding = function () {
}
// Comment each of the following lines to get only partial branding
- $("body", this.doc).css("background", brandColor.hex());
- $("#titles", this.doc).css("background", brandColor.hex());
+ $("body", this.doc).css("background", brandColor.toString());
+ $("#titles", this.doc).css("background", brandColor.toString());
// Make background-color of the body of bug salmon pink
// for security bugs.
if (this.hasKeyword("Security")) {
$("#bugzilla-body", this.doc).css({
'background-image' : 'none',
- 'background-color' : SalmonPink.hex()
+ 'background-color' : SalmonPink.toString()
});
}
@@ -569,7 +532,7 @@ bzPage.prototype.setBranding = function () {
var triagedColor = brandColor.lightColor();
$("#bz_field_status",this.doc).css({
'background-image' : 'none',
- 'background-color' : triagedColor.hex()
+ 'background-color' : triagedColor.toString()
});
}
@@ -874,7 +837,7 @@ bzPage.prototype.parseAttachmentLine = function (inElem,idx) {
*/
bzPage.prototype.selectOption = function(id,label) {
var selectElement = $("#"+id,this.doc);
- var theOption = $("option[value='"+label+"']",selectElement);
+ var theOption = $("option:contains('"+label+"'):first",selectElement);
theOption.attr("selected","selected");
var intEvent = $(this.doc).get(0).createEvent("HTMLEvents");
intEvent.initEvent("change", true, true);
@@ -927,10 +890,12 @@ bzPage.prototype.changeOwner = function(newAssignee) {
if (!isInList(newAssignee, this.CCList)) {
$("#newcc",this.doc).text(newAssignee);
}
- this.clickMouse($("#bz_assignee_edit_action",this.doc));
- $("#set_default_assignee",this.doc).removeAttr("checked");
- $("#assigned_to", this.doc).val(newAssignee);
- $("#setdefaultassigneebutton", this.doc).css("display","none");
+ if (newAssignee) {
+ this.clickMouse($("#bz_assignee_edit_action",this.doc));
+ $("#set_default_assignee",this.doc).removeAttr("checked");
+ $("#assigned_to", this.doc).val(newAssignee);
+ $("#setdefaultassigneebutton", this.doc).css("display","none");
+ }
};
/**
@@ -1161,31 +1126,47 @@ bzPage.prototype.addClosingUpstream = function() {
// Fix missing ID on the external_id SELECT
$("select[name='external_id']:first",this.doc).attr("id","external_id");
- if (inputBox.text().match(/^http.*/)) {
- var IBURLArr = parseURL(inputBox.text());
- console.log("IBURLArr = " + IBURLArr.toSource());
- externalBugID = parseInt(IBURLArr.params.id,10);
- inputBox.text(externalBugID);
- var bugzillaName = getBugzillaName(IBURLArr.host);
+ console.log("inputBox = " + inputBox.val());
+ if (inputBox.val().match(/^http.*/)) {
+ var helpAElem = this.doc.get(0).createElement("a");
+ wholeURL = inputBox.val();
+ helpAElem.href = wholeURL;
+ var paramsArr = helpAElem.search.replace(/^\?/,'').split('&');
+ // get ID#
+ var params = {}, s = [];
+ for (var i = 0, ii = paramsArr.length; i < ii; i++) {
+ if (!paramsArr[i]) {
+ continue;
+ }
+ s = paramsArr[i].split('=');
+ params[s[0]] = s[1];
+ }
+ if (params.id) {
+ externalBugID = parseInt(params.id,10);
+ inputBox.val(externalBugID);
+ }
+ // get host and bugzillaName
+ var bugzillaName = this.getBugzillaName(helpAElem.hostname);
this.selectOption("external_id", bugzillaName);
- console.log("externalBugID = " + externalBugID);
- } else if (!isNaN(inputBox.text())) {
- externalBugID = parseInt(inputBox.text(),10);
- var bugzillaID = $("#external_id").text();
- wholeURL = getWholeURL(bugzillaID,externalBugID);
+ } else if (!isNaN(inputBox.val())) {
+ externalBugID = parseInt(inputBox.val(),10);
+ var bugzillaID = $("#external_id",this.doc).val();
+ wholeURL = this.getWholeURL(bugzillaID,externalBugID);
} else {
// no inputBox.value -- maybe there is an external bug from
// the previous commit?
}
+ console.log("refs = " + refs.length);
+ console.log("externalBugID = " + externalBugID);
// It is not good to close bug as UPSTREAM, if there is no reference
// to the upstream bug.
- if ((refs.length > 2) || (externalBugID > 0)) {
+ if ((externalBugID > 0) || (refs.length > 2)) {
this.addTextToComment(msgStrs.sentUpstreamString.replace("§§§",wholeURL));
this.selectOption("bug_status", "CLOSED");
this.selectOption("resolution", "UPSTREAM");
} else {
- alert("No external bug specified among the External References!");
+ console.log("No external bug specified among the External References!");
}
};
@@ -1323,6 +1304,7 @@ bzPage.prototype.buildButtons = function (above,below) {
this.addNewButton(newPosition,"newqueryintab","Query for string",
"","QUERYSEL","",false);
}
+ // FIXME Get compiz bugs as well
if ((chipIDsGroupings.length >0) &&
this.maintCCAddr === "xgl-maint@redhat.com") {
// Add find chip magic button
@@ -1409,8 +1391,11 @@ function bzPage(doc) {
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.changeOwner(that.defaultAssignee);
+ that.component = $("#component option:selected:first", this.doc).text();
+ that.changeOwner(filterByRegexp(defAssigneeList, that.component).
+ toLowerCase());
});
}