Assign all stock apps an emoji, show them in the app list, and let the editor set them.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4242 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2023-03-21 23:08:04 +00:00
parent 53692a1ea8
commit ec65faa12d
12 changed files with 49 additions and 18 deletions

View File

@ -4,7 +4,7 @@ let gPermissions;
let gCurrentFile;
let gFiles = {};
let gApp = {files: {}};
let gApp = {files: {}, emoji: '📦'};
let gEditor;
let gSplit;
let gGraphs = {};
@ -219,6 +219,8 @@ function load(path) {
document.getElementById("editPane").style.display = 'flex';
}
gApp = json;
gApp.emoji = gApp.emoji || '📦';
document.getElementById('icon').value = gApp.emoji;
}
if (!isApp) {
document.getElementById("editPane").style.display = 'flex';
@ -293,6 +295,7 @@ function save(save_to) {
let app = {
type: "tildefriends-app",
files: Object.fromEntries(Object.keys(gFiles).map(x => [x, gFiles[x].id || gApp.files[x]])),
emoji: gApp.emoji || '📦',
};
Object.values(gFiles).forEach(function(file) { delete file.id; });
gApp = JSON.parse(JSON.stringify(app));
@ -325,6 +328,14 @@ function save(save_to) {
});
}
function changeIcon() {
let value = prompt('Enter a new app icon emoji:');
if (value !== undefined) {
gApp.emoji = value || '📦';
document.getElementById('icon').value = gApp.emoji;
}
}
function deleteApp() {
let name = document.getElementById("name");
let path = name && name.value ? name.value : url();
@ -965,6 +976,7 @@ window.addEventListener("load", function() {
document.getElementById('closeStats').addEventListener('click', () => closeStats());
document.getElementById('closeEditor').addEventListener('click', () => closeEditor());
document.getElementById('save').addEventListener('click', () => save());
document.getElementById('icon').addEventListener('click', () => changeIcon());
document.getElementById('delete').addEventListener('click', () => deleteApp());
document.getElementById('trace_button').addEventListener('click', function(event) {
event.preventDefault();

View File

@ -30,6 +30,7 @@
<div class="navigation hbox">
<input type="button" id="closeEditor" name="closeEditor" value="Close">
<input type="button" id="save" name="save" value="Save">
<input type="button" id="icon" name="icon" value="📦">
<input type="text" id="name" name="name" style="flex: 1 1; min-width: 1em"></input>
<input type="button" id="delete" name="delete" value="Delete">
<input type="button" id="trace_button" value="Trace">