zhaojs
2023-10-07 74f6db362e1aacb440eacce84e9433de1368a51a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
 
/* Prettyify */
$(document).ready(function () {
    prettyPrint();
});
 
 
/* Scrollspy */
var navHeight = $('.navbar').outerHeight(true) + 10
 
$('body').scrollspy({
    target: '.bs-sidebar',
    offset: navHeight
})
 
 
/* Prevent disabled links from causing a page reload */
$("li.disabled a").click(function () {
    event.preventDefault();
});
 
 
/* Adjust the scroll height of anchors to compensate for the fixed navbar */
window.disableShift = false;
var shiftWindow = function () {
    if (window.disableShift) {
        window.disableShift = false;
    } else {
        /* If we're at the bottom of the page, don't erronously scroll up */
        var scrolledToBottomOfPage = (
            (window.innerHeight + window.scrollY) >= document.body.offsetHeight
        );
        if (!scrolledToBottomOfPage) {
            scrollBy(0, -60);
        };
    };
};
if (location.hash) { shiftWindow(); }
window.addEventListener("hashchange", shiftWindow);
 
 
/* Deal with clicks on nav links that do not change the current anchor link. */
$("ul.nav a").click(function () {
    var href = this.href;
    var suffix = location.hash;
    var matchesCurrentHash = (href.indexOf(suffix, href.length - suffix.length) !== -1);
    if (location.hash && matchesCurrentHash) {
        /* Force a single 'hashchange' event to occur after the click event */
        window.disableShift = true;
        location.hash = '';
    };
});
 
$(document).bind('DOMNodeInserted',
    function (e) {
        if (e.target.id === 'carbonads') {
            $('.bs-sidebar').affix({
                offset: {
                    top: $('#carbonads').height() + 10
                }
            });
        }
    });