blob: f47ad1dff0b7b0924e0d19f4e0c1bc577a8a2ae3 (
plain) (
blame)
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
|
// Released under the MIT/X11 license
// http://www.opensource.org/licenses/mit-license.php
"use strict";
function hasXorgBugsCategory() {
var catRE = /\s*\[cat:.*?\]\s*/; // RE for testing whether
// there is already category tag in the Whiteboard
var whiteboardContent = document.
getElementById("status_whiteboard").value;
return (catRE.test(whiteboardContent));
}
/**
* Create a category list to the upper toolbar
*/
function makeBugCategoriesList(catList) {
// Create <select> element and add it first blank <option>
var targetDiv = document.getElementById("commit_top").parentNode;
var categoryList = document.createElement("select");
categoryList.setAttribute("id", "xorgBugsCategoriesSelect");
categoryList.setAttribute("name", "xorgBugsCategoriesSelect");
var optionElement = document.createElement("option");
optionElement.value = null;
optionElement.setAttribute("id", "catId_blank");
optionElement.appendChild(document.createTextNode("---"));
categoryList.appendChild(optionElement);
// Fill-in <select> with <options>s for each category one
catList.forEach(function (cat) {
optionElement = document.createElement("option");
optionElement.value = cat;
optionElement.setAttribute("id", "catId_" + cat.replace(" ","").toLowerCase());
optionElement.appendChild(document.createTextNode(cat));
categoryList.appendChild(optionElement);
});
categoryList.addEventListener("change", function (evt) {
var selectedCategory = "[cat:" + this.value + "]";
var whiteboardElement = document.getElementById("status_whiteboard");
if (hasXorgBugsCategory()) {
whiteboardElement.value = whiteboardElement.
value.replace(catRE, "");
}
addStuffToTextBox("status_whiteboard", selectedCategory);
}, false);
targetDiv.insertBefore(categoryList, targetDiv.firstChild);
}
|