diff --git a/apps/calendar/interface.html b/apps/calendar/interface.html index ea64632f8..71b9a153c 100644 --- a/apps/calendar/interface.html +++ b/apps/calendar/interface.html @@ -178,9 +178,8 @@ function getData() { })()\n`, contents => { const fileNames = JSON.parse(contents); if (fileNames.length > 0) { - Util.readStorage('calendar.days.json',data=>{ - holidays = JSON.parse(data || "[]") || []; - + Util.readStorageJSON('calendar.days.json',data=>{ + holidays = data || []; Util.hideModal(); render(); }); diff --git a/apps/espruinoterm/interface.html b/apps/espruinoterm/interface.html index 660b3a86c..6ff7b7da5 100644 --- a/apps/espruinoterm/interface.html +++ b/apps/espruinoterm/interface.html @@ -83,11 +83,8 @@ function onInit() { Util.showModal("Loading..."); - Util.readStorage("espruinoterm.json", function(j) { + Util.readStorageJSON("espruinoterm.json", function(options) { Util.hideModal(); - try { - options = JSON.parse(j); - } catch (e) {} if (!Array.isArray(options)) setDefaults(); refresh(); }); diff --git a/apps/grocery/interface.html b/apps/grocery/interface.html index 0c8df1e86..c424643a8 100644 --- a/apps/grocery/interface.html +++ b/apps/grocery/interface.html @@ -76,11 +76,11 @@ function getData() { // show loading window Util.showModal("Loading..."); - Util.readStorage('grocery_list.json', data=>{ + Util.readStorageJSON('grocery_list.json', data=>{ // remove window Util.hideModal(); - settings = JSON.parse(data || '{"products": []}'); + settings = data || {"products": []}; products = settings.products; renderProducts(); }); diff --git a/apps/guitarsongs/manage_songs.html b/apps/guitarsongs/manage_songs.html index 9280d8d96..bdcab53af 100644 --- a/apps/guitarsongs/manage_songs.html +++ b/apps/guitarsongs/manage_songs.html @@ -211,9 +211,9 @@ this.editSong = song; }, loadSongs: function () { - Util.readStorage('guitar_songs.json', (contents) => { + Util.readStorageJSON('guitar_songs.json', (contents) => { this.songsState = 'loaded'; - this.localSongs = JSON.parse(contents) || []; + this.localSongs = contents || []; this.watchSongs = JSON.parse(JSON.stringify(this.localSongs)); }); window.setTimeout(() => { diff --git a/apps/mylocation/interface.html b/apps/mylocation/interface.html index 79a122bf7..1bd3129ee 100644 --- a/apps/mylocation/interface.html +++ b/apps/mylocation/interface.html @@ -98,11 +98,10 @@ function onInit() { // read existing location - Util.readStorage("mylocation.json", function(data) { + Util.readStorageJSON("mylocation.json", function(data) { if (data===undefined) return; // no file try { - var j = JSON.parse(data); - setPosition(j); + setPosition(data); } catch (e) { console.error(e); } diff --git a/apps/noteify/interface.html b/apps/noteify/interface.html index 4d7974ad9..6635ff5ed 100644 --- a/apps/noteify/interface.html +++ b/apps/noteify/interface.html @@ -26,8 +26,8 @@ function disableFormInput() { function getData() { // show loading window Util.showModal("Loading..."); - Util.readStorage(`noteify.json`,data=>{ - notes = JSON.parse(data || "[]"); + Util.readStorageJSON(`noteify.json`,data=>{ + notes = data || []; // remove window Util.hideModal(); diff --git a/apps/openstmap/interface.html b/apps/openstmap/interface.html index 9e22c57e4..938a8ea32 100644 --- a/apps/openstmap/interface.html +++ b/apps/openstmap/interface.html @@ -150,15 +150,9 @@ TODO: files.trim().split(",").forEach(filename => { if (filename=="") return; promise = promise.then(() => new Promise(resolve => { - Util.readStorage(filename, fileContents => { - console.log(filename + " => " + fileContents); + Util.readStorageJSON(filename, mapInfo => { + console.log(filename + " => " + mapInfo); let mapNumber = filename.match(/\d+/)[0]; // figure out what map number we are - let mapInfo; - try { - mapInfo = JSON.parse(fileContents); - } catch (e) { - console.error(e); - } loadedMaps[mapNumber] = mapInfo; if (mapInfo!==undefined) { let latlon = L.latLng(mapInfo.lat, mapInfo.lon); diff --git a/apps/owmweather/interface.html b/apps/owmweather/interface.html index 3f9467a83..205035749 100644 --- a/apps/owmweather/interface.html +++ b/apps/owmweather/interface.html @@ -2,35 +2,34 @@ - +

Set OpenWeatherMap (OWM) API key

- +

Where to get your personal API key?

Go to https://home.openweathermap.org/users/sign_up and sign up for a free account.
After registration you can login and optain your personal API key.

- +