PageSourceSearch

https://bluegrass.ch/clubdesk/v_5.0.21/webpage/in-page-navigation.js

js bluegrass.ch collected 2026-10-02 13:52:17 UTC 2,889 bytes, 87 lines download raw bytes

1function pageUrl(url) {
2    url = url.split("#")[0];
3    if (url.endsWith("/")) {
4        url = url.substring(0, url.length - 1);
5    }
6    return url;
7}
8
9function updateSelection(hash) {
10    $(".cd-menu-active").removeClass("cd-menu-active");
11    $(".cd-menu-selected").removeClass("cd-menu-selected");
12    $(".cd-menu a").each(function (index, element) {
13        if (element.href && pageUrl(element.href) === pageUrl(location.href) && element.hash === hash) {
14            $(element).addClass("cd-menu-active").addClass("cd-menu-selected");
15            var parentId = element.dataset.parentId;
16            while (parentId) {
17                var parent = $(".cd-menu-item").filter("[data-id='" + parentId + "']");
18                parent.addClass("cd-menu-selected");
19                parentId = parent && parent.length ? parent[0].dataset.parentId : null;
20            }
21        }
22    });
23}
24
25function getOffset() {
26    var offset = 0;
27    var scrollOffsetQuery = $(window).width() >= 992 ? ".scroll-offset-desktop" : ".scroll-offset-mobile";
28    $(scrollOffsetQuery).each(function (index, element) {
29        if (this.offsetHeight > offset) {
30            offset = this.offsetHeight;
31        }
32    });
33    return offset;
34}
35
36$(document).ready(function () {
37    var anchors = [];
38    $(".cd-menu a").each(function () {
39        if (this.href && pageUrl(this.href) === pageUrl(location.href) && this.hash && this.hash.length > 1) {
40            var item = $(this.hash);
41            if (item.length && $.inArray(item[0], anchors) === -1) {
42                anchors.push(item[0]);
43            }
44            return this;
45        }
46    });
47
48    var isScrolling = false;
49    var lastId;
50    var updateMenus = function() {
51        if (isScrolling) return;
52
53        // get id of current scroll item
54        var cur = anchors.filter(function(anchor){
55            if ($(anchor).offset().top < $(this).scrollTop() + $(window).height() / 2)
56                return anchor;
57        });
58
59        // get id of the current element
60        cur = cur[cur.length-1];
61        var id = cur ? cur.id : "";
62
63        // update if necessary
64        if (lastId !== id) {
65            lastId = id;
66            updateSelection(id === "" ? "" : "#" + id);
67        }
68    };
69
70    $(window).scroll(updateMenus);
71
72    $("a").on('click', function (event) {
73        if (pageUrl(this.href) === pageUrl(location.href) && !this.classList.contains("cd-menu-expand")) {
74            event.preventDefault();
75            if (isScrolling) return;
76
77            updateSelection(this.hash);
78
79            var position = $(this.hash) && $(this.hash).offset() ? Math.max($(this.hash).offset().top - getOffset(), 0) : 0;
80            history.replaceState({}, '', this.href);
81            isScrolling = true;
82            $('html, body').animate({scrollTop: position}, 1200, function() { isScrolling = false; });
83        }
84    });
85
86    updateMenus();
87});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.