Skip to content

Instantly share code, notes, and snippets.

@aswinsekar
Last active May 3, 2021 06:19
Show Gist options
  • Save aswinsekar/cf41e2104613178db25b1385ddaa7eb6 to your computer and use it in GitHub Desktop.
Save aswinsekar/cf41e2104613178db25b1385ddaa7eb6 to your computer and use it in GitHub Desktop.
Routing code for Flourish book - https://flourishbooks.app/credits/ credits page
(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