Skip to content

Commit

Permalink
Fix dark mode settings and licensing
Browse files Browse the repository at this point in the history
  • Loading branch information
TCB13 committed May 20, 2022
1 parent fa82b2e commit 57583ff
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 27 deletions.
28 changes: 11 additions & 17 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,6 @@
<i class="bi bi-question-lg"></i>
</button>

<button type="button" class="btn py-3 border-top"
id="theme"
aria-current="page" title="Got Bugs?"
data-bs-toggle-tooltip="tooltip" data-bs-placement="right" data-bs-original-title="Got Bugs?"
>
<i class="bi bi-lightbulb"></i>
</button>

<button type="button" class="btn py-3 border-top"
aria-current="page" title="Settings"
data-bs-toggle-tooltip="tooltip" data-bs-placement="right" data-bs-original-title="Settings"
Expand Down Expand Up @@ -201,12 +193,12 @@ <h1>Shortcuts</h1>
<h1>Settings</h1>
<form class="mt-4 settings">
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="open_help">
<label class="form-check-label" for="open_help">Open the help panel on startup</label>
<input class="form-check-input" type="checkbox" value="" id="darkmode">
<label class="form-check-label" for="darkmode">Enable dark mode</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="darkmode">
<label class="form-check-label" for="darkmode">Prefer dark mode</label>
<input class="form-check-input" type="checkbox" value="" id="open_help">
<label class="form-check-label" for="open_help">Open the help panel on startup</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="save_history">
Expand All @@ -217,11 +209,13 @@ <h1>Settings</h1>
<label class="form-check-label" for="round_results">Round results to 10 decimal places</label>
</div>
</form>
<div class="border-top my-4 pt-2">
<p><small>TBCalc v1.1 - www.tcb13.com<br>
Copyright © TCB13 (Tadeu Bento) 2022. <a rel="license" target="_blank" href="/LICENSE.txt">Licensed as GPLv3.</a><br>
<a target="_blank" href="/INCLUDED_LICENSES.txt">This project uses open-source libraries.</a>
</small></p>
<div class="border-top my-4 pt-2 legal">
<p>
<span>TBCalc v1.2 - www.tcb13.com</span><br>
Copyright © TCB13 (Tadeu Bento) 2022.<br>
<a rel="license" target="_blank" href="https://tbcalc.tcb13.com/LICENSE.txt">Licensed under GPLv3.</a><br>
<a target="_blank" href="https://tbcalc.tcb13.com/INCLUDED_LICENSES.txt">This project uses open-source libraries.</a>
</p>
</div>
</div>
</div>
Expand Down
17 changes: 7 additions & 10 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
TBCalc v1.1 - Console Calculator
TBCalc v1.2 - Console Calculator
Copyright (C) 2022 TCB13 (Tadeu Bento)
https://tbcalc.tcb13.com | https://tcb13.com | https://tadeubento.com
Expand Down Expand Up @@ -37,6 +37,10 @@ window.onload = () => {
window.stm = new SettingsManager(settingCheckboxes, settings);
stm.load();

document.querySelector("form.settings input#darkmode").addEventListener("click", () => {
document.body.classList.toggle("dark-mode");
});

const input = document.querySelector(".interface .input");
if (stm.settings.save_history && localStorage.getItem("input")) {
input.value = localStorage.getItem("input");
Expand All @@ -50,13 +54,6 @@ window.onload = () => {
document.body.classList.add("dark-mode");
}

const themeBtn = document.getElementById("theme");
themeBtn.onclick = () => {
document.body.classList.toggle("dark-mode");
stm.settings.darkmode = !stm.settings.darkmode;
stm.store();
};

document.getElementById("refresh").onclick = () => location.reload();
document.getElementById("reset").onclick = () => calc.reset();
document.getElementById("save-file").onclick = () => calc.download();
Expand Down Expand Up @@ -100,12 +97,12 @@ class SettingsManager {

for (const checkbox of this.checkboxEls) {
checkbox.checked = this.settings[checkbox.id];
checkbox.onclick = () => {
checkbox.addEventListener("click", () => {
for (const checkbox of this.checkboxEls) {
this.settings[checkbox.id] = checkbox.checked;
}
localStorage.setItem("settings", JSON.stringify(this.settings));
}
});
}

}
Expand Down
8 changes: 8 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,11 @@ a, a:link, a:hover, a:active, a:visited, a:focus,
.interface .output .error {
color: red;
}

.legal {
font-size: 0.8rem;
}

.legal span {
font-weight: bold;
}

0 comments on commit 57583ff

Please sign in to comment.