diff options
Diffstat (limited to 'data/bzpage.js')
-rw-r--r-- | data/bzpage.js | 283 |
1 files changed, 150 insertions, 133 deletions
diff --git a/data/bzpage.js b/data/bzpage.js index c332634..47f14c0 100644 --- a/data/bzpage.js +++ b/data/bzpage.js @@ -1,4 +1,3 @@ -/*jslint forin: true, rhino: true, onevar: false, browser: true, evil: true, laxbreak: true, undef: true, nomen: true, eqeqeq: true, bitwise: true, maxerr: 1000, immed: false, white: false, plusplus: false, regexp: false, undef: false, strict: true */ // Released under the MIT/X11 license // http://www.opensource.org/licenses/mit-license.php "use strict"; @@ -29,7 +28,6 @@ var submitHandlerInstalled = false; // for setUpLogging })); */ function Message(cmd, data) { - console.log("Message: cmd = " + cmd + ", data = " + data); this.cmd = cmd; this.data = data; } @@ -52,27 +50,31 @@ NotLoggedinException.prototype.toString = function () { */ onMessage = function onMessage(msg) { switch (msg.cmd) { - case "ReloadThePage": - document.location.reload(true); - break; - case "RetClipboard": - if (msg.data.cmd == "queryLocal") { - queryInNewTab(msg.data.data, getComponent(), getProduct()); - } else if (msg.data.cmd == "queryUpstream") { - // - } - break; - case "CreateButtons": - constantData = msg.data.constData; - generateButtons(msg.data.instPkgs, msg.data.kNodes); - break; - case "Error": - alert("Error " + msg.data); - break; - case "Unhandled": - break; - default: + case "ReloadThePage": + document.location.reload(true); + break; + case "RetClipboard": + if (msg.data.cmd == "queryLocal") { + queryInNewTab(msg.data.data, getComponent(), getProduct()); + } else if (msg.data.cmd == "queryUpstream") { + // + } + break; + case "CreateButtons": + constantData = msg.data.constData; + 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()); + } } }; @@ -100,93 +102,102 @@ function executeCommand(cmdObj) { * @param cmdParams Object with the appropriate parameters for the command */ function centralCommandDispatch (cmdLabel, cmdParams) { + console.log("centralCommandDispatch : cmdLabel = " + cmdLabel + + ", cmdParams = " + cmdParams); switch (cmdLabel) { - 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; + 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; } } @@ -294,7 +305,7 @@ function addToCommentsDropdown (cmdObj) { * @param parent Node which is a parent of the object * @param callback Function to be called after clicking on the link * @param params Array with parameters of the callback - * @param Boolean breakBefore if there should be a <br> element before. + * @param Boolean before if there should be a <br> element before. * @return none */ function createDeadLink (id, text, parent, callback, params, before, covered, accesskey) { @@ -314,14 +325,18 @@ function createDeadLink (id, text, parent, callback, params, before, covered, ac if (accesskey) { newAElem.setAttribute("accesskey", accesskey); } - newAElem.setAttribute("href", ""); newAElem.textContent = text; - newAElem.addEventListener("click", function(evt) { - callback(params); - evt.stopPropagation(); - evt.preventDefault(); - }, false); + if (typeof callback === "string") { + newAElem.setAttribute("href", callback); + } else { + newAElem.setAttribute("href", ""); + newAElem.addEventListener("click", function(evt) { + callback(params); + evt.stopPropagation(); + evt.preventDefault(); + }, false); + } if ((before === "br") || (before === true)) { locParent.appendChild(document.createElement("br")); @@ -416,20 +431,20 @@ function generateButtons (pkgs, kNodes) { for (var cmdIdx in pkgs[pkg]) { var cmdObj = pkgs[pkg][cmdIdx]; 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; + 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; } } } @@ -850,7 +865,7 @@ function getSelection () { var text = ""; var selectionObject = window.getSelection(); if (selectionObject.rangeCount > 0) { - text = selectionObject.getRangeAt(0).toString(); + text = selectionObject.getRangeAt(0).toString().trim(); } return text; } @@ -899,7 +914,7 @@ function queryInNewTab(text, component, product) { + "&field1-0-2=status_whiteboard&type1-0-2=substring&value1-0-2=" + text; urlStr += searchText; - postMessage(new Message("OpenURLinNewTab", urlStr)); + postMessage(new Message("OpenURLinPanel", urlStr)); } } @@ -990,8 +1005,10 @@ function startup() { checkComments(); - var login = getLogin(); - postMessage(new Message("GetInstalledPackages", window.location.href)); + postMessage(new Message("GetInstalledPackages", { + location: window.location.href, + login: getLogin() + })); } startup(); |