diff options
author | 2017-08-05 13:56:11 +1000 | |
---|---|---|
committer | 2017-08-05 13:56:11 +1000 | |
commit | 4c9ded40ade3f5fbb53d492cb2bd12da41408621 (patch) | |
tree | fc4c99f1b2f27445b726c38f759eb50dd1db7bd0 /scripts/minimaws/lib/assets/common.js | |
parent | b97e374cdbc7988e193f6377f2604f1d4b6264ea (diff) |
minimaws: add buttons for restoring default BIOS/slot card, clean up and comment the JavaScript a bit more
Diffstat (limited to 'scripts/minimaws/lib/assets/common.js')
-rw-r--r-- | scripts/minimaws/lib/assets/common.js | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/scripts/minimaws/lib/assets/common.js b/scripts/minimaws/lib/assets/common.js index 2af47c9ed2c..79200217ddb 100644 --- a/scripts/minimaws/lib/assets/common.js +++ b/scripts/minimaws/lib/assets/common.js @@ -19,8 +19,7 @@ function sort_table(tbl, col, dir, numeric) function make_table_sortable(tbl) { var headers = tbl.tHead.rows[0].cells; - var i; - for (i = 0; i < headers.length; i++) + for (var i = 0; i < headers.length; i++) { (function (col) { @@ -32,9 +31,9 @@ function make_table_sortable(tbl) headers[col].appendChild(sorticon); headers[col].addEventListener( 'click', - function () + function (event) { - imgsrc = sorticon.getAttribute('src'); + var imgsrc = sorticon.getAttribute('src'); imgsrc = imgsrc.substr(imgsrc.lastIndexOf('/') + 1); if (imgsrc != 'sortind.png') dir = -dir; @@ -42,8 +41,7 @@ function make_table_sortable(tbl) sorticon.setAttribute('src', assetsurl + '/sortdesc.png'); else sorticon.setAttribute('src', assetsurl + '/sortasc.png'); - var i; - for (i = 0; i < headers.length; i++) + for (var i = 0; i < headers.length; i++) { if (i != col) headers[i].lastChild.setAttribute('src', assetsurl + '/sortind.png'); @@ -53,3 +51,28 @@ function make_table_sortable(tbl) }(i)); } } + + +function make_restore_default_handler(popup, index) +{ + return function (event) + { + if (popup.selectedIndex != index) + { + popup.selectedIndex = index; + popup.dispatchEvent(new Event('change')); + } + } +} + + +function make_restore_default_button(title, id, popup, index) +{ + var btn = document.createElement('button'); + btn.setAttribute('id', id); + btn.setAttribute('type', 'button'); + btn.disabled = popup.selectedIndex == index; + btn.textContent = title; + btn.onclick = make_restore_default_handler(popup, index); + return btn; +} |