Manages the 1-wire bus

Dependents:   oldheating heating

Revision:
10:b4e0b4c4e045
Parent:
9:6f663ad53c7e
diff -r 6f663ad53c7e -r b4e0b4c4e045 web/web-1wire-script.js
--- a/web/web-1wire-script.js	Wed Jun 10 11:41:03 2020 +0000
+++ b/web/web-1wire-script.js	Wed Jun 10 17:02:21 2020 +0000
@@ -87,14 +87,22 @@
     elem = Ajax.getElementOrNull('ajax-1-wire-tweak-release'); if (elem) elem.textContent = oneWireReleaseTweak;
     elem = Ajax.getElementOrNull('ajax-1-wire-trace'        ); if (elem) elem.setAttribute('dir', oneWireTrace ? 'rtl' : 'ltr');
 
-    elem = Ajax.getElementOrNull('ajax-name-0'); if (elem) elem.textContent = assignedNames[0];
-    elem = Ajax.getElementOrNull('ajax-name-1'); if (elem) elem.textContent = assignedNames[1];
-    elem = Ajax.getElementOrNull('ajax-name-2'); if (elem) elem.textContent = assignedNames[2];
-    elem = Ajax.getElementOrNull('ajax-name-3'); if (elem) elem.textContent = assignedNames[3];
-    elem = Ajax.getElementOrNull('ajax-rom-0' ); if (elem) elem.value = assignedRoms[0];
-    elem = Ajax.getElementOrNull('ajax-rom-1' ); if (elem) elem.value = assignedRoms[1];
-    elem = Ajax.getElementOrNull('ajax-rom-2' ); if (elem) elem.value = assignedRoms[2];
-    elem = Ajax.getElementOrNull('ajax-rom-3' ); if (elem) elem.value = assignedRoms[3];
+    elem = Ajax.getElementOrNull('ajax-name-0'); if (elem && assignedNames.length > 0) elem.textContent = assignedNames[0];
+    elem = Ajax.getElementOrNull('ajax-name-1'); if (elem && assignedNames.length > 1) elem.textContent = assignedNames[1];
+    elem = Ajax.getElementOrNull('ajax-name-2'); if (elem && assignedNames.length > 2) elem.textContent = assignedNames[2];
+    elem = Ajax.getElementOrNull('ajax-name-3'); if (elem && assignedNames.length > 3) elem.textContent = assignedNames[3];
+    elem = Ajax.getElementOrNull('ajax-name-4'); if (elem && assignedNames.length > 4) elem.textContent = assignedNames[4];
+    elem = Ajax.getElementOrNull('ajax-name-5'); if (elem && assignedNames.length > 5) elem.textContent = assignedNames[5];
+    elem = Ajax.getElementOrNull('ajax-name-6'); if (elem && assignedNames.length > 6) elem.textContent = assignedNames[6];
+    elem = Ajax.getElementOrNull('ajax-name-7'); if (elem && assignedNames.length > 7) elem.textContent = assignedNames[7];
+    elem = Ajax.getElementOrNull('ajax-rom-0' ); if (elem && assignedRoms.length  > 0) elem.value = assignedRoms[0];
+    elem = Ajax.getElementOrNull('ajax-rom-1' ); if (elem && assignedRoms.length  > 1) elem.value = assignedRoms[1];
+    elem = Ajax.getElementOrNull('ajax-rom-2' ); if (elem && assignedRoms.length  > 2) elem.value = assignedRoms[2];
+    elem = Ajax.getElementOrNull('ajax-rom-3' ); if (elem && assignedRoms.length  > 3) elem.value = assignedRoms[3];
+    elem = Ajax.getElementOrNull('ajax-rom-4' ); if (elem && assignedRoms.length  > 4) elem.value = assignedRoms[4];
+    elem = Ajax.getElementOrNull('ajax-rom-5' ); if (elem && assignedRoms.length  > 5) elem.value = assignedRoms[5];
+    elem = Ajax.getElementOrNull('ajax-rom-6' ); if (elem && assignedRoms.length  > 6) elem.value = assignedRoms[6];
+    elem = Ajax.getElementOrNull('ajax-rom-7' ); if (elem && assignedRoms.length  > 7) elem.value = assignedRoms[7];
 }
 
 Ajax.server     = '/1wire-ajax';