Skip to content

Commit

Permalink
Keypress for N + R and some QOL fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cthuff committed Nov 1, 2022
1 parent b89e2a0 commit 3a715f6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
9 changes: 6 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<form id="form">
<div style="text-align: center;">
<div style="padding-top: 10px;">
<label for="startTime">Start time: </label>
<label for="startTime">Start Time: </label>
<input type="time" value="08:00" id="startTime" style="font-size: medium;" required>
</div>
<div style="padding-top: 15px;">
Expand All @@ -26,7 +26,8 @@
<input type="time" value ="12:30" id="lunchEnd" required>
<br>
</div>
<div>
<div style="padding-bottom: 5px;">
<div>
<input style="text-align: center; vertical-align: middle;" type="checkbox" id="noLunch" name="noLunch">
<label style="font-size: x-large;"for="noLunch" id="lunchText">No Lunch Today?</label>
</div>
Expand All @@ -53,7 +54,9 @@
<div>
<button id="darkMode" onclick="toggle()">LightMode</button>
</div>

<div>
<p id="log"></p>
</div>
</div>
</footer>
<script src="wcigh.js"></script>
Expand Down
32 changes: 20 additions & 12 deletions wcigh.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
dark = false;
}
//Handles Toggling between Dark and Light Mode
function toggle(){
if (dark == true)
{
function toggle() {
if (dark == true) {
document.getElementById("darkMode").innerText = "DarkMode"
lightMode();
} else {
Expand Down Expand Up @@ -52,13 +51,14 @@
var noLunch = document.getElementById("noLunch");

//Listerners for each of the inputs to change the code immediatly when new entries are given
// window.addEventListener('keydown', function(e) {if(e.key == 'r') window.location.reload(); }, false);
window.addEventListener('keydown', function(e) {if(e.key == 'r') logic(); }, false);
startTime.addEventListener("input", function() { logic(); }, false);
// lunchStart.addEventListener("input", function() { logic(); }, false);
lunchStart.addEventListener("input", function() { if (lunchEnd.value == lunchStart.value) logic(); else { noLunch.checked = false; logic(); }}, false);
lunchEnd.addEventListener("input", function() { if (lunchEnd.value == lunchStart.value) logic(); else { noLunch.checked = false; logic(); }}, false);
// lunchEnd.addEventListener("input", function() { logic(); }, false);
lunchStart.addEventListener("input", function() { if (lunchEnd.value == lunchStart.value) logic(); else { noLunch.checked = false; noLunchFunc(); logic(); }}, false);
lunchEnd.addEventListener("input", function() { if (lunchEnd.value == lunchStart.value) logic(); else { noLunch.checked = false; noLunchFunc(); logic(); }}, false);
shiftTime.addEventListener("input", function() { logic(); }, false);
noLunch.addEventListener("change", function() { noLunchFunc(); }, false);
noLunch.addEventListener("input", function() { noLunchFunc(); logic();}, false);
window.addEventListener('keydown', function(e) {if(e.key == 'n') noLunch.click(); noLunchFunc(); }, false);

//Calls the two functions to modify the text on when they can clock out and time remaining
function logic(){
Expand Down Expand Up @@ -150,13 +150,21 @@
}
}

//
//If the user selects that they don't have a lunch, change the lunch times to be equal ie. no lunch taken
function noLunchFunc(){
if(noLunch.checked == true)
if(noLunch.checked == true) {
document.getElementById("lunchText").innerText = "No Lunch Today";
else
lunchStart.value = "12:00";
lunchEnd.value = "12:00";
}
else if(lunchEnd.value != lunchStart.value){
document.getElementById("lunchText").innerText = "No Lunch Today?";
lunchEnd.value = lunchStart.value;
}
else {
document.getElementById("lunchText").innerText = "No Lunch Today?";
lunchStart.value = "12:00";
lunchEnd.value = lunchStart.value + 30;
}
}

//This loads the time when the page first appears
Expand Down

0 comments on commit 3a715f6

Please sign in to comment.