diff options
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()); |