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) {
@ -96,4 +105,19 @@ function playVoice() {
nyanpassu.volume = 0.5;
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

@ -1,105 +1,89 @@
<!DOCTYPE html>
<html lang="{{ call $.T "language_code" }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="keywords" content="torrents, cartel, pantsu, anime, manga, sukebei, nyaapassu, horriblesubs, nyaa, hentai, dlsite">
<meta name="description" content='The leading open-source community-based nyaa.se successor, suitable for all anime and manga needs. にゃんぱす~!'>
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>{{if Sukebei}}Sukebei{{else}}Nyaa{{end}} Pantsu - {{block "title" .}}{{ call $.T "error_404" }}{{end}}</title>
<link rel="icon" type="image/png" href="/img/favicon.png?v=3" />
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="keywords" content="torrents, cartel, pantsu, anime, manga, sukebei, nyaapassu, horriblesubs, nyaa, hentai, dlsite">
<meta name="description" content='The leading open-source community-based nyaa.se successor, suitable for all anime and manga needs. にゃんぱす~!'>
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>{{if Sukebei}}Sukebei{{else}}Nyaa{{end}} Pantsu - {{block "title" .}}{{ call $.T "error_404" }}{{end}}</title>
<link rel="icon" type="image/png" href="/img/favicon.png?v=3" />
<!-- RSS Feed with Context -->
<link href="{{ block "rss_link" . }}{{ genRouteWithQuery "feed" .URL }}{{end}}" rel="alternate" type="application/rss+xml" title="Nyaa Pantsu - {{block "rsstitle" .}}Last torrents{{end}} RSS Feed" />
<!-- do NOT move -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
<!-- Base theme -->
<link rel="stylesheet" id="style" href="{{.URL.Parse "/css/main.css"}}?v=2">
<!-- User selected theme, if any -->
{{if $.Theme}}<link rel="stylesheet" id="theme" href="/css/{{$.Theme}}.css">{{end}}
<!-- RSS Feed with Context -->
<link href="{{ block "rss_link" . }}{{ genRouteWithQuery "feed" .URL }}{{end}}" rel="alternate" type="application/rss+xml" title="Nyaa Pantsu - {{block "rsstitle" .}}Last torrents{{end}} RSS Feed" />
<!-- do NOT move -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
<!-- Base theme -->
<link rel="stylesheet" id="style" href="{{.URL.Parse "/css/main.css"}}?v=2">
<!-- User selected theme, if any -->
{{if $.Theme}}<link rel="stylesheet" id="theme" href="/css/{{$.Theme}}.css">{{end}}
<!-- 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>
<!-- 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>
{{ block "additional_header" .}}{{end}}
</head>
</head>
<body {{if Sukebei}}class="sukebei"{{end}}>
<nav id="header" class="header">
<div class="container">
<div class="h-left">
<div class="h-logo">
<a href="{{.URL.Parse "/"}}"><img class="hide-md" src="/img/{{if Sukebei}}sukebei_logo.png{{else}}logo.png{{end}}" alt="NyaaPantsu"><img class="visible-md" src="/img/logo_s.png"/></a>
<nav id="header" class="header">
<div class="container">
<div class="h-left">
<div class="h-logo">
<a href="{{.URL.Parse "/"}}"><img class="hide-md" src="/img/{{if Sukebei}}sukebei_logo.png{{else}}logo.png{{end}}" alt="NyaaPantsu"><img class="visible-md" src="/img/logo_s.png"/></a>
</div>
<div class="h-nav">
<a href="{{.URL.Parse "/upload"}}" class="nav-btn"><div class="upload-icon visible-md"></div><span class="hide-md">{{ call $.T "upload" }}</span></a>
<a href="{{ genRouteWithQuery "feed" .URL }}" class="nav-btn"><div class="rss-icon visible-md"></div><span class="hide-md">RSS</span></a>
<a href="{{.URL.Parse "/faq"}}" class="nav-btn"><div class="faq-icon visible-md"></div><span class="hide-md">{{ call $.T "faq" }}</span></a>
{{if Sukebei}}
<a href="//nyaa.pantsu.cat" class="nav-btn"><div class="fun-icon visible-md"></div><span class="hide-md">{{ call $.T "fun" }}</span></a>
{{else}}
<a href="//sukebei.pantsu.cat" class="nav-btn"><div class="fap-icon visible-md"></div><span class="hide-md">{{ call $.T "fap" }}</span></a>
{{end}}
</div>
</div>
<div class="h-right">
{{block "badge_user" .}}{{end}}
<div class="h-search">
<form role="search" action="/search" method="get">
{{block "search_common" .}}{{end}}
{{block "search_button" .}}{{end}}
</form>
</div>
<div class="h-nav">
<a href="{{.URL.Parse "/upload"}}" class="nav-btn"><div class="upload-icon visible-md"></div><span class="hide-md">{{ call $.T "upload" }}</span></a>
<a href="{{ genRouteWithQuery "feed" .URL }}" class="nav-btn"><div class="rss-icon visible-md"></div><span class="hide-md">RSS</span></a>
<a href="{{.URL.Parse "/faq"}}" class="nav-btn"><div class="faq-icon visible-md"></div><span class="hide-md">{{ call $.T "faq" }}</span></a>
{{if Sukebei}}
<a href="//nyaa.pantsu.cat" class="nav-btn"><div class="fun-icon visible-md"></div><span class="hide-md">{{ call $.T "fun" }}</span></a>
{{else}}
<a href="//sukebei.pantsu.cat" class="nav-btn"><div class="fap-icon visible-md"></div><span class="hide-md">{{ call $.T "fap" }}</span></a>
{{end}}
</div>
</div>
<div class="h-right">
{{block "badge_user" .}}{{end}}
<div class="h-search">
<form role="search" action="/search" method="get">
{{block "search_common" .}}{{end}}
{{block "search_button" .}}{{end}}
</form>
</div>
</div>
</nav>
<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>
{{ if eq .Theme "tomorrow" }}
<audio id="explosion" hidden preload="none">
<source src="https://megumin.love/sounds/explosion.mp3" type="audio/mpeg">
</audio>
{{ else }}
<audio id="nyanpassu" hidden preload="none">
<source src="https://a.doko.moe/sewang.mp3" type="audio/mpeg">
</audio>
{{end}}
<div class="pagination">
{{ genNav .Navigation .URL 15 }}
</div>
<footer id="footer">
<div class="container footer center">
<div class="footer-opt">
<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>
<span><i>Powered by <a href="#">NyaaPantsu</a></i></span>
</div>
</footer>
</div>
</nav>
<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>
{{ if eq .Theme "tomorrow" }}
<audio id="explosion" hidden preload="none">
<source src="https://megumin.love/sounds/explosion.mp3" type="audio/mpeg">
</audio>
{{ else }}
<audio id="nyanpassu" hidden preload="none">
<source src="https://a.doko.moe/sewang.mp3" type="audio/mpeg">
</audio>
{{end}}
<div class="pagination">
{{ genNav .Navigation .URL 15 }}
</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>
<p><a href="/settings">Change Settings</a></p>
</div>
<span><i>Powered by <a href="#">NyaaPantsu</a></i></span>
</div>
</footer>
</div>
<script type="text/javascript" charset="utf-8" src="{{.URL.Parse "/js/main.js"}}?v=3"></script>
{{ block "footer_js" .}}{{end}}
</body>
</html>
<script type="text/javascript" charset="utf-8" src="{{.URL.Parse "/js/main.js"}}?v=3"></script>
{{ block "footer_js" .}}{{end}}
</body>
</html>