This way I transmit the remaining time before the timers are turned on.
- void remaining_time() {
- if (criterion-1) {
- ws.textAll("buffer1=" + String(buffer1));
- }
- if (criterion-2) {
- ws.textAll("buffer2=" + String(buffer2));
- }
- if (criterion-3) {
- ws.textAll("buffer3=" + String(buffer3));
- }
- }
- function onMessage(event) {
- var arrayS = event.data.split("=");
- switch (arrayS[0]) {
- case 'buffer1': document.getElementById("time1").innerHTML = arrayS[1]; break
- case 'buffer2': document.getElementById("time2").innerHTML = arrayS[1]; break
- case 'buffer3': document.getElementById("time3").innerHTML = arrayS[1]; break
- }
- }
I see it this way.
- void button_status() {
- if (criterion_butt-1) {
- ws.textAll(String(!ledState1));
- }
- if (criterion_butt-2) {
- ws.textAll(String(!ledState2 + 2));
- }
- if (criterion_butt-3) {
- ws.textAll(String(!ledState3 + 4));
- }
- }
- function onMessage(event) {
- switch (event.data) {
- case '0': document.getElementById("state1").innerHTML = "OFF"; break
- case '1': document.getElementById("state1").innerHTML = "ON";break
- case '2': document.getElementById("state2").innerHTML = "OFF"; break
- case '3': document.getElementById("state2").innerHTML = "ON"; break
- case '4': document.getElementById("state3").innerHTML = "OFF"; break
- case '5': document.getElementById("state3").innerHTML = "ON"; break
- }
- }
in JavaScript is to somehow distinguish (separate) them from each other.
Could you help me with this issue? If this was an example with comments for understanding, that would be magical!