1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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());
|