mirror of
https://github.com/kittywitch/dork.dev.git
synced 2026-02-09 23:29:17 -08:00
feat: put javascript into separate files
This commit is contained in:
parent
95345afe2f
commit
6ebd2ddee9
4 changed files with 31 additions and 31 deletions
20
static/colorscheme.js
Normal file
20
static/colorscheme.js
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
var radios = document.getElementsByName("color-scheme");
|
||||||
|
var prev = localStorage.getItem("color-scheme");
|
||||||
|
for (var i = 0; i < radios.length; i++) {
|
||||||
|
var _this = radios[i];
|
||||||
|
_this.checked = _this.value == prev;
|
||||||
|
radios[i].addEventListener("change", function() {
|
||||||
|
if (this.value !== prev) {
|
||||||
|
prev = this.value;
|
||||||
|
localStorage.setItem("color-scheme", this.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
var button = document.getElementById("clear-color-scheme");
|
||||||
|
button.addEventListener("click", function() {
|
||||||
|
for (var i = 0; i < radios.length; i++) {
|
||||||
|
var _this = radios[i];
|
||||||
|
_this.checked = false;
|
||||||
|
localStorage.removeItem("color-scheme");
|
||||||
|
}
|
||||||
|
});
|
||||||
9
static/nonoscript.js
Normal file
9
static/nonoscript.js
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
function nonoscriptImplementer() {
|
||||||
|
var nonoscript = document.getElementsByClassName("nonoscript");
|
||||||
|
console.log(nonoscript);
|
||||||
|
for (let item of nonoscript) {
|
||||||
|
console.log("meep!");
|
||||||
|
item.classList.remove("nonoscript");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window.onload = nonoscriptImplementer();
|
||||||
|
|
@ -49,26 +49,6 @@
|
||||||
|
|
||||||
<noscript>Persistence of user-selected color scheme is not possible without Javascript, however automatic detection from CSS will still work.</noscript>
|
<noscript>Persistence of user-selected color scheme is not possible without Javascript, however automatic detection from CSS will still work.</noscript>
|
||||||
|
|
||||||
<script>
|
<script src="/colorscheme.js">
|
||||||
var radios = document.getElementsByName("color-scheme");
|
|
||||||
var prev = localStorage.getItem("color-scheme");
|
|
||||||
for (var i = 0; i < radios.length; i++) {
|
|
||||||
var _this = radios[i];
|
|
||||||
_this.checked = _this.value == prev;
|
|
||||||
radios[i].addEventListener("change", function() {
|
|
||||||
if (this.value !== prev) {
|
|
||||||
prev = this.value;
|
|
||||||
localStorage.setItem("color-scheme", this.value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
var button = document.getElementById("clear-color-scheme");
|
|
||||||
button.addEventListener("click", function() {
|
|
||||||
for (var i = 0; i < radios.length; i++) {
|
|
||||||
var _this = radios[i];
|
|
||||||
_this.checked = false;
|
|
||||||
localStorage.removeItem("color-scheme");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
<!-- End of component for color scheme selection -->
|
<!-- End of component for color scheme selection -->
|
||||||
|
|
|
||||||
|
|
@ -16,15 +16,6 @@
|
||||||
```
|
```
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<script>
|
<script src="/nonoscript.js">
|
||||||
function nonoscriptImplementer() {
|
|
||||||
var nonoscript = document.getElementsByClassName("nonoscript");
|
|
||||||
console.log(nonoscript);
|
|
||||||
for (let item of nonoscript) {
|
|
||||||
console.log("meep!");
|
|
||||||
item.classList.remove("nonoscript");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
window.onload = nonoscriptImplementer();
|
|
||||||
</script>
|
</script>
|
||||||
<!-- End of component for no-noscript -->
|
<!-- End of component for no-noscript -->
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue