Skip to content

Commit 32b1041

Browse files
committed
Improve style, show no connection on error
1 parent 29dee4c commit 32b1041

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

web/src/index.htm

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99
<body>
1010
<div class="heading">STORINATOR</div>
1111

12-
<button id="powerLed" type="button" class="button" disabled>
12+
<button
13+
id="powerLed"
14+
type="button"
15+
class="button"
16+
disabled
17+
style="color: #b413ff"
18+
>
1319
NO CONNECTION
1420
</button>
1521
<button
@@ -69,7 +75,7 @@
6975
powerLed.textContent = 'POWER LED'
7076
powerLed.style.color = '#eb1e8f'
7177
} else {
72-
powerLed.style.color = '#cfcfcf'
78+
powerLed.style.color = '#b413ff'
7379
powerLed.textContent = 'NO CONNECTION'
7480
}
7581
}
@@ -100,12 +106,16 @@
100106
if (this.response.toString().includes(REQ_POWER_STATUS + ':on'))
101107
togglePowerLedColor('on')
102108
else togglePowerLedColor('off')
109+
} else if (this.readyState == 4) {
110+
togglePowerLedColor('nocon')
111+
console.log('No connection to server.')
103112
}
104-
} else if (this.readyState == 4 && this.status == 404) {
105-
togglePowerLedColor('nocon')
106-
console.log('No connection to server.')
107113
}
108114
}
115+
xhttp.onerror = function () {
116+
togglePowerLedColor('nocon')
117+
console.log('No connection to server.')
118+
}
109119
xhttp.open('GET', request, true)
110120
xhttp.send()
111121
}

web/src/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ a {
4949
display: flex;
5050
align-items: center;
5151
justify-content: center;
52-
padding: 5%;
52+
margin: 5%;
5353
}

0 commit comments

Comments
 (0)