aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-03-23 20:18:23 +0100
committerMatěj Cepl <mcepl@redhat.com>2011-03-23 20:18:23 +0100
commit2e5993bc9bd0d468f4e9d12dd39e0548ba9adda1 (patch)
treef31a0d612efbfa5beb78e4718768c55c650f14d8
parentc662ccddab2cbcc6d13f49a21c04a6aea808f457 (diff)
downloadbugzilla-triage-2e5993bc9bd0d468f4e9d12dd39e0548ba9adda1.tar.gz
Fix indentation and else for Mozilla coding guidelines.
-rw-r--r--data/lib/bzpage.js1078
-rw-r--r--data/lib/color.js312
-rw-r--r--data/lib/jumpNextBug.js8
-rw-r--r--data/lib/logging-front.js123
-rw-r--r--data/lib/rhbzpage.js1323
-rw-r--r--data/lib/skip-bug.js20
-rw-r--r--data/lib/util.js293
-rw-r--r--lib/libbugzilla.js575
-rw-r--r--lib/logger.js170
-rw-r--r--lib/main.js228
-rw-r--r--lib/prompts.js130
-rw-r--r--lib/util.js60
-rw-r--r--lib/xmlrpc.js231
-rw-r--r--tests/pagemod-test-helpers.js35
-rw-r--r--tests/test-color.js28
-rw-r--r--tests/test-match-pattern.js14
-rw-r--r--tests/test-pageMod.js74
-rw-r--r--tests/test-util.js254
-rw-r--r--tests/test-xmlrpc.js46
19 files changed, 2527 insertions, 2475 deletions
diff --git a/data/lib/bzpage.js b/data/lib/bzpage.js
index 893a5ea..9afb112 100644
--- a/data/lib/bzpage.js
+++ b/data/lib/bzpage.js
@@ -9,43 +9,44 @@ var NumberOfFrames = 7;
// constants
var SalmonPink = new Color(255, 224, 176); // RGB 255, 224, 176; HSL 36, 2,
- // 85
+ // 85
var ReporterColor = new Color(255, 255, 166); // RGB 255, 255, 166; HSL 60, 2,
- // 83
+ // 83
// global variables
var config = {};
var constantData = {}; // This should be probably eliminated ASAP or
- // or done by other means. TODO
+ // or done by other means. TODO
/**
* central handler processing messages from the main script.
*/
onMessage = function onMessage(msg) {
- console.log("onMessage - incoming : msg.cmd = " + msg.cmd);
- switch (msg.cmd) {
- case "ReloadThePage":
- document.location.reload(true);
- break;
- case "queryLocal":
- queryInNewTab(msg.data, getComponent(), getProduct());
- break;
- case "CreateButtons":
- constantData = msg.data.constData;
- config = msg.data.config;
- generateButtons(msg.data.instPkgs, msg.data.kNodes);
- break;
- case "Error":
- alert("Error " + msg.data);
- break;
- case "Unhandled":
- break;
- default:
- if (RHOnMessageHandler) {
- RHOnMessageHandler(msg);
- } else {
- console.error("Error: unknown RPC call " + msg.toSource());
- }
- }
+ console.log("onMessage - incoming : msg.cmd = " + msg.cmd);
+ switch (msg.cmd) {
+ case "ReloadThePage":
+ document.location.reload(true);
+ break;
+ case "queryLocal":
+ queryInNewTab(msg.data, getComponent(), getProduct());
+ break;
+ case "CreateButtons":
+ constantData = msg.data.constData;
+ config = msg.data.config;
+ generateButtons(msg.data.instPkgs, msg.data.kNodes);
+ break;
+ case "Error":
+ alert("Error " + msg.data);
+ break;
+ case "Unhandled":
+ break;
+ default:
+ if (RHOnMessageHandler) {
+ RHOnMessageHandler(msg);
+ }
+ else {
+ console.error("Error: unknown RPC call " + msg.toSource());
+ }
+ }
};
/**
@@ -60,9 +61,9 @@ onMessage = function onMessage(msg) {
* impatiently when this bite us.
*/
function executeCommand(cmdObj) {
- for (var key in cmdObj) {
- centralCommandDispatch(key, cmdObj[key]);
- }
+ for (var key in cmdObj) {
+ centralCommandDispatch(key, cmdObj[key]);
+ }
}
/**
@@ -72,105 +73,106 @@ function executeCommand(cmdObj) {
* @param cmdParams Object with the appropriate parameters for the command
*/
function centralCommandDispatch (cmdLabel, cmdParams) {
- console.log("centralCommandDispatch : cmdLabel = " + cmdLabel);
- switch (cmdLabel) {
- case "name":
- case "position":
- break;
- case "resolution":
- case "product":
- case "component":
- case "version":
- case "priority":
- selectOption(cmdLabel, cmdParams);
- break;
- case "status":
- selectOption("bug_status", cmdParams);
- break;
- case "platform":
- selectOption("rep_platform", cmdParams);
- break;
- case "os":
- selectOption("op_sys", cmdParams);
- break;
- case "severity":
- selectOption("bug_severity", cmdParams);
- break;
- case "target":
- selectOption("target_milestone", cmdParams);
- break;
- case "addKeyword":
- addStuffToTextBox("keywords",cmdParams);
- break;
- case "removeKeyword":
- removeStuffFromTextBox("keywords", cmdParams);
- break;
- case "addWhiteboard":
- addStuffToTextBox("status_whiteboard",cmdParams);
- break;
- case "removeWhiteboard":
- removeStuffFromTextBox("status_whiteboard",cmdParams);
- break;
- case "assignee":
- changeAssignee(cmdParams);
- break;
- case "qacontact":
- clickMouse("bz_qa_contact_edit_action");
- document.getElementById("qa_contact").value = cmdParams;
- break;
- case "url":
- clickMouse("bz_url_edit_action");
- document.getElementById("bug_file_loc").value = cmdParams;
- break;
- // TODO dependson/blocked doesn't work. Find out why.
- case "addDependsOn":
- clickMouse("dependson_edit_action");
- addStuffToTextBox("dependson", cmdParams);
- break;
- case "removeDependsOn":
- clickMouse("dependson_edit_action");
- removeStuffFromTextBox("dependson", cmdParams);
- break;
- case "addBlocks":
- clickMouse("blocked_edit_action");
- addStuffToTextBox("blocked", cmdParams);
- break;
- case "removeBlocks":
- clickMouse("blocked_edit_action");
- removeStuffFromTextBox("blocked", cmdParams);
- break;
- case "comment":
- addStuffToTextBox("comment", cmdParams);
- break;
- case "commentIdx":
- throw "There should be no commentIdx here at all.";
- break;
- case "setNeedinfo":
- // cmdParams are actually ignored for now; we may in future
- // distinguish different actors to be target of needinfo
- setNeedinfoReporter();
- break;
- case "addCC":
- addToCCList(cmdParams);
- break;
- case "queryStringOurBugzilla":
- queryForSelection();
- break;
- // TODO flags, see also
- case "commit":
- if (cmdParams) {
- // Directly commit the form
- document.forms.namedItem("changeform").submit();
- }
- break;
- default:
- if (RHcentralCommandDispatch) {
- RHcentralCommandDispatch(cmdLabel, cmdParams);
- } else {
- console.error("Unknown command:\n" + cmdLabel + "\nparameters:\n" + cmdParams);
- }
- break;
- }
+ console.log("centralCommandDispatch : cmdLabel = " + cmdLabel);
+ switch (cmdLabel) {
+ case "name":
+ case "position":
+ break;
+ case "resolution":
+ case "product":
+ case "component":
+ case "version":
+ case "priority":
+ selectOption(cmdLabel, cmdParams);
+ break;
+ case "status":
+ selectOption("bug_status", cmdParams);
+ break;
+ case "platform":
+ selectOption("rep_platform", cmdParams);
+ break;
+ case "os":
+ selectOption("op_sys", cmdParams);
+ break;
+ case "severity":
+ selectOption("bug_severity", cmdParams);
+ break;
+ case "target":
+ selectOption("target_milestone", cmdParams);
+ break;
+ case "addKeyword":
+ addStuffToTextBox("keywords",cmdParams);
+ break;
+ case "removeKeyword":
+ removeStuffFromTextBox("keywords", cmdParams);
+ break;
+ case "addWhiteboard":
+ addStuffToTextBox("status_whiteboard",cmdParams);
+ break;
+ case "removeWhiteboard":
+ removeStuffFromTextBox("status_whiteboard",cmdParams);
+ break;
+ case "assignee":
+ changeAssignee(cmdParams);
+ break;
+ case "qacontact":
+ clickMouse("bz_qa_contact_edit_action");
+ document.getElementById("qa_contact").value = cmdParams;
+ break;
+ case "url":
+ clickMouse("bz_url_edit_action");
+ document.getElementById("bug_file_loc").value = cmdParams;
+ break;
+ // TODO dependson/blocked doesn't work. Find out why.
+ case "addDependsOn":
+ clickMouse("dependson_edit_action");
+ addStuffToTextBox("dependson", cmdParams);
+ break;
+ case "removeDependsOn":
+ clickMouse("dependson_edit_action");
+ removeStuffFromTextBox("dependson", cmdParams);
+ break;
+ case "addBlocks":
+ clickMouse("blocked_edit_action");
+ addStuffToTextBox("blocked", cmdParams);
+ break;
+ case "removeBlocks":
+ clickMouse("blocked_edit_action");
+ removeStuffFromTextBox("blocked", cmdParams);
+ break;
+ case "comment":
+ addStuffToTextBox("comment", cmdParams);
+ break;
+ case "commentIdx":
+ throw "There should be no commentIdx here at all.";
+ break;
+ case "setNeedinfo":
+ // cmdParams are actually ignored for now; we may in future
+ // distinguish different actors to be target of needinfo
+ setNeedinfoReporter();
+ break;
+ case "addCC":
+ addToCCList(cmdParams);
+ break;
+ case "queryStringOurBugzilla":
+ queryForSelection();
+ break;
+ // TODO flags, see also
+ case "commit":
+ if (cmdParams) {
+ // Directly commit the form
+ document.forms.namedItem("changeform").submit();
+ }
+ break;
+ default:
+ if (RHcentralCommandDispatch) {
+ RHcentralCommandDispatch(cmdLabel, cmdParams);
+ }
+ else {
+ console.error("Unknown command:\n" + cmdLabel + "\nparameters:\n" + cmdParams);
+ }
+ break;
+ }
}
/**
@@ -185,57 +187,59 @@ function centralCommandDispatch (cmdLabel, cmdParams) {
* do actual activity.
*/
function killNodes(doc, target, remove) {
- var targetArr = target instanceof Array ? target : target.trim().split(/[,\s]+/);
- targetArr.forEach(function(x) {
- if (remove) {
- var targetNode = doc.getElementById(x);
- targetNode.parentNode.removeChild(targetNode);
- } else {
- x.style.display = "none";
- }
- });
+ var targetArr = target instanceof Array ? target : target.trim().split(/[,\s]+/);
+ targetArr.forEach(function(x) {
+ if (remove) {
+ var targetNode = doc.getElementById(x);
+ targetNode.parentNode.removeChild(targetNode);
+ }
+ else {
+ x.style.display = "none";
+ }
+ });
}
/**
* Change assignee of the bug
*
* @param newAssignee String with the email address of new assigneeAElement
- * or 'default' if the component's default assignee should be used.
- * Value null clears "Reset Assignee to default for component" checkbox
+ * or 'default' if the component's default assignee should be used.
+ * Value null clears "Reset Assignee to default for component" checkbox
* @return none
*/
function changeAssignee (newAssignee) {
- var defAssigneeButton = null;
- // Previous assignee should know what's going on in his bug
- addToCCList(getOwner());
-
- // Optional value null
- if (newAssignee === null) {
- document.getElementById("set_default_assignee").removeAttribute(
- "checked");
+ var defAssigneeButton = null;
+ // Previous assignee should know what's going on in his bug
+ addToCCList(getOwner());
+
+ // Optional value null
+ if (newAssignee === null) {
+ document.getElementById("set_default_assignee").removeAttribute(
+ "checked");
+ return ;
+ }
+
+ if (getDefaultAssignee) {
+ if (newAssignee === "default") {
+ var defAss = getDefaultAssignee();
+ if (defAss) {
+ newAssignee = defAss;
+ }
+ else {
return ;
+ }
}
+ }
- if (getDefaultAssignee) {
- if (newAssignee === "default") {
- var defAss = getDefaultAssignee();
- if (defAss) {
- newAssignee = defAss;
- } else {
- return ;
- }
- }
- }
-
- if (newAssignee) {
- clickMouse("bz_assignee_edit_action");
- document.getElementById("assigned_to").value = newAssignee;
- document.getElementById("set_default_assignee").checked = false;
- defAssigneeButton = document.getElementById("defassignee_btn");
- if (defAssigneeButton) {
- defAssigneeButton.style.display = "none";
- }
+ if (newAssignee) {
+ clickMouse("bz_assignee_edit_action");
+ document.getElementById("assigned_to").value = newAssignee;
+ document.getElementById("set_default_assignee").checked = false;
+ defAssigneeButton = document.getElementById("defassignee_btn");
+ if (defAssigneeButton) {
+ defAssigneeButton.style.display = "none";
}
+ }
}
/**
@@ -247,29 +251,29 @@ function changeAssignee (newAssignee) {
* function will set up new one.
*/
function addToCommentsDropdown (cmdObj) {
- var select = document.getElementById("comment_action");
- if (!select) {
- config.commandsList = [];
- document.getElementById("comments").innerHTML +=
- "<div id='make_bugzilla_comment_action'>" +
- " <label for='comment_action'>Add Comment: </label>" +
- " <select id='comment_action'>" +
- " <option value=''>-- Select Comment from List --</option>" +
- " </select>" +
- "</div>";
- select = document.getElementById("comment_action");
- select.addEventListener("change", function (evt) {
- var value = select.options[select.selectedIndex].value;
- executeCommand(config.commandsList[value]);
- }, false);
- }
+ var select = document.getElementById("comment_action");
+ if (!select) {
+ config.commandsList = [];
+ document.getElementById("comments").innerHTML +=
+ "<div id='make_bugzilla_comment_action'>" +
+ " <label for='comment_action'>Add Comment: </label>" +
+ " <select id='comment_action'>" +
+ " <option value=''>-- Select Comment from List --</option>" +
+ " </select>" +
+ "</div>";
+ select = document.getElementById("comment_action");
+ select.addEventListener("change", function (evt) {
+ var value = select.options[select.selectedIndex].value;
+ executeCommand(config.commandsList[value]);
+ }, false);
+ }
- var opt = document.createElement("option");
- var objIdx = config.commandsList.length + 1;
- opt.value = objIdx;
- config.commandsList[objIdx] = cmdObj;
- opt.textContent = cmdObj.name;
- select.appendChild(opt);
+ var opt = document.createElement("option");
+ var objIdx = config.commandsList.length + 1;
+ opt.value = objIdx;
+ config.commandsList[objIdx] = cmdObj;
+ opt.textContent = cmdObj.name;
+ select.appendChild(opt);
}
/**
@@ -283,116 +287,119 @@ function addToCommentsDropdown (cmdObj) {
* @return none
*/
function createNewButton (location, after, cmdObj) {
- try {
- var newId = cmdObj.name.toLowerCase().replace(/[^a-z0-9]+/,"","g") + "_btn";
- } catch (e) {
- console.error("createNewButton : e = " + e +
- "\ncreateNewButton : cmdObj.toSource() = " +
- cmdObj.toSource());
- }
-
- // protection against double-firings
- if (document.getElementById(newId)) {
- console.log("Element with id " + newId + " already exists!");
- return ;
- }
-
- var newButton = document.createElement("input");
- newButton.setAttribute("id", newId);
- newButton.setAttribute("type", "button");
- newButton.value = cmdObj.name;
- newButton.addEventListener("click", function(evt) {
- executeCommand(cmdObj);
- }, false);
-
- var originalLocation = document.getElementById(location);
-
- try {
- if (after) {
- originalLocation.parentNode.insertBefore(newButton,
- originalLocation.nextSibling);
- originalLocation.parentNode.insertBefore(document
- .createTextNode("\u00A0"), newButton);
- } else {
- originalLocation.parentNode.insertBefore(newButton, originalLocation);
- originalLocation.parentNode.insertBefore(document
- .createTextNode("\u00A0"), originalLocation);
- }
- } catch (e) {
- if (e instanceof TypeError) {
- console.error("cannot find originalLocation element with id " + location);
- } else {
- throw e;
- }
- }
+ try {
+ var newId = cmdObj.name.toLowerCase().replace(/[^a-z0-9]+/,"","g") + "_btn";
+ } catch (e) {
+ console.error("createNewButton : e = " + e +
+ "\ncreateNewButton : cmdObj.toSource() = " +
+ cmdObj.toSource());
+ }
+
+ // protection against double-firings
+ if (document.getElementById(newId)) {
+ console.log("Element with id " + newId + " already exists!");
+ return ;
+ }
+
+ var newButton = document.createElement("input");
+ newButton.setAttribute("id", newId);
+ newButton.setAttribute("type", "button");
+ newButton.value = cmdObj.name;
+ newButton.addEventListener("click", function(evt) {
+ executeCommand(cmdObj);
+ }, false);
+
+ var originalLocation = document.getElementById(location);
+
+ try {
+ if (after) {
+ originalLocation.parentNode.insertBefore(newButton,
+ originalLocation.nextSibling);
+ originalLocation.parentNode.insertBefore(document
+ .createTextNode("\u00A0"), newButton);
+ }
+ else {
+ originalLocation.parentNode.insertBefore(newButton, originalLocation);
+ originalLocation.parentNode.insertBefore(document
+ .createTextNode("\u00A0"), originalLocation);
+ }
+ } catch (e) {
+ if (e instanceof TypeError) {
+ console.error("cannot find originalLocation element with id " + location);
+ }
+ else {
+ throw e;
+ }
+ }
}
/**
* Generate button based on
*/
function generateButtons (pkgs, kNodes) {
- var topRowPosition = "topRowPositionID";
- var bottomRowPosition = "commit";
-
- // =========================================================
- if (kNodes && window.location.hostname in kNodes) {
- var killConf = kNodes[window.location.hostname];
- killNodes(document, killConf[0], killConf[1]);
- }
-
- // create anchor for the top toolbar
- var commentBox = document.getElementById("comment");
- var brElement = document.createElement("br");
- brElement.setAttribute("id",topRowPosition);
- commentBox.parentNode.normalize();
- commentBox.parentNode.insertBefore(brElement, commentBox);
-
- for (var pkg in pkgs) {
- for (var cmdIdx in pkgs[pkg]) {
- var cmdObj = pkgs[pkg][cmdIdx];
- if (cmdObj.position !== undefined) {
- switch (cmdObj.position) {
- case "topRow":
- createNewButton(topRowPosition, false, cmdObj);
- break;
- case "bottomRow":
- createNewButton(bottomRowPosition, false, cmdObj);
- break;
- case "dropDown":
- addToCommentsDropdown(cmdObj);
- break;
- default: // [+-]ID
- var firstChr = cmdObj.position.charAt(0);
- var newId = cmdObj.position.substr(1);
- createNewButton(newId, firstChr === "+", cmdObj);
- break;
- }
- } else {
- console.error("generateButtons : rejected cmdObj = " +
- cmdObj.toSource());
- }
+ var topRowPosition = "topRowPositionID";
+ var bottomRowPosition = "commit";
+
+ // =========================================================
+ if (kNodes && window.location.hostname in kNodes) {
+ var killConf = kNodes[window.location.hostname];
+ killNodes(document, killConf[0], killConf[1]);
+ }
+
+ // create anchor for the top toolbar
+ var commentBox = document.getElementById("comment");
+ var brElement = document.createElement("br");
+ brElement.setAttribute("id",topRowPosition);
+ commentBox.parentNode.normalize();
+ commentBox.parentNode.insertBefore(brElement, commentBox);
+
+ for (var pkg in pkgs) {
+ for (var cmdIdx in pkgs[pkg]) {
+ var cmdObj = pkgs[pkg][cmdIdx];
+ if (cmdObj.position !== undefined) {
+ switch (cmdObj.position) {
+ case "topRow":
+ createNewButton(topRowPosition, false, cmdObj);
+ break;
+ case "bottomRow":
+ createNewButton(bottomRowPosition, false, cmdObj);
+ break;
+ case "dropDown":
+ addToCommentsDropdown(cmdObj);
+ break;
+ default: // [+-]ID
+ var firstChr = cmdObj.position.charAt(0);
+ var newId = cmdObj.position.substr(1);
+ createNewButton(newId, firstChr === "+", cmdObj);
+ break;
}
+ }
+ else {
+ console.error("generateButtons : rejected cmdObj = " +
+ cmdObj.toSource());
+ }
}
- // TODO This is weird in this place, but that's the place where all constantData etc.
- // are finally defined and available.
- if (RHBZinit) {
- RHBZinit();
- }
+ }
+ // TODO This is weird in this place, but that's the place where all constantData etc.
+ // are finally defined and available.
+ if (RHBZinit) {
+ RHBZinit();
+ }
}
function setConfigurationButton () {
- var additionalButtons = document.querySelector("#bugzilla-body *.related_actions");
- var configurationButtonUI = document.createElement("li");
- configurationButtonUI.innerHTML = "\u00A0-\u00A0<a href='' id='configurationButton'>"
- + "Triage configuration</a>";
- additionalButtons.appendChild(configurationButtonUI);
- document.getElementById("configurationButton").addEventListener(
- "click",
- function(evt) {
- postMessage(new Message("ChangeJSONURL", null));
- evt.stopPropagation();
- evt.preventDefault();
- }, false);
+ var additionalButtons = document.querySelector("#bugzilla-body *.related_actions");
+ var configurationButtonUI = document.createElement("li");
+ configurationButtonUI.innerHTML = "\u00A0-\u00A0<a href='' id='configurationButton'>"
+ + "Triage configuration</a>";
+ additionalButtons.appendChild(configurationButtonUI);
+ document.getElementById("configurationButton").addEventListener(
+ "click",
+ function(evt) {
+ postMessage(new Message("ChangeJSONURL", null));
+ evt.stopPropagation();
+ evt.preventDefault();
+ }, false);
}
/**
@@ -401,7 +408,7 @@ function setConfigurationButton () {
* @return string
*/
function getSummary() {
- return document.getElementById("short_desc_nonedit_display").textContent;
+ return document.getElementById("short_desc_nonedit_display").textContent;
}
/**
@@ -410,37 +417,37 @@ function getSummary() {
* @return string
*/
function getReporter () {
- var reporterElement = getOptionTableCell("bz_show_bug_column_2", "Reported");
- // RH Bugzilla after upgrade to 3.6.2 moved the information to other column
- if (!reporterElement) {
- reporterElement = getOptionTableCell("bz_show_bug_column_1", "Reported", true);
- }
- // Maemo calls the label "Reporter" and it doesn't have ids on table columns ... TODO(maemo)
- return parseMailto(reporterElement);
+ var reporterElement = getOptionTableCell("bz_show_bug_column_2", "Reported");
+ // RH Bugzilla after upgrade to 3.6.2 moved the information to other column
+ if (!reporterElement) {
+ reporterElement = getOptionTableCell("bz_show_bug_column_1", "Reported", true);
+ }
+ // Maemo calls the label "Reporter" and it doesn't have ids on table columns ... TODO(maemo)
+ return parseMailto(reporterElement);
}
function getComponent() {
- var elem = document.getElementById("component");
- if (elem) {
- return elem.value;
- }
- return null;
+ var elem = document.getElementById("component");
+ if (elem) {
+ return elem.value;
+ }
+ return null;
}
function getProduct() {
- var elem = document.getElementById("product");
- if (elem) {
- return elem.value;
- }
- return null;
+ var elem = document.getElementById("product");
+ if (elem) {
+ return elem.value;
+ }
+ return null;
}
function commentsWalker (fce) {
- var comments = document.getElementById("comments").
- getElementsByClassName("bz_comment");
- Array.forEach(comments, function(item) {
- fce(item);
- });
+ var comments = document.getElementById("comments").
+ getElementsByClassName("bz_comment");
+ Array.forEach(comments, function(item) {
+ fce(item);
+ });
}
/**
@@ -448,22 +455,22 @@ function commentsWalker (fce) {
*
*/
function checkComments () {
- var reporter = getReporter();
- commentsWalker(function(x) {
- var email = parseMailto(x.getElementsByClassName("vcard")[0]
- .getElementsByTagName("a")[0]);
- if (email.indexOf(reporter) != -1) {
- x.style.backgroundColor = ReporterColor.toString();
- }
- });
+ var reporter = getReporter();
+ commentsWalker(function(x) {
+ var email = parseMailto(x.getElementsByClassName("vcard")[0]
+ .getElementsByTagName("a")[0]);
+ if (email.indexOf(reporter) != -1) {
+ x.style.backgroundColor = ReporterColor.toString();
+ }
+ });
}
function collectComments () {
- var outStr = "";
- commentsWalker(function(x) {
- outStr += x.getElementsByTagName("pre")[0].textContent + "\n";
- });
- return outStr.trim();
+ var outStr = "";
+ commentsWalker(function(x) {
+ outStr += x.getElementsByTagName("pre")[0].textContent + "\n";
+ });
+ return outStr.trim();
}
@@ -478,37 +485,37 @@ function collectComments () {
*
*/
function selectOption (id, label, fireEvent) {
- if (!fireEvent) {
- fireEvent = true;
- }
- var sel = document.getElementById(id);
- sel.value = label;
- if (fireEvent) {
- var intEvent = document.createEvent("HTMLEvents");
- intEvent.initEvent("change", true, true);
- sel.dispatchEvent(intEvent);
- }
+ if (!fireEvent) {
+ fireEvent = true;
+ }
+ var sel = document.getElementById(id);
+ sel.value = label;
+ if (fireEvent) {
+ var intEvent = document.createEvent("HTMLEvents");
+ intEvent.initEvent("change", true, true);
+ sel.dispatchEvent(intEvent);
+ }
}
function selectOptionByLabel(id, label, fireEvent) {
- if (!fireEvent) {
- fireEvent = true;
- }
- var sel = document.getElementById(id);
- var labelRE = new RegExp(label.trim());
- var ourOption = Array.filter(sel.options, function (op) {
- return op.textContent.trim() === label;
- });
-
- if (ourOption[0]) {
- sel.value = ourOption[0].value;
- }
-
- if (fireEvent) {
- var intEvent = document.createEvent("HTMLEvents");
- intEvent.initEvent("change", true, true);
- sel.dispatchEvent(intEvent);
- }
+ if (!fireEvent) {
+ fireEvent = true;
+ }
+ var sel = document.getElementById(id);
+ var labelRE = new RegExp(label.trim());
+ var ourOption = Array.filter(sel.options, function (op) {
+ return op.textContent.trim() === label;
+ });
+
+ if (ourOption[0]) {
+ sel.value = ourOption[0].value;
+ }
+
+ if (fireEvent) {
+ var intEvent = document.createEvent("HTMLEvents");
+ intEvent.initEvent("change", true, true);
+ sel.dispatchEvent(intEvent);
+ }
}
/**
@@ -518,10 +525,10 @@ function selectOptionByLabel(id, label, fireEvent) {
* @return None
*/
function clickMouse (targetID) {
- var localEvent = document.createEvent("MouseEvents");
- localEvent.initMouseEvent("click", true, true, document.defaultView, 0, 0,
- 0, 0, 0, false, false, false, false, 0, null);
- document.getElementById(targetID).dispatchEvent(localEvent);
+ var localEvent = document.createEvent("MouseEvents");
+ localEvent.initMouseEvent("click", true, true, document.defaultView, 0, 0,
+ 0, 0, 0, false, false, false, false, 0, null);
+ document.getElementById(targetID).dispatchEvent(localEvent);
}
/**
@@ -533,13 +540,14 @@ function clickMouse (targetID) {
* @return none
*/
function addStuffToTextBox (id, stuff) {
- var textBox = document.getElementById(id);
- if (textBox.tagName.toLowerCase() === "textarea") {
- stuff = textBox.value ? "\n\n" + stuff : stuff;
- textBox.value += stuff;
- } else {
- textBox.value = addCSVValue(textBox.value,stuff);
- }
+ var textBox = document.getElementById(id);
+ if (textBox.tagName.toLowerCase() === "textarea") {
+ stuff = textBox.value ? "\n\n" + stuff : stuff;
+ textBox.value += stuff;
+ }
+ else {
+ textBox.value = addCSVValue(textBox.value,stuff);
+ }
}
/**
@@ -549,8 +557,8 @@ function addStuffToTextBox (id, stuff) {
* @param stuff String/Array with keyword(s) to be removed
*/
function removeStuffFromTextBox (id, stuff) {
- var changedElement = document.getElementById(id);
- changedElement.value = removeCSVValue(changedElement.value,stuff);
+ var changedElement = document.getElementById(id);
+ changedElement.value = removeCSVValue(changedElement.value,stuff);
}
/**
@@ -561,14 +569,14 @@ function removeStuffFromTextBox (id, stuff) {
* @return Boolean found?
*/
function idContainsWord (id, str) {
- var kwd = "";
- try {
- kwd = document.getElementById(id).value;
- } catch (e) {
- // For those who don't have particular element at all or if it is empty
- return false;
- }
- return (isInList(str, kwd.trim().split(/[,\s]+/)));
+ var kwd = "";
+ try {
+ kwd = document.getElementById(id).value;
+ } catch (e) {
+ // For those who don't have particular element at all or if it is empty
+ return false;
+ }
+ return (isInList(str, kwd.trim().split(/[,\s]+/)));
}
/**
@@ -578,7 +586,7 @@ function idContainsWord (id, str) {
* @return Boolean
*/
function hasKeyword (str) {
- return (idContainsWord('keywords', str));
+ return (idContainsWord('keywords', str));
}
/**
@@ -587,21 +595,21 @@ function hasKeyword (str) {
* @return Element with the href attribute containng the information
*/
function getOptionTableCell(tableId, label) {
- var cleanLabelRE = new RegExp("^\\s*([^.:]*):?\\s*$");
- label = label.trim().replace(cleanLabelRE,"$1").toLowerCase();
-
- var rows = document.getElementById(tableId).getElementsByTagName("tr");
- var ourLine = Array.filter(rows, function(row) {
- var curLabel = row.getElementsByTagName("td")[0].textContent.toLowerCase();
- curLabel = curLabel.replace(cleanLabelRE,"$1");
- return (curLabel === label); // maybe this could be a RE match instead
- });
+ var cleanLabelRE = new RegExp("^\\s*([^.:]*):?\\s*$");
+ label = label.trim().replace(cleanLabelRE,"$1").toLowerCase();
- if (ourLine.length > 0) {
- return ourLine[0].getElementsByTagName("td")[1].
- getElementsByTagName("a")[0];
- }
- return null;
+ var rows = document.getElementById(tableId).getElementsByTagName("tr");
+ var ourLine = Array.filter(rows, function(row) {
+ var curLabel = row.getElementsByTagName("td")[0].textContent.toLowerCase();
+ curLabel = curLabel.replace(cleanLabelRE,"$1");
+ return (curLabel === label); // maybe this could be a RE match instead
+ });
+
+ if (ourLine.length > 0) {
+ return ourLine[0].getElementsByTagName("td")[1].
+ getElementsByTagName("a")[0];
+ }
+ return null;
}
/**
@@ -613,17 +621,17 @@ function getOptionTableCell(tableId, label) {
* with parameter [reporter|assignee|general-email-address]
*/
function setNeedinfoReporter () {
- clickMouse("needinfo");
- selectOption("needinfo_role", "reporter");
+ clickMouse("needinfo");
+ selectOption("needinfo_role", "reporter");
}
/**
*
*/
function getOwner () {
- // TODO(maemo) doesn't work on maemo
- var assigneeAElement = getOptionTableCell("bz_show_bug_column_1","Assigned To");
- return parseMailto(assigneeAElement);
+ // TODO(maemo) doesn't work on maemo
+ var assigneeAElement = getOptionTableCell("bz_show_bug_column_1","Assigned To");
+ return parseMailto(assigneeAElement);
}
/**
@@ -633,8 +641,8 @@ function getOwner () {
* @return String with the maintainer's email address
*/
function getDefaultBugzillaMaintainer (component) {
- var address = filterByRegexp(constantData.defBugzillaMaintainerArr, component);
- return address;
+ var address = filterByRegexp(constantData.defBugzillaMaintainerArr, component);
+ return address;
}
/**
@@ -642,37 +650,37 @@ function getDefaultBugzillaMaintainer (component) {
*
* @param DOM element to be parsed
* @return array with string name of the attachment, integer its id number,
- * string of MIME type, integer of size in kilobytes, and the whole
- * element itself
+ * string of MIME type, integer of size in kilobytes, and the whole
+ * element itself
*
* TODO error handling is missing ... it's bleee
*/
function parseAttachmentLine(inElem) {
- var MIMEtype = "";
- var size = 0;
+ var MIMEtype = "";
+ var size = 0;
- // Skip over obsolete attachments
- if (inElem.getElementsByClassName("bz_obsolete").length > 0) {
- return ([]);
- }
+ // Skip over obsolete attachments
+ if (inElem.getElementsByClassName("bz_obsolete").length > 0) {
+ return ([]);
+ }
- // getting name of the attachment
- var attName = inElem.getElementsByTagName("b")[0].textContent.trim();
+ // getting name of the attachment
+ var attName = inElem.getElementsByTagName("b")[0].textContent.trim();
- // TODO probably could use url.URL object
- var aHrefsArr = inElem.getElementsByTagName("a");
- var aHref = Array.filter(aHrefsArr, function(x) {
- return x.textContent.trim() === "Details";
- })[0];
- var id = parseURL(aHref.getAttribute("href")).params.id;
+ // TODO probably could use url.URL object
+ var aHrefsArr = inElem.getElementsByTagName("a");
+ var aHref = Array.filter(aHrefsArr, function(x) {
+ return x.textContent.trim() === "Details";
+ })[0];
+ var id = parseURL(aHref.getAttribute("href")).params.id;
- // getting MIME type and size
- var stringArray = inElem.getElementsByClassName("bz_attach_extra_info")[0].textContent.
- replace(/[\n ()]+/g, " ").trim().split(", ");
- size = parseInt(stringArray[0], 10);
- MIMEtype = stringArray[1].split(" ")[0];
+ // getting MIME type and size
+ var stringArray = inElem.getElementsByClassName("bz_attach_extra_info")[0].textContent.
+ replace(/[\n ()]+/g, " ").trim().split(", ");
+ size = parseInt(stringArray[0], 10);
+ MIMEtype = stringArray[1].split(" ")[0];
- return [ attName, id, MIMEtype, size, inElem ];
+ return [ attName, id, MIMEtype, size, inElem ];
}
/**
@@ -680,17 +688,17 @@ function parseAttachmentLine(inElem) {
*
* @return Array of arrays, one for each attachments;
* each record has string name of the attachment, integer its id number,
- * string of MIME type, integer of size in kilobytes, and the whole
- * element itself
+ * string of MIME type, integer of size in kilobytes, and the whole
+ * element itself
*/
function getAttachments () {
- var outAtts = [];
- var atts = document.getElementById("attachment_table").
- getElementsByTagName("tr");
- for ( var i = 1, ii = atts.length - 1; i < ii; i++) {
- outAtts.push(parseAttachmentLine(atts[i]));
- }
- return outAtts;
+ var outAtts = [];
+ var atts = document.getElementById("attachment_table").
+ getElementsByTagName("tr");
+ for ( var i = 1, ii = atts.length - 1; i < ii; i++) {
+ outAtts.push(parseAttachmentLine(atts[i]));
+ }
+ return outAtts;
}
/**
@@ -699,19 +707,19 @@ function getAttachments () {
* @return String with the login name of the currently logged-in user
*/
function getLogin () {
- var lastLIElement = document.querySelector("#header ul.links li:last-of-type");
- var loginArr = lastLIElement.textContent.split("\n");
- var loginStr = loginArr[loginArr.length - 1].trim();
- return loginStr;
+ var lastLIElement = document.querySelector("#header ul.links li:last-of-type");
+ var loginArr = lastLIElement.textContent.split("\n");
+ var loginStr = loginArr[loginArr.length - 1].trim();
+ return loginStr;
}
function getSelection () {
- var text = "";
- var selectionObject = window.getSelection();
- if (selectionObject.rangeCount > 0) {
- text = selectionObject.getRangeAt(0).toString().trim();
- }
- return text;
+ var text = "";
+ var selectionObject = window.getSelection();
+ if (selectionObject.rangeCount > 0) {
+ text = selectionObject.getRangeAt(0).toString().trim();
+ }
+ return text;
}
/**
@@ -720,42 +728,42 @@ function getSelection () {
* @param text to be searched for
* @param component String with the component name (maybe latter regexp?)
* @param product (optional) string with the product name, if undefined,
- * search in all products
+ * search in all products
* @return None
*
*/
function queryInNewTab(text, component, product) {
- var urlStr = "https://" + window.location.hostname + "/buglist.cgi?query_format=advanced";
- if (product) {
- urlStr += "&product=" + product.trim();
- }
- if (component) {
- if ("equivalentComponents" in constantData) {
- var equivCompsArr = constantData.equivalentComponents.
- filter(function (REstr) {
- return new RegExp(REstr).test(getComponent());
- }, this);
- if (equivCompsArr.length > 0) {
- component = equivCompsArr[0];
- }
- }
- urlStr += "&component=" + component.trim();
- }
-
- // using more complicated query tables here, because they can be more easily
- // edited
- // for further investigative searches
- if (text) {
- text = encodeURIComponent(text.trim());
- var searchText = "&field0-0-0=longdesc&type0-0-0=substring&value0-0-0="
- + text
- + "&field0-0-1=attach_data.thedata&type0-0-1=substring&value0-0-1="
- + text
- + "&field0-0-2=status_whiteboard&type0-0-2=substring&value0-0-2="
- + text;
- urlStr += searchText;
- postMessage(new Message("OpenURLinTab", urlStr));
- }
+ var urlStr = "https://" + window.location.hostname + "/buglist.cgi?query_format=advanced";
+ if (product) {
+ urlStr += "&product=" + product.trim();
+ }
+ if (component) {
+ if ("equivalentComponents" in constantData) {
+ var equivCompsArr = constantData.equivalentComponents.
+ filter(function (REstr) {
+ return new RegExp(REstr).test(getComponent());
+ }, this);
+ if (equivCompsArr.length > 0) {
+ component = equivCompsArr[0];
+ }
+ }
+ urlStr += "&component=" + component.trim();
+ }
+
+ // using more complicated query tables here, because they can be more easily
+ // edited
+ // for further investigative searches
+ if (text) {
+ text = encodeURIComponent(text.trim());
+ var searchText = "&field0-0-0=longdesc&type0-0-0=substring&value0-0-0="
+ + text
+ + "&field0-0-1=attach_data.thedata&type0-0-1=substring&value0-0-1="
+ + text
+ + "&field0-0-2=status_whiteboard&type0-0-2=substring&value0-0-2="
+ + text;
+ urlStr += searchText;
+ postMessage(new Message("OpenURLinTab", urlStr));
+ }
}
/**
@@ -763,12 +771,13 @@ function queryInNewTab(text, component, product) {
* function this.queryInNewTab, and run it.
*/
function queryForSelection() {
- var text = getSelection();
- if (!text) {
- postMessage(new Message("GetClipboard", "queryLocal"));
- } else {
- queryInNewTab(text, getComponent(), getProduct());
- }
+ var text = getSelection();
+ if (!text) {
+ postMessage(new Message("GetClipboard", "queryLocal"));
+ }
+ else {
+ queryInNewTab(text, getComponent(), getProduct());
+ }
}
/**
@@ -778,17 +787,18 @@ function queryForSelection() {
* of the bugzilla should be added
*/
function addToCCList (who) {
- if (!who) {
- return ;
- }
- if (who === "self") {
- document.getElementById("addselfcc").checked = true;
- } else {
- clickMouse("cc_edit_area_showhide");
- if (!isInList(who, getCCList())) {
- addStuffToTextBox("newcc",who);
- }
+ if (!who) {
+ return ;
+ }
+ if (who === "self") {
+ document.getElementById("addselfcc").checked = true;
+ }
+ else {
+ clickMouse("cc_edit_area_showhide");
+ if (!isInList(who, getCCList())) {
+ addStuffToTextBox("newcc",who);
}
+ }
}
/**
@@ -797,58 +807,58 @@ function addToCCList (who) {
* @return Array with email addresses as Strings.
*/
function getCCList () {
- var CCListSelect = document.getElementById("cc");
- var outCCList = [];
- if (CCListSelect) {
- outCCList = Array.map(CCListSelect.options, function(item) {
- return item.value;
- });
- }
- return outCCList;
+ var CCListSelect = document.getElementById("cc");
+ var outCCList = [];
+ if (CCListSelect) {
+ outCCList = Array.map(CCListSelect.options, function(item) {
+ return item.value;
+ });
+ }
+ return outCCList;
}
function startup() {
- // First, preflight check ... if we are not logged in, there
- // is nothing we can do.
- var logoutLink = Array.some(document.links, function (x) {
- return x.search === "?logout=1" ;
- });
- if (!logoutLink) {
- return null; // This should just finish whole content script without
- // doing any harm to anybody.
- }
-
- // Prepare for query buttons
- // element ID brElementPlace_location is later used in JSON files
- // Stay with this add_comment element even if RH BZ upgrades, this seems
- // to be generally much more stable (even with other bugzillas, e.g. b.gnome.org)
- // then some getElementById.
- var commentArea = document.getElementsByName("add_comment")[0].parentNode;
- if (commentArea) {
- var brElementPlacer = commentArea.getElementsByTagName("br");
- brElementPlacer = brElementPlacer[0];
- if (brElementPlacer) {
- brElementPlacer.setAttribute("id","brElementPlacer_location");
- brElementPlacer.parentNode.insertBefore(document.createElement("br"),
- brElementPlacer);
- }
- }
-
- // TODO Probably could be ignored ... used only once on line 973 of rhbzpage.js
- // if (parseAbrtBacktraces && this.RE.Abrt.test(getSummary())) {
- // title = document.getElementById("short_desc_nonedit_display").textContent;
-
- // So, now we know we are logged in, so we can get to
- // the real work.
- setConfigurationButton();
- submitHandlerInstalled = false;
-
- checkComments();
-
- postMessage(new Message("GetInstalledPackages", {
- location: window.location.href,
- login: getLogin()
- }));
+ // First, preflight check ... if we are not logged in, there
+ // is nothing we can do.
+ var logoutLink = Array.some(document.links, function (x) {
+ return x.search === "?logout=1" ;
+ });
+ if (!logoutLink) {
+ return null; // This should just finish whole content script without
+ // doing any harm to anybody.
+ }
+
+ // Prepare for query buttons
+ // element ID brElementPlace_location is later used in JSON files
+ // Stay with this add_comment element even if RH BZ upgrades, this seems
+ // to be generally much more stable (even with other bugzillas, e.g. b.gnome.org)
+ // then some getElementById.
+ var commentArea = document.getElementsByName("add_comment")[0].parentNode;
+ if (commentArea) {
+ var brElementPlacer = commentArea.getElementsByTagName("br");
+ brElementPlacer = brElementPlacer[0];
+ if (brElementPlacer) {
+ brElementPlacer.setAttribute("id","brElementPlacer_location");
+ brElementPlacer.parentNode.insertBefore(document.createElement("br"),
+ brElementPlacer);
+ }
+ }
+
+ // TODO Probably could be ignored ... used only once on line 973 of rhbzpage.js
+ // if (parseAbrtBacktraces && this.RE.Abrt.test(getSummary())) {
+ // title = document.getElementById("short_desc_nonedit_display").textContent;
+
+ // So, now we know we are logged in, so we can get to
+ // the real work.
+ setConfigurationButton();
+ submitHandlerInstalled = false;
+
+ checkComments();
+
+ postMessage(new Message("GetInstalledPackages", {
+ location: window.location.href,
+ login: getLogin()
+ }));
}
startup();
diff --git a/data/lib/color.js b/data/lib/color.js
index c6cdc71..163071e 100644
--- a/data/lib/color.js
+++ b/data/lib/color.js
@@ -7,41 +7,44 @@
// http://www.mjijackson.com/2008/02\
// /rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript
function Color(r, g, b) {
- this.Luminosity = 0.85;
- this.Desaturated = 0.4;
-
- if (r instanceof Array) {
- 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.Luminosity = 0.85;
+ this.Desaturated = 0.4;
+
+ if (r instanceof Array) {
+ 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;
+ this.g = g;
+ this.b = b;
};
Color.prototype.hs = function(nStr) {
- if (Number(nStr) === 0) {
- return "00";
- } else if (nStr.length < 2) {
- return "0" + nStr;
- } else {
- return nStr;
- }
+ if (Number(nStr) === 0) {
+ return "00";
+ }
+ else if (nStr.length < 2) {
+ return "0" + nStr;
+ }
+ else {
+ return nStr;
+ }
};
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);
- return "#" + this.hs(rH) + this.hs(gH) + this.hs(bH);
+ var rH = Number(this.r.toFixed()).toString(16);
+ var gH = Number(this.g.toFixed()).toString(16);
+ var bH = Number(this.b.toFixed()).toString(16);
+ return "#" + this.hs(rH) + this.hs(gH) + this.hs(bH);
};
/**
@@ -55,32 +58,33 @@ Color.prototype.toString = function() {
* @return Array The HSL representation
*/
Color.prototype.hsl = function() {
- 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) {
- h = s = 0; // achromatic
- } else {
- var d = max - min;
- s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
- switch (max) {
- case r:
- h = (g - b) / d + (g < b ? 6 : 0);
- break;
- case g:
- h = (b - r) / d + 2;
- break;
- case b:
- h = (r - g) / d + 4;
- break;
- }
- h /= 6;
+ 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) {
+ h = s = 0; // achromatic
+ }
+ else {
+ var d = max - min;
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
+ switch (max) {
+ case r:
+ h = (g - b) / d + (g < b ? 6 : 0);
+ break;
+ case g:
+ h = (b - r) / d + 2;
+ break;
+ case b:
+ h = (r - g) / d + 4;
+ break;
}
+ h /= 6;
+ }
- return [ h, s, l ];
+ return [ h, s, l ];
};
/**
@@ -94,38 +98,39 @@ 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;
+ function hue2rgb(p, q, t) {
+ if (t < 0) {
+ t += 1;
}
-
- var r, g, b;
-
- if (s === 0) {
- r = g = b = l; // achromatic
- } else {
- var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
- var p = 2 * l - q;
- r = hue2rgb(p, q, h + 1 / 3);
- g = hue2rgb(p, q, h);
- b = hue2rgb(p, q, h - 1 / 3);
+ if (t > 1) {
+ t -= 1;
}
-
- return [ r * 255, g * 255, b * 255 ];
+ 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) {
+ r = g = b = l; // achromatic
+ }
+ else {
+ var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
+ var p = 2 * l - q;
+ r = hue2rgb(p, q, h + 1 / 3);
+ g = hue2rgb(p, q, h);
+ b = hue2rgb(p, q, h - 1 / 3);
+ }
+
+ return [ r * 255, g * 255, b * 255 ];
};
/**
@@ -139,33 +144,34 @@ Color.prototype.hslToRgb = function(h, s, l) {
* @return Array The HSV representation
*/
Color.prototype.hsv = function() {
- 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;
-
- if (max === min) {
- h = 0; // achromatic
- } else {
- switch (max) {
- case r:
- h = (g - b) / d + (g < b ? 6 : 0);
- break;
- case g:
- h = (b - r) / d + 2;
- break;
- case b:
- h = (r - g) / d + 4;
- break;
- }
- h /= 6;
+ 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;
+
+ if (max === min) {
+ h = 0; // achromatic
+ }
+ else {
+ switch (max) {
+ case r:
+ h = (g - b) / d + (g < b ? 6 : 0);
+ break;
+ case g:
+ h = (b - r) / d + 2;
+ break;
+ case b:
+ h = (r - g) / d + 4;
+ break;
}
+ h /= 6;
+ }
- return [ h, s, v ];
+ return [ h, s, v ];
};
/**
@@ -179,58 +185,58 @@ Color.prototype.hsv = function() {
* @return Array The RGB representation
*/
Color.prototype.hsvToRgb = function(h, s, v) {
- var r, g, b;
-
- var i = Math.floor(h * 6);
- var f = h * 6 - i;
- var p = v * (1 - s);
- var q = v * (1 - f * s);
- 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;
- }
-
- return [ r * 255, g * 255, b * 255 ];
+ var r, g, b;
+
+ var i = Math.floor(h * 6);
+ var f = h * 6 - i;
+ var p = v * (1 - s);
+ var q = v * (1 - f * s);
+ 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;
+ }
+
+ return [ r * 255, g * 255, b * 255 ];
};
/**
* Provide
*/
Color.prototype.lightColor = function() {
- var hslArray = this.hsl();
- var h = Number(hslArray[0]);
- var s = Number(hslArray[1]) * this.Desaturated;
- var l = this.Luminosity;
- var desA = this.hslToRgb(h, s, l);
- return new Color(desA[0], desA[1], desA[2]);
+ var hslArray = this.hsl();
+ var h = Number(hslArray[0]);
+ var s = Number(hslArray[1]) * this.Desaturated;
+ var l = this.Luminosity;
+ var desA = this.hslToRgb(h, s, l);
+ return new Color(desA[0], desA[1], desA[2]);
};
diff --git a/data/lib/jumpNextBug.js b/data/lib/jumpNextBug.js
index f07bed0..af0ff39 100644
--- a/data/lib/jumpNextBug.js
+++ b/data/lib/jumpNextBug.js
@@ -6,10 +6,10 @@ var nextRE = new RegExp("Next");
var aNavigElements = document.querySelectorAll("#bugzilla-body .navigation a");
var filteredElements = Array.filter(aNavigElements, function(elem) {
- return nextRE.test(elem.textContent);
+ return nextRE.test(elem.textContent);
});
if (filteredElements.length > 0) {
- nextElement = filteredElements[0];
- nextElement.setAttribute("accesskey", "n");
- nextElement.innerHTML = "<u>N</u>ext";
+ nextElement = filteredElements[0];
+ nextElement.setAttribute("accesskey", "n");
+ nextElement.innerHTML = "<u>N</u>ext";
}
diff --git a/data/lib/logging-front.js b/data/lib/logging-front.js
index f6b3546..d186d7f 100644
--- a/data/lib/logging-front.js
+++ b/data/lib/logging-front.js
@@ -8,80 +8,81 @@ var FullLogsColor = new Color(0, 40, 103);
var submitHandlerInstalled = false; // for setUpLogging
function addLogRecord() {
- var rec = {};
- rec.date = new Date();
- rec.url = document.location.toString();
- rec.title = document.title;
- var comment = window.prompt(
- "Enter comments for this comment");
- if (comment !== null) {
- comment = comment.trim();
- if (comment.length > 0) {
- comment = comment.trim();
- rec.comment = comment;
- var dateStr = getISODate(rec.date);
- var urlStr = window.location.hostname;
- var bugNo = getBugNoFromURL(window.location.href);
- rec.key = dateStr + "+" +
- urlStr + "+" + bugNo;
- postMessage(new Message("AddLogRecord", rec));
- }
- return rec;
+ var rec = {};
+ rec.date = new Date();
+ rec.url = document.location.toString();
+ rec.title = document.title;
+ var comment = window.prompt(
+ "Enter comments for this comment");
+ if (comment !== null) {
+ comment = comment.trim();
+ if (comment.length > 0) {
+ comment = comment.trim();
+ rec.comment = comment;
+ var dateStr = getISODate(rec.date);
+ var urlStr = window.location.hostname;
+ var bugNo = getBugNoFromURL(window.location.href);
+ rec.key = dateStr + "+" +
+ urlStr + "+" + bugNo;
+ postMessage(new Message("AddLogRecord", rec));
}
- return null;
+ return rec;
+ }
+ return null;
}
/**
*/
function setUpLogging () {
- // Protection against double-call
- if (document.getElementById("generateTSButton")) {
- return ;
- }
+ // Protection against double-call
+ if (document.getElementById("generateTSButton")) {
+ return ;
+ }
- // For adding additional buttons to the top toolbar
- var additionalButtons = document.querySelector("#bugzilla-body *.related_actions");
- var that = this;
+ // For adding additional buttons to the top toolbar
+ var additionalButtons = document.querySelector("#bugzilla-body *.related_actions");
+ var that = this;
- // logging all submits for timesheet
- if (!submitHandlerInstalled) {
- document.forms.namedItem("changeform").addEventListener("submit",function (evt) {
- if (addLogRecord() === null) {
- evt.stopPropagation();
- evt.preventDefault();
- }
- }, false);
- submitHandlerInstalled = true;
- }
+ // logging all submits for timesheet
+ if (!submitHandlerInstalled) {
+ document.forms.namedItem("changeform").addEventListener("submit",function (evt) {
+ if (addLogRecord() === null) {
+ evt.stopPropagation();
+ evt.preventDefault();
+ }
+ }, false);
+ submitHandlerInstalled = true;
+ }
- // (id, text, parent, callback, params, before, covered, accesskey)
- createDeadLink("generateTSButton", "Generate TS", additionalButtons,
- function(evt) {
- postMessage(new Message("GenerateTS"));
- }, [], "dash", "li");
+ // (id, text, parent, callback, params, before, covered, accesskey)
+ createDeadLink("generateTSButton", "Generate TS", additionalButtons,
+ function(evt) {
+ postMessage(new Message("GenerateTS"));
+ }, [], "dash", "li");
- createDeadLink("clearLogs", "Clear TS", additionalButtons,
- function(evt) {
- postMessage(new Message("ClearTS"));
- }, [], "dash", "li");
+ createDeadLink("clearLogs", "Clear TS", additionalButtons,
+ function(evt) {
+ postMessage(new Message("ClearTS"));
+ }, [], "dash", "li");
- createDeadLink("importTSButton", "Import TS", additionalButtons,
- function(evt) {
- postMessage(new Message("ImportTS"));
- }, [], "dash", "li");
+ createDeadLink("importTSButton", "Import TS", additionalButtons,
+ function(evt) {
+ postMessage(new Message("ImportTS"));
+ }, [], "dash", "li");
- /* TODO
- var clearLogAElem = document.getElementById("clearLogs");
- if (this.log.isEmpty()) {
- clearLogAElem.style.color = this.log.EmptyLogsColor;
- clearLogAElem.style.fontWeight = "normal";
- } else {
- clearLogAElem.style.color = this.log.FullLogsColor;
- clearLogAElem.style.fontWeight = "bolder";
- }
- */
+ /* TODO
+ var clearLogAElem = document.getElementById("clearLogs");
+ if (this.log.isEmpty()) {
+ clearLogAElem.style.color = this.log.EmptyLogsColor;
+ clearLogAElem.style.fontWeight = "normal";
+ }
+ else {
+ clearLogAElem.style.color = this.log.FullLogsColor;
+ clearLogAElem.style.fontWeight = "bolder";
+ }
+ */
}
if (window.location.hostname == "bugzilla.redhat.com") {
- setUpLogging();
+ setUpLogging();
}
diff --git a/data/lib/rhbzpage.js b/data/lib/rhbzpage.js
index 65e16a2..9af0127 100644
--- a/data/lib/rhbzpage.js
+++ b/data/lib/rhbzpage.js
@@ -6,8 +6,8 @@ var titleParsedAttachment = "Part of the thread where crash happened";
// For identification of graphics card
var manuChipStrs = [ [ "ATI Radeon", "ATI", "1002" ],
- [ "ATI Mobility Radeon", "ATI", "1002" ],
- [ "Intel Corporation", "INTEL", "8086" ], [ "NVIDIA", "NV", "10de" ] ];
+ [ "ATI Mobility Radeon", "ATI", "1002" ],
+ [ "Intel Corporation", "INTEL", "8086" ], [ "NVIDIA", "NV", "10de" ] ];
// http://en.wikipedia.org/wiki/HSL_color_space
// when only the value of S is changed
@@ -15,43 +15,43 @@ var manuChipStrs = [ [ "ATI Radeon", "ATI", "1002" ],
var RHColor = new Color(158, 41, 43); // RGB 158, 41, 43; HSL 359, 1, 39
var FedoraColor = new Color(0, 40, 103); // RGB 0, 40, 103; HSL 359, 1, 39
var RawhideColor = new Color(0, 119, 0); // or "green", or RGB 0, 119, 0, or
- // HSL
+ // HSL
// 120, 0, 23
var RHITColor = new Color(102, 0, 102); // RGB 102, 0, 102; HSL 300, 0, 20
// [ 126.386] (--) NOUVEAU(0): Chipset: "NVIDIA NVaf"
var logAnalyzeLogic = {
- "AnalyzeInterestingLine": {
- /*
- [ 126.378] (--) PCI:*(0:4:0:0) 10de:08a0:106b:00c2 rev 162, Mem @ 0xd2000000/16777216, \
- 0xc0000000/268435456, 0xd0000000/33554432, I/O @ 0x00001000/128, BIOS @ 0x????????/131072
- */
- re: [
- "^(\\[[ .0-9]+\\])?\\s*\\(--\\) PCI:\\*\\([0-9:]+\\)\\s*" +
- "([0-9a-f:]+).*$",
- "^\\s*\\[?[ 0-9.]*\\]?\\s*\\(--\\) "+
- "([A-Za-z]+)\\([0-9]?\\): Chipset: (.*)$",
- ],
- func: chipsetMagic
- },
- /*
- [ 126.385] (WW) Falling back to old probe method for vesa
- [ 126.385] (WW) Falling back to old probe method for fbdev
- [ 126.386] (--) NOUVEAU(0): Chipset: "NVIDIA NVaf"
- Backtrace:
-
- [ 33.158] Kernel command line: ro root=LABEL=root rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=us drm.debug=0x04
-
- */
- "AnalyzeXorgLogBacktrace": {
- re: "^\\s*(\\[[0-9 .]*\\])?\\s*(\\((EE|WW)\\)|.* [cC]hipset:.*)|\\s*(Backtrace|Kernel command line)",
- func: analyzeXorg
- }
+ "AnalyzeInterestingLine": {
+ /*
+ [ 126.378] (--) PCI:*(0:4:0:0) 10de:08a0:106b:00c2 rev 162, Mem @ 0xd2000000/16777216, \
+ 0xc0000000/268435456, 0xd0000000/33554432, I/O @ 0x00001000/128, BIOS @ 0x????????/131072
+ */
+ re: [
+ "^(\\[[ .0-9]+\\])?\\s*\\(--\\) PCI:\\*\\([0-9:]+\\)\\s*" +
+ "([0-9a-f:]+).*$",
+ "^\\s*\\[?[ 0-9.]*\\]?\\s*\\(--\\) "+
+ "([A-Za-z]+)\\([0-9]?\\): Chipset: (.*)$",
+ ],
+ func: chipsetMagic
+ },
+ /*
+ [ 126.385] (WW) Falling back to old probe method for vesa
+ [ 126.385] (WW) Falling back to old probe method for fbdev
+ [ 126.386] (--) NOUVEAU(0): Chipset: "NVIDIA NVaf"
+ Backtrace:
+
+ [ 33.158] Kernel command line: ro root=LABEL=root rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=us drm.debug=0x04
+
+ */
+ "AnalyzeXorgLogBacktrace": {
+ re: "^\\s*(\\[[0-9 .]*\\])?\\s*(\\((EE|WW)\\)|.* [cC]hipset:.*)|\\s*(Backtrace|Kernel command line)",
+ func: analyzeXorg
+ }
};
var ProfessionalProducts = [
- "Red Hat Enterprise Linux",
- "Red Hat Enterprise MRG"
+ "Red Hat Enterprise Linux",
+ "Red Hat Enterprise MRG"
];
// END OF CONSTANTS
@@ -60,29 +60,29 @@ var btSnippet = null;
var reqCounter = 0; // TODO should be probably a dict indexed by called method
function RHOnMessageHandler(msg) {
- switch (msg.cmd) {
- case "Error":
- alert("Error " + msg.data);
- break;
- case "Unhandled":
- break;
- case "AddAttachmentCallback":
- addAttachmentCallback(msg.data);
- break;
- case "FixAttachmentMIMECallback":
- XMLRPCcallback();
- break;
- case "AnalyzeInterestingLine":
- case "AnalyzeXorgLogBacktrace":
- findInterestingLine(msg.data, msg.cmd);
- break;
- case "queryUpstream":
- queryUpstreamCallback(msg.data);
- break;
- default:
- console.error("Error: unknown RPC call " + msg.toSource());
- break;
- }
+ switch (msg.cmd) {
+ case "Error":
+ alert("Error " + msg.data);
+ break;
+ case "Unhandled":
+ break;
+ case "AddAttachmentCallback":
+ addAttachmentCallback(msg.data);
+ break;
+ case "FixAttachmentMIMECallback":
+ XMLRPCcallback();
+ break;
+ case "AnalyzeInterestingLine":
+ case "AnalyzeXorgLogBacktrace":
+ findInterestingLine(msg.data, msg.cmd);
+ break;
+ case "queryUpstream":
+ queryUpstreamCallback(msg.data);
+ break;
+ default:
+ console.error("Error: unknown RPC call " + msg.toSource());
+ break;
+ }
}
// RHBugzillaPage object
@@ -94,8 +94,8 @@ function RHOnMessageHandler(msg) {
* we haven't set it up.
*/
function getDefaultAssignee() {
- return filterByRegexp(constantData.defaultAssignee,
- getComponent()).toLowerCase();
+ return filterByRegexp(constantData.defaultAssignee,
+ getComponent()).toLowerCase();
}
/**
@@ -105,76 +105,78 @@ function getDefaultAssignee() {
* sets this.defaultAssignee property according to defaultAssignee list
*/
function setDefaultAssignee() {
- var defAss = getDefaultAssignee();
-
- // Add setting default assignee
- if ((defAss.length > 0) && (defAss !== getOwner())) {
- createNewButton("bz_assignee_edit_container",true, {
- "name": "Def. Assignee",
- "assignee": "default"
- });
- }
+ var defAss = getDefaultAssignee();
+
+ // Add setting default assignee
+ if ((defAss.length > 0) && (defAss !== getOwner())) {
+ createNewButton("bz_assignee_edit_container",true, {
+ "name": "Def. Assignee",
+ "assignee": "default"
+ });
+ }
}
/**
* Auxiliary function to compute more complicated resolution
*/
function closeSomeRelease() {
- // for RAWHIDE close as RAWHIDE,
- // if active selection -> CURRENTRELEASE
- // and put the release version to
- // "Fixed in Version" textbox
- // otherwise -> NEXTRELEASE
- selectOption("bug_status", "CLOSED");
- var text = getSelection();
- var resolution = "";
-
- if (text.length > 0) {
- resolution = "CURRENTRELEASE";
- document.getElementById("cf_fixed_in").value = text;
- } else if (document.getElementById("version").value === "rawhide") {
- resolution = "RAWHIDE";
- } else {
- resolution = "NEXTRELEASE";
- }
- centralCommandDispatch("resolution", resolution);
+ // for RAWHIDE close as RAWHIDE,
+ // if active selection -> CURRENTRELEASE
+ // and put the release version to
+ // "Fixed in Version" textbox
+ // otherwise -> NEXTRELEASE
+ selectOption("bug_status", "CLOSED");
+ var text = getSelection();
+ var resolution = "";
+
+ if (text.length > 0) {
+ resolution = "CURRENTRELEASE";
+ document.getElementById("cf_fixed_in").value = text;
+ }
+ else if (document.getElementById("version").value === "rawhide") {
+ resolution = "RAWHIDE";
+ }
+ else {
+ resolution = "NEXTRELEASE";
+ }
+ centralCommandDispatch("resolution", resolution);
}
/**
* Additional commands specific for this subclass, overriding superclass one.
*/
function RHcentralCommandDispatch(cmdLabel, cmdParams) {
- switch (cmdLabel) {
- // Set up our own commands
- case "closeUpstream":
- addClosingUpstream();
- break;
- case "computeResolution":
- closeSomeRelease();
- break;
- case "queryStringUpstreamBugzilla":
- queryUpstream();
- break;
- case "sendBugUpstream":
- sendBugUpstream();
- break;
- case "markTriaged":
- markBugTriaged();
- break;
- case "chipMagic":
- fillInWhiteBoard(cmdParams);
- break;
- // If we don't have it here, call superclass method
- default:
- console.error("Unknown command:\n" + cmdLabel + "\nparameters:\n" + cmdParams);
- break;
- }
+ switch (cmdLabel) {
+ // Set up our own commands
+ case "closeUpstream":
+ addClosingUpstream();
+ break;
+ case "computeResolution":
+ closeSomeRelease();
+ break;
+ case "queryStringUpstreamBugzilla":
+ queryUpstream();
+ break;
+ case "sendBugUpstream":
+ sendBugUpstream();
+ break;
+ case "markTriaged":
+ markBugTriaged();
+ break;
+ case "chipMagic":
+ fillInWhiteBoard(cmdParams);
+ break;
+ // If we don't have it here, call superclass method
+ default:
+ console.error("Unknown command:\n" + cmdLabel + "\nparameters:\n" + cmdParams);
+ break;
+ }
}
function addAttachmentCallback(resp) {
- var newAttachID = parseInt(resp.params.param.value.array.data.value.int, 10);
- console.log("attachID = " + newAttachID);
- // FIXME callback.call(param, newAttachID, data.length);
+ var newAttachID = parseInt(resp.params.param.value.array.data.value.int, 10);
+ console.log("attachID = " + newAttachID);
+ // FIXME callback.call(param, newAttachID, data.length);
}
/**
@@ -183,30 +185,30 @@ function addAttachmentCallback(resp) {
* XML-RPC call yet.
*/
function addAttachment(data, callback, param) {
- var params = [];
+ var params = [];
- if (!constantData.passwordState.passAvailable) {
- console.error("addAttachment : No password, no XML-RPC calls; sorry");
- return null;
- }
-
- params.push(getBugNo());
- params.push({
- description: titleParsedAttachment,
- filename: "parsed-backtrace.txt",
- contenttype: "text/plain",
- data: window.btoa(data),
- nomail: true
- });
-
- postMessage(new Message("MakeXMLRPCall", {
- url: constantData.XMLRPCData[window.location.hostname].url,
- login: getLogin(),
- method: "bugzilla.addAttachment",
- params: params,
- callRPC: "AddAttachmentCallback"
- }));
- reqCounter++;
+ if (!constantData.passwordState.passAvailable) {
+ console.error("addAttachment : No password, no XML-RPC calls; sorry");
+ return null;
+ }
+
+ params.push(getBugNo());
+ params.push({
+ description: titleParsedAttachment,
+ filename: "parsed-backtrace.txt",
+ contenttype: "text/plain",
+ data: window.btoa(data),
+ nomail: true
+ });
+
+ postMessage(new Message("MakeXMLRPCall", {
+ url: constantData.XMLRPCData[window.location.hostname].url,
+ login: getLogin(),
+ method: "bugzilla.addAttachment",
+ params: params,
+ callRPC: "AddAttachmentCallback"
+ }));
+ reqCounter++;
}
/* === Bugzilla functions === */
@@ -214,69 +216,69 @@ function addAttachment(data, callback, param) {
*
*/
function pasteBacktraceInComments(atts) {
- /*
- Let's comment it out, and we'll see if anything breaks.
- TODO This paragraph looks suspicous ... what is it?
- Does it belong to this function?
- var notedLabel = document.querySelector("label[for='newcc']");
- while (notedLabel.firstChild) {
- var node = notedLabel.removeChild(notedLabel.firstChild);
- notedLabel.parentNode.insertBefore(node, notedLabel);
- }
- notedLabel.parentNode.removeChild(notedLabel);
- */
-
- // FIXME BROKEN and its depending functions are even more broken
- return null;
-
- var abrtQueryURL = "https://bugzilla.redhat.com/buglist.cgi?" +
- "cmdtype=dorem&remaction=run&namedcmd=all%20NEW%20abrt%20crashes&"+
+ /*
+ Let's comment it out, and we'll see if anything breaks.
+ TODO This paragraph looks suspicous ... what is it?
+ Does it belong to this function?
+ var notedLabel = document.querySelector("label[for='newcc']");
+ while (notedLabel.firstChild) {
+ var node = notedLabel.removeChild(notedLabel.firstChild);
+ notedLabel.parentNode.insertBefore(node, notedLabel);
+ }
+ notedLabel.parentNode.removeChild(notedLabel);
+ */
+
+ // FIXME BROKEN and its depending functions are even more broken
+ return null;
+
+ var abrtQueryURL = "https://bugzilla.redhat.com/buglist.cgi?" +
+ "cmdtype=dorem&remaction=run&namedcmd=all%20NEW%20abrt%20crashes&"+
"sharer_id=74116";
- var mainTitle = document
- .getElementsByClassName("bz_alias_short_desc_container")[0];
-
- createDeadLink ("callAbrtQuery_link",
- "Abrt bugs", mainTitle, abrtQueryURL, [], false, null, "a");
-
- if (idContainsWord("cf_devel_whiteboard", 'btparsed')) {
- addStuffToTextBox('status_whiteboard', 'btparsed');
- }
-
- if (!(isTriaged() || idContainsWord("status_whiteboard",
- 'btparsed') || (atts.length > 0))) {
- var btAttachments = atts
- .filter(function(att) {
- return (/File: backtrace/.test(att[0]));
- });
- // TODO we need to go through all backtrace attachments, but
- // just the first one will do for now, we would need to do async
- // parsing
- btAttachments.forEach(function(x) {
- var attURL = "https://bugzilla.redhat.com/attachment.cgi?id="
- + x[1];
- if ((!btSnippet) && // ???? FIXME
- (!idContainsWord("status_whiteboard", 'btparsed'))) {
- Request({
- url: attURL,
- onComplete: function(response) {
- if (response.status == 200) {
- btSnippet = parseBacktrace(response.text);
- if (btSnippet) {
- addCheckShowLink(x,btSnippet);
- }
- }
- }
- }).get();
+ var mainTitle = document
+ .getElementsByClassName("bz_alias_short_desc_container")[0];
+
+ createDeadLink ("callAbrtQuery_link",
+ "Abrt bugs", mainTitle, abrtQueryURL, [], false, null, "a");
+
+ if (idContainsWord("cf_devel_whiteboard", 'btparsed')) {
+ addStuffToTextBox('status_whiteboard', 'btparsed');
+ }
+
+ if (!(isTriaged() || idContainsWord("status_whiteboard",
+ 'btparsed') || (atts.length > 0))) {
+ var btAttachments = atts
+ .filter(function(att) {
+ return (/File: backtrace/.test(att[0]));
+ });
+ // TODO we need to go through all backtrace attachments, but
+ // just the first one will do for now, we would need to do async
+ // parsing
+ btAttachments.forEach(function(x) {
+ var attURL = "https://bugzilla.redhat.com/attachment.cgi?id="
+ + x[1];
+ if ((!btSnippet) && // ???? FIXME
+ (!idContainsWord("status_whiteboard", 'btparsed'))) {
+ Request({
+ url: attURL,
+ onComplete: function(response) {
+ if (response.status == 200) {
+ btSnippet = parseBacktrace(response.text);
+ if (btSnippet) {
+ addCheckShowLink(x,btSnippet);
+ }
}
- }, this);
- }
- // Add "show BT" links
- if (parsedAttachments.length > 0) {
- this.parsedAttachments.forEach(function (att) {
- addShowParsedBTLink(att);
- });
- }
+ }
+ }).get();
+ }
+ }, this);
+ }
+ // Add "show BT" links
+ if (parsedAttachments.length > 0) {
+ this.parsedAttachments.forEach(function (att) {
+ addShowParsedBTLink(att);
+ });
+ }
}
/**
@@ -286,8 +288,8 @@ function pasteBacktraceInComments(atts) {
* @return none
*/
function showAttachment(id) {
- postMessage(new Message("OpenURLinPanel",
- "https://" + window.location.hostname + "/attachment.cgi?id=" + id));
+ postMessage(new Message("OpenURLinPanel",
+ "https://" + window.location.hostname + "/attachment.cgi?id=" + id));
}
/**
@@ -296,54 +298,54 @@ function showAttachment(id) {
* @param att Attachment object
*/
function addShowParsedBTLink(att) {
- var elem = att[4].querySelector("td:last-of-type");
- createDeadLink("showParsedBacktraceWindow-" + att[1], "showBT",
- elem, showAttachment, att[1], true);
+ var elem = att[4].querySelector("td:last-of-type");
+ createDeadLink("showParsedBacktraceWindow-" + att[1], "showBT",
+ elem, showAttachment, att[1], true);
}
/**
* Unfinished ... see above FIXME BROKEN AND DOESN'T WORK
*/
function addNewAttachmentRow(origAtt,
- newAttId, newAttSize) {
- var that = this;
- var oldAddBTLink = document.getElementById("attachBacktraceActivator");
- oldAddBTLink.parentNode.removeChild(oldAddBTLink);
- var newTRElem = origAtt[4].cloneNode(true);
-
- // fix number of the attachment
- Array.forEach(newTRElem.getElementsByTagName("a"), function (aEl) {
- aEl.setAttribute("href",
- aEl.getAttribute("href").replace(origAtt[1], newAttId));
- });
+ newAttId, newAttSize) {
+ var that = this;
+ var oldAddBTLink = document.getElementById("attachBacktraceActivator");
+ oldAddBTLink.parentNode.removeChild(oldAddBTLink);
+ var newTRElem = origAtt[4].cloneNode(true);
- var aElements = newTRElem.getElementsByTagName("a");
- aElements[0].setAttribute("name","parsed-backtrace.txt");
- aElements[0].getElementsByTagName("b")[0].textContent = titleParsedAttachment;
+ // fix number of the attachment
+ Array.forEach(newTRElem.getElementsByTagName("a"), function (aEl) {
+ aEl.setAttribute("href",
+ aEl.getAttribute("href").replace(origAtt[1], newAttId));
+ });
- var sizeSpan = newTRElem.getElementsByClassName("bz_attach_extra_info")[0];
- sizeSpan.textContent = "(" + (newAttSize / 1024).toFixed(2) + " KB, text/plain)";
+ var aElements = newTRElem.getElementsByTagName("a");
+ aElements[0].setAttribute("name","parsed-backtrace.txt");
+ aElements[0].getElementsByTagName("b")[0].textContent = titleParsedAttachment;
- // aElements[1].textContent = new Date().toString(); TODO we should add eventually, but not pressing
+ var sizeSpan = newTRElem.getElementsByClassName("bz_attach_extra_info")[0];
+ sizeSpan.textContent = "(" + (newAttSize / 1024).toFixed(2) + " KB, text/plain)";
- var vcardSpan = newTRElem.getElementsByClassName("vcard")[0];
- if (vcardSpan !== undefined) {
- var vcardSpanClassList = vcardSpan.classList;
- if (/@redhat\.com/.test(this.login) && !vcardSpanClassList.contains("redhat_user")) {
- vcardSpanClassList.add("redhat_user");
- }
- var vcardAElem = vcardSpan.getElementsByTagName("a")[0];
- vcardAElem.setAttribute("title", this.login);
- vcardAElem.setAttribute("href", "mailto:" + this.login);
- vcardAElem.className = "email";
- vcardAElem.innerHTML="<span class='fn'>" + this.login + "</span>";
+ // aElements[1].textContent = new Date().toString(); TODO we should add eventually, but not pressing
+
+ var vcardSpan = newTRElem.getElementsByClassName("vcard")[0];
+ if (vcardSpan !== undefined) {
+ var vcardSpanClassList = vcardSpan.classList;
+ if (/@redhat\.com/.test(this.login) && !vcardSpanClassList.contains("redhat_user")) {
+ vcardSpanClassList.add("redhat_user");
}
+ var vcardAElem = vcardSpan.getElementsByTagName("a")[0];
+ vcardAElem.setAttribute("title", this.login);
+ vcardAElem.setAttribute("href", "mailto:" + this.login);
+ vcardAElem.className = "email";
+ vcardAElem.innerHTML="<span class='fn'>" + this.login + "</span>";
+ }
- var elem = newTRElem.querySelector("td:last-of-type");
- this.createDeadLink("showBacktrace", "show BT", elem,
- this.showAttachment, newAttId, false);
+ var elem = newTRElem.querySelector("td:last-of-type");
+ this.createDeadLink("showBacktrace", "show BT", elem,
+ this.showAttachment, newAttId, false);
- origAtt[4].parentNode.insertBefore(newTRElem, origAtt[4].nextSibling);
+ origAtt[4].parentNode.insertBefore(newTRElem, origAtt[4].nextSibling);
}
/**
@@ -354,13 +356,13 @@ function addNewAttachmentRow(origAtt,
* @return none
*/
function addCheckShowLink(oldAtt, snippet) {
- var elem = oldAtt[4].querySelector("td:last-of-type");
+ var elem = oldAtt[4].querySelector("td:last-of-type");
/*
- createDeadLink("attachBacktraceActivator", "add parsed BT", elem, function(x) {
- // pass function and parameters as two separate parameters, the function to be called from
- // addAttachment
- addAttachment(snippet, addNewAttachmentRow, oldAtt);
- }, [], true);
+ createDeadLink("attachBacktraceActivator", "add parsed BT", elem, function(x) {
+ // pass function and parameters as two separate parameters, the function to be called from
+ // addAttachment
+ addAttachment(snippet, addNewAttachmentRow, oldAtt);
+ }, [], true);
*/
}
@@ -371,30 +373,30 @@ function addCheckShowLink(oldAtt, snippet) {
* @return none
*/
function markBadAttachments(atts) {
- var badMIMEArray = [ "application/octet-stream", "text/x-log", "undefined" ];
- if (!constantData.passwordState.passAvailable) {
- console.log("markBadAttachments : No password, no XML-RPC calls; sorry");
- return null;
- }
-
- var badAttachments = atts.filter(function(att) {
- return (isInList(att[2], badMIMEArray));
+ var badMIMEArray = [ "application/octet-stream", "text/x-log", "undefined" ];
+ if (!constantData.passwordState.passAvailable) {
+ console.log("markBadAttachments : No password, no XML-RPC calls; sorry");
+ return null;
+ }
+
+ var badAttachments = atts.filter(function(att) {
+ return (isInList(att[2], badMIMEArray));
+ });
+
+ if (badAttachments.length > 0) {
+ var titleElement = document.
+ getElementsByClassName("bz_alias_short_desc_container")[0];
+ titleElement.style.backgroundColor = "olive";
+
+ createDeadLink("fixAllButton", "Fix all", titleElement, function() {
+ Array.forEach(badAttachments, function(x) {
+ fixAttachById(x[1]);
+ });
+ }, [], false, null, "f");
+ badAttachments.forEach(function(x, i, a) {
+ addTextLink(x);
});
-
- if (badAttachments.length > 0) {
- var titleElement = document.
- getElementsByClassName("bz_alias_short_desc_container")[0];
- titleElement.style.backgroundColor = "olive";
-
- createDeadLink("fixAllButton", "Fix all", titleElement, function() {
- Array.forEach(badAttachments, function(x) {
- fixAttachById(x[1]);
- });
- }, [], false, null, "f");
- badAttachments.forEach(function(x, i, a) {
- addTextLink(x);
- });
- }
+ }
}
/**
@@ -403,10 +405,10 @@ function markBadAttachments(atts) {
* @return Boolean true if it is a RHEL bug
*/
function isEnterprise() {
- var result = ProfessionalProducts.some(function(elem,idx,arr) {
- return new RegExp(elem).test(getProduct());
- });
- return result;
+ var result = ProfessionalProducts.some(function(elem,idx,arr) {
+ return new RegExp(elem).test(getProduct());
+ });
+ return result;
}
/**
@@ -415,7 +417,7 @@ function isEnterprise() {
* @return Boolean whether the bug has been triaged or not
*/
function isTriaged() {
- return hasKeyword("Triaged");
+ return hasKeyword("Triaged");
}
/**
@@ -427,77 +429,80 @@ function isTriaged() {
* @return none
*/
function setBranding() {
- var brandColor = {};
- var TriagedColor = {};
-
- var ITbutton = document.getElementById("cf_issuetracker");
- var its = ITbutton ? ITbutton.value.trim() : "";
-
- if (isEnterprise()) {
- if (its && (its.length > 0)) {
- brandColor = RHITColor;
- } else {
- brandColor = RHColor;
- }
- } else if (new RegExp("Fedora").test(document.getElementById("product").value)) {
- if (document.getElementById("version").value === "rawhide") {
- brandColor = RawhideColor;
- } else {
- brandColor = FedoraColor;
- }
- }
-
- // Comment each of the following lines to get only partial branding
- document.getElementsByTagName("body")[0].style.background = brandColor
- .toString()
- + " none";
- document.getElementById("titles").style.background = brandColor.toString()
- + " none";
-
- // Remove "Bug" from the title of the bug page, so we have more space with
- // plenty of tabs
- var titleElem = document.getElementsByTagName("title")[0];
-
- titleElem.textContent = titleElem.textContent.slice(4);
- var bodyTitleParent = document.getElementById("summary_alias_container").parentNode;
- var bodyTitleElem = bodyTitleParent.getElementsByTagName("b")[0];
- bodyTitleElem.textContent = bodyTitleElem.textContent.slice(4);
-
- // Make background-color of the body of bug salmon pink
- // for security bugs.
- if (hasKeyword("Security")) {
- document.getElementById("bugzilla-body").style.background = SalmonPink
- .toString() + ' none';
- }
-
- // Make it visible whether the bug has been triaged
- if (isTriaged()) {
- document.getElementById("bz_field_status").style.background = brandColor
- .lightColor().toString()
- + " none";
- }
-
- var compElems;
- if (config.suspiciousComponents
- && isInList(getComponent(), config.suspiciousComponents)
- && (compElems = document
- .getElementById("bz_component_edit_container"))) {
- compElems.style.background = "red none";
- }
+ var brandColor = {};
+ var TriagedColor = {};
+
+ var ITbutton = document.getElementById("cf_issuetracker");
+ var its = ITbutton ? ITbutton.value.trim() : "";
+
+ if (isEnterprise()) {
+ if (its && (its.length > 0)) {
+ brandColor = RHITColor;
+ }
+ else {
+ brandColor = RHColor;
+ }
+ }
+ else if (new RegExp("Fedora").test(document.getElementById("product").value)) {
+ if (document.getElementById("version").value === "rawhide") {
+ brandColor = RawhideColor;
+ }
+ else {
+ brandColor = FedoraColor;
+ }
+ }
+
+ // Comment each of the following lines to get only partial branding
+ document.getElementsByTagName("body")[0].style.background = brandColor
+ .toString()
+ + " none";
+ document.getElementById("titles").style.background = brandColor.toString()
+ + " none";
+
+ // Remove "Bug" from the title of the bug page, so we have more space with
+ // plenty of tabs
+ var titleElem = document.getElementsByTagName("title")[0];
+
+ titleElem.textContent = titleElem.textContent.slice(4);
+ var bodyTitleParent = document.getElementById("summary_alias_container").parentNode;
+ var bodyTitleElem = bodyTitleParent.getElementsByTagName("b")[0];
+ bodyTitleElem.textContent = bodyTitleElem.textContent.slice(4);
+
+ // Make background-color of the body of bug salmon pink
+ // for security bugs.
+ if (hasKeyword("Security")) {
+ document.getElementById("bugzilla-body").style.background = SalmonPink
+ .toString() + ' none';
+ }
+
+ // Make it visible whether the bug has been triaged
+ if (isTriaged()) {
+ document.getElementById("bz_field_status").style.background = brandColor
+ .lightColor().toString()
+ + " none";
+ }
+
+ var compElems;
+ if (config.suspiciousComponents
+ && isInList(getComponent(), config.suspiciousComponents)
+ && (compElems = document
+ .getElementById("bz_component_edit_container"))) {
+ compElems.style.background = "red none";
+ }
}
/**
*
*/
function queryUpstreamCallback(text) {
- var searchData = filterByRegexp(constantData.queryUpstreamBug, getComponent());
- var urlBase = searchData.url;
- text = searchData.searchBy+":"+searchData.fillIn+" "+text.trim();
- if (searchData.fillIn == "$$$") {
- text = text.replace("$$$", getComponent());
- }
- text = encodeURIComponent(text).replace("%20","+");
- postMessage(new Message("OpenURLinTab", urlBase + text));
+ var searchData = filterByRegexp(constantData.queryUpstreamBug, getComponent());
+ var urlBase = searchData.url;
+ text = searchData.searchBy+":"+searchData.fillIn+" "+text.trim();
+ if (searchData.fillIn == "$$$") {
+ text = text.replace("$$$", getComponent());
+ }
+ text = encodeURIComponent(text).replace("%20","+");
+ postMessage(new Message("OpenURLinTab", urlBase + text));
}
/**
@@ -506,16 +511,17 @@ function queryUpstreamCallback(text) {
* @return none
*/
function queryUpstream() {
- if (!constantData.queryUpstreamBug) {
- alert("We don't have constantData.queryUpstreamBug set up!");
- return null;
- }
- var text = getSelection();
- if (!text) {
- postMessage(new Message("GetClipboard", "queryUpstream"));
- } else {
- queryUpstreamCallback(text);
- }
+ if (!constantData.queryUpstreamBug) {
+ alert("We don't have constantData.queryUpstreamBug set up!");
+ return null;
+ }
+ var text = getSelection();
+ if (!text) {
+ postMessage(new Message("GetClipboard", "queryUpstream"));
+ }
+ else {
+ queryUpstreamCallback(text);
+ }
}
/**
@@ -524,17 +530,17 @@ function queryUpstream() {
* @return none
*/
function sendBugUpstream() {
- var urlStr = filterByRegexp(constantData.newUpstreamBug, getComponent());
- if (!urlStr) {
- return null;
- }
+ var urlStr = filterByRegexp(constantData.newUpstreamBug, getComponent());
+ if (!urlStr) {
+ return null;
+ }
- postMessage(new Message("OpenBugUpstream", {
- url: urlStr,
- subject: document.getElementById("short_desc_nonedit_display").
- textContent.trim(),
- comment: collectComments()
- }));
+ postMessage(new Message("OpenBugUpstream", {
+ url: urlStr,
+ subject: document.getElementById("short_desc_nonedit_display").
+ textContent.trim(),
+ comment: collectComments()
+ }));
}
/**
@@ -543,14 +549,14 @@ function sendBugUpstream() {
* @return none
*/
function addCheckXorgLogLink(attList) {
- if (config.xorglogAnalysis) {
- attList.forEach(function (row) {
- var elemS = row[4].getElementsByTagName("td");
- var elem = elemS[elemS.length - 1];
- createDeadLink("xorgLogAnalyzeLink", "check", elem,
- analyzeXorgLog, [row[1], "AnalyzeXorgLogBacktrace"], "br");
- });
- }
+ if (config.xorglogAnalysis) {
+ attList.forEach(function (row) {
+ var elemS = row[4].getElementsByTagName("td");
+ var elem = elemS[elemS.length - 1];
+ createDeadLink("xorgLogAnalyzeLink", "check", elem,
+ analyzeXorgLog, [row[1], "AnalyzeXorgLogBacktrace"], "br");
+ });
+ }
}
/**
@@ -558,38 +564,39 @@ function addCheckXorgLogLink(attList) {
* whiteboard
*
* @param PCIidArrObj object with two fields
- * id Array manufacturer-ID and product-ID (PCI IDs)
- * chipsetLine RE
+ * id Array manufacturer-ID and product-ID (PCI IDs)
+ * chipsetLine RE
* @param driverStr String with the driver name
* @return None
*/
function fillInWhiteBoard(PCIidArrObj) {
- var outStr = "";
- var cardIDStr = "";
- var cardIDArr = [];
- var cardName = "";
- var PCIid = (PCIidArrObj.id[0] + "," + PCIidArrObj.id[1]).toUpperCase();
-
- if (PCIidArrObj.id[0].toLowerCase() == "10de") {
- cardName = PCIidArrObj.chipsetLine[2].replace(/\s*nvidia\s*/ig,"").
- replace('"','','g');
- } else {
- try {
- cardName = constantData.chipNames[PCIid][0];
- } catch (e if e instanceof TypeError) {
- PCIid = PCIid.toLowerCase().replace(",",":");
- postMessage(new Message("SetClipboard", PCIid.toString()));
- alert("PCI ID " + PCIid + " is not known!");
- return ; // early termination
- } catch (e) {
- throw e;
- }
- }
-
- clickMouse("editme_action");
- var titleElem = document.getElementById('short_desc');
- titleElem.value = '[' + cardName + ']\u00A0' + titleElem.value;
- document.getElementById("fillin_btn").style.display = "none";
+ var outStr = "";
+ var cardIDStr = "";
+ var cardIDArr = [];
+ var cardName = "";
+ var PCIid = (PCIidArrObj.id[0] + "," + PCIidArrObj.id[1]).toUpperCase();
+
+ if (PCIidArrObj.id[0].toLowerCase() == "10de") {
+ cardName = PCIidArrObj.chipsetLine[2].replace(/\s*nvidia\s*/ig,"").
+ replace('"','','g');
+ }
+ else {
+ try {
+ cardName = constantData.chipNames[PCIid][0];
+ } catch (e if e instanceof TypeError) {
+ PCIid = PCIid.toLowerCase().replace(",",":");
+ postMessage(new Message("SetClipboard", PCIid.toString()));
+ alert("PCI ID " + PCIid + " is not known!");
+ return ; // early termination
+ } catch (e) {
+ throw e;
+ }
+ }
+
+ clickMouse("editme_action");
+ var titleElem = document.getElementById('short_desc');
+ titleElem.value = '[' + cardName + ']\u00A0' + titleElem.value;
+ document.getElementById("fillin_btn").style.display = "none";
}
/**
@@ -601,78 +608,80 @@ function fillInWhiteBoard(PCIidArrObj) {
* @return None
*/
function fillInChipMagic(XlogID) {
- analyzeXorgLog(XlogID, "AnalyzeInterestingLine");
+ analyzeXorgLog(XlogID, "AnalyzeInterestingLine");
}
function chipsetMagic (interestingLineArr) {
- // parse Xorg.0.log
- if (interestingLineArr.length >0) {
- var interestingArray = interestingLineArr[0];
- if (interestingArray.length > 1) {
- var interestingPCIID = interestingArray[2].trim().split(":");
- createNewButton("short_desc_nonedit_display", false, {
- "name": "Fill In",
- "chipMagic": {
- "id": interestingPCIID,
- "chipsetLine": interestingLineArr[1]
- },
- });
- }
- }
+ // parse Xorg.0.log
+ if (interestingLineArr.length >0) {
+ var interestingArray = interestingLineArr[0];
+ if (interestingArray.length > 1) {
+ var interestingPCIID = interestingArray[2].trim().split(":");
+ createNewButton("short_desc_nonedit_display", false, {
+ "name": "Fill In",
+ "chipMagic": {
+ "id": interestingPCIID,
+ "chipsetLine": interestingLineArr[1]
+ },
+ });
+ }
+ }
}
function analyzeXorg(results) {
- var innerString = "";
-
- if (results.length > 0) {
- results.splice(0, 1); // remove headers
- results.sort();
-
- results.forEach(function(lRE) {
- innerString += lRE.input + "<br>\n";
- });
- innerString += "----------<br>\n" +
- results.length + " interesting lines found.";
- } else {
- innerString += "No matching lines found!";
- }
+ var innerString = "";
+
+ if (results.length > 0) {
+ results.splice(0, 1); // remove headers
+ results.sort();
+
+ results.forEach(function(lRE) {
+ innerString += lRE.input + "<br>\n";
+ });
+ innerString += "----------<br>\n" +
+ results.length + " interesting lines found.";
+ }
+ else {
+ innerString += "No matching lines found!";
+ }
- document.body.style.cursor = "auto";
- postMessage(new Message("OpenStringInPanel",
- '<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">' +
- "<html><head><title>Xorg.0.log analysis</title></head><body><pre>\n" +
- innerString.trim() +
- "\n</pre></body></html>"));
+ document.body.style.cursor = "auto";
+ postMessage(new Message("OpenStringInPanel",
+ '<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">' +
+ "<html><head><title>Xorg.0.log analysis</title></head><body><pre>\n" +
+ innerString.trim() +
+ "\n</pre></body></html>"));
}
function analyzeXorgLog(attachID, backMsg) {
- document.body.style.cursor = "wait";
- postMessage(new Message("GetURL", {
- url: "https://" + window.location.hostname + "/attachment.cgi?id=" + attachID,
- backMessage: backMsg
- }));
+ document.body.style.cursor = "wait";
+ postMessage(new Message("GetURL", {
+ url: "https://" + window.location.hostname + "/attachment.cgi?id=" + attachID,
+ backMessage: backMsg
+ }));
}
function findInterestingLine(wholeLog, backMsg) {
- var REstr = logAnalyzeLogic[backMsg].re;
- var REarr = [];
- if (typeof REstr == "string") {
- REarr = [new RegExp(REstr)];
- } else if (Array.isArray(REstr)) {
- REarr = REstr.map(function (reone) {
- return new RegExp(reone);
- });
- }
- var results = [];
- wholeLog.split("\n").
- forEach(function(line) {
- REarr.forEach(function (re, reIdx) {
- if (re.test(line)) {
- results.push(re.exec(line));
- }
- });
- });
- logAnalyzeLogic[backMsg].func(results);
+ var REstr = logAnalyzeLogic[backMsg].re;
+ var REarr = [];
+ if (typeof REstr == "string") {
+ REarr = [new RegExp(REstr)];
+ }
+ else if (Array.isArray(REstr)) {
+ REarr = REstr.map(function (reone) {
+ return new RegExp(reone);
+ });
+ }
+ var results = [];
+ wholeLog.split("\n").
+ forEach(function(line) {
+ REarr.forEach(function (re, reIdx) {
+ if (re.test(line)) {
+ results.push(re.exec(line));
+ }
+ });
+ });
+ logAnalyzeLogic[backMsg].func(results);
}
/**
@@ -682,14 +691,15 @@ function findInterestingLine(wholeLog, backMsg) {
* @return String with the string for the external_id SELECT
*/
function getBugzillaName(URLhostname) {
- var bugzillaID = "";
- var bzLabelNames = constantData.bugzillaLabelNames;
- if (bzLabelNames[URLhostname]) {
- bugzillaID = bzLabelNames[URLhostname];
- } else {
- bugzillaID = "";
- }
- return bugzillaID;
+ var bugzillaID = "";
+ var bzLabelNames = constantData.bugzillaLabelNames;
+ if (bzLabelNames[URLhostname]) {
+ bugzillaID = bzLabelNames[URLhostname];
+ }
+ else {
+ bugzillaID = "";
+ }
+ return bugzillaID;
}
/**
@@ -702,12 +712,12 @@ function getBugzillaName(URLhostname) {
* + responseText
*/
function XMLRPCcallback() {
- reqCounter--;
- if (reqCounter <= 0) {
- setTimeout(function () {
- window.location.reload(true);
- }, 1000);
- }
+ reqCounter--;
+ if (reqCounter <= 0) {
+ setTimeout(function () {
+ window.location.reload(true);
+ }, 1000);
+ }
}
/**
@@ -717,7 +727,7 @@ function XMLRPCcallback() {
* @param id Integer with the attachment id to be fixed
* @param type String with the new MIME type, optional defaults to "text/plain"
* @param email Boolean whether email should be sent to appropriate person;
- * option, defaults to false
+ * option, defaults to false
*
* updateAttachMimeType($data_ref, $username, $password)
*
@@ -733,32 +743,32 @@ function XMLRPCcallback() {
*
*/
function fixAttachById(id, type, email) {
- var params = [];
-
- if (type === undefined) {
- type = "text/plain";
- }
- if (email === undefined) {
- email = false;
- }
-
- // https://bugzilla.redhat.com/\
- // docs/en/html/api/extensions/compat_xmlrpc/code/webservice.html
- // test on https://bugzilla.redhat.com/show_bug.cgi?id=485145
- params.push({
- 'attach_id' : id,
- 'mime_type' : type,
- 'nomail' : !email
- });
-
- postMessage(new Message("MakeXMLRPCall", {
- url: constantData.XMLRPCData[window.location.hostname].url,
- login: getLogin(),
- method: "bugzilla.updateAttachMimeType",
- params: params,
- callRPC: "FixAttachmentMIMECallback"
- }));
- reqCounter++;
+ var params = [];
+
+ if (type === undefined) {
+ type = "text/plain";
+ }
+ if (email === undefined) {
+ email = false;
+ }
+
+ // https://bugzilla.redhat.com/\
+ // docs/en/html/api/extensions/compat_xmlrpc/code/webservice.html
+ // test on https://bugzilla.redhat.com/show_bug.cgi?id=485145
+ params.push({
+ 'attach_id' : id,
+ 'mime_type' : type,
+ 'nomail' : !email
+ });
+
+ postMessage(new Message("MakeXMLRPCall", {
+ url: constantData.XMLRPCData[window.location.hostname].url,
+ login: getLogin(),
+ method: "bugzilla.updateAttachMimeType",
+ params: params,
+ callRPC: "FixAttachmentMIMECallback"
+ }));
+ reqCounter++;
}
/**
@@ -769,10 +779,10 @@ function fixAttachById(id, type, email) {
* @return none
*/
function addTextLink(row) {
- var elemS = row[4].getElementsByTagName("td");
- var elem = elemS[elemS.length - 1];
- createDeadLink("addFix2TextLink", "text", elem,
- fixAttachById, row[1], "br");
+ var elemS = row[4].getElementsByTagName("td");
+ var elem = elemS[elemS.length - 1];
+ createDeadLink("addFix2TextLink", "text", elem,
+ fixAttachById, row[1], "br");
}
/**
@@ -782,186 +792,189 @@ function addTextLink(row) {
* @return none
*/
function addClosingUpstream() {
- var refs = document.getElementById("external_bugs_table")
- .getElementsByTagName("tr");
-
- // that's a bad id, if there is a one. :)
- var inputBox = document.getElementById("inputbox");
- var externalBugID = 0;
- var wholeURL = "";
-
- // Fix missing ID on the external_id SELECT
- document.getElementsByName("external_id")[0].setAttribute("id",
- "external_id");
-
- if (inputBox.value.match(/^http.*/)) {
- externalBugID = getBugNoFromURL(inputBox.value);
- if (externalBugID) {
- inputBox.value = externalBugID;
- }
- // get bugzillaName and set the label
- var bugzillaName = getBugzillaName(wholeURL.host);
- selectOptionByLabel("external_id", bugzillaName);
- } else if (!isNaN(inputBox.value)) {
- externalBugID = parseInt(inputBox.value, 10);
- var bugzillaHostname = document.getElementById("external_id").value;
- wholeURL = bugzillaHostname+"show_bug.cgi?id="+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 ((externalBugID > 0) || (refs.length > 2)) {
- var msgStr = constantData.commentStrings.sentUpstreamString;
- msgStr = msgStr.replace("§§§", wholeURL);
- centralCommandDispatch("comment",msgStr);
- centralCommandDispatch("status", "CLOSED");
- centralCommandDispatch("resolution", "UPSTREAM");
- } else {
- console.log("No external bug specified among the External References!");
- }
+ var refs = document.getElementById("external_bugs_table")
+ .getElementsByTagName("tr");
+
+ // that's a bad id, if there is a one. :)
+ var inputBox = document.getElementById("inputbox");
+ var externalBugID = 0;
+ var wholeURL = "";
+
+ // Fix missing ID on the external_id SELECT
+ document.getElementsByName("external_id")[0].setAttribute("id",
+ "external_id");
+
+ if (inputBox.value.match(/^http.*/)) {
+ externalBugID = getBugNoFromURL(inputBox.value);
+ if (externalBugID) {
+ inputBox.value = externalBugID;
+ }
+ // get bugzillaName and set the label
+ var bugzillaName = getBugzillaName(wholeURL.host);
+ selectOptionByLabel("external_id", bugzillaName);
+ }
+ else if (!isNaN(inputBox.value)) {
+ externalBugID = parseInt(inputBox.value, 10);
+ var bugzillaHostname = document.getElementById("external_id").value;
+ wholeURL = bugzillaHostname+"show_bug.cgi?id="+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 ((externalBugID > 0) || (refs.length > 2)) {
+ var msgStr = constantData.commentStrings.sentUpstreamString;
+ msgStr = msgStr.replace("§§§", wholeURL);
+ centralCommandDispatch("comment",msgStr);
+ centralCommandDispatch("status", "CLOSED");
+ centralCommandDispatch("resolution", "UPSTREAM");
+ }
+ else {
+ console.log("No external bug specified among the External References!");
+ }
}
function markBugTriaged() {
- // https://fedoraproject.org/wiki/BugZappers/Meetings/Minutes-2009-Oct-27
- // http://meetbot.fedoraproject.org/fedora-meeting/2009-11-24\
- // /fedora-meeting.2009-11-24-15.11.log.html
- // http://meetbot.fedoraproject.org/fedora-meeting/2009-11-24\
- // /fedora-meeting.2009-11-24-15.11.log.html
- addStuffToTextBox("keywords","Triaged");
+ // https://fedoraproject.org/wiki/BugZappers/Meetings/Minutes-2009-Oct-27
+ // http://meetbot.fedoraproject.org/fedora-meeting/2009-11-24\
+ // /fedora-meeting.2009-11-24-15.11.log.html
+ // http://meetbot.fedoraproject.org/fedora-meeting/2009-11-24\
+ // /fedora-meeting.2009-11-24-15.11.log.html
+ addStuffToTextBox("keywords","Triaged");
}
/**
*
*/
function parseBacktrace (ret) {
- var signalHandler = new RegExp("^\\s*#[0-9]*\\s*<signal handler called>");
- var frameNo = new RegExp("^\\s*#([0-9]*)\\s");
-
- var splitArray = ret.split("\n");
- var i = 0, ii = splitArray.length;
- var outStr = "", curLine = "", numStr = "";
- var lineCounter = 0, endLineNo = 0;
-
- // TODO shouldn't we just cut off and analyze whole thread?
- while (i < ii) {
- if (signalHandler.test(splitArray[i])) {
- break;
- }
- i++;
- }
-
- if (i < ii) {
- lineCounter = parseInt(frameNo.exec(splitArray[i])[1], 10);
- endLineNo = lineCounter + NumberOfFrames;
- curLine = splitArray[i];
- while ((lineCounter < endLineNo) && (curLine.trim().length > 0)
- && (i < ii)) {
- outStr += curLine + '\n';
- numStr = frameNo.exec(curLine);
- if (numStr) {
- lineCounter = parseInt(numStr[1], 10);
- }
- i++;
- curLine = splitArray[i];
- }
- return outStr;
- }
- return "";
+ var signalHandler = new RegExp("^\\s*#[0-9]*\\s*<signal handler called>");
+ var frameNo = new RegExp("^\\s*#([0-9]*)\\s");
+
+ var splitArray = ret.split("\n");
+ var i = 0, ii = splitArray.length;
+ var outStr = "", curLine = "", numStr = "";
+ var lineCounter = 0, endLineNo = 0;
+
+ // TODO shouldn't we just cut off and analyze whole thread?
+ while (i < ii) {
+ if (signalHandler.test(splitArray[i])) {
+ break;
+ }
+ i++;
+ }
+
+ if (i < ii) {
+ lineCounter = parseInt(frameNo.exec(splitArray[i])[1], 10);
+ endLineNo = lineCounter + NumberOfFrames;
+ curLine = splitArray[i];
+ while ((lineCounter < endLineNo) && (curLine.trim().length > 0)
+ && (i < ii)) {
+ outStr += curLine + '\n';
+ numStr = frameNo.exec(curLine);
+ if (numStr) {
+ lineCounter = parseInt(numStr[1], 10);
+ }
+ i++;
+ curLine = splitArray[i];
+ }
+ return outStr;
+ }
+ return "";
}
function RHBZinit() {
- // inheritance ... call superobject's constructor
- var AbrtRE = new RegExp("^\\s*\\[abrt\\]");
- var FillMagicDoneRE = new RegExp("^\\s*\\[[0-9a-zA-Z_]*\\]");
- var btSnippet = "";
-
- var signaturesCounter = 0;
- var chipMagicInterestingLine = "";
-
- // getBadAttachments
- var XorgLogAttList = [];
- var XorgLogAttListIndex = 0;
- var attachments = getAttachments();
- markBadAttachments(attachments);
-
- var parsedAttachments = attachments.filter(function (att) {
- return (new RegExp(titleParsedAttachment).test(att[0]));
- });
-
- if (constantData.defaultAssignee) {
- setDefaultAssignee();
- }
-
- // Dig out backtrace protection against double-firing?
- btSnippet = "";
-
- var parseAbrtBacktraces = config.parseAbrtBacktraces;
- if (parseAbrtBacktraces && AbrtRE.test(getSummary())) {
- pasteBacktraceInComments(parsedAttachments);
- }
-
- // Find out Xorg.0.log attachment URL
- XorgLogAttList = attachments.filter(function (value) {
- // Xorg.0.log must be text, otherwise we cannot parse it
- return (/[xX].*log/.test(value[0]) && /text/.test(value[2]));
+ // inheritance ... call superobject's constructor
+ var AbrtRE = new RegExp("^\\s*\\[abrt\\]");
+ var FillMagicDoneRE = new RegExp("^\\s*\\[[0-9a-zA-Z_]*\\]");
+ var btSnippet = "";
+
+ var signaturesCounter = 0;
+ var chipMagicInterestingLine = "";
+
+ // getBadAttachments
+ var XorgLogAttList = [];
+ var XorgLogAttListIndex = 0;
+ var attachments = getAttachments();
+ markBadAttachments(attachments);
+
+ var parsedAttachments = attachments.filter(function (att) {
+ return (new RegExp(titleParsedAttachment).test(att[0]));
});
- // Just add a link to every Xorg.0.log link analyzing it.
- addCheckXorgLogLink(XorgLogAttList);
-
- var maintCCAddr = "";
- if (constantData.CCmaintainer) {
- maintCCAddr = filterByRegexp(constantData.CCmaintainer,
- getComponent())[0]; // filterByRegexp returns array, not string
- }
-
- // TODO Get compiz bugs as well
- if ((constantData.chipNames) &&
- (XorgLogAttList[0]) &&
- (!FillMagicDoneRE.test(getSummary())) &&
- (maintCCAddr === "xgl-maint@redhat.com")) {
- // Add find chip magic button
- var whiteboard_string = document.getElementById("status_whiteboard").value;
- if (!/card_/.test(whiteboard_string)) {
- fillInChipMagic(XorgLogAttList[0][1]);
- }
- }
- // we should make visible whether maintCCAddr is in CCList
- if (maintCCAddr && isInList(maintCCAddr, getCCList())) {
- var ccEditBoxElem = document.getElementById("cc_edit_area_showhide");
- ccEditBoxElem.style.color = "navy";
- ccEditBoxElem.style.fontWeight = "bolder";
- ccEditBoxElem.style.textDecoration = "underline";
- }
-
- // Take care of signature for Fedora bugzappers
- if (config.signature && config.signature.length > 0) {
- var signatureFedoraString = config.signature;
- document.forms.namedItem("changeform").addEventListener("submit",
- function(aEvt) {
- if (signaturesCounter < 1) {
- addStuffToTextBox("comment", signatureFedoraString);
- signaturesCounter += 1;
- }
- }, false);
- }
- setBranding();
-
- // set default assignee on change of the component
- var compElement = document.getElementById("component");
- if (compElement && (compElement.options)) {
- document.getElementById("component").addEventListener("change",
- function() {
- changeAssignee("default");
- }, false);
- }
+ if (constantData.defaultAssignee) {
+ setDefaultAssignee();
+ }
+
+ // Dig out backtrace protection against double-firing?
+ btSnippet = "";
+
+ var parseAbrtBacktraces = config.parseAbrtBacktraces;
+ if (parseAbrtBacktraces && AbrtRE.test(getSummary())) {
+ pasteBacktraceInComments(parsedAttachments);
+ }
+
+ // Find out Xorg.0.log attachment URL
+ XorgLogAttList = attachments.filter(function (value) {
+ // Xorg.0.log must be text, otherwise we cannot parse it
+ return (/[xX].*log/.test(value[0]) && /text/.test(value[2]));
+ });
+ // Just add a link to every Xorg.0.log link analyzing it.
+ addCheckXorgLogLink(XorgLogAttList);
+
+ var maintCCAddr = "";
+ if (constantData.CCmaintainer) {
+ maintCCAddr = filterByRegexp(constantData.CCmaintainer,
+ getComponent())[0]; // filterByRegexp returns array, not string
+ }
+
+ // TODO Get compiz bugs as well
+ if ((constantData.chipNames) &&
+ (XorgLogAttList[0]) &&
+ (!FillMagicDoneRE.test(getSummary())) &&
+ (maintCCAddr === "xgl-maint@redhat.com")) {
+ // Add find chip magic button
+ var whiteboard_string = document.getElementById("status_whiteboard").value;
+ if (!/card_/.test(whiteboard_string)) {
+ fillInChipMagic(XorgLogAttList[0][1]);
+ }
+ }
+
+ // we should make visible whether maintCCAddr is in CCList
+ if (maintCCAddr && isInList(maintCCAddr, getCCList())) {
+ var ccEditBoxElem = document.getElementById("cc_edit_area_showhide");
+ ccEditBoxElem.style.color = "navy";
+ ccEditBoxElem.style.fontWeight = "bolder";
+ ccEditBoxElem.style.textDecoration = "underline";
+ }
+
+ // Take care of signature for Fedora bugzappers
+ if (config.signature && config.signature.length > 0) {
+ var signatureFedoraString = config.signature;
+ document.forms.namedItem("changeform").addEventListener("submit",
+ function(aEvt) {
+ if (signaturesCounter < 1) {
+ addStuffToTextBox("comment", signatureFedoraString);
+ signaturesCounter += 1;
+ }
+ }, false);
+ }
+ setBranding();
- // Uncheck "set default assignee" when the assignee is changed by other means
- document.getElementById("assigned_to").addEventListener("change",
+ // set default assignee on change of the component
+ var compElement = document.getElementById("component");
+ if (compElement && (compElement.options)) {
+ document.getElementById("component").addEventListener("change",
function() {
- changeAssignee(null);
+ changeAssignee("default");
}, false);
+ }
+
+ // Uncheck "set default assignee" when the assignee is changed by other means
+ document.getElementById("assigned_to").addEventListener("change",
+ function() {
+ changeAssignee(null);
+ }, false);
}
diff --git a/data/lib/skip-bug.js b/data/lib/skip-bug.js
index da6f606..3639448 100644
--- a/data/lib/skip-bug.js
+++ b/data/lib/skip-bug.js
@@ -3,17 +3,17 @@
// "use strict";
function reloadPage() {
- var stemURL = 'https://HOSTNAME/show_bug.cgi?id=';
- var titleElems = document.getElementsByTagName('title');
- if (titleElems) {
- var REArr = new RegExp('[bB]ug\\s+([0-9]+)').
- exec(titleElems[0].textContent);
- var hostname = document.location.hostname;
- if (REArr) {
- document.location = stemURL.
- replace('HOSTNAME',hostname) + REArr[1];
- }
+ var stemURL = 'https://HOSTNAME/show_bug.cgi?id=';
+ var titleElems = document.getElementsByTagName('title');
+ if (titleElems) {
+ var REArr = new RegExp('[bB]ug\\s+([0-9]+)').
+ exec(titleElems[0].textContent);
+ var hostname = document.location.hostname;
+ if (REArr) {
+ document.location = stemURL.
+ replace('HOSTNAME',hostname) + REArr[1];
}
+ }
}
reloadPage();
diff --git a/data/lib/util.js b/data/lib/util.js
index e51a657..f336a7f 100644
--- a/data/lib/util.js
+++ b/data/lib/util.js
@@ -19,31 +19,31 @@
* operations are used (to normalize results across browsers).
*/
function parseURL(url) {
- var a = document.createElement('a');
- 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(/tps?:\/\/[^\/]+(.+)/) || [,''])[1],
- segments: a.pathname.replace(/^\//,'').split('/')
- };
+ var a = document.createElement('a');
+ 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(/tps?:\/\/[^\/]+(.+)/) || [,''])[1],
+ segments: a.pathname.replace(/^\//,'').split('/')
+ };
}
/**
@@ -54,18 +54,18 @@ function parseURL(url) {
* @return XML object
*/
function parseXMLfromString (inStuff) {
- // if (typeof inStuff !== 'string') In future we should recognize this.response
- // and get just .text property out of it. TODO
- var respStr = inStuff.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, ""); // bug 336551
- return new XML(respStr);
+ // if (typeof inStuff !== 'string') In future we should recognize this.response
+ // and get just .text property out of it. TODO
+ var respStr = inStuff.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, ""); // bug 336551
+ return new XML(respStr);
}
/**
* Get a bug no
*/
function getBugNo() {
- console.log("bugNo = " + document.forms.namedItem('changeform').getElementsByName("id")[0].value);
- return document.forms.namedItem('changeform').getElementsByName("id")[0].value;
+ console.log("bugNo = " + document.forms.namedItem('changeform').getElementsByName("id")[0].value);
+ return document.forms.namedItem('changeform').getElementsByName("id")[0].value;
}
/**
@@ -74,10 +74,10 @@ function getBugNo() {
* @return String with the bug ID
*/
function getBugNoFromURL(url) {
- var params = parseURL(url).params;
- if (params && params.id) {
- return params.id;
- }
+ var params = parseURL(url).params;
+ if (params && params.id) {
+ return params.id;
+ }
}
/**
@@ -92,43 +92,46 @@ function getBugNoFromURL(url) {
* @return none
*/
function createDeadLink (id, text, parent, callback, params, before, covered, accesskey) {
- params = valToArray(params);
- var locParent = {};
+ params = valToArray(params);
+ var locParent = {};
- // Yes, I want != here, not !==
- if (covered != null) {
- locParent = document.createElement(covered);
- parent.appendChild(locParent);
- } else {
- locParent = parent;
- }
+ // Yes, I want != here, not !==
+ if (covered != null) {
+ locParent = document.createElement(covered);
+ parent.appendChild(locParent);
+ }
+ else {
+ locParent = parent;
+ }
- var newAElem = document.createElement("a");
- newAElem.setAttribute("id", id);
- if (accesskey) {
- newAElem.setAttribute("accesskey", accesskey);
- }
- newAElem.textContent = text;
+ var newAElem = document.createElement("a");
+ newAElem.setAttribute("id", id);
+ if (accesskey) {
+ newAElem.setAttribute("accesskey", accesskey);
+ }
+ newAElem.textContent = text;
- if (typeof callback === "string") {
- newAElem.setAttribute("href", callback);
- } else {
- newAElem.setAttribute("href", "");
- newAElem.addEventListener("click", function(evt) {
- evt.stopPropagation();
- evt.preventDefault();
- // We need apply, because params could be array of parameters
- callback.apply(null, params);
- }, false);
- }
+ if (typeof callback === "string") {
+ newAElem.setAttribute("href", callback);
+ }
+ else {
+ newAElem.setAttribute("href", "");
+ newAElem.addEventListener("click", function(evt) {
+ evt.stopPropagation();
+ evt.preventDefault();
+ // We need apply, because params could be array of parameters
+ callback.apply(null, params);
+ }, false);
+ }
- if ((before === "br") || (before === true)) {
- locParent.appendChild(document.createElement("br"));
- } else if (before === "dash") {
- locParent.appendChild(document.createTextNode("\u00A0-\u00A0"));
- }
+ if ((before === "br") || (before === true)) {
+ locParent.appendChild(document.createElement("br"));
+ }
+ else if (before === "dash") {
+ locParent.appendChild(document.createTextNode("\u00A0-\u00A0"));
+ }
- locParent.appendChild(newAElem);
+ locParent.appendChild(newAElem);
}
/*
@@ -141,19 +144,19 @@ function createDeadLink (id, text, parent, callback, params, before, covered, ac
*
*/
function parseMailto(aElement) {
- var emailStr = "", hrefStr = "";
- // use url utils
- if (aElement) {
- hrefStr = decodeURIComponent(aElement.getAttribute("href"));
- emailStr = hrefStr.split(":");
- // workaround for Gnome bugzilla ... no mailto: here.
- if (emailStr.length < 2) {
- var params = parseURL("https://" + window.location.hostname + "/" + hrefStr).params;
- return decodeURI(params.login);
- }
- return emailStr[1];
+ var emailStr = "", hrefStr = "";
+ // use url utils
+ if (aElement) {
+ hrefStr = decodeURIComponent(aElement.getAttribute("href"));
+ emailStr = hrefStr.split(":");
+ // workaround for Gnome bugzilla ... no mailto: here.
+ if (emailStr.length < 2) {
+ var params = parseURL("https://" + window.location.hostname + "/" + hrefStr).params;
+ return decodeURI(params.login);
}
- return null;
+ return emailStr[1];
+ }
+ return null;
}
/**
@@ -163,12 +166,12 @@ function parseMailto(aElement) {
* @return string with the formatted date
*/
function getISODate(dateStr) {
- function pad(n) {
- return n < 10 ? '0' + n : n;
- }
- var date = new Date(dateStr);
- return date.getFullYear() + '-' + pad(date.getMonth() + 1) + '-' +
- pad(date.getDate());
+ function pad(n) {
+ return n < 10 ? '0' + n : n;
+ }
+ var date = new Date(dateStr);
+ return date.getFullYear() + '-' + pad(date.getMonth() + 1) + '-' +
+ pad(date.getDate());
}
/**
@@ -180,10 +183,10 @@ function getISODate(dateStr) {
* @return position of the string in the list, or -1 if none found.
*/
function isInList(mbr, list) {
- if (!list) {
- return false;
- }
- return (list.indexOf(mbr) !== -1);
+ if (!list) {
+ return false;
+ }
+ return (list.indexOf(mbr) !== -1);
};
/**
@@ -196,10 +199,10 @@ function isInList(mbr, list) {
* the result will be untouched actual argument of the call.
*/
function valToArray(val) {
- var isArr = val &&
- val.constructor &&
- val.constructor.name === "Array";
- return isArr ? val : [val];
+ var isArr = val &&
+ val.constructor &&
+ val.constructor.name === "Array";
+ return isArr ? val : [val];
}
/**
@@ -210,18 +213,18 @@ function valToArray(val) {
* @return String with merged lists
*/
function addCSVValue(str, value) {
- var parts = (str.trim().length > 0 ? str.split(/[,\s]+/) : []);
- if (!value) {
- return str;
- }
- if (!isInList(value, parts)) {
- var newValue = valToArray(value);
- parts = parts.concat(newValue);
- }
- // this is necessary to get comma-space separated string even when
- // value is an array already
- parts = parts.join(",").split(",");
- return parts.join(", ");
+ var parts = (str.trim().length > 0 ? str.split(/[,\s]+/) : []);
+ if (!value) {
+ return str;
+ }
+ if (!isInList(value, parts)) {
+ var newValue = valToArray(value);
+ parts = parts.concat(newValue);
+ }
+ // this is necessary to get comma-space separated string even when
+ // value is an array already
+ parts = parts.join(",").split(",");
+ return parts.join(", ");
}
/**
@@ -232,13 +235,13 @@ function addCSVValue(str, value) {
* @return String with the resulting list comma separated
*/
function removeCSVValue(str, value) {
- str = str.trim();
- var parts = str ? str.split(/[,\s]+/) : [];
- var valueArr = value instanceof Array ? value : value.split(/[,\s]+/);
- parts = parts.filter(function (e, i, a) {
- return (!isInList(e, valueArr));
- });
- return parts.join(", ");
+ str = str.trim();
+ var parts = str ? str.split(/[,\s]+/) : [];
+ var valueArr = value instanceof Array ? value : value.split(/[,\s]+/);
+ parts = parts.filter(function (e, i, a) {
+ return (!isInList(e, valueArr));
+ });
+ return parts.join(", ");
}
/**
@@ -250,17 +253,18 @@ function removeCSVValue(str, value) {
* @return Object chosen element
*/
function filterByRegexp(list, chosingMark) {
- var chosenPair = [];
- if (list.length > 0) {
- chosenPair = list.filter(function (pair) {
- return new RegExp(pair.regexp, "i").test(chosingMark);
- });
- }
- if (chosenPair.length > 0) {
- return chosenPair[0].addr;
- } else {
- return "";
- }
+ var chosenPair = [];
+ if (list.length > 0) {
+ chosenPair = list.filter(function (pair) {
+ return new RegExp(pair.regexp, "i").test(chosingMark);
+ });
+ }
+ if (chosenPair.length > 0) {
+ return chosenPair[0].addr;
+ }
+ else {
+ return "";
+ }
}
/**
@@ -275,16 +279,17 @@ function filterByRegexp(list, chosingMark) {
* do actual activity.
*/
function killNodes(doc, target, remove) {
- target = target.trim();
- var targetArr = target instanceof Array ? target : target.split(/[,\s]+/);
- targetArr.forEach(function(x) {
- if (remove) {
- var targetNode = doc.getElementById(x);
- targetNode.parentNode.removeChild(targetNode);
- } else {
- x.style.display = "none";
- }
- });
+ target = target.trim();
+ var targetArr = target instanceof Array ? target : target.split(/[,\s]+/);
+ targetArr.forEach(function(x) {
+ if (remove) {
+ var targetNode = doc.getElementById(x);
+ targetNode.parentNode.removeChild(targetNode);
+ }
+ else {
+ x.style.display = "none";
+ }
+ });
}
/**
@@ -295,22 +300,22 @@ function killNodes(doc, target, remove) {
*/
function removeDuplicates (arr) {
for (var i = 0; i < arr.length; i++) {
- for (var j = i + 1; j < arr.length; j++) {
- if (arr[i] == arr[j]) {
- arr.splice (j, 1);
- }
+ for (var j = i + 1; j < arr.length; j++) {
+ if (arr[i] == arr[j]) {
+ arr.splice (j, 1);
}
}
+ }
return arr;
}
// ============================================
/**
* object to pack messaging. Use as in
- postMessage(new Message("GetPassword", {
- login: login,
- hostname: location.hostname
- }));
+ postMessage(new Message("GetPassword", {
+ login: login,
+ hostname: location.hostname
+ }));
*/
function Message(cmd, data) {
this.cmd = cmd;
@@ -322,10 +327,10 @@ function log(msg) {
}
var NotLoggedinException = function NotLoggedinException (message) {
- this.message = message;
- this.name = "NotLoggedinException";
+ this.message = message;
+ this.name = "NotLoggedinException";
};
NotLoggedinException.prototype.toString = function () {
- return this.name + ': "' + this.message + '"';
+ return this.name + ': "' + this.message + '"';
};
diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js
index aeccead..45a1fc4 100644
--- a/lib/libbugzilla.js
+++ b/lib/libbugzilla.js
@@ -16,7 +16,7 @@ var xrpc = require("xmlrpc");
var panelMod = require("panel");
var JSONURLDefault = "https://fedorahosted.org/released"+
- "/bugzilla-triage-scripts/Config_data.json";
+ "/bugzilla-triage-scripts/Config_data.json";
var BTSPrefNS = "bugzilla-triage.setting.";
var BTSPassRealm = "BTSXMLRPCPass";
@@ -24,7 +24,7 @@ var passwords = {}; // hash of passwords indexed by a hostname
var config = exports.config = {};
function Message(cmd, data) {
- console.log("Message: cmd = " + cmd + ", data = " + data);
+ console.log("Message: cmd = " + cmd + ", data = " + data);
this.cmd = cmd;
this.data = data;
}
@@ -41,10 +41,10 @@ function log(msg) {
* @return XML object
*/
function parseXMLfromString (inStuff) {
- // if (typeof inStuff !== 'string') In future we should recognize this.response
- // and get just .text property out of it. TODO
- var respStr = inStuff.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, ""); // bug 336551
- return new XML(respStr);
+ // if (typeof inStuff !== 'string') In future we should recognize this.response
+ // and get just .text property out of it. TODO
+ var respStr = inStuff.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, ""); // bug 336551
+ return new XML(respStr);
}
/**
@@ -54,343 +54,346 @@ function parseXMLfromString (inStuff) {
* This is a slow variant for bugs other than actual window
*/
function getRealBugNoSlow(bugNo, location, callback) {
- console.log("We have to deal with bug aliased as " + this.bugNo);
- // https://bugzilla.redhat.com/show_bug.cgi?ctype=xml&id=serialWacom
- Request({
- url: location.href+"&ctype=xml",
- onComplete: function(response) {
- if (response.status === 200) {
- var xmlRepr = parseXMLfromString(response.text);
- // TODO this probably wrong, both XPath and .text attribute
- var bugID = parseInt(xmlRepr.bug.bug_id.text, 10);
- if (isNaN(bugID)) {
- throw new Error("Cannot get bug no. even from XML representation!");
- }
- console.log("The real bug no. is " + bugID);
- callback(bugID)
- }
+ console.log("We have to deal with bug aliased as " + this.bugNo);
+ // https://bugzilla.redhat.com/show_bug.cgi?ctype=xml&id=serialWacom
+ Request({
+ url: location.href+"&ctype=xml",
+ onComplete: function(response) {
+ if (response.status === 200) {
+ var xmlRepr = parseXMLfromString(response.text);
+ // TODO this probably wrong, both XPath and .text attribute
+ var bugID = parseInt(xmlRepr.bug.bug_id.text, 10);
+ if (isNaN(bugID)) {
+ throw new Error("Cannot get bug no. even from XML representation!");
}
- }).get();
+ console.log("The real bug no. is " + bugID);
+ callback(bugID)
+ }
+ }
+ }).get();
}
function getPassword(login, domain, callback) {
- var passPrompt = "Enter your Bugzilla password for fixing MIME attachment types";
- var switchPrompt = "Do you want to switch off features requiring password completely";
- var prefName = BTSPrefNS+"withoutPassowrd";
- var retObject = {
- password: null, // password string or null if no password provided
- withoutPass: false // whether user doesn't want to use password at all
- };
-
- passUtils.search({
- username: login,
- url: domain,
- realm: BTSPassRealm,
- onComplete: function onComplete([credential]) {
- if (credential) {
- // We found the password, just go ahead and use it
- retObject.password = credential.password;
- callback(retObject);
- } else {
- // We don't have a stored password, ask for one
- var passwordText = prompts.promptPassword(passPrompt);
- if (passwordText && passwordText.length > 0) {
- // Right, we've got it … store it and then use it.
- retObject.password = passwordText;
- passUtils.store({
- username: login,
- password: passwordText,
- url: domain,
- realm: BTSPassRealm,
- onComplete: function onComplete() {
- callback(retObject);
- }
- });
- } else {
- // We don't have password, and user haven't entered one?
- // Does he want to live passwordless?
- // FIXME should we call the callback at all?
- var switchOff = prompts.promptYesNoCancel(switchPrompt);
- if (switchOff) {
- preferences.set(prefName,true);
- }
- retObject.withoutPass = switchOff;
- callback(retObject);
- }
+ var passPrompt = "Enter your Bugzilla password for fixing MIME attachment types";
+ var switchPrompt = "Do you want to switch off features requiring password completely";
+ var prefName = BTSPrefNS+"withoutPassowrd";
+ var retObject = {
+ password: null, // password string or null if no password provided
+ withoutPass: false // whether user doesn't want to use password at all
+ };
+
+ passUtils.search({
+ username: login,
+ url: domain,
+ realm: BTSPassRealm,
+ onComplete: function onComplete([credential]) {
+ if (credential) {
+ // We found the password, just go ahead and use it
+ retObject.password = credential.password;
+ callback(retObject);
+ }
+ else {
+ // We don't have a stored password, ask for one
+ var passwordText = prompts.promptPassword(passPrompt);
+ if (passwordText && passwordText.length > 0) {
+ // Right, we've got it … store it and then use it.
+ retObject.password = passwordText;
+ passUtils.store({
+ username: login,
+ password: passwordText,
+ url: domain,
+ realm: BTSPassRealm,
+ onComplete: function onComplete() {
+ callback(retObject);
}
+ });
}
- });
+ else {
+ // We don't have password, and user haven't entered one?
+ // Does he want to live passwordless?
+ // FIXME should we call the callback at all?
+ var switchOff = prompts.promptYesNoCancel(switchPrompt);
+ if (switchOff) {
+ preferences.set(prefName,true);
+ }
+ retObject.withoutPass = switchOff;
+ callback(retObject);
+ }
+ }
+ }
+ });
}
exports.changeJSONURL = function changeJSONURL() {
- var prfNm = BTSPrefNS+"JSONURL";
- var url = preferences.get(prfNm,"");
-
- var reply = prompts.prompt("New location of JSON configuration file", url);
- if (reply && (reply != url)) {
- preferences.set(prfNm, reply.trim());
- // TODO Restartless add-on needs to resolve this.
- prompts.alert("For now, you should really restart Firefox!");
- }
+ var prfNm = BTSPrefNS+"JSONURL";
+ var url = preferences.get(prfNm,"");
+
+ var reply = prompts.prompt("New location of JSON configuration file", url);
+ if (reply && (reply != url)) {
+ preferences.set(prfNm, reply.trim());
+ // TODO Restartless add-on needs to resolve this.
+ prompts.alert("For now, you should really restart Firefox!");
+ }
};
/**
*
libbz.getInstalledPackages(msg.data, function (pkgsMsg) {
- worker.postMessage(pkgsMsg);
+ worker.postMessage(pkgsMsg);
locationLoginObj: {
- location: window.location.href,
- login: getLogin()
- }
+ location: window.location.href,
+ login: getLogin()
+ }
*/
exports.getInstalledPackages = function getInstalledPackages(locationLoginObj, callback) {
- var installedPackages = {};
- var enabledPackages = [];
- var location = locationLoginObj.location;
-
- if (typeof location == "string") {
- location = new urlMod.URL(location);
+ var installedPackages = {};
+ var enabledPackages = [];
+ var location = locationLoginObj.location;
+
+ if (typeof location == "string") {
+ location = new urlMod.URL(location);
+ }
+
+ // Collect enabled packages per hostname (plus default ones)
+ if (config.gJSONData && ("commentPackages" in config.gJSONData)) {
+ if ("enabledPackages" in config.gJSONData.configData) {
+ var epObject = config.gJSONData.configData.enabledPackages;
+ if (location.host in epObject) {
+ enabledPackages = enabledPackages.concat(epObject[location.host].split(/[,\s]+/));
+ }
+ if ("any" in epObject) {
+ enabledPackages = enabledPackages.concat(epObject.any.split(/[,\s]+/));
+ }
}
- // Collect enabled packages per hostname (plus default ones)
- if (config.gJSONData && ("commentPackages" in config.gJSONData)) {
- if ("enabledPackages" in config.gJSONData.configData) {
- var epObject = config.gJSONData.configData.enabledPackages;
- if (location.host in epObject) {
- enabledPackages = enabledPackages.concat(epObject[location.host].split(/[,\s]+/));
- }
- if ("any" in epObject) {
- enabledPackages = enabledPackages.concat(epObject.any.split(/[,\s]+/));
- }
- }
-
- var allIdx = null;
- if ((allIdx = enabledPackages.indexOf("all")) != -1) {
- enabledPackages = enabledPackages.splice(allIdx,
- config.gJSONData.commentPackages.keys());
- }
-
- // TODO To be decided, whether we cannot just eliminate packages in
- // installedPackages and having it just as a plain list of all cmdObjects.
- enabledPackages.forEach(function (pkg, idx, arr) {
- if (pkg in config.gJSONData.commentPackages) {
- installedPackages[pkg] = config.gJSONData.commentPackages[pkg];
- }
- });
- }
-
- // Expand commentIdx properties into full comments
- var cmdObj = {};
- for (var pkgKey in installedPackages) {
- for (var cmdObjKey in installedPackages[pkgKey]) {
- cmdObj = installedPackages[pkgKey][cmdObjKey];
- if ("commentIdx" in cmdObj) {
- cmdObj.comment = config.gJSONData.commentStrings[cmdObj.commentIdx];
- delete cmdObj.commentIdx;
- }
- }
+ var allIdx = null;
+ if ((allIdx = enabledPackages.indexOf("all")) != -1) {
+ enabledPackages = enabledPackages.splice(allIdx,
+ config.gJSONData.commentPackages.keys());
}
- if (config.gJSONData.commentStrings &&
- "sentUpstreamString" in config.gJSONData.commentStrings) {
- config.constantData.commentStrings = {};
- config.constantData.commentStrings.sentUpstreamString =
- config.gJSONData.commentStrings["sentUpstreamString"];
+ // TODO To be decided, whether we cannot just eliminate packages in
+ // installedPackages and having it just as a plain list of all cmdObjects.
+ enabledPackages.forEach(function (pkg, idx, arr) {
+ if (pkg in config.gJSONData.commentPackages) {
+ installedPackages[pkg] = config.gJSONData.commentPackages[pkg];
+ }
+ });
+ }
+
+ // Expand commentIdx properties into full comments
+ var cmdObj = {};
+ for (var pkgKey in installedPackages) {
+ for (var cmdObjKey in installedPackages[pkgKey]) {
+ cmdObj = installedPackages[pkgKey][cmdObjKey];
+ if ("commentIdx" in cmdObj) {
+ cmdObj.comment = config.gJSONData.commentStrings[cmdObj.commentIdx];
+ delete cmdObj.commentIdx;
+ }
}
+ }
+
+ if (config.gJSONData.commentStrings &&
+ "sentUpstreamString" in config.gJSONData.commentStrings) {
+ config.constantData.commentStrings = {};
+ config.constantData.commentStrings.sentUpstreamString =
+ config.gJSONData.commentStrings["sentUpstreamString"];
+ }
+
+ var locURL = new urlMod.URL(locationLoginObj.location);
+ var passDomain = locURL.scheme + "://" + locURL.host;
+ getPassword(locationLoginObj.login, passDomain, function (passwObj) {
+ // In order to avoid sending whole password to the content script,
+ // we are sending just these two Booleans.
+ config.constantData.passwordState = {
+ passAvailable: (passwObj.password !== null),
+ withoutPass: passwObj.withoutPass
+ };
- var locURL = new urlMod.URL(locationLoginObj.location);
- var passDomain = locURL.scheme + "://" + locURL.host;
- getPassword(locationLoginObj.login, passDomain, function (passwObj) {
- // In order to avoid sending whole password to the content script,
- // we are sending just these two Booleans.
- config.constantData.passwordState = {
- passAvailable: (passwObj.password !== null),
- withoutPass: passwObj.withoutPass
- };
-
- callback(new Message("CreateButtons", {
- instPkgs: installedPackages,
- constData: config.constantData,
- config: config.configData,
- kNodes: config.gJSONData.configData.killNodes
- }));
- });
+ callback(new Message("CreateButtons", {
+ instPkgs: installedPackages,
+ constData: config.constantData,
+ config: config.configData,
+ kNodes: config.gJSONData.configData.killNodes
+ }));
+ });
};
exports.getClipboard = function getClipboard(cb) {
- cb(clipboard.get());
+ cb(clipboard.get());
};
exports.setClipboard = function setClipboard(stuff) {
- clipboard.set(stuff, "text");
+ clipboard.set(stuff, "text");
};
exports.getURL = function getURL(url, callback) {
- Request({
- url: url,
- onComplete: function(response) {
- if (response.status == 200) {
- callback(response.text);
- }
- }
- }).get();
+ Request({
+ url: url,
+ onComplete: function(response) {
+ if (response.status == 200) {
+ callback(response.text);
+ }
+ }
+ }).get();
};
exports.openStringInNewPanel = function openStringInNewPanel(inHTMLStr) {
- openURLInNewPanel("data:text/html;charset=utf-8," +
- inHTMLStr);
+ openURLInNewPanel("data:text/html;charset=utf-8," +
+ inHTMLStr);
};
var openURLInNewPanel = exports.openURLInNewPanel = function openURLInNewPanel(url) {
- var panel = panelMod.Panel({
- contentURL: url,
- width: 640,
- height: 640
- });
- panel.show();
+ var panel = panelMod.Panel({
+ contentURL: url,
+ width: 640,
+ height: 640
+ });
+ panel.show();
};
var openURLInNewTab = exports.openURLInNewTab = function openURLInNewTab(url) {
- tabs.open({
- url: url,
- inBackground: true,
- onReady: function(t) {
- t.activate();
- }
- });
+ tabs.open({
+ url: url,
+ inBackground: true,
+ onReady: function(t) {
+ t.activate();
+ }
+ });
};
exports.createUpstreamBug = function createUpstreamBug(urlStr, subject, comment) {
- tabs.open({
- url: urlStr,
- inBackground: true,
- onReady: function (t) {
- var otherElems = t.contentDocument.forms.namedItem("Create").elements;
- // Summary
- otherElems.namedItem("short_desc").value = subject;
- // Comment
- otherElems.namedItem("comment").value = collectComments();
- t.activate();
- }
- });
+ tabs.open({
+ url: urlStr,
+ inBackground: true,
+ onReady: function (t) {
+ var otherElems = t.contentDocument.forms.namedItem("Create").elements;
+ // Summary
+ otherElems.namedItem("short_desc").value = subject;
+ // Comment
+ otherElems.namedItem("comment").value = collectComments();
+ t.activate();
+ }
+ });
};
// Make a XML-RPC call ... most of the business logic should stay in the content script
exports.makeXMLRPCCall = function makeXMLRPCCall(url, login, method, params, callback) {
- var urlObj = urlMod.URL(url);
- getPassword(login,
- urlObj.schema + "://" + urlObj.host,
- function (passwObj) {
- if (!passwObj.password) {
- // TODO this should happen, only when user presses Escape in password prompt
- return null;
- }
-
- var msg = new xrpc.XMLRPCMessage(method);
- params.forEach(function (par) {
- msg.addParameter(par);
- });
- msg.addParameter(login);
- msg.addParameter(passwObj.password);
-
- Request({
- url: url,
- onComplete: function(response) {
- if (response.status == 200) {
- var resp = parseXMLfromString(response.text);
- callback(resp.toXMLString());
- }
- },
- content: msg.xml(),
- contentType: "text/xml"
- }).post();
- }
- );
+ var urlObj = urlMod.URL(url);
+ getPassword(login,
+ urlObj.schema + "://" + urlObj.host,
+ function (passwObj) {
+ if (!passwObj.password) {
+ // TODO this should happen, only when user presses Escape in password prompt
+ return null;
+ }
+
+ var msg = new xrpc.XMLRPCMessage(method);
+ params.forEach(function (par) {
+ msg.addParameter(par);
+ });
+ msg.addParameter(login);
+ msg.addParameter(passwObj.password);
+
+ Request({
+ url: url,
+ onComplete: function(response) {
+ if (response.status == 200) {
+ var resp = parseXMLfromString(response.text);
+ callback(resp.toXMLString());
+ }
+ },
+ content: msg.xml(),
+ contentType: "text/xml"
+ }).post();
+ }
+ );
};
exports.initialize = function initialize(config, callback) {
- var prefName = BTSPrefNS+"JSONURL";
- var urlStr = "";
-
- if (preferences.isSet(prefName)) {
- urlStr = preferences.get(prefName);
- } else {
- urlStr = JSONURLDefault;
- preferences.set(prefName, JSONURLDefault);
- }
-
- // Randomize URL to avoid caching
- // TODO see https://fedorahosted.org/bugzilla-triage-scripts/ticket/21
- // for more thorough discussion and possible further improvement
- urlStr += (urlStr.match(/\?/) == null ? "?" : "&") + (new Date()).getTime();
-
- Request({
- url: urlStr,
- onComplete: function (response) {
- if (response.status == 200) {
- config.gJSONData = response.json;
-
- // Get additional tables
- if ("downloadJSON" in config.gJSONData.configData) {
- var URLsList = config.gJSONData.configData.downloadJSON;
- var dwnldObj = "";
- URLsList.forEach(function (arr) {
- var title = arr[0];
- var url = arr[1];
- Request({
- url: url,
- onComplete: function(response) {
- if (response.status == 200) {
- config.constantData[title] = response.json;
- }
- }
- }).get();
- });
+ var prefName = BTSPrefNS+"JSONURL";
+ var urlStr = "";
+
+ if (preferences.isSet(prefName)) {
+ urlStr = preferences.get(prefName);
+ }
+ else {
+ urlStr = JSONURLDefault;
+ preferences.set(prefName, JSONURLDefault);
+ }
+
+ // Randomize URL to avoid caching
+ // TODO see https://fedorahosted.org/bugzilla-triage-scripts/ticket/21
+ // for more thorough discussion and possible further improvement
+ urlStr += (urlStr.match(/\?/) == null ? "?" : "&") + (new Date()).getTime();
+
+ Request({
+ url: urlStr,
+ onComplete: function (response) {
+ if (response.status == 200) {
+ config.gJSONData = response.json;
+
+ // Get additional tables
+ if ("downloadJSON" in config.gJSONData.configData) {
+ var URLsList = config.gJSONData.configData.downloadJSON;
+ var dwnldObj = "";
+ URLsList.forEach(function (arr) {
+ var title = arr[0];
+ var url = arr[1];
+ Request({
+ url: url,
+ onComplete: function(response) {
+ if (response.status == 200) {
+ config.constantData[title] = response.json;
}
+ }
+ }).get();
+ });
+ }
- config.configData = {};
- config.configData.matches = config.gJSONData.configData.matches;
- config.configData.skipMatches = config.configData.matches.map(function(x) {
- return x.replace("show_bug.cgi.*","((process|post)_bug|attachment)\.cgi$");
- });
-
- config.constantData = {};
- if ("constantData" in config.gJSONData) {
- config.constantData = config.gJSONData.constantData;
- config.constantData.queryUpstreamBug = JSON.parse(
- selfMod.data.load("queryUpstreamBug.json"));
- config.constantData.XMLRPCData = JSON.parse(
- selfMod.data.load("XMLRPCdata.json"));
- config.constantData.bugzillaLabelNames =
- JSON.parse(selfMod.data.load("bugzillalabelNames.json"));
- config.constantData.newUpstreamBug =
- JSON.parse(selfMod.data.load("newUpstreamBug.json"));
- config.constantData.ProfessionalProducts =
- JSON.parse(selfMod.data.load("professionalProducts.json"));
- }
+ config.configData = {};
+ config.configData.matches = config.gJSONData.configData.matches;
+ config.configData.skipMatches = config.configData.matches.map(function(x) {
+ return x.replace("show_bug.cgi.*","((process|post)_bug|attachment)\.cgi$");
+ });
- if ("CCmaintainer" in config.constantData) {
- config.configData.defBugzillaMaintainerArr = config.constantData.CCmaintainer;
- }
+ config.constantData = {};
+ if ("constantData" in config.gJSONData) {
+ config.constantData = config.gJSONData.constantData;
+ config.constantData.queryUpstreamBug = JSON.parse(
+ selfMod.data.load("queryUpstreamBug.json"));
+ config.constantData.XMLRPCData = JSON.parse(
+ selfMod.data.load("XMLRPCdata.json"));
+ config.constantData.bugzillaLabelNames =
+ JSON.parse(selfMod.data.load("bugzillalabelNames.json"));
+ config.constantData.newUpstreamBug =
+ JSON.parse(selfMod.data.load("newUpstreamBug.json"));
+ config.constantData.ProfessionalProducts =
+ JSON.parse(selfMod.data.load("professionalProducts.json"));
+ }
- if ("suspiciousComponents" in config.gJSONData.configData) {
- config.configData.suspiciousComponents =
- config.gJSONData.configData.suspiciousComponents;
- }
+ if ("CCmaintainer" in config.constantData) {
+ config.configData.defBugzillaMaintainerArr = config.constantData.CCmaintainer;
+ }
- if ("XorgLogAnalysis" in config.gJSONData.configData) {
- config.configData.xorglogAnalysis =
- config.gJSONData.configData.XorgLogAnalysis;
- }
+ if ("suspiciousComponents" in config.gJSONData.configData) {
+ config.configData.suspiciousComponents =
+ config.gJSONData.configData.suspiciousComponents;
+ }
- if ("submitsLogging" in config.gJSONData.configData &&
- config.gJSONData.configData.submitsLogging) {
- logger.initialize(JSON.parse(selfMod.data.load(
- "bugzillalabelAbbreviations.json")));
- }
- }
- callback();
+ if ("XorgLogAnalysis" in config.gJSONData.configData) {
+ config.configData.xorglogAnalysis =
+ config.gJSONData.configData.XorgLogAnalysis;
+ }
+
+ if ("submitsLogging" in config.gJSONData.configData &&
+ config.gJSONData.configData.submitsLogging) {
+ logger.initialize(JSON.parse(selfMod.data.load(
+ "bugzillalabelAbbreviations.json")));
}
- }).get();
+ }
+ callback();
+ }
+ }).get();
}
diff --git a/lib/logger.js b/lib/logger.js
index 07f42ba..4411a72 100644
--- a/lib/logger.js
+++ b/lib/logger.js
@@ -1,4 +1,5 @@
-// Released under the MIT/X11 license
+/
+Released under the MIT/X11 license
// http://www.opensource.org/licenses/mit-license.php
"use strict";
var urlMod = require("url");
@@ -17,113 +18,118 @@ var FullLogsColor = "rgb(0, 40, 103)";
var abbsMap = {};
exports.initialize = function initialize(aMap) {
- if (!myStorage.storage.logs) {
- myStorage.storage.logs = {};
- }
- abbsMap = aMap;
+ if (!myStorage.storage.logs) {
+ myStorage.storage.logs = {};
+ }
+ abbsMap = aMap;
};
exports.addLogRecord = function addLogRecord(rec) {
- if (myStorage.storage.logs[rec.key]) {
- myStorage.storage.logs[rec.key].comment += "<br/>\n" + comment;
- } else {
- myStorage.storage.logs[rec.key] = rec;
- }
+ if (myStorage.storage.logs[rec.key]) {
+ myStorage.storage.logs[rec.key].comment += "<br/>\n" + comment;
+ }
+ else {
+ myStorage.storage.logs[rec.key] = rec;
+ }
};
function storeSize() {
- var size = 0, key;
- for (key in myStorage.storage.logs) {
- size++;
- }
- return size;
+ var size = 0, key;
+ for (key in myStorage.storage.logs) {
+ size++;
+ }
+ return size;
}
function isEmpty() {
- return (storeSize() === 0);
+ return (storeSize() === 0);
}
exports.clearTimeSheet = function clearTimeSheet() {
- myStorage.storage.logs = {};
- var size = storeSize();
+ myStorage.storage.logs = {};
+ var size = storeSize();
};
exports.importTimeSheet = function importTimeSheet() {
- var filename = prompts.promptFileOpenPicker();
- if (fileMod.exists(filename)) {
- var otherTS = JSON.parse(fileMod.read(filename));
- if (otherTS.logs) {
- for (var rec in otherTS.logs) {
- myStorage.storage.logs[rec] = otherTS.logs[rec];
- }
- } else {
- console.error("This is not a log file!");
- }
- } else {
- console.error("File " + filename + " doesn't exist!");
+ var filename = prompts.promptFileOpenPicker();
+ if (fileMod.exists(filename)) {
+ var otherTS = JSON.parse(fileMod.read(filename));
+ if (otherTS.logs) {
+ for (var rec in otherTS.logs) {
+ myStorage.storage.logs[rec] = otherTS.logs[rec];
+ }
}
+ else {
+ console.error("This is not a log file!");
+ }
+ }
+ else {
+ console.error("File " + filename + " doesn't exist!");
+ }
};
function getBugzillaAbbr(url) {
- // for https://bugzilla.redhat.com/show_bug.cgi?id=579123 get RH
- // for https://bugzilla.mozilla.org/show_bug.cgi?id=579123 get MoFo
- return abbsMap[urlMod.URL(url).host];
+ // for https://bugzilla.redhat.com/show_bug.cgi?id=579123 get RH
+ // for https://bugzilla.mozilla.org/show_bug.cgi?id=579123 get MoFo
+ return abbsMap[urlMod.URL(url).host];
}
exports.generateTimeSheet = function generateTimeSheet() {
- var docHTML = timeSheetRecordsPrinter(myStorage.storage.logs);
- libbz.openURLInNewTab("data:text/html;charset=utf-8," + docHTML);
+ var docHTML = timeSheetRecordsPrinter(myStorage.storage.logs);
+ libbz.openURLInNewTab("data:text/html;charset=utf-8," + docHTML);
};
function timeSheetRecordsPrinter(records) {
- var commentBugRE = new RegExp("[bB]ug\\s+([0-9]+)","g");
- // sort the records into temporary array
- var tmpArr = [];
- var outStr = '<!DOCTYPE html>' +
- "<html><head>\n"+
- "<meta charset='utf-8'/>\n"+
- "<title>Status report</title>\n</head>\n<body>\n" +
- "<h1>TimeSheet</h1>\n";
+ var commentBugRE = new RegExp("[bB]ug\\s+([0-9]+)","g");
+ // sort the records into temporary array
+ var tmpArr = [];
+ var outStr = '<!DOCTYPE html>' +
+ "<html><head>\n"+
+ "<meta charset='utf-8'/>\n"+
+ "<title>Status report</title>\n</head>\n<body>\n" +
+ "<h1>TimeSheet</h1>\n";
- for (var i in records) {
- if (records.hasOwnProperty(i)) {
- tmpArr.push( [ i, records[i] ]);
- }
+ for (var i in records) {
+ if (records.hasOwnProperty(i)) {
+ tmpArr.push( [ i, records[i] ]);
+ }
+ }
+ tmpArr.sort(function(a, b) {
+ if (a[0] > b[0]) {
+ return 1;
+ }
+ else if (a[0] < b[0]) {
+ return -1;
+ }
+ else {
+ return 0;
}
- tmpArr.sort(function(a, b) {
- if (a[0] > b[0]) {
- return 1;
- } else if (a[0] < b[0]) {
- return -1;
- } else {
- return 0;
- }
- });
+ });
- var currentDay = "";
- // now print the array
- tmpArr.forEach(function(rec) {
- var x = rec[1];
- var dayStr = utilMod.getISODate(x.date);
- var host = urlMod.URL(x.url).host;
- var BZName = getBugzillaAbbr(x.url);
- var bugNo = utilMod.getBugNo(x.url);
- if (dayStr != currentDay) {
- currentDay = dayStr;
- outStr += "<hr/><p><strong>" + currentDay
- + "</strong></p>\n";
- }
- // replace "bug ####" with a hyperlink to the current bugzilla
- var comment = x.comment.replace(commentBugRE,
- "<a href='http://"+host+"/show_bug.cgi?id=$1'>$&</a>");
- outStr += "<p><em><a href='"
- + x.url
- + "'>Bug "
- + BZName + "/" + bugNo + ": "
- + x.title
- + "</a>"
- + " </em>\n<br/>" + comment + "</p>\n";
- });
- outStr += "</body></html>";
- return outStr;
+ var currentDay = "";
+ // now print the array
+ tmpArr.forEach(function(rec) {
+ var x = rec[1];
+ var dayStr = utilMod.getISODate(x.date);
+ var host = urlMod.URL(x.url).host;
+ var BZName = getBugzillaAbbr(x.url);
+ var bugNo = utilMod.getBugNo(x.url);
+ if (dayStr != currentDay) {
+ currentDay = dayStr;
+ outStr += "<hr/><p><strong>" + currentDay
+ + "</strong></p>\n";
+ }
+ // replace "bug ####" with a hyperlink to the current bugzilla
+ var comment = x.comment.replace(commentBugRE,
+ "<a href='http://"+host+"/show_bug.cgi?id=$1'>$&</a>");
+ outStr += "<p><em><a href='"
+ + x.url
+ + "'>Bug "
+ + BZName + "/" + bugNo + ": "
+ + x.title
+ + "</a>"
+ + " </em>\n<br/>" + comment + "</p>\n";
+ });
+ outStr += "</body></html>";
+ return outStr;
}
diff --git a/lib/main.js b/lib/main.js
index b553f6f..2e79e3a 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -6,7 +6,7 @@
// http://hg.mozilla.org/users/ehsan.akhgari_gmail.com/extensions/file/tip/bugzillatweaks
// http://hg.mozilla.org/users/ehsan.akhgari_gmail.com/extensions/file/ecfa0f028b81/bugzillatweaks/lib/main.js
// http://hg.mozilla.org/users/avarma_mozilla.com/atul-packages/file/42ac1e99a107/packages\
-// /facebook-acquaintances/lib/main.js#l11
+// /facebook-acquaintances/lib/main.js#l11
// http://ehsanakhgari.org/blog/2010-05-31/my-experience-jetpack-sdk#comment-1253
//
"use strict";
@@ -19,138 +19,138 @@ var logger = require("logger");
var Message = require("util").Message;
function isOurPage(window, matchingURLs) {
- var url = window.location.href;
+ var url = window.location.href;
- // like ["regexp-url1", "regexp-url2"]
- return matchingURLs.some(function (element,i,a) {
- return new RegExp(element).test(url);
- });
+ // like ["regexp-url1", "regexp-url2"]
+ return matchingURLs.some(function (element,i,a) {
+ return new RegExp(element).test(url);
+ });
}
/**
*
*/
function skipThisPage(doc) {
- var stemURL = "https://HOSTNAME/show_bug.cgi?id=";
- var titleElems = doc.getElementsByTagName("title");
- var titleStr = titleElems[0].textContent;
- var REArr = new RegExp("[bB]ug\\s+([0-9]+)").exec(titleStr);
- var hostname = doc.location.hostname;
- if (REArr) {
- var bugNo = REArr[1];
- doc.location = stemURL.replace("HOSTNAME",hostname) + bugNo;
- }
+ var stemURL = "https://HOSTNAME/show_bug.cgi?id=";
+ var titleElems = doc.getElementsByTagName("title");
+ var titleStr = titleElems[0].textContent;
+ var REArr = new RegExp("[bB]ug\\s+([0-9]+)").exec(titleStr);
+ var hostname = doc.location.hostname;
+ if (REArr) {
+ var bugNo = REArr[1];
+ doc.location = stemURL.replace("HOSTNAME",hostname) + bugNo;
+ }
}
var messageHandler = exports.messageHandler = function messageHandler(worker, msg) {
- switch (msg.cmd) {
- case "LogMessage":
- console.log(msg.data);
- break;
- case "ExecCmd":
- libbz.executeCommand(msg.data);
- break;
- case "AddLogRecord":
- logger.addLogRecord(msg.data);
- break;
- case "GenerateTS":
- logger.generateTimeSheet();
- break;
- case "ClearTS":
- logger.clearTimeSheet();
- break;
- case "ImportTS":
- logger.importTimeSheet();
- break;
- case "GetInstalledPackages":
- // send message with packages back
- libbz.getInstalledPackages(msg.data, function (pkgsMsg) {
- worker.postMessage(pkgsMsg);
- });
- break;
- case "GetClipboard":
- libbz.getClipboard(function (clipboard) {
- worker.postMessage(new Message(msg.data, clipboard));
- });
- break;
- case "SetClipboard":
- libbz.setClipboard(msg.data);
- break;
- case "ChangeJSONURL":
- libbz.changeJSONURL();
- break;
- case "OpenURLinPanel":
- libbz.openURLInNewPanel(msg.data);
- break;
- case "OpenURLinTab":
- libbz.openURLInNewTab(msg.data);
- break;
- case "OpenStringInPanel":
- libbz.openStringInNewPanel(msg.data);
- break;
- case "MakeXMLRPCall":
- // url, login, method, params, callback
- libbz.makeXMLRPCCall(msg.data.url, msg.data.login, msg.data.method,
- msg.data.params, function(ret) {
- worker.postMessage(new Message(msg.data.callRPC, ret));
- });
- break;
- case "GetURL":
- libbz.getURL(msg.data.url, function(stuff) {
- worker.postMessage(new Message(msg.data.backMessage, stuff));
- });
- break;
- case "OpenBugUpstream":
- libbz.createUpstreamBug(msg.data.url, msg.data.subject, msg.data.comment);
- break;
- case "testReady":
- // we ignore it here, interesting only in unit test
- break;
- default:
- console.error(msg.toSource());
- }
+ switch (msg.cmd) {
+ case "LogMessage":
+ console.log(msg.data);
+ break;
+ case "ExecCmd":
+ libbz.executeCommand(msg.data);
+ break;
+ case "AddLogRecord":
+ logger.addLogRecord(msg.data);
+ break;
+ case "GenerateTS":
+ logger.generateTimeSheet();
+ break;
+ case "ClearTS":
+ logger.clearTimeSheet();
+ break;
+ case "ImportTS":
+ logger.importTimeSheet();
+ break;
+ case "GetInstalledPackages":
+ // send message with packages back
+ libbz.getInstalledPackages(msg.data, function (pkgsMsg) {
+ worker.postMessage(pkgsMsg);
+ });
+ break;
+ case "GetClipboard":
+ libbz.getClipboard(function (clipboard) {
+ worker.postMessage(new Message(msg.data, clipboard));
+ });
+ break;
+ case "SetClipboard":
+ libbz.setClipboard(msg.data);
+ break;
+ case "ChangeJSONURL":
+ libbz.changeJSONURL();
+ break;
+ case "OpenURLinPanel":
+ libbz.openURLInNewPanel(msg.data);
+ break;
+ case "OpenURLinTab":
+ libbz.openURLInNewTab(msg.data);
+ break;
+ case "OpenStringInPanel":
+ libbz.openStringInNewPanel(msg.data);
+ break;
+ case "MakeXMLRPCall":
+ // url, login, method, params, callback
+ libbz.makeXMLRPCCall(msg.data.url, msg.data.login, msg.data.method,
+ msg.data.params, function(ret) {
+ worker.postMessage(new Message(msg.data.callRPC, ret));
+ });
+ break;
+ case "GetURL":
+ libbz.getURL(msg.data.url, function(stuff) {
+ worker.postMessage(new Message(msg.data.backMessage, stuff));
+ });
+ break;
+ case "OpenBugUpstream":
+ libbz.createUpstreamBug(msg.data.url, msg.data.subject, msg.data.comment);
+ break;
+ case "testReady":
+ // we ignore it here, interesting only in unit test
+ break;
+ default:
+ console.error(msg.toSource());
+ }
};
var contentScriptLibraries = [
- self.data.url("lib/jumpNextBug.js"),
- self.data.url("lib/util.js"),
- self.data.url("lib/color.js"),
- self.data.url("lib/logging-front.js"),
- self.data.url("lib/rhbzpage.js"),
- self.data.url("lib/bzpage.js")
+ self.data.url("lib/jumpNextBug.js"),
+ self.data.url("lib/util.js"),
+ self.data.url("lib/color.js"),
+ self.data.url("lib/logging-front.js"),
+ self.data.url("lib/rhbzpage.js"),
+ self.data.url("lib/bzpage.js")
];
libbz.initialize(libbz.config, function () {
- pageMod.PageMod({
- include: [
- "https://bugzilla.redhat.com/show_bug.cgi?id=*",
- "https://bugzilla.mozilla.org/show_bug.cgi?id=*",
- "https://bugzilla.gnome.org/show_bug.cgi?id=*"
- ],
- contentScriptWhen: 'ready',
- contentScriptFile: contentScriptLibraries,
- onAttach: function onAttach(worker, msg) {
- worker.on('message', function (msg) {
- messageHandler(worker, msg);
- });
- }
- });
-});
-
-pageMod.PageMod({
+ pageMod.PageMod({
include: [
- "https://bugzilla.redhat.com/process_bug.cgi",
- "https://bugzilla.redhat.com/post_bug.cgi",
- "https://bugzilla.redhat.com/attachment.cgi",
- "https://bugzilla.mozilla.org/process_bug.cgi",
- "https://bugzilla.mozilla.org/post_bug.cgi",
- "https://bugzilla.mozilla.org/attachment.cgi",
- "https://bugzilla.gnome.org/process_bug.cgi",
- "https://bugzilla.gnome.org/post_bug.cgi",
- "https://bugzilla.gnome.org/attachment.cgi"
+ "https://bugzilla.redhat.com/show_bug.cgi?id=*",
+ "https://bugzilla.mozilla.org/show_bug.cgi?id=*",
+ "https://bugzilla.gnome.org/show_bug.cgi?id=*"
],
contentScriptWhen: 'ready',
- contentScriptFile: self.data.url("lib/skip-bug.js")
+ contentScriptFile: contentScriptLibraries,
+ onAttach: function onAttach(worker, msg) {
+ worker.on('message', function (msg) {
+ messageHandler(worker, msg);
+ });
+ }
+ });
+});
+
+pageMod.PageMod({
+ include: [
+ "https://bugzilla.redhat.com/process_bug.cgi",
+ "https://bugzilla.redhat.com/post_bug.cgi",
+ "https://bugzilla.redhat.com/attachment.cgi",
+ "https://bugzilla.mozilla.org/process_bug.cgi",
+ "https://bugzilla.mozilla.org/post_bug.cgi",
+ "https://bugzilla.mozilla.org/attachment.cgi",
+ "https://bugzilla.gnome.org/process_bug.cgi",
+ "https://bugzilla.gnome.org/post_bug.cgi",
+ "https://bugzilla.gnome.org/attachment.cgi"
+ ],
+ contentScriptWhen: 'ready',
+ contentScriptFile: self.data.url("lib/skip-bug.js")
});
// tabs.open("https://bugzilla.redhat.com/show_bug.cgi?id=679515");
diff --git a/lib/prompts.js b/lib/prompts.js
index ed9b3e5..7cfd3d1 100644
--- a/lib/prompts.js
+++ b/lib/prompts.js
@@ -15,9 +15,9 @@ var promptTitle = "Bugzilla Triage Script";
* @return none
*/
exports.alert = function alert(msg) {
- var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Ci.nsIPromptService);
- prompts.alert(null, promptTitle, msg);
+ var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Ci.nsIPromptService);
+ prompts.alert(null, promptTitle, msg);
};
/**
@@ -26,19 +26,20 @@ exports.alert = function alert(msg) {
* @return String with the password
*/
exports.prompt = function prompt(prompt, defaultValue) {
- var stringValue = {
- value: defaultValue ? defaultValue : ""
- };
+ var stringValue = {
+ value: defaultValue ? defaultValue : ""
+ };
- var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Ci.nsIPromptService);
- var result = prompts.prompt(null, promptTitle, prompt,
- stringValue, null, {});
- if (result) {
- return stringValue.value;
- } else {
- return null;
- }
+ var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Ci.nsIPromptService);
+ var result = prompts.prompt(null, promptTitle, prompt,
+ stringValue, null, {});
+ if (result) {
+ return stringValue.value;
+ }
+ else {
+ return null;
+ }
};
/**
@@ -47,27 +48,28 @@ exports.prompt = function prompt(prompt, defaultValue) {
* @return String with the password
*/
exports.promptPassword = function promptPassword(prompt) {
- if (!prompt) { // either undefined or null
- prompt = "Enter password:";
- }
- var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Ci.nsIPromptService);
- var password = {
- value : ""
- }; // default the password to pass
- var check = {
- value : true
- }; // default the checkbox to true
- var result = prompts.promptPassword(null, "Bugzilla Triage Script", prompt,
- password, null, check);
- // result is true if OK was pressed, false if cancel was pressed.
- // password.value is set if OK was pressed.
- // The checkbox is not displayed.
- if (result) {
- return password.value ? password.value : null;
- } else {
- return null;
- }
+ if (!prompt) { // either undefined or null
+ prompt = "Enter password:";
+ }
+ var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Ci.nsIPromptService);
+ var password = {
+ value : ""
+ }; // default the password to pass
+ var check = {
+ value : true
+ }; // default the checkbox to true
+ var result = prompts.promptPassword(null, "Bugzilla Triage Script", prompt,
+ password, null, check);
+ // result is true if OK was pressed, false if cancel was pressed.
+ // password.value is set if OK was pressed.
+ // The checkbox is not displayed.
+ if (result) {
+ return password.value ? password.value : null;
+ }
+ else {
+ return null;
+ }
};
/**
@@ -75,21 +77,23 @@ exports.promptPassword = function promptPassword(prompt) {
* https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIPromptService
*/
exports.promptYesNoCancel = function promptOKNoCancel(prompt) {
- if (!prompt) { // either undefined or null
- throw new Error("Prompt is required!");
- }
- var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Ci.nsIPromptService);
+ if (!prompt) { // either undefined or null
+ throw new Error("Prompt is required!");
+ }
+ var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Ci.nsIPromptService);
- var result = prompts.confirmEx(null, "Bugzilla Triage Script", prompt,
- prompts.STD_YES_NO_BUTTONS, null, null, null, null, {});
- if (result === 0) {
- return true;
- } else if (result === 1) {
- return false;
- } else {
- return null;
- }
+ var result = prompts.confirmEx(null, "Bugzilla Triage Script", prompt,
+ prompts.STD_YES_NO_BUTTONS, null, null, null, null, {});
+ if (result === 0) {
+ return true;
+ }
+ else if (result === 1) {
+ return false;
+ }
+ else {
+ return null;
+ }
};
/**
@@ -97,18 +101,18 @@ exports.promptYesNoCancel = function promptOKNoCancel(prompt) {
* documentation is https://developer.mozilla.org/en/NsIFilePicker
*/
exports.promptFileOpenPicker = function promptFilePicker (win) {
- var window = require("window-utils").activeWindow;
- var fp = Cc["@mozilla.org/filepicker;1"]
- .createInstance(Ci.nsIFilePicker);
- fp.init(window, "JSON File Open", Ci.nsIFilePicker.modeOpen);
- fp.appendFilter("JSON files", "*.json");
- fp.appendFilters(Ci.nsIFilePicker.filterAll);
- fp.filterIndex = 0;
- var res = fp.show();
+ var window = require("window-utils").activeWindow;
+ var fp = Cc["@mozilla.org/filepicker;1"]
+ .createInstance(Ci.nsIFilePicker);
+ fp.init(window, "JSON File Open", Ci.nsIFilePicker.modeOpen);
+ fp.appendFilter("JSON files", "*.json");
+ fp.appendFilters(Ci.nsIFilePicker.filterAll);
+ fp.filterIndex = 0;
+ var res = fp.show();
- if (res === Ci.nsIFilePicker.returnOK ||
- res === Ci.nsIFilePicker.returnReplace ) {
- return fp.file.path;
- }
- return null;
+ if (res === Ci.nsIFilePicker.returnOK ||
+ res === Ci.nsIFilePicker.returnReplace ) {
+ return fp.file.path;
+ }
+ return null;
};
diff --git a/lib/util.js b/lib/util.js
index 089e31c..d28f001 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -12,26 +12,26 @@ var urlMod = require("url");
* get parameters of URL as an object (name, value)
*/
function getParamsFromURL (url, base) {
- if (!url || (url.toString().length === 0)) {
- throw new Error("Missing URL value!");
- }
+ if (!url || (url.toString().length === 0)) {
+ throw new Error("Missing URL value!");
+ }
- if (!(url instanceof urlMod.URL)) {
- url = new urlMod.URL(url.toString(), base);
- }
+ if (!(url instanceof urlMod.URL)) {
+ url = new urlMod.URL(url.toString(), base);
+ }
- var paramsArr = url.path.split("?");
- if (paramsArr.length === 1) {
- return {};
+ var paramsArr = url.path.split("?");
+ if (paramsArr.length === 1) {
+ return {};
}
- // get convert URL parameters to an Object
- var params = {}, s = [];
- paramsArr[1].split('&').forEach(function(par) {
- s = par.split('=');
- params[s[0]] = s[1];
- });
- return params;
+ // get convert URL parameters to an Object
+ var params = {}, s = [];
+ paramsArr[1].split('&').forEach(function(par) {
+ s = par.split('=');
+ params[s[0]] = s[1];
+ });
+ return params;
}
/**
@@ -43,10 +43,10 @@ function getParamsFromURL (url, base) {
* @return String with the bug ID (hopefully number, but not for aliases)
*/
exports.getBugNo = function getBugNo(url) {
- var params = getParamsFromURL(url);
- if (params && params.id) {
- return params.id;
- }
+ var params = getParamsFromURL(url);
+ if (params && params.id) {
+ return params.id;
+ }
};
/**
@@ -56,20 +56,20 @@ exports.getBugNo = function getBugNo(url) {
* @return string with the formatted date
*/
exports.getISODate = function getISODate(dateStr) {
- function pad(n) {
- return n < 10 ? '0' + n : n;
- }
- var date = new Date(dateStr);
- return date.getFullYear() + '-' + pad(date.getMonth() + 1) + '-' +
- pad(date.getDate());
+ function pad(n) {
+ return n < 10 ? '0' + n : n;
+ }
+ var date = new Date(dateStr);
+ return date.getFullYear() + '-' + pad(date.getMonth() + 1) + '-' +
+ pad(date.getDate());
};
/**
* object to pack messaging. Use as in
- postMessage(new Message("GetPassword", {
- login: login,
- hostname: location.hostname
- }));
+ postMessage(new Message("GetPassword", {
+ login: login,
+ hostname: location.hostname
+ }));
*/
exports.Message = function Message(cmd, data) {
this.cmd = cmd;
diff --git a/lib/xmlrpc.js b/lib/xmlrpc.js
index 0b84c07..8b71f32 100644
--- a/lib/xmlrpc.js
+++ b/lib/xmlrpc.js
@@ -27,159 +27,162 @@
*/
var XMLRPCMessage = exports.XMLRPCMessage = function XMLRPCMessage(methodname) {
- this.method = methodname || "system.listMethods";
- this.params = [];
- return this;
+ this.method = methodname || "system.listMethods";
+ this.params = [];
+ return this;
};
XMLRPCMessage.prototype.myIsArray = function myIsArray(obj) {
- return (typeof obj.sort === 'function');
+ return (typeof obj.sort === 'function');
};
XMLRPCMessage.prototype.setMethod = function (methodName) {
- if (methodName !== undefined) {
- this.method = methodName;
- }
+ if (methodName !== undefined) {
+ this.method = methodName;
+ }
};
XMLRPCMessage.prototype.addParameter = function (data) {
- if (data !== undefined) {
- this.params.push(data);
- }
+ if (data !== undefined) {
+ this.params.push(data);
+ }
};
XMLRPCMessage.prototype.xml = function () {
- var method = this.method;
+ var method = this.method;
- // assemble the XML message header
- var xml = "";
+ // assemble the XML message header
+ var xml = "";
- xml += "<?xml version=\"1.0\"?>\n";
- xml += "<methodCall>\n";
- xml += "<methodName>" + method + "</methodName>\n";
- xml += "<params>\n";
+ xml += "<?xml version=\"1.0\"?>\n";
+ xml += "<methodCall>\n";
+ xml += "<methodName>" + method + "</methodName>\n";
+ xml += "<params>\n";
- // do individual parameters
- this.params.forEach(function (data) {
- xml += "<param>\n";
- xml += "<value>" +
- this.getParamXML(this.dataTypeOf(data),
- data) + "</value>\n";
- xml += "</param>\n";
- }, this);
- xml += "</params>\n";
- xml += "</methodCall>";
+ // do individual parameters
+ this.params.forEach(function (data) {
+ xml += "<param>\n";
+ xml += "<value>" +
+ this.getParamXML(this.dataTypeOf(data),
+ data) + "</value>\n";
+ xml += "</param>\n";
+ }, this);
+ xml += "</params>\n";
+ xml += "</methodCall>";
- return xml; // for now
+ return xml; // for now
};
XMLRPCMessage.prototype.dataTypeOf = function (o) {
- // identifies the data type
- var type = typeof (o);
- type = type.toLowerCase();
- switch (type) {
- case "number":
- if (Math.round(o) === o) {
- type = "i4";
- } else {
- type = "double";
- }
- break;
- case "object":
- if ((o instanceof Date)) {
- type = "date";
- } else if (this.myIsArray(o)) {
- type = "array";
- } else {
- type = "struct";
- }
- break;
+ // identifies the data type
+ var type = typeof (o);
+ type = type.toLowerCase();
+ switch (type) {
+ case "number":
+ if (Math.round(o) === o) {
+ type = "i4";
+ }
+ else {
+ type = "double";
+ }
+ break;
+ case "object":
+ if ((o instanceof Date)) {
+ type = "date";
+ }
+ else if (this.myIsArray(o)) {
+ type = "array";
+ }
+ else {
+ type = "struct";
}
- return type;
+ break;
+ }
+ return type;
};
XMLRPCMessage.prototype.doValueXML = function (type, data) {
- var xml = "<" + type + ">" + data + "</" + type + ">";
- return xml;
+ var xml = "<" + type + ">" + data + "</" + type + ">";
+ return xml;
};
XMLRPCMessage.prototype.doBooleanXML = function (data) {
- var value = (data === true) ? 1 : 0;
- var xml = "<boolean>" + value + "</boolean>";
- return xml;
+ var value = (data === true) ? 1 : 0;
+ var xml = "<boolean>" + value + "</boolean>";
+ return xml;
};
XMLRPCMessage.prototype.doDateXML = function (data) {
- function leadingZero(n) {
- // pads a single number with a leading zero. Heh.
- if (n.length === 1) {
- n = "0" + n;
- }
- return n;
+ function leadingZero(n) {
+ // pads a single number with a leading zero. Heh.
+ if (n.length === 1) {
+ n = "0" + n;
}
- function dateToISO8601(date) {
- // wow I hate working with the Date object
- var year = date.getYear();
- var month = this.leadingZero(date.getMonth());
- var day = this.leadingZero(date.getDate());
- var time = this.leadingZero(date.getHours()) +
- ":" + this.leadingZero(date.getMinutes()) +
- ":" + this.leadingZero(date.getSeconds());
-
- var converted = year + month + day + "T" + time;
- return converted;
- }
-
- var xml = "<dateTime.iso8601>";
- xml += dateToISO8601(data);
- xml += "</dateTime.iso8601>";
- return xml;
+ return n;
+ }
+ function dateToISO8601(date) {
+ // wow I hate working with the Date object
+ var year = date.getYear();
+ var month = this.leadingZero(date.getMonth());
+ var day = this.leadingZero(date.getDate());
+ var time = this.leadingZero(date.getHours()) +
+ ":" + this.leadingZero(date.getMinutes()) +
+ ":" + this.leadingZero(date.getSeconds());
+
+ var converted = year + month + day + "T" + time;
+ return converted;
+ }
+
+ var xml = "<dateTime.iso8601>";
+ xml += dateToISO8601(data);
+ xml += "</dateTime.iso8601>";
+ return xml;
};
XMLRPCMessage.prototype.doArrayXML = function (data) {
- var xml = "<array><data>\n";
- for (var i = 0; i < data.length; i++) {
- xml += "<value>" +
- this.getParamXML(this.dataTypeOf(data[i]),
- data[i]) + "</value>\n";
- }
- xml += "</data></array>\n";
- return xml;
+ var xml = "<array><data>\n";
+ for (var i = 0; i < data.length; i++) {
+ xml += "<value>" +
+ this.getParamXML(this.dataTypeOf(data[i]),
+ data[i]) + "</value>\n";
+ }
+ xml += "</data></array>\n";
+ return xml;
};
XMLRPCMessage.prototype.doStructXML = function (data) {
- var xml = "<struct>\n";
- for (var i in data) {
- xml += "<member>\n";
- xml += "<name>" + i + "</name>\n";
- xml += "<value>" + this.getParamXML(this.dataTypeOf(data[i]),
- data[i]) + "</value>\n";
- xml += "</member>\n";
- }
- xml += "</struct>\n";
- return xml;
+ var xml = "<struct>\n";
+ for (var i in data) {
+ xml += "<member>\n";
+ xml += "<name>" + i + "</name>\n";
+ xml += "<value>" + this.getParamXML(this.dataTypeOf(data[i]),
+ data[i]) + "</value>\n";
+ xml += "</member>\n";
+ }
+ xml += "</struct>\n";
+ return xml;
};
XMLRPCMessage.prototype.getParamXML = function (type, data) {
- var xml;
- switch (type) {
- case "date":
- xml = this.doDateXML(data);
- break;
- case "array":
- xml = this.doArrayXML(data);
- break;
- case "struct":
- xml = this.doStructXML(data);
- break;
- case "boolean":
- xml = this.doBooleanXML(data);
- break;
- default:
- xml = this.doValueXML(type, data);
- break;
- }
- return xml;
+ var xml;
+ switch (type) {
+ case "date":
+ xml = this.doDateXML(data);
+ break;
+ case "array":
+ xml = this.doArrayXML(data);
+ break;
+ case "struct":
+ xml = this.doStructXML(data);
+ break;
+ case "boolean":
+ xml = this.doBooleanXML(data);
+ break;
+ default:
+ xml = this.doValueXML(type, data);
+ break;
+ }
+ return xml;
};
diff --git a/tests/pagemod-test-helpers.js b/tests/pagemod-test-helpers.js
index b019810..8621421 100644
--- a/tests/pagemod-test-helpers.js
+++ b/tests/pagemod-test-helpers.js
@@ -7,27 +7,28 @@ const {Cc,Ci} = require("chrome");
* and checks the effect of the page mod on 'onload' event via testCallback.
*/
exports.testPageMod = function testPageMod(test, testURL, pageModOptions,
- testCallback, timeout) {
+ testCallback, timeout) {
var xulApp = require("xul-app");
if (!xulApp.versionInRange(xulApp.platformVersion, "1.9.3a3", "*") &&
- !xulApp.versionInRange(xulApp.platformVersion, "1.9.2.7", "1.9.2.*")) {
- test.pass("Note: not testing PageMod, as it doesn't work on this platform version");
- return null;
+ !xulApp.versionInRange(xulApp.platformVersion, "1.9.2.7", "1.9.2.*")) {
+ test.pass("Note: not testing PageMod, as it doesn't work on this platform version");
+ return null;
}
var wm = Cc['@mozilla.org/appshell/window-mediator;1']
- .getService(Ci.nsIWindowMediator);
+ .getService(Ci.nsIWindowMediator);
var browserWindow = wm.getMostRecentWindow("navigator:browser");
if (!browserWindow) {
- test.pass("page-mod tests: could not find the browser window, so " +
- "will not run. Use -a firefox to run the pagemod tests.")
- return null;
+ test.pass("page-mod tests: could not find the browser window, so " +
+ "will not run. Use -a firefox to run the pagemod tests.")
+ return null;
}
if (timeout !== undefined) {
test.waitUntilDone(timeout);
- } else {
- test.waitUntilDone();
+ }
+ else {
+ test.waitUntilDone();
}
let loader = test.makeSandboxedLoader();
@@ -41,13 +42,13 @@ exports.testPageMod = function testPageMod(test, testURL, pageModOptions,
var b = tabBrowser.getBrowserForTab(newTab);
function onPageLoad() {
- b.removeEventListener("load", onPageLoad, true);
- testCallback(b.contentWindow.wrappedJSObject, function done() {
- pageMods.forEach(function(mod) mod.destroy());
- // XXX leaks reported if we don't close the tab?
- tabBrowser.removeTab(newTab);
- test.done();
- });
+ b.removeEventListener("load", onPageLoad, true);
+ testCallback(b.contentWindow.wrappedJSObject, function done() {
+ pageMods.forEach(function(mod) mod.destroy());
+ // XXX leaks reported if we don't close the tab?
+ tabBrowser.removeTab(newTab);
+ test.done();
+ });
}
b.addEventListener("load", onPageLoad, true);
diff --git a/tests/test-color.js b/tests/test-color.js
index 2006fd9..eefb97d 100644
--- a/tests/test-color.js
+++ b/tests/test-color.js
@@ -5,27 +5,27 @@
// testing Color object
var ensureColorNew = function (test) {
- var col = new util.Color(255, 255, 166);
- test.assertEqual(col.toString(), "#ffffa6",
- "creation of new RGB Color object");
+ var col = new util.Color(255, 255, 166);
+ test.assertEqual(col.toString(), "#ffffa6",
+ "creation of new RGB Color object");
};
var ensureColorUpdate = function (test) {
- var col = new util.Color(255, 255, 166);
- col.update(255, 224, 176);
- test.assertEqual(col.toString(), "#ffe0b0",
- "updating Color object");
+ var col = new util.Color(255, 255, 166);
+ col.update(255, 224, 176);
+ test.assertEqual(col.toString(), "#ffe0b0",
+ "updating Color object");
};
var ensureColorHSL = function (test) {
- var col = new util.Color(255, 224, 176);
- test.assertEqual(col.hsl().toSource(),
- "[0.10126582278481013, 1, 0.8450980392156863]",
- "converting to HSL model");
+ var col = new util.Color(255, 224, 176);
+ test.assertEqual(col.hsl().toSource(),
+ "[0.10126582278481013, 1, 0.8450980392156863]",
+ "converting to HSL model");
};
var ensureColorLight = function (test) {
- var col = new util.Color(255, 224, 176);
- test.assertEqual(col.lightColor().toString(), "#e8dcc9",
- "getting a light color");
+ var col = new util.Color(255, 224, 176);
+ test.assertEqual(col.lightColor().toString(), "#e8dcc9",
+ "getting a light color");
};
diff --git a/tests/test-match-pattern.js b/tests/test-match-pattern.js
index ed51b43..9e3d2bd 100644
--- a/tests/test-match-pattern.js
+++ b/tests/test-match-pattern.js
@@ -1,11 +1,11 @@
var { MatchPattern } = require("match-pattern");
exports.ensureMatchPattern = function (test) {
- var pattern = new MatchPattern("https://bugzilla.redhat.com/attachment.cgi");
- console.log("pattern = " + pattern);
- test.assert(pattern.
- test("https://bugzilla.redhat.com/attachment.cgi"), "testing match pattern");
- test.assert(!pattern.
- test("https://bugzilla.redhat.com/attachment.cgi?bugid=676538&action=enter"),
- "testing failing match pattern");
+ var pattern = new MatchPattern("https://bugzilla.redhat.com/attachment.cgi");
+ console.log("pattern = " + pattern);
+ test.assert(pattern.
+ test("https://bugzilla.redhat.com/attachment.cgi"), "testing match pattern");
+ test.assert(!pattern.
+ test("https://bugzilla.redhat.com/attachment.cgi?bugid=676538&action=enter"),
+ "testing failing match pattern");
};
diff --git a/tests/test-pageMod.js b/tests/test-pageMod.js
index 8662a4c..5434bbd 100644
--- a/tests/test-pageMod.js
+++ b/tests/test-pageMod.js
@@ -13,15 +13,15 @@ var testURL = self.data.url('tests/change-more-bugs01.html');
var JSONifiedMessage = '{"cmd":"testMessage","data":{"a":"first","b":"second"}}';
exports.ensureMessagesWork = function(test) {
- var msg = new utilMod.Message("testMessage", { a: "first", b: "second" } );
- test.assertEqual(msg.cmd, "testMessage",
- "msg.cmd comes over well");
- test.assertEqual(msg.data.a, "first",
- "msg.data.a comes over well");
- test.assertEqual(msg.data.b, "second",
- "msg.data.b comes over well");
- test.assertEqual(JSON.stringify(msg), JSONifiedMessage,
- "JSONification of Message works as well");
+ var msg = new utilMod.Message("testMessage", { a: "first", b: "second" } );
+ test.assertEqual(msg.cmd, "testMessage",
+ "msg.cmd comes over well");
+ test.assertEqual(msg.data.a, "first",
+ "msg.data.a comes over well");
+ test.assertEqual(msg.data.b, "second",
+ "msg.data.b comes over well");
+ test.assertEqual(JSON.stringify(msg), JSONifiedMessage,
+ "JSONification of Message works as well");
};
/*
@@ -30,36 +30,36 @@ var theURL = main.theURL;
var testURL = self.data.url('tests/change-more-bugs01.html');
var contentScriptLibraries = {
- "bugzilla.redhat.com": [
- self.data.url("util.js"),
- self.data.url("color.js"),
- self.data.url("rhbzpage.js"),
- self.data.url("bzpage.js")
- ]
+ "bugzilla.redhat.com": [
+ self.data.url("util.js"),
+ self.data.url("color.js"),
+ self.data.url("rhbzpage.js"),
+ self.data.url("bzpage.js")
+ ]
};
libbz.initialize(libbz.config, function () {
- pageMod.PageMod({
- include: [
- "https://bugzilla.redhat.com/show_bug.cgi?id=*"
- ],
- contentScriptWhen: 'ready',
- contentScriptFile: contentScriptLibraries["bugzilla.redhat.com"],
- onAttach: function onAttach(worker, msg) {
- console.log("worker: " + worker);
- worker.on('message', function (msg) {
- messageHandler(worker, msg);
- });
- }
- });
-});
-
-pageMod.PageMod({
+ pageMod.PageMod({
include: [
- "https://bugzilla.redhat.com/process_bug.cgi"
+ "https://bugzilla.redhat.com/show_bug.cgi?id=*"
],
contentScriptWhen: 'ready',
- contentScriptFile: self.data.url("skip-bug.js")
+ contentScriptFile: contentScriptLibraries["bugzilla.redhat.com"],
+ onAttach: function onAttach(worker, msg) {
+ console.log("worker: " + worker);
+ worker.on('message', function (msg) {
+ messageHandler(worker, msg);
+ });
+ }
+ });
+});
+
+pageMod.PageMod({
+ include: [
+ "https://bugzilla.redhat.com/process_bug.cgi"
+ ],
+ contentScriptWhen: 'ready',
+ contentScriptFile: self.data.url("skip-bug.js")
});
*/
@@ -96,12 +96,12 @@ var ensureSimplePageLoad = function (test) {
var ensurePageLoadsWell = function (test) {
var wm = Cc['@mozilla.org/appshell/window-mediator;1']
- .getService(Ci.nsIWindowMediator);
+ .getService(Ci.nsIWindowMediator);
var browserWindow = wm.getMostRecentWindow("navigator:browser");
if (!browserWindow) {
- test.fail("page-mod tests: could not find the browser window, so " +
- "will not run. Use -a firefox to run the pagemod tests.");
- return null;
+ test.fail("page-mod tests: could not find the browser window, so " +
+ "will not run. Use -a firefox to run the pagemod tests.");
+ return null;
}
var loader = test.makeSandboxedLoader();
diff --git a/tests/test-util.js b/tests/test-util.js
index d4e4a78..26c5f6d 100644
--- a/tests/test-util.js
+++ b/tests/test-util.js
@@ -7,208 +7,208 @@ var urlMod = require("url");
// testing util.heir
var ensureHeir = function (test) {
- var fedlimid = {}, naoise = {};
-
- function Father(x) {
- this.family = x;
- }
-
- Father.prototype.getFamily = function getFamily() {
- return this.family;
- };
-
- function Son(x, w) {
- Father.call(this, x);
- this.wife = w;
- }
-
- Son.prototype = util.heir(Father);
- Son.prototype.constructor = Son;
-
- Son.prototype.getWife = function getWife() {
- return this.wife;
- };
+ var fedlimid = {}, naoise = {};
+
+ function Father(x) {
+ this.family = x;
+ }
+
+ Father.prototype.getFamily = function getFamily() {
+ return this.family;
+ };
+
+ function Son(x, w) {
+ Father.call(this, x);
+ this.wife = w;
+ }
- Son.prototype.getFamily = function getFamily() {
- var upFamily =
- Father.prototype.getFamily.call(this);
- return upFamily + ", " + this.wife;
- };
-
- // for curious and non-Celtic
- // http://en.wikipedia.org/wiki/Deirdre :)
- fedlimid = new Father("mac Daill");
- naoise = new Son("Usnech", "Deirdre");
-
- test.assertEqual(fedlimid.getFamily(), "mac Daill",
- "checking creation of new simple object");
-
- test.assertEqual(naoise.getWife(), "Deirdre",
- "checking creation of new daughter object");
-
- test.assertEqual(naoise.getFamily(), "Usnech, Deirdre",
- "checking creation of new overloaded method");
+ Son.prototype = util.heir(Father);
+ Son.prototype.constructor = Son;
+
+ Son.prototype.getWife = function getWife() {
+ return this.wife;
+ };
+
+ Son.prototype.getFamily = function getFamily() {
+ var upFamily =
+ Father.prototype.getFamily.call(this);
+ return upFamily + ", " + this.wife;
+ };
+
+ // for curious and non-Celtic
+ // http://en.wikipedia.org/wiki/Deirdre :)
+ fedlimid = new Father("mac Daill");
+ naoise = new Son("Usnech", "Deirdre");
+
+ test.assertEqual(fedlimid.getFamily(), "mac Daill",
+ "checking creation of new simple object");
+
+ test.assertEqual(naoise.getWife(), "Deirdre",
+ "checking creation of new daughter object");
+
+ test.assertEqual(naoise.getFamily(), "Usnech, Deirdre",
+ "checking creation of new overloaded method");
};
// testing util.isInList
var ensureIsInListTrue = function (test) {
- test.assert(util.isInList("a", ["a"]),
- "conversion of a string to an array");
+ test.assert(util.isInList("a", ["a"]),
+ "conversion of a string to an array");
};
var ensureIsInListFalse = function (test) {
- test.assert(!util.isInList("b", ["a"]),
- "conversion of a string to an array");
+ test.assert(!util.isInList("b", ["a"]),
+ "conversion of a string to an array");
};
var ensureIsInListEmpty = function (test) {
- test.assert(!util.isInList("b", []),
- "conversion of a string to an array");
+ test.assert(!util.isInList("b", []),
+ "conversion of a string to an array");
};
var ensureIsInListNoMember = function (test) {
- test.assert(!util.isInList("", ["x"]),
- "conversion of a string to an array");
+ test.assert(!util.isInList("", ["x"]),
+ "conversion of a string to an array");
};
// testing util.filterByRegexp
var ensureFilterByRegexp = function (test) {
- var list = [
- {
- "regexp": "test(ing|ed)",
- "addr": "correct"
- },
- {
- "regexp": "ba.*d",
- "addr": true
- }
- ];
-
- test.assertEqual(util.filterByRegexp(list, "testing"), "correct",
- "simple testing of filterByRegexp");
- test.assertEqual(util.filterByRegexp(list, "unknown value"), "",
- "simple testing of filterByRegexp with non-found address");
- test.assert(util.filterByRegexp(list, "baaad"),
- "simple testing of filterByRegexp with non-string return value");
+ var list = [
+ {
+ "regexp": "test(ing|ed)",
+ "addr": "correct"
+ },
+ {
+ "regexp": "ba.*d",
+ "addr": true
+ }
+ ];
+
+ test.assertEqual(util.filterByRegexp(list, "testing"), "correct",
+ "simple testing of filterByRegexp");
+ test.assertEqual(util.filterByRegexp(list, "unknown value"), "",
+ "simple testing of filterByRegexp with non-found address");
+ test.assert(util.filterByRegexp(list, "baaad"),
+ "simple testing of filterByRegexp with non-string return value");
};
var ensureFilterByRegexpEmpty = function (test) {
- test.assertRaises(function () {
- util.filterByRegexp(undefined, "tralala");
- },
- "list is undefined",
- "filterByRegexp throws an exception with empty list");
+ test.assertRaises(function () {
+ util.filterByRegexp(undefined, "tralala");
+ },
+ "list is undefined",
+ "filterByRegexp throws an exception with empty list");
};
// testing util.getISODate
var ensureGetISODate = function (test) {
- test.assertEqual(util.getISODate("Mon May 31 2010 23:29:09 GMT+0200 (CET)"),
- "2010-05-31", "conversion of a Date to ISO-formatted String");
+ test.assertEqual(util.getISODate("Mon May 31 2010 23:29:09 GMT+0200 (CET)"),
+ "2010-05-31", "conversion of a Date to ISO-formatted String");
};
// testing util.valToArray
var ensureValToArrayString = function (test) {
- test.assertEqual(JSON.stringify(util.valToArray("a")),
- JSON.stringify(["a"]),
- "conversion of a string to an array");
+ test.assertEqual(JSON.stringify(util.valToArray("a")),
+ JSON.stringify(["a"]),
+ "conversion of a string to an array");
};
var ensureValToArrayEmpty = function (test) {
- test.assertEqual(JSON.stringify(util.valToArray("")),
- JSON.stringify([""]),
- "conversion of an empty string to an array");
+ test.assertEqual(JSON.stringify(util.valToArray("")),
+ JSON.stringify([""]),
+ "conversion of an empty string to an array");
};
var ensureValToArrayArray = function (test) {
- test.assertEqual(JSON.stringify(util.valToArray(["a"])),
- JSON.stringify(["a"]),
- "non-conversion of an array");
+ test.assertEqual(JSON.stringify(util.valToArray(["a"])),
+ JSON.stringify(["a"]),
+ "non-conversion of an array");
};
// testing util.addCSVValue
var ensureCSVAddedToNull = function (test) {
- test.assertEqual(util.addCSVValue("", "b"), "b",
- "adding a string to empty string");
+ test.assertEqual(util.addCSVValue("", "b"), "b",
+ "adding a string to empty string");
};
var ensureCSVAddedNull = function (test) {
- test.assertEqual(util.addCSVValue("a", ""), "a",
- "adding nothing to a string");
+ test.assertEqual(util.addCSVValue("a", ""), "a",
+ "adding nothing to a string");
};
var ensureCSVAddedString = function (test) {
- test.assertEqual(util.addCSVValue("a", "b"), "a, b",
- "adding one string to another one");
+ test.assertEqual(util.addCSVValue("a", "b"), "a, b",
+ "adding one string to another one");
};
var ensureCSVAddedArray = function (test) {
- test.assertEqual(util.addCSVValue("a", ["b", "c"]), "a, b, c",
- "adding array to a string");
+ test.assertEqual(util.addCSVValue("a", ["b", "c"]), "a, b, c",
+ "adding array to a string");
};
var ensureCSVAddedArray2Array = function (test) {
- test.assertEqual(util.addCSVValue("a, b", ["c", "d"]), "a, b, c, d",
- "adding one array to another");
+ test.assertEqual(util.addCSVValue("a, b", ["c", "d"]), "a, b, c, d",
+ "adding one array to another");
};
// testing util.removeCSVValue
var ensureCSVRemoveSimple = function (test) {
- test.assertEqual(util.removeCSVValue("a, b", "b"), "a",
- "removing one string from an array");
+ test.assertEqual(util.removeCSVValue("a, b", "b"), "a",
+ "removing one string from an array");
};
// also checking a tolerancy against different ways of writing arrays
var ensureCSVRemoveNonMember = function (test) {
- test.assertEqual(util.removeCSVValue("a,b", "c"), "a, b",
- "removing a string from an array of which it isn't a member");
+ test.assertEqual(util.removeCSVValue("a,b", "c"), "a, b",
+ "removing a string from an array of which it isn't a member");
};
var ensureCSVRemoveEmpty = function (test) {
- test.assertEqual(util.removeCSVValue("", "c"), "",
- "removing a string from an empty array");
+ test.assertEqual(util.removeCSVValue("", "c"), "",
+ "removing a string from an empty array");
};
// testing util.getObjectKeys
var ensureGetObjectKeys = function (test) {
- var testObj = {
- a: 1,
- b: 2
- };
- test.assertEqual(JSON.stringify(util.getObjectKeys(testObj)),
- JSON.stringify(["a", "b"]),
- "getting keys from a object");
+ var testObj = {
+ a: 1,
+ b: 2
+ };
+ test.assertEqual(JSON.stringify(util.getObjectKeys(testObj)),
+ JSON.stringify(["a", "b"]),
+ "getting keys from a object");
};
// testing util.getParamsFromURL
var ensureGetParamsFromURL = function (test) {
- test.assertEqual(JSON.stringify(util.getParamsFromURL("https://bugzilla.redhat.com/show_bug.cgi?id=549066")),
- JSON.stringify({id:"549066"}),
- "simply compare result of bugzilla show_page URL");
- var complexURL = new urlMod.URL("http://www.google.com/search?ie=UTF-8&oe=UTF-8&sourceid=navclient"+
- "&gfns=1&q=gg+javascript+url+parse");
- test.assertEqual(JSON.stringify(util.getParamsFromURL(complexURL)),
- JSON.stringify({
- "ie":"UTF-8",
- "oe":"UTF-8",
- "sourceid":"navclient",
- "gfns":"1",
- "q":"gg+javascript+url+parse"
- }),
- "simply compare result of bugzilla show_page URL");
- test.assertEqual(JSON.stringify(util.getParamsFromURL("https://bugzilla.redhat.com/")),
- JSON.stringify({}),
- "URL without any parameters");
- test.assertRaises(function () {util.getParamsFromURL("");},
- "Missing URL value!", "No URL");
+ test.assertEqual(JSON.stringify(util.getParamsFromURL("https://bugzilla.redhat.com/show_bug.cgi?id=549066")),
+ JSON.stringify({id:"549066"}),
+ "simply compare result of bugzilla show_page URL");
+ var complexURL = new urlMod.URL("http://www.google.com/search?ie=UTF-8&oe=UTF-8&sourceid=navclient"+
+ "&gfns=1&q=gg+javascript+url+parse");
+ test.assertEqual(JSON.stringify(util.getParamsFromURL(complexURL)),
+ JSON.stringify({
+ "ie":"UTF-8",
+ "oe":"UTF-8",
+ "sourceid":"navclient",
+ "gfns":"1",
+ "q":"gg+javascript+url+parse"
+ }),
+ "simply compare result of bugzilla show_page URL");
+ test.assertEqual(JSON.stringify(util.getParamsFromURL("https://bugzilla.redhat.com/")),
+ JSON.stringify({}),
+ "URL without any parameters");
+ test.assertRaises(function () {util.getParamsFromURL("");},
+ "Missing URL value!", "No URL");
};
// testing util.getBugNo
var ensureGetBugNo = function (test) {
- var bugNo = util.getBugNo("https://bugzilla.redhat.com/show_bug.cgi?id=597141");
- test.assertEqual(bugNo, 597141, "getting bug number");
- bugNo = util.getBugNo("https://bugzilla.redhat.com/show_bug.cgi?id=serialWacom");
- test.assertEqual(bugNo, "serialWacom", "getting a bug alias; there is no guarantee of getting number!");
+ var bugNo = util.getBugNo("https://bugzilla.redhat.com/show_bug.cgi?id=597141");
+ test.assertEqual(bugNo, 597141, "getting bug number");
+ bugNo = util.getBugNo("https://bugzilla.redhat.com/show_bug.cgi?id=serialWacom");
+ test.assertEqual(bugNo, "serialWacom", "getting a bug alias; there is no guarantee of getting number!");
};
diff --git a/tests/test-xmlrpc.js b/tests/test-xmlrpc.js
index afb78c5..677a581 100644
--- a/tests/test-xmlrpc.js
+++ b/tests/test-xmlrpc.js
@@ -3,30 +3,30 @@
"use strict";
var xrpc = require("xmlrpc");
var xmlOut = "<?xml version=\"1.0\"?>\n" +
- "<methodCall>\n<methodName>bugzilla.updateAttachMimeType</methodName>\n" +
- "<params>\n<param>\n<value><struct>\n<member>\n<name>attach_id</name>\n" +
- "<value><string>myId</string></value>\n</member>\n<member>\n" +
- "<name>mime_type</name>\n<value><string>text/plain</string></value>\n</member>\n" +
- "<member>\n<name>nomail</name>\n<value><string>billg@microsoft.com</string>" +
- "</value>\n</member>\n</struct>\n</value>\n</param>\n<param>\n" +
- "<value><string>me@example.com</string></value>\n</param>\n" +
- "<param>\n<value><string>secret</string></value>\n</param>\n" +
- "<param>\n<value><double>3.14</double></value>\n</param>\n" +
- "<param>\n<value><boolean>1</boolean></value>\n</param>\n" +
- "</params>\n</methodCall>";
+ "<methodCall>\n<methodName>bugzilla.updateAttachMimeType</methodName>\n" +
+ "<params>\n<param>\n<value><struct>\n<member>\n<name>attach_id</name>\n" +
+ "<value><string>myId</string></value>\n</member>\n<member>\n" +
+ "<name>mime_type</name>\n<value><string>text/plain</string></value>\n</member>\n" +
+ "<member>\n<name>nomail</name>\n<value><string>billg@microsoft.com</string>" +
+ "</value>\n</member>\n</struct>\n</value>\n</param>\n<param>\n" +
+ "<value><string>me@example.com</string></value>\n</param>\n" +
+ "<param>\n<value><string>secret</string></value>\n</param>\n" +
+ "<param>\n<value><double>3.14</double></value>\n</param>\n" +
+ "<param>\n<value><boolean>1</boolean></value>\n</param>\n" +
+ "</params>\n</methodCall>";
// testing xrpc.XMLRPCMessage
exports.ensureGenerateXMLRPC = function (test) {
- var msg = new xrpc.XMLRPCMessage("bugzilla.updateAttachMimeType");
- msg.addParameter({
- 'attach_id' : "myId",
- 'mime_type' : "text/plain",
- 'nomail' : "billg@microsoft.com"
- });
- msg.addParameter("me@example.com");
- msg.addParameter("secret");
- msg.addParameter(3.14);
- msg.addParameter(true);
- test.assertEqual(msg.xml(), xmlOut,
- "generate XML-RPC message");
+ var msg = new xrpc.XMLRPCMessage("bugzilla.updateAttachMimeType");
+ msg.addParameter({
+ 'attach_id' : "myId",
+ 'mime_type' : "text/plain",
+ 'nomail' : "billg@microsoft.com"
+ });
+ msg.addParameter("me@example.com");
+ msg.addParameter("secret");
+ msg.addParameter(3.14);
+ msg.addParameter(true);
+ test.assertEqual(msg.xml(), xmlOut,
+ "generate XML-RPC message");
};