diff options
Diffstat (limited to 'web/global/global.js')
| -rw-r--r-- | web/global/global.js | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/web/global/global.js b/web/global/global.js index 13c0917..8ca9493 100644 --- a/web/global/global.js +++ b/web/global/global.js @@ -229,3 +229,67 @@ function initTablesorter() { type: "numeric" }); } + +// Updates the test case filter table. +// - tableSel is the JQuery selector for the table. +// - testCases is the array of test case names. +// - nc is the maximum number of columns. +function updateTestCaseTable(tableSel, testCases, nc, onclickHandler) { + + // Clear table: + $(tableSel + " tr").remove(); + + // Populate table: + + var nr = Math.ceil(testCases.length / nc); // # of rows + var c1 = testCases.length % nc; // lowest column index for empty bottom cell + + var html = ""; + for (r = 0; r < nr; ++r) { + if ((r < (nr - 1)) || (nc > 1)) + html += "<tr>"; + for (c = 0; c < nc; ++c) { + if ((r == (nr - 1)) && (c1 > 0) && (c >= c1)) { + if (r > 0) + html += "<td></td>"; // Fill in empty bottom cell + } else { + var index = -1; + if (c <= c1) + index = r + c * nr; + else + index = r + c1 * nr + (c - c1) * (nr - 1); + + var name = testCases[index]; + html += "<td style=\"white-space: nowrap\">"; + html += "<input type=\"checkbox\" id=\"tc" + index + "\" " + + "name=\"" + name + "\""; + if (!(onclickHandler === undefined)) + html += "onclick=\"" + onclickHandler + "\""; + html += "/>"; + html += "<label for=\"tc" + index + "\">" + name + + "</label>"; + html += "</td>"; + } + } + if ((r < (nr - 1)) || (nc > 1)) + html += "</tr>"; + } + + $(tableSel).append(html); +} + +// Toggles the visibilities of two div elements in a mutually exclusive +// fashion (i.e. exactly one of them is visible at any time). +// hiddenSel and shownSel are the JQuery selectors for the div elements that +// represent the hidden and shown state respectively. +function toggleVisibility(hiddenSel, shownSel) { + var divObj_hidden = $(hiddenSel); + var divObj_shown = $(shownSel); + if (divObj_shown.css("display") == "none") { + divObj_shown.css("display", "block"); + divObj_hidden.css("display", "none"); + } else { + divObj_shown.css("display", "none"); + divObj_hidden.css("display", "block"); + } +} |
