diff options
author | Matěj Cepl <mcepl@redhat.com> | 2011-05-31 01:39:46 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2011-05-31 01:44:58 +0200 |
commit | 2d8a9dabb4957ae1158ba000ee211b33bd0a81be (patch) | |
tree | ef1bddf7cae9957f8d4820cff531b62ff6ee1d21 /data/mozlib/mozpage.js | |
parent | b21ce54137dd75f42d98b3b15178e8f0ea056a14 (diff) | |
download | bugzilla-triage-2d8a9dabb4957ae1158ba000ee211b33bd0a81be.tar.gz |
First draft of the flags handling for Mozilla bugzilla.
Will fix #103 (when reviewed)
Diffstat (limited to 'data/mozlib/mozpage.js')
-rw-r--r-- | data/mozlib/mozpage.js | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/data/mozlib/mozpage.js b/data/mozlib/mozpage.js new file mode 100644 index 0000000..51af8b5 --- /dev/null +++ b/data/mozlib/mozpage.js @@ -0,0 +1,73 @@ +// Released under the MIT/X11 license +// http://www.opensource.org/licenses/mit-license.php + + +// END OF CONSTANTS + +var btSnippet = null; + +function MozOnMessageHandler(msg, nextHandler) { + switch (msg.cmd) { + case "Error": + alert("Error " + msg.data); + break; + case "Unhandled": + break; + default: + if (nextHandler) { + var nextHandler = nextHandlerList.splice(0, 1); + if (nextHandler[0]) { + nextHandler[0](msg, nextHandlerList); + } + } + else { + console.error("Error: unknown RPC call " + msg.toSource()); + } + break; + } +} + +// MozBugzillaPage object +function collectFlags() { + var flags = {}; + var tdColumn2 = document.getElementById("bz_show_bug_column_2"); + var flag_selects = tdColumn2.querySelectorAll("td.field_value select"); + Array.forEach(flag_selects, function(sel) { + var label = tdColumn2.querySelector("label[for='" + sel.id + "']"); + if (label) { + var key = label.textContent.trim().replace(/\s*:?$/,""); + flags[key] = sel.id; + } + }); + return flags; +} + +function changeFlag(flags, label, newValue) { + selectOption(flags[label], newValue); +} + +/** + * Additional commands specific for this subclass, overriding superclass one. + */ +function MozCentralCommandDispatch(cmdLabel, cmdParams) { + switch (cmdLabel) { + // Set up our own commands + case "setFlag": + changeFlag(mozFlags, cmdParams, "+"); + break; + case "unsetFlag": + changeFlag(mozFlags, cmdParams, "-"); + break; + case "clearFlag": + changeFlag(mozFlags, cmdParams, "---"); + break; + // FIXME what is the meaning of value == "?" + default: + console.error("Unknown command:\n" + cmdLabel + "\nparameters:\n" + cmdParams); + break; + } +} + + +var mozFlags = collectFlags(); +console.log("mozFlags = " + mozFlags.toSource()); |