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
akuma06 80ab45d81e New profile user menu (#761)
* Fixing user profile page

* Modified css rule word-break to break-word
* Modified torrents table in user page to look like home listing
* Made the button reset api look like a button according to actual
design
* Modified user menu to have the same spacing accross templates
* User menu is in another template file loaded dynamically

* Fixing the access to userprofile variable

* Menu needs to access the user profile with $.UserProfile
* User Notification template variable removed, instead using user
profile variable

* Reverting back theme flickering fix
2017-05-26 14:33:55 +02:00

57 lignes
1,5 Kio
JavaScript

var explosion = document.getElementById("explosion");
var nyanpassu = document.getElementById("nyanpassu");
function toggleNightMode() {
var night = localStorage.getItem("night");
if(night == "true") {
document.getElementsByTagName("head")[0].removeChild(darkStyleLink);
} else {
document.getElementsByTagName("head")[0].appendChild(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
var lang = document.getElementsByTagName("html")[0].getAttribute("lang");
var ymdOpt = { year: "numeric", month: "2-digit", day: "2-digit" };
var hmOpt = { hour: "numeric", minute: "numeric" };
var list = document.getElementsByClassName("date-short");
for(var i in list) {
var e = list[i];
e.title = e.innerText;
e.innerText = new Date(e.innerText).toLocaleString(lang, ymdOpt);
}
var list = document.getElementsByClassName("date-full");
for(var i in list) {
var e = list[i];
e.title = e.innerText;
e.innerText = new Date(e.innerText).toLocaleString(lang);
}
/*Fixed-Navbar offset fix*/
window.onload = function() {
var shiftWindow = function() { scrollBy(0, -70) };
if (location.hash) shiftWindow();
window.addEventListener("hashchange", shiftWindow);
};
function playVoice() {
switch (theme) {
case "tomorrow.css":
explosion.play();
break;
default:
nyanpassu.volume = 0.5;
nyanpassu.play();
break;
}
}