diff options
author | Luciano Iam <lucianito@gmail.com> | 2020-04-11 10:08:54 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2020-04-11 22:30:41 +0200 |
commit | b7acaf1193f85a81ffafe33a867836917fcea4e6 (patch) | |
tree | 753949585932873c1e3c569f1b7f987ac95379ed /share/web_surfaces/index | |
parent | 9aef43181855256b7b6690aa2422769198c3aecf (diff) |
WebSockets: update web index to handle latest index.json format and show surface paths on disk
Diffstat (limited to 'share/web_surfaces/index')
-rw-r--r-- | share/web_surfaces/index/main.css | 8 | ||||
-rw-r--r-- | share/web_surfaces/index/main.js | 31 |
2 files changed, 26 insertions, 13 deletions
diff --git a/share/web_surfaces/index/main.css b/share/web_surfaces/index/main.css index 3b330fa36f..a10d9f84b9 100644 --- a/share/web_surfaces/index/main.css +++ b/share/web_surfaces/index/main.css @@ -78,4 +78,10 @@ h2 { .surface-list > ul > li { margin: 4ex 0; -}
\ No newline at end of file +} + +.disk-path { + font-family: Monaco, monospace; + font-size: 0.66em; + color: #bbb; +} diff --git a/share/web_surfaces/index/main.js b/share/web_surfaces/index/main.js index 9a8e9301a5..6c648653cb 100644 --- a/share/web_surfaces/index/main.js +++ b/share/web_surfaces/index/main.js @@ -30,29 +30,36 @@ } } - function buildItem (group, model) { + function buildItem (groupPath, surface) { const li = document.createElement('li'); li.innerHTML = `<li> - <a href="${group}/${model.id}/">${model.name}</a> - <p>${model.description}</p> + <a href="${groupPath}/${surface.path}/">${surface.name}</a> + <p>${surface.description}</p> </li>`; return li; } function printIndex (index) { - ['builtin', 'user'].forEach((group) => { - const ul = document.getElementById(group); - let models = index[group]; + for (let group of index) { + const path = group['path']; + const span = document.querySelector(`#${path} span`); + span.innerHTML = group['diskPath']; - if (models.length > 0) { - models.sort((a, b) => a.name.localeCompare(b.name)); - for (model of models) { - ul.appendChild(buildItem(group, model)); + let surfaces = group.surfaces; + + if (surfaces.length > 0) { + const ul = document.querySelector(`#${path} > ul`); + surfaces.sort((a, b) => a.name.localeCompare(b.name)); + + for (surface of surfaces) { + ul.appendChild(buildItem(path, surface)); } } else { - ul.parentNode.style.display = 'none'; + const p = document.createElement('p'); + p.innerHTML = '<p>No surfaces found</p>'; + document.getElementById(path).appendChild(p); } - }); + } document.getElementById('index').style.display = 'inline'; } |