Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/public/js/main.js
tomleb b0982f07a6 Change color for bg-danger and fix night theme flickering issue (#370)
* Change color for bg-danger

* Fix annoying flickering with night theme

* use new class instead of overriding bootstrap's
2017-05-11 16:54:53 -05:00

49 lignes
1,3 Kio
JavaScript

var night = localStorage.getItem("night");
function toggleNightMode() {
var night = localStorage.getItem("night");
if(night == "true") {
document.getElementById("style-dark").remove()
} else {
document.getElementsByTagName("head")[0].append(darkStyleLink);
}
localStorage.setItem("night", (night == "true") ? "false" : "true");
}
// Used by spoiler tags
function toggleLayer(elem) {
if (elem.classList.contains("hide"))
elem.classList.remove("hide");
else
elem.classList.add("hide");
}
// Date formatting
function formatDate(date) { // thanks stackoverflow
var monthNames = [
"January", "February", "March",
"April", "May", "June", "July",
"August", "September", "October",
"November", "December"
];
var day = date.getDate();
var monthIndex = date.getMonth();
var year = date.getFullYear();
return day + ' ' + monthNames[monthIndex] + ' ' + year;
}
var list = document.getElementsByClassName("date-short");
for(var i in list) {
var e = list[i];
e.title = e.innerText;
e.innerText = formatDate(new Date(e.innerText));
}
var list = document.getElementsByClassName("date-full");
for(var i in list) {
var e = list[i];
e.title = e.innerText;
var date = new Date(e.innerText);
e.innerText = date.toDateString() + " " + date.toLocaleTimeString();
}