summaryrefslogtreecommitdiffstatshomepage
path: root/scripts/minimaws/lib/assets/machine.js
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/minimaws/lib/assets/machine.js')
-rw-r--r--scripts/minimaws/lib/assets/machine.js112
1 files changed, 108 insertions, 4 deletions
diff --git a/scripts/minimaws/lib/assets/machine.js b/scripts/minimaws/lib/assets/machine.js
index d0774d02c0a..b488ae9e9a4 100644
--- a/scripts/minimaws/lib/assets/machine.js
+++ b/scripts/minimaws/lib/assets/machine.js
@@ -1,9 +1,11 @@
// license:BSD-3-Clause
// copyright-holders:Vas Crabb
+'use strict';
var slot_info = Object.create(null);
var bios_sets = Object.create(null);
var machine_flags = Object.create(null);
+var softwarelist_info = Object.create(null);
function make_slot_popup_id(name) { return ('select-slot-choice-' + name).replace(/:/g, '-'); }
@@ -136,7 +138,7 @@ var fetch_bios_sets = (function ()
{
pending[device] = true;
var req = new XMLHttpRequest();
- req.open('GET', appurl + 'rpc/bios/' + device, true);
+ req.open('GET', appurl + 'rpc/bios/' + encodeURIComponent(device), true);
req.responseType = 'json';
req.onload =
function ()
@@ -171,7 +173,7 @@ var fetch_machine_flags = (function ()
{
pending[device] = true;
var req = new XMLHttpRequest();
- req.open('GET', appurl + 'rpc/flags/' + device, true);
+ req.open('GET', appurl + 'rpc/flags/' + encodeURIComponent(device), true);
req.responseType = 'json';
req.onload =
function ()
@@ -197,6 +199,47 @@ var fetch_machine_flags = (function ()
})();
+var fetch_softwarelist_info = (function ()
+ {
+ var pending = Object.create(null);
+ return function (device)
+ {
+ if (!Object.prototype.hasOwnProperty.call(softwarelist_info, device) && !Object.prototype.hasOwnProperty.call(pending, device))
+ {
+ pending[device] = true;
+ var req = new XMLHttpRequest();
+ req.open('GET', appurl + 'rpc/softwarelists/' + encodeURIComponent(device), true);
+ req.responseType = 'json';
+ req.onload =
+ function ()
+ {
+ delete pending[device];
+ if (req.status == 200)
+ {
+ softwarelist_info[device] = req.response;
+ var slotslist = document.getElementById('list-slot-options');
+ if (slotslist)
+ {
+ for (var item = slotslist.firstChild; item; item = item.nextSibling)
+ {
+ if ((item.nodeName == 'DT') && (item.getAttribute('data-slotcard') == device))
+ {
+ var slotname = item.getAttribute('data-slotname');
+ add_softwarelist_rows(
+ device,
+ slotname,
+ document.getElementById('select-slot-choice-' + slotname.replace(/:/g, '-')).value);
+ }
+ }
+ }
+ }
+ };
+ req.send();
+ }
+ };
+ })();
+
+
function add_flag_rows(table, device)
{
var sorted_features = Object.keys(machine_flags[device].features).sort();
@@ -228,6 +271,51 @@ function add_flag_rows(table, device)
}
+function add_softwarelist_rows(device, slot, card)
+{
+ var sorted_softwarelists = Object.keys(softwarelist_info[device]).sort();
+ var cardtag = slot + ':' + card;
+ if (sorted_softwarelists.length)
+ {
+ var table = document.getElementById('tbl-softwarelists').tBodies[0];
+ sorted_softwarelists.forEach(
+ function (tag)
+ {
+ var cell, link;
+ var info = softwarelist_info[device][tag];
+ var href = appurl + 'softwarelist/' + encodeURIComponent(info.shortname);
+ var row = table.appendChild(document.createElement('tr'));
+ row.setAttribute('id', 'row-softwarelists-' + (cardtag + tag).replace(/:/g, '-'))
+ row.appendChild(document.createElement('td')).textContent = cardtag;
+ link = row.appendChild(document.createElement('td')).appendChild(document.createElement('a'));
+ link.setAttribute('href', href);
+ link.textContent = info.shortname;
+ link = row.appendChild(document.createElement('td')).appendChild(document.createElement('a'));
+ link.setAttribute('href', href);
+ link.textContent = info.description;
+ row.appendChild(document.createElement('td')).textContent = info.status;
+ total = info.total;
+ cell = row.appendChild(document.createElement('td'));
+ cell.textContent = total.toString(10);
+ cell.style.textAlign = 'right';
+ if (!total)
+ total = 1;
+ cell = row.appendChild(document.createElement('td'));
+ cell.textContent = (info.supported * 100.0 / total).toFixed(1) + '%';
+ cell.style.textAlign = 'right';
+ cell = row.appendChild(document.createElement('td'));
+ cell.textContent = (info.partiallysupported * 100.0 / total).toFixed(1) + '%';
+ cell.style.textAlign = 'right';
+ cell = row.appendChild(document.createElement('td'));
+ cell.textContent = (info.unsupported * 100.0 / total).toFixed(1) + '%';
+ cell.style.textAlign = 'right';
+ });
+ document.getElementById('heading-softwarelists').style.removeProperty('display');
+ document.getElementById('tbl-softwarelists').style.removeProperty('display');
+ }
+}
+
+
function add_bios_row(slot, table, device)
{
var sorted_sets = Object.keys(bios_sets[device]).sort();
@@ -394,6 +482,16 @@ function make_slot_change_handler(name, slot, defaults, dfltbtn)
slotslist.removeChild(next);
}
+ // clear out any software lists from previous selection
+ var softwarelist_rowid_prefix = 'row-softwarelists-' + prefix.replace(/:/g, '-');
+ for (var candidate = document.getElementById('tbl-softwarelists').tBodies[0].rows[0]; candidate; )
+ {
+ var next = candidate.nextSibling;
+ if ((candidate.nodeName == 'TR') && candidate.getAttribute('id').startsWith(softwarelist_rowid_prefix))
+ candidate.parentNode.removeChild(candidate);
+ candidate = next;
+ }
+
if (selection === null)
{
// no selection, remove the slot card details table
@@ -413,7 +511,7 @@ function make_slot_change_handler(name, slot, defaults, dfltbtn)
row.appendChild(document.createElement('th')).textContent = 'Short name:';
var link = row.appendChild(document.createElement('td')).appendChild(document.createElement('a'));
link.textContent = selection.device;
- link.setAttribute('href', appurl + 'machine/' + selection.device);
+ link.setAttribute('href', appurl + 'machine/' + encodeURIComponent(selection.device));
// if we have emulation flags, populate now, otherwise fetch asynchronously
if (!Object.prototype.hasOwnProperty.call(machine_flags, selection.device))
@@ -427,6 +525,12 @@ function make_slot_change_handler(name, slot, defaults, dfltbtn)
else
add_bios_row(slotname, tbl, selection.device);
+ // if we have software list info, populate now, otherweise fetch asynchronously
+ if (!Object.prototype.hasOwnProperty.call(softwarelist_info, selection.device))
+ fetch_softwarelist_info(selection.device);
+ else
+ add_softwarelist_rows(selection.device, slotname, choice);
+
// drop the details table into the list
if (def.firstChild)
def.replaceChild(tbl, def.firstChild);
@@ -487,7 +591,7 @@ function fetch_slots(machine)
function make_request(device)
{
var req = new XMLHttpRequest();
- req.open('GET', appurl + 'rpc/slots/' + device, true);
+ req.open('GET', appurl + 'rpc/slots/' + encodeURIComponent(device), true);
req.responseType = 'json';
req.onload =
function ()