let appJSON = []; // List of apps and info from apps.json let appsInstalled = []; // list of app JSON let appSortInfo = {}; // list of data to sort by, from appdates.csv { created, modified } let files = []; // list of files on Bangle let DEFAULTSETTINGS = { pretokenise : true, favourites : ["boot","launch","setting"] }; let SETTINGS = JSON.parse(JSON.stringify(DEFAULTSETTINGS)); // clone httpGet("apps.json").then(apps=>{ try { appJSON = JSON.parse(apps); } catch(e) { console.log(e); showToast("App List Corrupted","error"); } refreshLibrary(); refreshFilter(); }); httpGet("appdates.csv").then(csv=>{ document.querySelector(".sort-nav").classList.remove("hidden"); csv.split("\n").forEach(line=>{ let l = line.split(","); appSortInfo[l[0]] = { created : Date.parse(l[1]), modified : Date.parse(l[2]) }; }); }).catch(err=>{ console.log("No recent.csv - app sort disabled"); }); // =========================================== Top Navigation function showChangeLog(appid) { let app = appNameToApp(appid); function show(contents) { showPrompt(app.name+" Change Log",contents,{ok:true}).catch(()=>{}); } httpGet(`apps/${appid}/ChangeLog`). then(show).catch(()=>show("No Change Log available")); } function showReadme(appid) { let app = appNameToApp(appid); let appPath = `apps/${appid}/`; let markedOptions = { baseUrl : appPath }; function show(contents) { if (!contents) return; showPrompt(app.name + " Documentation", marked(contents, markedOptions), {ok: true}, false).catch(() => {}); } httpGet(appPath+app.readme).then(show).catch(()=>show("Failed to load README.")); } function getAppDescription(app) { let appPath = `apps/${app.id}/`; let markedOptions = { baseUrl : appPath }; return marked(app.description, markedOptions); } function handleCustomApp(appTemplate) { // Pops up an IFRAME that allows an app to be customised if (!appTemplate.custom) throw new Error("App doesn't have custom HTML"); return new Promise((resolve,reject) => { let modal = htmlElement(`