Make theme switchable in footer and store choice in cookie for 30 days
This commit is contained in:
parent
dd8bd05aa0
commit
bf7e60a284
3 changed files with 44 additions and 6 deletions
|
@ -319,7 +319,7 @@
|
||||||
</div>
|
</div>
|
||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<span class="text-muted">MMDVM-Dashboard Version <script>document.write(dashboard_version);</script> by DG9VH | <a href="https://github.com/dg9vh/MMDVMHost-Websocketboard">get your own</a> | Follow me <a href="https://twitter.com/DG9VH">@DG9VH</a></span>
|
<span class="text-muted">MMDVM-Dashboard Version <script>document.write(dashboard_version);</script> by DG9VH | <a href="https://github.com/dg9vh/MMDVMHost-Websocketboard">get your own</a> | Follow me <a href="https://twitter.com/DG9VH">@DG9VH</a> | <a href="javascript:switchTheme();">switch theme</a></span>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
<script>
|
<script>
|
||||||
|
|
|
@ -25,15 +25,53 @@ var array_services = [];
|
||||||
|
|
||||||
setInterval(getCurrentTXing, 1000);
|
setInterval(getCurrentTXing, 1000);
|
||||||
|
|
||||||
|
var usedTheme = getCookie("Theme");
|
||||||
|
|
||||||
|
if (usedTheme == "") {
|
||||||
|
if (useDarkTheme)
|
||||||
|
usedTheme = "dark";
|
||||||
|
else
|
||||||
|
usedTheme = "bright";
|
||||||
|
setCookie("Theme",usedTheme, 30);
|
||||||
|
}
|
||||||
|
|
||||||
var element = document.createElement("link");
|
var element = document.createElement("link");
|
||||||
element.setAttribute("rel", "stylesheet");
|
element.setAttribute("rel", "stylesheet");
|
||||||
element.setAttribute("type", "text/css");
|
element.setAttribute("type", "text/css");
|
||||||
if (useDarkTheme)
|
element.setAttribute("href", "css/styles-" + usedTheme + ".css");
|
||||||
element.setAttribute("href", "css/styles-dark.css");
|
|
||||||
else
|
|
||||||
element.setAttribute("href", "css/styles-bright.css");
|
|
||||||
document.getElementsByTagName("head")[0].appendChild(element);
|
document.getElementsByTagName("head")[0].appendChild(element);
|
||||||
|
|
||||||
|
function setCookie(cname, cvalue, exdays) {
|
||||||
|
var d = new Date();
|
||||||
|
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
|
||||||
|
var expires = "expires="+d.toUTCString();
|
||||||
|
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCookie(cname) {
|
||||||
|
var name = cname + "=";
|
||||||
|
var ca = document.cookie.split(';');
|
||||||
|
for(var i = 0; i < ca.length; i++) {
|
||||||
|
var c = ca[i];
|
||||||
|
while (c.charAt(0) == ' ') {
|
||||||
|
c = c.substring(1);
|
||||||
|
}
|
||||||
|
if (c.indexOf(name) == 0) {
|
||||||
|
return c.substring(name.length, c.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function switchTheme() {
|
||||||
|
if (usedTheme == "dark") {
|
||||||
|
setCookie("Theme", "bright", 30);
|
||||||
|
} else {
|
||||||
|
setCookie("Theme", "dark", 30);
|
||||||
|
}
|
||||||
|
document.location.reload();
|
||||||
|
}
|
||||||
|
|
||||||
function logIt(message) {
|
function logIt(message) {
|
||||||
if (debug == 1 || message.startsWith("Logtailer-Errormessage:")) {
|
if (debug == 1 || message.startsWith("Logtailer-Errormessage:")) {
|
||||||
console.log(JSON.stringify(message));
|
console.log(JSON.stringify(message));
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
var dashboard_version = "2021-04-22 07:57:14";
|
var dashboard_version = "2021-04-22 19:08:37";
|
||||||
|
|
Loading…
Reference in a new issue