Last active
May 3, 2021 06:19
-
-
Save aswinsekar/cf41e2104613178db25b1385ddaa7eb6 to your computer and use it in GitHub Desktop.
Routing code for Flourish book - https://flourishbooks.app/credits/ credits page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
if (location.href.indexOf("credits") !== -1) { | |
if (location.hash.length) { | |
var hash = location.hash; | |
var book = hash.split("-"); | |
var hashFinalDone = false; | |
if (book[0]) { | |
book = book[0].split("#book")[1]; | |
book = parseInt(book[0]); | |
if (isNaN(book)) { | |
book = 1; | |
} | |
} | |
location.hash = "#book" + book; | |
function hashHandler() { | |
if (!hashFinalDone) { | |
location.hash = hash; | |
hashFinalDone = true; | |
} | |
window.removeEventListener("hashchange", hashHandler); | |
} | |
window.addEventListener("hashchange", hashHandler, false); | |
setTimeout(hashHandler, 2000); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment