From 30a5fe6656a8d2911e6a478416bd792aa2a7da8e Mon Sep 17 00:00:00 2001 From: adrian w kirk Date: Sun, 11 Apr 2021 11:09:57 +0100 Subject: [PATCH] Adding custom page for selecting sliding text languages --- apps.json | 1 + apps/slidingtext/custom.html | 69 +++++++++++++++++++++++++++++++++ apps/slidingtext/slidingtext.js | 20 +++++++++- 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 apps/slidingtext/custom.html diff --git a/apps.json b/apps.json index b637d48c9..d62d311ae 100644 --- a/apps.json +++ b/apps.json @@ -222,6 +222,7 @@ "type":"clock", "allow_emulator":true, "readme": "README.md", + "custom":"custom.html", "storage": [ {"name":"slidingtext.app.js","url":"slidingtext.js"}, {"name":"slidingtext.img","url":"slidingtext-icon.js","evaluate":true}, diff --git a/apps/slidingtext/custom.html b/apps/slidingtext/custom.html new file mode 100644 index 000000000..8c9edada1 --- /dev/null +++ b/apps/slidingtext/custom.html @@ -0,0 +1,69 @@ + + + + + + +

Please select watch languages

+ + + + + + +
EnabledName
+ +

Click

+ + + + + + diff --git a/apps/slidingtext/slidingtext.js b/apps/slidingtext/slidingtext.js index 2d91a9fa3..bef252668 100644 --- a/apps/slidingtext/slidingtext.js +++ b/apps/slidingtext/slidingtext.js @@ -275,7 +275,25 @@ function setColor(main_color,other_color,bg_color){ } // load the date formats required -var locales = ["en","en2","fr","jp"]; + +LANGUAGES_FILE = "slidingtext.languages.json"; +var LANGUAGES_DEFAULT = ["en","en2"]; +var locales = null; +try{ + locales = require("Storage").readJSON(LANGUAGES_FILE); + if(locales != null){ + console.log("loaded languages:" + JSON.stringify(locales)); + } else { + console.log("no languages loaded"); + locales = LANGUAGES_DEFAULT; + } +} catch(e){ + console.log("failed to load languages:" + e); +} +if(locales == null || locales.length == 0){ + locales = LANGUAGES_DEFAULT; + console.log("defaulting languages to locale:" + locales); +} let date_formatters = []; for(var i=0; i< locales.length; i++){