Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Update main.js (#1366)

Cette révision appartient à :
kilo 2017-08-12 08:52:54 +02:00 révisé par ewhal
Parent 99f93a83be
révision 645a711222

Voir le fichier

@ -139,10 +139,10 @@ function startupCode() {
var startPos = document.cookie.indexOf("theme=") + 6
var endPos = document.cookie.substring(startPos).indexOf(";")
UserTheme = [endPos == "-1" ? document.cookie.substring(startPos) : document.cookie.substring(startPos, endPos + startPos), "tomorrow"]
//Get user's default theme and set the alternative one as tomorrow
//Get user's default theme and set the alternative one as tomorrow
}
else
UserTheme = ["g", "tomorrow"]
UserTheme = ["g", "tomorrow"]
//If user has no default theme, set these by default
@ -150,14 +150,17 @@ function startupCode() {
var startPos = document.cookie.indexOf("theme2=") + 7
var endPos = document.cookie.substring(startPos).indexOf(";")
UserTheme[1] = endPos == "-1" ? document.cookie.substring(startPos) : document.cookie.substring(startPos, endPos + startPos)
//If user already has ran the ToggleTheme() function in the past, we get the value of the second theme (the one the script switches to)
if(!UserTheme.includes("tomorrow"))
UserTheme[1] = "tomorrow"
//If none of the theme are tomorrow, which happens if the user is on dark mode (with theme2 on g.css) and that he switches to classic or g.css in settings, we set the second one as tomorrow
//If user already has ran the ToggleTheme() function in the past, we get the value of the second theme (the one the script switches to)
if(!UserTheme.includes("tomorrow"))
UserTheme[1] = "tomorrow"
//If none of the theme are tomorrow, which happens if the user is on dark mode (with theme2 on g.css) and that he switches to classic or g.css in settings, we set the second one as tomorrow
else if(UserTheme[0] == UserTheme[1])
UserTheme[1] = "g"
//If both theme are tomorrow, which happens if theme2 is on tomorrow (always is by default) and that the user sets tomorrow as his theme through settings page, we set secondary theme to g.css
}
else {
if(UserTheme[0] == UserTheme[1])
UserTheme[1] = "g"
UserTheme[1] = "g"
//If tomorrow is twice in UserTheme, which happens when the user already has tomorrow as his default theme and toggle the dark mode for the first time, we set the second theme as g.css
document.cookie = "theme2=" + UserTheme[1] + ";path=/;domain=pantsu.cat;expires=" + farFutureString()
//Set cookie for future theme2 uses