|
9 | 9 | <body> |
10 | 10 | <div class="heading">STORINATOR</div> |
11 | 11 |
|
| 12 | + <button |
| 13 | + id="powerLed" |
| 14 | + type="button" |
| 15 | + class="button" |
| 16 | + disabled> |
| 17 | + POWER LED |
| 18 | + </button> |
12 | 19 | <button |
13 | 20 | id="powerBtn" |
14 | 21 | type="button" |
15 | 22 | class="activeButton" |
16 | | - onclick="sendCommand(CMD_POWER_ON)" |
17 | | - > |
| 23 | + onclick="sendCommand(CMD_POWER_ON)"> |
18 | 24 | POWER ON |
19 | 25 | </button> |
20 | 26 | <button |
21 | 27 | id="standByBtn" |
22 | 28 | type="button" |
23 | 29 | class="activeButton" |
24 | | - onclick="sendCommand(CMD_STAND_BY)" |
25 | | - > |
| 30 | + onclick="sendCommand(CMD_STAND_BY)"> |
26 | 31 | STANDBY |
27 | 32 | </button> |
28 | 33 | <button |
29 | 34 | id="resetBtn" |
30 | 35 | type="button" |
31 | 36 | class="activeButton" |
32 | | - onclick="sendCommand(CMD_RESET)" |
33 | | - > |
| 37 | + onclick="sendCommand(CMD_RESET)"> |
34 | 38 | RESET |
35 | 39 | </button> |
36 | 40 | <button |
37 | 41 | id="killBtn" |
38 | 42 | type="button" |
39 | 43 | class="activeButton" |
40 | | - onclick="sendCommand(CMD_KILL)" |
41 | | - > |
| 44 | + onclick="sendCommand(CMD_KILL)"> |
42 | 45 | KILL |
43 | 46 | </button> |
44 | 47 |
|
| 48 | + <a href="https://github.com/MatiasG19/arduino-remote-switch">Arduino Remote Switch on GitHub</a> |
| 49 | + |
45 | 50 | <script> |
46 | 51 | const CMD_POWER_ON = "powerOn", CMD_STAND_BY = "standBy", CMD_RESET = "reset", CMD_KILL = "kill" |
47 | 52 | const REQ_POWER_STATUS = "powerStatus" |
48 | 53 |
|
49 | 54 | setInterval(() => { |
| 55 | + togglePowerLedColor(true) |
50 | 56 | requestStatus(REQ_POWER_STATUS) |
51 | 57 | }, 3000) |
52 | 58 |
|
53 | | - function togglePowerButtonColor(state) { |
54 | | - const powerBtn = document.getElementById('powerBtn') |
| 59 | + function togglePowerLedColor(state) { |
| 60 | + const powerLed = document.getElementById('powerLed') |
55 | 61 | if (state) { |
56 | | - powerBtn.style.color = "#27e670" |
| 62 | + powerLed.style.color = "#27e670" |
57 | 63 | } else { |
58 | | - powerBtn.style.color = "#cfcfcf" |
| 64 | + powerLed.style.color = "#eb1e8f" |
59 | 65 | } |
60 | 66 | } |
61 | 67 |
|
|
80 | 86 | console.debug(`requestStatus:${request}:${this.responseText}`) |
81 | 87 | if(request == REQ_POWER_STATUS && typeof this.response === "string") { |
82 | 88 | if(this.response.toString().includes(REQ_POWER_STATUS+":on")) |
83 | | - togglePowerButtonColor(true) |
| 89 | + togglePowerLedColor(true) |
84 | 90 | else |
85 | | - togglePowerButtonColor(false) |
| 91 | + togglePowerLedColor(false) |
86 | 92 | } |
87 | 93 | } |
88 | 94 | } |
|
0 commit comments