finish basic structure

master
Bryan 2020-12-17 08:23:26 -06:00
parent 5943089d42
commit f28373b4cd
6 changed files with 327 additions and 76 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

BIN
img/home.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 646 B

BIN
img/settings2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 690 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

View File

@ -1,87 +1,338 @@
<!DOCKTYPE html> <!DOCTYPE html>
<html lang=en-US>
<html>
<head> <head>
<title>Trigger</title>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="Keywords" content=""> <title>Trigger - Login</title>
<meta name="Description" content="Door opener"> <link rel="icon" href="img/favicon.png" type="img/png">
<link rel="icon" href="res/favicon.png" type="image/png">
<script>
const runCGI = () => {
const xmlhttp = new XMLHttpRequest();
// xmlhttp.open("GET", "https://ths.tnet.space/cgi-bin/unlock-main.cgi?passwd=c5S8De2TTPkDhkXREzSP&delay=5");
// xmlhttp.send();
}
//document.getElementById("unlock-button").onclick = runCGI();
</script>
<style> <style>
* { * {
font-family: "sans";
box-sizing: border-box; box-sizing: border-box;
margin: 0; }
html {
position: relative;
height: 100%
}
body {
height: 100%;
padding: 0; padding: 0;
margin: 0;
background: #333;
color: white;
}
.app-bar {
background-color: #FF8800;
}
nav {
height: 56px;
margin: 0;
padding: 16px;
}
.app-bar h1 {
text-align: center;
font-family: sans;
font-size: 45px;
height: 72;
paddng: 0;
margin: 0;
}
.app-bar button {
position: fixed;
font-size: 20px;
height: 24px;
right: 16px;
background-color: #FF8800;
border: none;
}
#open-setting-screen-button {
display: block;
}
#close-setting-screen-button {
display: none;
}
.screen-container {
position: fixed;
width: 100%;
height: calc(100vh - 56px);
padding: 0;
margin: 0;
}
.main-screen {
left: 0;
transition: all, .3s;
/* border: 1px solid yellow; */
}
.setting-screen {
left: 100%;
transition: all, .3s;
/* border: 1px solid blue; */
}
/* .settings-form h1 { */
/* text-align: center; */
}
.settings-form ul {
position: relative;
max-width: 300px;
height: 300px;
list-style: none;
/* border: 1px solid #000; */
border-radius: 5px;
padding: 0px;
margin-left: auto;
margin-right: auto;
}
.settings-form li {
display: flex;
padding: 0;
padding-top: 20px;
margin: 0;
justify-content: center;
}
.settings-form label {
padding-top: 1em;
width: 100px;
}
.settings-form input {
width: 200px;
border: 1px solid #7FBD32;
border-radius: 3em;
background-color: #EEE;
padding: 1em;
}
.settings-form button {
width: 100px;
padding: .5em;
margin-left: auto;
margin-right: auto;
margin-top: 20px;
/* border: 2px solid green; */
font-size: 1.2em;
color: white;
border-radius: 3em;
background: #FF8800;
/* color: white; */
} }
h1 { h1 {
text-align: center; text-align: center;
font-family: sans; font-family: sans;
font-size: 45px; font-size: 24px;
background-color: orange; background-color: #FF8800;
paddng: 0;
margin: 0;
}
#button-block {
position: fixed;
width: 100vw;
bottom: 0px;
} }
.button-container { .button-container {
width: 100px;
height: 100px;
padding: 10px;
border-radius: 50px;
margin: 0 auto;
}
#unlock-button {
background-color: limegreen;
position: fixed;
bottom: 0;
left: calc((100% / 2) - 50px);
padding: 10px;
margin: 0 auto;
}
#unlock-button:active {
background-color: green;
}
#unlock-icon {
width: auto;
height: 75px;
position: relative; position: relative;
display: block; display: block;
margin-left: auto; width: 300px;
margin-right: auto; height: 56px;
padding: 5px; border-radius: 56px;
margin: 32px auto 32px auto;
text-align: center;
background-color: #555;
border: 4px #7FBD32 solid;
} }
.button-container:active {
background-color: green;
width: 290px;
}
/* #unlock-button:active { */
/* background-color: green; */
/* } */
.button-icon {
width: auto;
height: 40px;
position: absolute;
display: block;
/* margin-right: 10px; */
/* margin-left: auto; */
/* margin-top: 3px; */
/* margin-bottom: auto; */
padding: 2px;
left: 6px;
bottom: 4px;
border: 1px solid white;
border-radius: 2em;
background-color: white;
}
.app-bar button img {
height: 24px;
width: auto;
}
</style> </style>
</head> </head>
<body> <body>
<header>
<h1 id="doorName">Main Door</h1>
</header>
<!-- <nav class="app-bar">
<div> <button id="open-setting-screen-button"><img src="img/settings2.png"></button>
<img src="res/doorstatus.png" alt="Door Status"> <button id="close-setting-screen-button"><img src="img/home.png"></button>
</div> </div>
--> </nav>
<div class="button-container" id="unlock-button" onclick="runCGI()"> <!-- <div id="screen-container"> -->
<img id="unlock-icon" src="res/unlockicon.png" alt="Unlock Button">
<!-- Main Screen -->
<section class="screen-container main-screen">
<h1 class="app-bar">Main Door</h1>
<div id="button-block">
<div class="button-container" id="delay-unlock-button">
<p>
<span id="show-delay"></span>
<span>Delay Unlock</span>
</p>
<img class="button-icon" src="img/clockwise.png" alt="Unlock Button">
</div> </div>
<!-- </a> -->
<div class="button-container" id="unlock-button">
<p>Unlock Now</p>
<img class="button-icon" src="img/unlock.png" alt="Unlock Button">
</div>
</div>
</section>
<!-- Settings Screen -->
<section class="screen-container setting-screen"">
<h1 class="app-bar">Settings</h1>
<form class="settings-form">
<ul>
<li>
<label for="device-id">Device ID</label>
<input type="text" id="device-id" name="deviceID">
</li>
<li>
<label for="api-key">API Key</label>
<input type="text" id="api-key" name="apiKey">
</li>
<li>
<label for="delay-time">Delay</label>
<input type="number" min="0" id="delay-time" name="delayTime">
</li>
<li>
<button type="button" id="save-settings-button" name="saveSettings">Save</button>
</li>
</ul>
</form>
</section>
<!-- </div> -->
<script>
const openSettingScreenButton = document.querySelector("#open-setting-screen-button");
const closeSettingScreenButton = document.querySelector("#close-setting-screen-button");
const saveSettingsButton = document.querySelector("#save-settings-button");
const delayUnlockButton = document.querySelector("#delay-unlock-button");
const unlockButton = document.querySelector("#unlock-button");
const settingScreen = document.querySelector(".setting-screen");
const mainScreen = document.querySelector(".main-screen");
const deviceIDInput = document.querySelector("#device-id");
const delayInput = document.querySelector("#delay-time");
const apiKeyInput = document.querySelector("#api-key");
const showDelay = document.querySelector("#show-delay");
let deviceID = "";
let delay = "";
let apiKey = "";
// make fetch function that calls cgi script with attributes (device id, api key, delay)
const setSettings = () => {
if (localStorage.getItem("apiKey") && localStorage.getItem("deviceID")) {
apiKey = localStorage.getItem("apiKey");
deviceID = localStorage.getItem("deviceID");
if (localStorage.getItem("delay")) {
delay = localStorage.getItem("delay");
} else {
delay = 0;
}
apiKeyInput.value = apiKey;
deviceIDInput.value = deviceID;
delayInput.value = delay;
showDelay.innerHTML = `${delay}s`;
} else {
gotoSettingScreen();
}
}
const gotoSettingScreen = () => {
openSettingScreenButton.style.display = "none";
closeSettingScreenButton.style.display = "block";
settingScreen.style.left = "0";
mainScreen.style.left = "-100%";
}
const gotoMainScreen = () => {
closeSettingScreenButton.style.display = "none";
openSettingScreenButton.style.display = "block";
mainScreen.style.left = "0";
settingScreen.style.left = "100%";
}
openSettingScreenButton.addEventListener("click", gotoSettingScreen);
closeSettingScreenButton.addEventListener("click", gotoMainScreen);
// Save settings button
saveSettingsButton.addEventListener("click", function() {
localStorage.setItem("deviceID", deviceIDInput.value);
localStorage.setItem("delay", delayInput.value);
localStorage.setItem("apiKey", apiKeyInput.value);
setSettings();
});
unlockButton.addEventListener("click", function () {
alert("unlock");
});
delayUnlockButton.addEventListener("click", function () {
alert("delay unlock");
});
document.body.onload = setSettings;
</script>
</body> </body>
</html> </html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB