Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Use template for night theme switcher inline js

Cette révision appartient à :
tomleb 2017-05-11 17:58:41 -04:00 révisé par Austin
Parent a502dd8c3f
révision 34933e0b82
3 fichiers modifiés avec 16 ajouts et 24 suppressions

14
templates/_night_theme.html Fichier normal
Voir le fichier

@ -0,0 +1,14 @@
{{define "night_theme_init"}}
<script type="text/javascript">
// Night mode
var night = localStorage.getItem("night");
var darkStyleLink = document.createElement('link');
darkStyleLink.id = "style-dark";
darkStyleLink.rel = "stylesheet";
darkStyleLink.type = "text/css";
darkStyleLink.href = "/css/style-night.css"
if (night == "true") {
document.getElementsByTagName("head")[0].append(darkStyleLink);
}
</script>
{{end}}

Voir le fichier

@ -26,18 +26,7 @@
<!-- Website CSS --> <!-- Website CSS -->
<link rel="stylesheet" id="style" href="{{.URL.Parse "/css/style.css"}}"> <link rel="stylesheet" id="style" href="{{.URL.Parse "/css/style.css"}}">
<script type="text/javascript"> {{block "night_theme_init" .}}{{end}}
// Night mode
var night = localStorage.getItem("night");
var darkStyleLink = document.createElement('link');
darkStyleLink.id = "style-dark";
darkStyleLink.rel = "stylesheet";
darkStyleLink.type = "text/css";
darkStyleLink.href = "/css/style-night.css"
if (night == "true") {
document.getElementsByTagName("head")[0].append(darkStyleLink);
}
</script>
</head> </head>
<body> <body>
<nav class="navbar navbar-default" id="mainmenu"> <nav class="navbar navbar-default" id="mainmenu">

Voir le fichier

@ -30,18 +30,7 @@
<!-- Website CSS --> <!-- Website CSS -->
<link rel="stylesheet" id="style" href="{{.URL.Parse "/css/style.css"}}"> <link rel="stylesheet" id="style" href="{{.URL.Parse "/css/style.css"}}">
<script type="text/javascript"> {{block "night_theme_init" .}}{{end}}
// Night mode
var night = localStorage.getItem("night");
var darkStyleLink = document.createElement('link');
darkStyleLink.id = "style-dark";
darkStyleLink.rel = "stylesheet";
darkStyleLink.type = "text/css";
darkStyleLink.href = "/css/style-night.css"
if (night == "true") {
document.getElementsByTagName("head")[0].append(darkStyleLink);
}
</script>
</head> </head>
<body> <body>
<nav class="navbar navbar-default" id="mainmenu"> <nav class="navbar navbar-default" id="mainmenu">