diff --git a/copyparty/__main__.py b/copyparty/__main__.py
index ac99f24d..f9d0fd09 100755
--- a/copyparty/__main__.py
+++ b/copyparty/__main__.py
@@ -1145,7 +1145,7 @@ def add_db_metadata(ap):
def add_ui(ap, retry):
ap2 = ap.add_argument_group('ui options')
ap2.add_argument("--grid", action="store_true", help="show grid/thumbnails by default (volflag=grid)")
- ap2.add_argument("--lang", metavar="LANG", type=u, default="eng", help="language")
+ ap2.add_argument("--lang", metavar="LANG", type=u, default="eng", help="language; one of the following: eng nor")
ap2.add_argument("--theme", metavar="NUM", type=int, default=0, help="default theme to use")
ap2.add_argument("--themes", metavar="NUM", type=int, default=8, help="number of themes installed")
ap2.add_argument("--unlist", metavar="REGEX", type=u, default="", help="don't show files matching REGEX in file list. Purely cosmetic! Does not affect API calls, just the browser. Example: [\033[32m\\.(js|css)$\033[0m] (volflag=unlist)")
diff --git a/copyparty/web/baguettebox.js b/copyparty/web/baguettebox.js
index d5e55da6..066073f8 100644
--- a/copyparty/web/baguettebox.js
+++ b/copyparty/web/baguettebox.js
@@ -524,7 +524,7 @@ window.baguetteBox = (function () {
options[item] = newOptions[item];
}
- var an = options.animation = sread('ganim') || anims[ANIM ? 0 : 2];
+ var an = options.animation = sread('ganim', anims) || anims[ANIM ? 0 : 2];
btnAnim.textContent = ['⇄', '⮺', '⚡'][anims.indexOf(an)];
btnAnim.setAttribute('tt', 'animation: ' + an);
diff --git a/copyparty/web/browser.html b/copyparty/web/browser.html
index 77324346..a0631698 100644
--- a/copyparty/web/browser.html
+++ b/copyparty/web/browser.html
@@ -166,7 +166,7 @@
readme = {{ readme|tojson }},
ls0 = {{ ls0|tojson }};
- document.documentElement.className = localStorage.theme || dtheme;
+ document.documentElement.className = localStorage.cpp_thm || dtheme;
diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js
index fc7d33c8..9a1ea033 100644
--- a/copyparty/web/browser.js
+++ b/copyparty/web/browser.js
@@ -941,12 +941,27 @@ var Ls = {
"lang_set": "passer det å laste siden på nytt?",
},
};
-var L = Ls[sread("lang") || lang];
-if (Ls.eng && L != Ls.eng) {
- for (var k in Ls.eng)
- if (!L[k])
- L[k] = Ls.eng[k];
+var LANGS = ["eng", "nor"],
+ L = Ls[sread("cpp_lang", LANGS) || lang] || Ls.eng || Ls.nor;
+
+for (var a = 0; a < LANGS.length; a++) {
+ for (var b = a + 1; b < LANGS.length; b++) {
+ var i1 = Object.keys(Ls[LANGS[a]]).length > Object.keys(Ls[LANGS[b]]).length ? a : b,
+ i2 = i1 == a ? b : a,
+ t1 = Ls[LANGS[i1]],
+ t2 = Ls[LANGS[i2]];
+
+ for (var k in t1)
+ if (!t2[k]) {
+ console.log("E missing TL", LANGS[i2], k);
+ t2[k] = t1[k];
+ }
+ }
}
+
+if (!has(LANGS, lang))
+ alert('unsupported --lang "' + lang + '" specified in server args;\nplease use one of these: ' + LANGS);
+
modal.load();
@@ -1354,7 +1369,7 @@ var mpl = (function () {
'
');
var r = {
- "pb_mode": (sread('pb_mode') || 'next').split('-')[0],
+ "pb_mode": (sread('pb_mode', ['loop', 'next']) || 'next').split('-')[0],
"os_ctl": bcfg_get('au_os_ctl', have_mctl) && have_mctl,
'traversals': 0,
};
@@ -6532,7 +6547,9 @@ var mukey = (function () {
"6d ", "7d ", "8d ", "9d ", "10d", "11d", "12d", "1d ", "2d ", "3d ", "4d ", "5d ",
"6m ", "7m ", "8m ", "9m ", "10m", "11m", "12m", "1m ", "2m ", "3m ", "4m ", "5m "
]
- };
+ },
+ defnot = 'rekobo_alnum';
+
var map = {},
html = [];
@@ -6557,7 +6574,7 @@ var mukey = (function () {
}
function load_notation(notation) {
- swrite("key_notation", notation);
+ swrite("cpp_keynot", notation);
map = {};
var dst = maps[notation];
for (var k in maps)
@@ -6605,7 +6622,10 @@ var mukey = (function () {
}
}
- var notation = sread("key_notation") || "rekobo_alnum";
+ var notation = sread("cpp_keynot") || defnot;
+ if (!maps[notation])
+ notation = defnot;
+
ebi('key_' + notation).checked = true;
load_notation(notation);
@@ -6624,7 +6644,7 @@ var light, theme, themen;
var settheme = (function () {
var ax = 'abcdefghijklmnopqrstuvwx';
- theme = sread('theme') || 'a';
+ theme = sread('cpp_thm') || 'a';
if (!/^[a-x][yz]/.exec(theme))
theme = dtheme;
@@ -6666,7 +6686,7 @@ var settheme = (function () {
l = light ? 'y' : 'z';
theme = c + l + ' ' + c + ' ' + l;
themen = c + l;
- swrite('theme', theme);
+ swrite('cpp_thm', theme);
freshen();
}
@@ -6677,7 +6697,7 @@ var settheme = (function () {
(function () {
function freshen() {
- lang = sread("lang") || lang;
+ lang = sread("cpp_lang", LANGS) || lang;
var html = [];
for (var k in Ls)
if (Ls.hasOwnProperty(k))
@@ -6693,7 +6713,7 @@ var settheme = (function () {
function setlang(e) {
ev(e);
L = Ls[this.textContent];
- swrite("lang", this.textContent);
+ swrite("cpp_lang", this.textContent);
freshen();
modal.confirm(Ls.eng.lang_set + "\n\n" + Ls.nor.lang_set, location.reload.bind(location), null);
};
diff --git a/copyparty/web/splash.html b/copyparty/web/splash.html
index 67feeea2..47db5a1a 100644
--- a/copyparty/web/splash.html
+++ b/copyparty/web/splash.html
@@ -110,7 +110,7 @@ var SR = {{ r|tojson }},
lang="{{ lang }}",
dfavico="{{ favico }}";
-document.documentElement.className=localStorage.theme||"{{ this.args.theme }}";
+document.documentElement.className=localStorage.cpp_thm||"{{ this.args.theme }}";
diff --git a/copyparty/web/splash.js b/copyparty/web/splash.js
index 55143084..63fb4a25 100644
--- a/copyparty/web/splash.js
+++ b/copyparty/web/splash.js
@@ -35,7 +35,7 @@ var Ls = {
"v2": "use this server as a local HDD$N$NWARNING: this will show your password!",
}
},
- d = Ls[sread("lang") || lang];
+ d = Ls[sread("cpp_lang", ["eng", "nor"]) || lang] || Ls.eng || Ls.nor;
for (var k in (d || {})) {
var f = k.slice(-1),
diff --git a/copyparty/web/svcs.html b/copyparty/web/svcs.html
index 6b4cedcc..c1aaf0bf 100644
--- a/copyparty/web/svcs.html
+++ b/copyparty/web/svcs.html
@@ -218,7 +218,7 @@ var SR = {{ r|tojson }},
lang="{{ lang }}",
dfavico="{{ favico }}";
-document.documentElement.className=localStorage.theme||"{{ args.theme }}";
+document.documentElement.className=localStorage.cpp_thm||"{{ args.theme }}";
diff --git a/copyparty/web/util.js b/copyparty/web/util.js
index 825e854b..286339e4 100644
--- a/copyparty/web/util.js
+++ b/copyparty/web/util.js
@@ -882,9 +882,10 @@ function jcp(obj) {
}
-function sread(key) {
+function sread(key, al) {
try {
- return localStorage.getItem(key);
+ var ret = localStorage.getItem(key);
+ return (!al || has(al, ret)) ? ret : null;
}
catch (e) {
return null;
@@ -906,7 +907,13 @@ function jread(key, fb) {
if (!str)
return fb;
- return JSON.parse(str);
+ try {
+ // '' throws, null is ok, sasuga
+ return JSON.parse(str);
+ }
+ catch (e) {
+ return fb;
+ }
}
function jwrite(key, val) {