72 lines
2.1 KiB
JavaScript
72 lines
2.1 KiB
JavaScript
'use strict';
|
|
function reverse(str) { return str.split("").reverse().join(""); }
|
|
function getName() { return "nomis"; }
|
|
function getAt() { return "@"; }
|
|
function getDomain() { return "okew"; }
|
|
function getDot() { return "."; }
|
|
function getTld() { return "oi"; }
|
|
function getAddress() { return reverse(getName()) + getAt() + reverse(getDomain()) + getDot() + reverse(getTld()); }
|
|
|
|
function comments(elm) {
|
|
var link = document.getElementById('comment-add');
|
|
link.href = "mai" + "lto:" + getAddress() + "?subject=" + link.dataset.title;
|
|
elm.remove();
|
|
}
|
|
|
|
function contact() {
|
|
var link = document.getElementById('contact');
|
|
link.href = "mai" + "lto:" + getAddress();
|
|
}
|
|
|
|
// function menu() {
|
|
// var button = document.getElementById('menu-button'),
|
|
// menu = document.getElementById('menu');
|
|
//
|
|
// button.onclick = function () {
|
|
// if (document.body.classList.contains('menu-open')) {
|
|
// document.body.classList.remove('menu-open');
|
|
// } else {
|
|
// window.scroll({ top: 0, left: 0 });
|
|
// document.body.classList.add('menu-open');
|
|
// }
|
|
// };
|
|
// }
|
|
|
|
function changeTheme() {
|
|
// https://css-tricks.com/a-complete-guide-to-dark-mode-on-the-web/#using-javascript-local-storage
|
|
const btn = document.querySelector(".btn-toggle");
|
|
const prefersDarkScheme = window.matchMedia("(prefers-color-scheme: dark)");
|
|
|
|
const currentTheme = localStorage.getItem("theme");
|
|
|
|
if (currentTheme == "dark") {
|
|
document.body.classList.toggle("dark-theme");
|
|
} else if (currentTheme == "light") {
|
|
document.body.classList.toggle("light-theme");
|
|
}
|
|
|
|
btn.addEventListener("click", function () {
|
|
if (prefersDarkScheme.matches) {
|
|
document.body.classList.toggle("light-theme");
|
|
var theme = document.body.classList.contains("light-theme")
|
|
? "light"
|
|
: "dark";
|
|
} else {
|
|
document.body.classList.toggle("dark-theme");
|
|
var theme = document.body.classList.contains("dark-theme")
|
|
? "dark"
|
|
: "light";
|
|
}
|
|
|
|
localStorage.setItem("theme", theme);
|
|
});
|
|
}
|
|
|
|
function main() {
|
|
// menu();
|
|
contact();
|
|
changeTheme();
|
|
}
|
|
|
|
main();
|