X-Git-Url: https://git.yukkurigames.com/?p=heroik.git;a=blobdiff_plain;f=heroik.js;h=88b1d32b114e57821e0d6faec5bb8c158b46b4e4;hp=401268bdbdf12d9d7eef9cccdee73b5d62001302;hb=73ba41c3716a5c304cfd75982ee2f92785ce1d4e;hpb=f0ceb77ec0706a7efac4bee757be88899d0e925f diff --git a/heroik.js b/heroik.js index 401268b..88b1d32 100644 --- a/heroik.js +++ b/heroik.js @@ -30,11 +30,7 @@ function scrollToId (id) { function open (event) { var href = this.href; var target = this.target === "_parent" ? window.parent : window; - - if (this.getAttribute('href')[0] === "#") - scrollToId(this.getAttribute('href').slice(1)); - else - target.location.href = this.href; + target.location.href = this.href; event.preventDefault(); } @@ -44,6 +40,10 @@ window.addEventListener('load', function () { scrollToId(location.hash.slice(1)); }); +window.addEventListener('hashchange', function () { + scrollToId(location.hash.slice(1)); +}); + window.addEventListener('DOMContentLoaded', function () { if (navigator.standalone) document.body.className += ' standalone'; @@ -58,6 +58,10 @@ function choice (seq) { return seq[(Math.random() * seq.length) | 0]; } +function not (f) { + return function () { return !f.apply(this, arguments); }; +} + function contains (element) { return this.indexOf(element) >= 0; }