Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 41 additions & 33 deletions web/src/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,60 @@
<link rel="stylesheet" href="style.css" />
</head>
<body>
<h2>STORINATOR</h2>
<div class="heading">STORINATOR</div>

<div class="statusContainer">
<div class="led-box">
<div id="powerLed" class="led-off"></div>
<p>Power</p>
</div>
</div>

<div class="operationContainer">
<button type="button" class="powerOnButton" onclick="sendCommand(CMD_POWER_ON)">
ON
</button>
<button type="button" class="standbyButton" onclick="sendCommand(CMD_STAND_BY)">
STANDBY
</button>
<button type="button" class="resetButton" onclick="sendCommand(CMD_RESET)">
RESET
</button>
<button type="button" class="killButton" onclick="sendCommand(CMD_KILL)">
KILL
</button>
</div>
<button
id="powerBtn"
type="button"
class="activeButton"
onclick="sendCommand(CMD_POWER_ON)"
>
POWER ON
</button>
<button
id="standByBtn"
type="button"
class="activeButton"
onclick="sendCommand(CMD_STAND_BY)"
>
STANDBY
</button>
<button
id="resetBtn"
type="button"
class="activeButton"
onclick="sendCommand(CMD_RESET)"
>
RESET
</button>
<button
id="killBtn"
type="button"
class="activeButton"
onclick="sendCommand(CMD_KILL)"
>
KILL
</button>

<script>
var state = false
const CMD_POWER_ON = "powerOn", CMD_STAND_BY = "standBy", CMD_RESET = "reset", CMD_KILL = "kill"
const REQ_POWER_STATUS = "powerStatus"

setInterval(() => {
requestStatus(REQ_POWER_STATUS)
}, 3000)

function togglePowerLed(state) {
const powerLed = document.getElementById('powerLed')
function togglePowerButtonColor(state) {
const powerBtn = document.getElementById('powerBtn')
if (state) {
powerLed.classList.remove('led-off')
powerLed.classList.add('led-green')
powerBtn.style.color = "#27e670"
} else {
powerLed.classList.remove('led-green')
powerLed.classList.add('led-off')
powerBtn.style.color = "#cfcfcf"
}
}

function sendCommand(request) {
if (!confirm(request.toUpperCase())) return
function sendCommand(type) {
if (!confirm(type.toUpperCase())) return

var xhttp = new XMLHttpRequest()
xhttp.onreadystatechange = function () {
Expand All @@ -72,9 +80,9 @@ <h2>STORINATOR</h2>
console.debug(`requestStatus:${request}:${this.responseText}`)
if(request == REQ_POWER_STATUS && typeof this.response === "string") {
if(this.response.toString().includes(REQ_POWER_STATUS+":on"))
togglePowerLed(true)
togglePowerButtonColor(true)
else
togglePowerLed(false)
togglePowerButtonColor(false)
}
}
}
Expand Down
118 changes: 31 additions & 87 deletions web/src/style.css
Original file line number Diff line number Diff line change
@@ -1,102 +1,46 @@
body {
font-family: 'Lucida Console', 'Courier New', monospace;
}

.operationContainer {

}

button {
position: relative;
display: inline-block;
width: 100px;
height: 34px;
}

.powerOnButton {
background-color: #04e486;
}

.powerOnButton:hover {
background-color: #60ebb1;
color: black;
}

.powerOnButton:active {
background-color: #08b16b;
color: white;
html {
height: 95%;
font-family: 'Lucida Console', 'Arial', monospace;
}

.standbyButton {
background-color: #ee7707;
}

.standbyButton:hover {
background-color: #f09b4c;
color: white;
}

.standbyButton:active {
background-color: #c26208;
color: white;
}

.resetButton {
background-color: #d60656;
}

.resetButton:hover {
background-color: #cf4376;
color: black;
}

.resetButton:active {
background-color: #b41f56;
color: white;
body {
background-color: #1f1e29;
color: #cfcfcf;
height: 95%;
}

/**********************************************/
/* Status */
/**********************************************/
.statusContainer {
margin: 30px;
.heading {
font-size: 5vh;
text-align: center;
}

.led-box {
height: 30px;
margin: 10px 30px;
button {
position: relative;
display: inline-block;
}
width: calc(100% - 2vw);
min-width: 50px;
max-width: 200vh;
height: 20%;
min-height: 50px;
border: none;
border-radius: 1vw;
margin: 1vh 1vw 1vh 1vw;
font-size: 10vh;

.led-box p {
font-size: 12px;
text-align: center;
margin: 1em;
color: #cfcfcf;
background-color: #313131;
}

.led-green {
margin: 0 auto;
width: 24px;
height: 24px;
background-color: #aee9d0;
border-radius: 50%;
box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #08b16b 0 -1px 9px, #42e4a0 0 2px 12px;
.activeButton {
cursor: pointer;
}

.led-blue {
margin: 0 auto;
width: 24px;
height: 24px;
background-color: #24E0FF;
border-radius: 50%;
box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset rgb(59, 59, 190) 0 -1px 9px, #3F8CFF 0 2px 14px;
.activeButton:hover {
background-color: #cfcfcf;
color: black;
}

.led-off {
margin: 0 auto;
width: 24px;
height: 24px;
background-color: #ffffff;
border-radius: 50%;
box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset rgb(65, 65, 73) 0 -1px 9px, #ffffff 0 2px 14px;
.activeButton:active {
background-color: #494949;
color: #cfcfcf;
}