tildefriends/apps/apps/app.js

31 lines
816 B
JavaScript

async function main() {
var apps = await core.apps();
var core_apps = await core.apps('core');
var doc = `<!DOCTYPE html>
<html>
<body style="background: #888">
<h1>Apps</h1>
<ul id="apps"></ul>
<h1>Core Apps</h1>
<ul id="core_apps"></ul>
</body>
<script>
function populate_apps(id, name, apps) {
var list = document.getElementById(id);
for (let app of Object.keys(apps).sort()) {
var li = list.appendChild(document.createElement('li'));
var a = document.createElement('a');
a.innerText = app;
a.href = '/~' + name + '/' + app + '/';
a.target = '_top';
li.appendChild(a);
}
}
populate_apps('apps', '${core.user.credentials?.session?.name}', ${JSON.stringify(apps)});
populate_apps('core_apps', 'core', ${JSON.stringify(core_apps)});
</script>
</html>`
app.setDocument(doc);
}
main();