Browse Source

www: fix css error; add support for inline translations via lang= tags

Fix minor error in css.
Make the Javascript translation code able to set "display: none;" on
objects with a lang= tag that doesn't match the current language,
allowing for more complex text to do translations inline.
H. Peter Anvin 2 years ago
parent
commit
70a4273a93
6 changed files with 14 additions and 1 deletions
  1. BIN
      esp32/output/max80.ino.bin
  2. 1 0
      esp32/www/lang/sv
  3. 1 1
      esp32/www/max80.css
  4. 12 0
      esp32/www/max80.js
  5. BIN
      fpga/output/v1.fw
  6. BIN
      fpga/output/v2.fw

BIN
esp32/output/max80.ino.bin


+ 1 - 0
esp32/www/lang/sv

@@ -1,3 +1,4 @@
+LANG=sv
 body .status=Status
 body .config=Konfiguration
 body .update=Uppdatera

+ 1 - 1
esp32/www/max80.css

@@ -144,7 +144,7 @@ output {
     display: block;
 }
 .onerr h3 {
-    text-weight: bold;
+    font-weight: bold;
     text-decoration: underline;
 }
 .getstatus input {

+ 12 - 0
esp32/www/max80.js

@@ -210,8 +210,20 @@ function translate(top = document) {
 }
 document.addEventListener('load', (e) => translate(), PassiveListener);
 
+var lang_styleobj = document.createElement('style');
+document.head.append(lang_styleobj);
+function setlang(lang)  {
+    if (lang) {
+	if (lang_styleobj.sheet.rules.length)
+	    lang_styleobj.sheet.deleteRule(0);
+	lang_styleobj.sheet.insertRule('[lang]:not([lang="'+lang+'"]) { display: none; }');
+    }
+}
+setlang('en');
+
 fetchconfig('/sys/lang')
     .then((map) => {
+	setlang(map.get('LANG'));
 	translations = map;
 	if (delay_translate)
 	    translate();

BIN
fpga/output/v1.fw


BIN
fpga/output/v2.fw