Procházet zdrojové kódy

max80.js: change fillin() and load() to use CSS selectors

Especially for translation, it will be more useful to be able to use
CSS selectors to change multiple entries of the same class.
H. Peter Anvin před 2 roky
rodič
revize
5ca5b5f400
1 změnil soubory, kde provedl 2 přidání a 3 odebrání
  1. 2 3
      esp32/www/com/max80.js

+ 2 - 3
esp32/www/com/max80.js

@@ -83,12 +83,11 @@ function loadform(form, url) {
 	.catch(() => {});
 }
 
-// Replace HTML element contents with the contents of a map
+// Replace the contents of selected HTML elements based on a map with selectors
 function fillin(map,html)
 {
     for (const [key,val] of map) {
-	var e = document.getElementById(key);
-	if (e) {
+	for (var e of document.querySelectorAll(key)) {
 	    if (html)
 		e.innerHTML = val;
 	    else