95173a0f33
* Should fix old uploader name in torrent view * Fix "save changes" in modtools * Modtool more colorful * Fix search bar placement in modpanel * Make colors more consistent; less would be super helpful tbqach fam * Display the old username if it's there * Fix some admin index html * Add custom icons and remove png code from all CSS * Move a good amount of cosmetic code from main to classic * Fix some weird bug with point-events; add some global icon formatting; fix mascot fucking up * Spruce up admin panel with icons on smaller viewports, along with adding trash icon * 404 redesign ;^) * Mufuyu mascot on all themes; says something slightly lewd * Fix weird user menu bug where shit would overflow
87 lignes
2,8 Kio
JavaScript
87 lignes
2,8 Kio
JavaScript
// @source https://github.com/NyaaPantsu/nyaa/tree/dev/public/js
|
|
// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat
|
|
var explosion = document.getElementById("explosion");
|
|
var nyanpassu = document.getElementById("nyanpassu");
|
|
var kawaii = document.getElementById("kawaii");
|
|
|
|
// Switches between themes when a new one is selected
|
|
function switchThemes(){
|
|
themeName = document.getElementById("theme-selector").value
|
|
var head = document.getElementsByTagName("head")[0];
|
|
// Remove the theme in place, it fails if one isn't set
|
|
try{
|
|
head.removeChild(document.getElementById("theme"));
|
|
} catch(err){}
|
|
// Don't add a node if we don't want extra styling
|
|
if(themeName === ""){
|
|
return;
|
|
}
|
|
// Create the new one and put it back
|
|
var newTheme = document.createElement("link");
|
|
newTheme.setAttribute("rel", "stylesheet");
|
|
newTheme.setAttribute("href", "/css/"+ themeName + ".css");
|
|
newTheme.setAttribute("id", "theme");
|
|
head.appendChild(newTheme);
|
|
}
|
|
|
|
// Used by spoiler tags
|
|
function toggleLayer(elem) {
|
|
if (elem.classList.contains("hide"))
|
|
elem.classList.remove("hide");
|
|
else
|
|
elem.classList.add("hide");
|
|
}
|
|
function parseAllDates() {
|
|
// Date formatting
|
|
var lang = document.getElementsByTagName("html")[0].getAttribute("lang");
|
|
var ymdOpt = { year: "numeric", month: "short", day: "numeric" };
|
|
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);
|
|
}
|
|
}
|
|
|
|
parseAllDates();
|
|
|
|
/*Fixed-Navbar offset fix*/
|
|
document.addEventListener("DOMContentLoaded", function(event) {
|
|
var shiftWindow = function() { scrollBy(0, -70) };
|
|
if (location.hash) shiftWindow();
|
|
window.addEventListener("hashchange", shiftWindow);
|
|
|
|
document.getElementsByClassName("search-box")[0].addEventListener("focus", function (e) {
|
|
var w = document.getElementsByClassName("h-user")[0].offsetWidth;
|
|
document.getElementsByClassName("h-user")[0].style.display = "none";
|
|
document.getElementsByClassName("search-box")[0].style.width = document.getElementsByClassName("search-box")[0].offsetWidth + w + "px";
|
|
});
|
|
document.getElementsByClassName("search-box")[0].addEventListener("blur", function (e) {
|
|
document.getElementsByClassName("search-box")[0].style.width = "";
|
|
document.getElementsByClassName("h-user")[0].style.display = "inline-block";
|
|
});
|
|
});
|
|
|
|
function playVoice() {
|
|
if (explosion) {
|
|
explosion.play();
|
|
}
|
|
else if (kawaii) {
|
|
kawaii.volume = 0.7;
|
|
kawaii.play();
|
|
}
|
|
else {
|
|
nyanpassu.volume = 0.5;
|
|
nyanpassu.play();
|
|
}
|
|
}
|
|
// @license-end
|