INNER CODE UNIT · JavaScript

updatehistory

bitcoin-dot-org/Bitcoin.org · js/main.js:288

    function updatehistory() {
        // Don't call window.history if not supported.
        if (!window.history || !window.history.replaceState) return;
        // Don't update window url when it doesn't need to be updated.
        if (new RegExp('#' + closer[0].id + '$').test(window.location.href.toString())) return;
        // Don't update window url when the window is over the first title in the page.
        if (pageoffset < first[1]) return;
        // Don't update window url when page is not loaded, or user just clicked a url.
        if (!toc.hasAttribute('data-timestamp') || toc.getAttribute('data-timestamp') > new Date().getTime() - 1000) return;
        window.history.replaceState(null, null, '#' + closer[0].id);
    }
    // Reset timestamp on page load and each time the user clicks a url.
    function evtimestamp() {
        toc = document.getElementById('toc');
        document.getElementById('toc').setAttribute('data-timestamp', new Date().getTime());
    }
    addEvent(window, 'scroll', init);
    addEvent(window, 'popstate', evtimestamp);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…