-
Notifications
You must be signed in to change notification settings - Fork 0
/
html_functions.js
98 lines (86 loc) · 3.46 KB
/
html_functions.js
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
var table = null;
var currRow = null;
function addElement(text, classToSet, newCell) {
if (newCell) {
const cell = document.createElement("td");
cell.innerHTML = text;
cell.className = classToSet;
currRow.appendChild(cell);
}
else {
const newText = document.createElement("p");
newText.innerHTML = text;
newText.className = classToSet;
currRow.lastChild.appendChild(newText);
}
}
function addButton(text, cellClassToSet, classToSet, idToSet, setDisabled = false, type = "secondary") {
const cell = document.createElement("td");
cell.className = cellClassToSet;
const button = document.createElement("button");
button.innerHTML = text;
button.setAttribute("type", "button");
if (setDisabled) {
button.setAttribute("disabled", "");
button.classList.add("btn", "btn-danger", classToSet);
}
else {
button.classList.add("btn", `btn-${type}`, "btn-lg", classToSet);
}
if (idToSet != null) button.id = idToSet;
cell.appendChild(button);
currRow.appendChild(cell);
return button;
}
function addDropdown(text, buttonClass, elements, releaseId, buttonSmall) {
const cell = document.createElement("td");
cell.classList.add("ver-dropdown");
const toggleButton = document.createElement("button");
toggleButton.innerHTML = text;
toggleButton.classList.add("btn", buttonClass, "dropdown-toggle");
if (buttonSmall) toggleButton.classList.add("btn-sm");
toggleButton.id = `${releaseId}Dropdown`
toggleButton.setAttribute("type", "button");
toggleButton.setAttribute("data-bs-toggle", "dropdown");
toggleButton.setAttribute("aria-expanded", "false");
const dropdown = document.createElement("ul");
dropdown.classList.add("dropdown-menu");
dropdown.setAttribute("aria-labelledby", `${releaseId}Dropdown`);
elements.forEach(function(element) {
const dropdownElement = document.createElement("li");
if (element.divider) {
dropdownElement.classList.add("dropdown-divider");
}
else {
dropdownElement.innerHTML = element.name;
if (element.action) dropdownElement.addEventListener("click", function() {window.stManagement[element.action](getVersionName(getVersionData(releaseId)))});
dropdownElement.classList.add("dropdown-item");
if (element.class) dropdownElement.classList.add(element.class);
}
dropdown.appendChild(dropdownElement);
})
cell.appendChild(toggleButton);
cell.appendChild(dropdown);
document.getElementById(releaseId).appendChild(cell);
}
function newRow(rowId, preRelease = "false") {
if (table === null) table = document.getElementById("release-table");
currRow = table.insertRow();
currRow.id = rowId;
if (preRelease.toLowerCase() == "true") {
currRow.className = "pre-release";
}
}