Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Keeping Mascot hidden

Should fix #808
* Mascot hide is kept while navigating with a localstorage value
Cette révision appartient à :
akuma06 2017-05-29 13:12:05 +02:00
Parent f5f240f2d6
révision dd03550c66
2 fichiers modifiés avec 105 ajouts et 97 suppressions

Voir le fichier

@ -72,7 +72,7 @@ for(var i in list) {
e.innerText = new Date(e.innerText).toLocaleString(lang);
}
/*Fixed-Navbar offset fix*/
window.onload = function() {
document.addEventListener("DOMContentLoaded", function(event) {
var shiftWindow = function() { scrollBy(0, -70) };
if (location.hash) shiftWindow();
window.addEventListener("hashchange", shiftWindow);
@ -86,7 +86,16 @@ window.onload = function() {
document.getElementsByClassName("search-box")[0].style.width = "";
document.getElementsByClassName("h-user")[0].style.display = "inline-block";
});
};
// Keep mascot hiding choice
var hideMascot = (localStorage.getItem("hide_mascot") == "true")
if (hideMascot) {
var btn = document.getElementById("mascotKeepHide");
btn.innerHTML = "Mascot";
document.getElementById("mascot").className = "hide";
btn.value = "show";
}
});
function playVoice() {
if (explosion) {
@ -97,3 +106,18 @@ function playVoice() {
nyanpassu.play();
}
}
function toggleMascot(btn) {
var state= btn.value;
if (state == "hide") {
btn.innerHTML = "Mascot";
document.getElementById("mascot").className = "hide";
btn.value = "show";
localStorage.setItem("hide_mascot", "true")
} else {
btn.innerHTML = "Mascot";
document.getElementById("mascot").className = "";
btn.value = "hide";
localStorage.setItem("hide_mascot", "false")
}
}

Voir le fichier

@ -22,21 +22,6 @@
<!-- Search Box for Google -->
<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebSite","url":"https://nyaa.pantsu.cat/","potentialAction":{"@type":"SearchAction","target":"https://nyaa.pantsu.cat/search?q={search_term_string}","query-input":"required name=search_term_string"}}</script>
<script>
// We need this inline javascript for preventing theme flickering
function toggleMascot(btn) {
var state= btn.value;
if (state == "hide") {
btn.innerHTML = "Mascot";
document.getElementById("mascot").className = "hide";
btn.value = "show";
} else {
btn.innerHTML = "Mascot";
document.getElementById("mascot").className = "";
btn.value = "hide";
}
}
</script>
{{ block "additional_header" .}}{{end}}
</head>
<body {{if Sukebei}}class="sukebei"{{end}}>
@ -68,11 +53,11 @@
</div>
</div>
</nav>
<div id="content">
<div id="content">
<div class="content container center">
{{block "content" .}}{{call $.T "nothing_here"}}{{end}}
</div>
<div id="mascot" class="hide-xs" onclick="playVoice();"></div>
<div id="mascot" class="hide-xs" onclick="playVoice();"></div>
{{ if eq .Theme "tomorrow" }}
<audio id="explosion" hidden preload="none">
<source src="https://megumin.love/sounds/explosion.mp3" type="audio/mpeg">
@ -84,13 +69,12 @@
{{end}}
<div class="pagination">
{{ genNav .Navigation .URL 15 }}
</div>
<footer id="footer">
</div>
<footer id="footer">
<div class="container footer center">
<div class="footer-opt">
<button class="form-input btn" onclick="toggleMascot(this)" value="hide"><span class="oi" data-glyph="eye"></span> Mascot</button>
<button class="form-input btn" id="mascotKeepHide" onclick="toggleMascot(this)" value="hide"><span class="oi" data-glyph="eye"></span> Mascot</button>
<p><a href="/settings">Change Settings</a></p>
</div>
@ -98,8 +82,8 @@
</div>
</footer>
</div>
</div>
<script type="text/javascript" charset="utf-8" src="{{.URL.Parse "/js/main.js"}}?v=3"></script>
{{ block "footer_js" .}}{{end}}
</body>
</body>
</html>