Switch back to replace.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Captain ALM 2022-07-30 23:58:23 +01:00
parent 489ec3a7df
commit b1a6dbe4db
Signed by: alfred
GPG Key ID: 4E4ADD02609997B1

View File

@ -9,11 +9,9 @@ var SortOrderBStateI = true
var SortOrderEnabled = false var SortOrderEnabled = false
var SortValue = "" var SortValue = ""
var OrderValue = "" var OrderValue = ""
var ReplaceNeeded = true
function SetupJS() { function SetupJS() {
SetupIndexArray() SetupIndexArray()
SetupJSTheme() SetupJSTheme()
SetupJSHPL()
SetupJSHSO() SetupJSHSO()
SetupJSSOI() SetupJSSOI()
} }
@ -75,20 +73,11 @@ function SetupJSTheme() {
th.onclick = ToggleTheme th.onclick = ToggleTheme
} }
} }
function PushHistory(url) { function ReplaceHistory(url) {
var s = true var s = true
if (window.history) { if (window.history) {
if (window.history.pushState) { if (window.history.replaceState) {
var objectData = { window.history.replaceState({}, "", url);
light: !!document.getElementById("so-theme"),
order: document.getElementById("so-order").value,
sort: document.getElementById("so-sort").value
};
if (ReplaceNeeded) {
window.history.replaceState(objectData, "", url);
ReplaceNeeded = false
}
window.history.pushState( objectData, "", url);
s = false s = false
} }
} }
@ -109,7 +98,7 @@ function ToggleTheme() {
th.title = "Switch to Light Mode" th.title = "Switch to Light Mode"
document.getElementById("so-form").removeChild(document.getElementById("so-theme")) document.getElementById("so-form").removeChild(document.getElementById("so-theme"))
logo.href = "?" logo.href = "?"
PushHistory(url+"?"+TheParameters+"#") ReplaceHistory(url+"?"+TheParameters+"#")
thsty.href = CssDarkURL thsty.href = CssDarkURL
} else { } else {
thimg.src = MoonImageURL thimg.src = MoonImageURL
@ -122,31 +111,13 @@ function ToggleTheme() {
document.getElementById("so-form").appendChild(thi) document.getElementById("so-form").appendChild(thi)
logo.href = "?light" logo.href = "?light"
if (TheParameters === "") { if (TheParameters === "") {
PushHistory(url+"?light#") ReplaceHistory(url+"?light#")
} else { } else {
PushHistory(url+"?light&"+TheParameters+"#") ReplaceHistory(url+"?light&"+TheParameters+"#")
} }
thsty.href = CssLightURL thsty.href = CssLightURL
} }
} }
function SetupJSHPL(){
if (window.history) {
if (window.history.pushState) {
window.addEventListener("popstate", HandleHistoryPop)
}
}
}
function HandleHistoryPop(event) {
if (event.state) {
SortOrderEnabled = false
var isnl = !document.getElementById("so-theme")
if ((event.state.light && isnl) || (!event.state.light && !isnl)) {ToggleTheme();}
document.getElementById("so-order").value = event.state.order
document.getElementById("so-sort").value = event.state.sort
EntrySort(event.state.order, event.state.sort)
SortOrderEnabled = true
}
}
function SetupJSHSO() { function SetupJSHSO() {
var pb = document.getElementById("sort-menu-button") var pb = document.getElementById("sort-menu-button")
var pane = document.getElementById("so-pane") var pane = document.getElementById("so-pane")
@ -252,9 +223,9 @@ function EntrySort(o, s) {
var url = document.location.href var url = document.location.href
url = url.split("#", 1)[0].split('?', 1)[0] url = url.split("#", 1)[0].split('?', 1)[0]
if (document.getElementById("so-theme")) { if (document.getElementById("so-theme")) {
PushHistory(url+"?light&"+TheParameters) ReplaceHistory(url+"?light&"+TheParameters)
} else { } else {
PushHistory(url+"?"+TheParameters) ReplaceHistory(url+"?"+TheParameters)
} }
for (var i = 0; i < EntryIndices.length; i++) { for (var i = 0; i < EntryIndices.length; i++) {
var tNode = document.getElementById("entry-"+EntryIndices[i]) var tNode = document.getElementById("entry-"+EntryIndices[i])