aboutsummaryrefslogtreecommitdiffstats
path: root/data/lib
diff options
context:
space:
mode:
Diffstat (limited to 'data/lib')
-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
7 files changed, 1596 insertions, 1561 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 + '"';
};