mirror of
https://github.com/kristoferssolo/kristofersxyz.git
synced 2025-10-21 18:30:34 +00:00
Added jQuery
This commit is contained in:
parent
87424d64d3
commit
d977897ccd
@ -1,27 +1,31 @@
|
|||||||
|
$(document).ready(function() {
|
||||||
let lightmode = localStorage.getItem("lightmode")
|
let lightmode = localStorage.getItem("lightmode")
|
||||||
const HTML = document.documentElement
|
const HTML = $("html")
|
||||||
const AUDIO = document.getElementById("flashbang")
|
const AUDIO = $("#flashbang")
|
||||||
|
|
||||||
const ENABLE_LIGHT_MODE = () => {
|
const enable_light_mode = () => {
|
||||||
HTML.setAttribute("data-color-mode", "light")
|
HTML.attr("data-color-mode", "light")
|
||||||
|
$("meta[name='color-scheme']").attr("content", "light")
|
||||||
localStorage.setItem("lightmode", "enabled")
|
localStorage.setItem("lightmode", "enabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
const DISABLE_LIGHT_MODE = () => {
|
const disable_light_mode = () => {
|
||||||
HTML.setAttribute("data-color-mode", "dark")
|
HTML.attr("data-color-mode", "dark")
|
||||||
|
$("meta[name='color-scheme']").attr("content", "dark")
|
||||||
localStorage.setItem("lightmode", null)
|
localStorage.setItem("lightmode", null)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lightmode === "enabled") {
|
if (lightmode === "enabled") {
|
||||||
ENABLE_LIGHT_MODE()
|
enable_light_mode()
|
||||||
}
|
}
|
||||||
|
|
||||||
document.querySelector("#color-mode-toggle").addEventListener("click", () => {
|
$("#color-mode-toggle").click(() => {
|
||||||
lightmode = localStorage.getItem("lightmode")
|
lightmode = localStorage.getItem("lightmode")
|
||||||
if (lightmode !== "enabled") {
|
if (lightmode !== "enabled") {
|
||||||
ENABLE_LIGHT_MODE()
|
enable_light_mode()
|
||||||
AUDIO.play()
|
AUDIO[0].play()
|
||||||
} else {
|
} else {
|
||||||
DISABLE_LIGHT_MODE()
|
disable_light_mode()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
<html lang="en" data-color-mode="dark">
|
<html lang="en" data-color-mode="dark">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="color-scheme" content="dark light">
|
<meta name="color-scheme" content="dark">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<link rel="icon" href="{% static 'main/img/icons/logo.svg' %}" />
|
<link rel="icon" href="{% static 'main/img/icons/logo.svg' %}" />
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
@ -28,6 +28,7 @@
|
|||||||
<link rel="stylesheet"
|
<link rel="stylesheet"
|
||||||
type="text/css"
|
type="text/css"
|
||||||
href="{% static 'main/css/layout.css' %}"/>
|
href="{% static 'main/css/layout.css' %}"/>
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
|
||||||
<script src="{% static 'main/js/navigation.js' %}" defer></script>
|
<script src="{% static 'main/js/navigation.js' %}" defer></script>
|
||||||
<script src="{% static 'main/js/lightmode.js' %}" defer></script>
|
<script src="{% static 'main/js/lightmode.js' %}" defer></script>
|
||||||
{% block meta %}{% endblock %}
|
{% block meta %}{% endblock %}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user