PageSourceSearch

https://appliedbitlogistics.io/deci/js/base.js

js appliedbitlogistics.io collected 2026-10-08 10:02:39 UTC 7,724 bytes, 283 lines download raw bytes

1function getSearchTerm() {
2    var sPageURL = window.location.search.substring(1);
3    var sURLVariables = sPageURL.split('&');
4    for (var i = 0; i < sURLVariables.length; i++) {
5        var sParameterName = sURLVariables[i].split('=');
6        if (sParameterName[0] == 'q') {
7            return sParameterName[1];
8        }
9    }
10}
11
12function applyTopPadding() {
13    // Update various absolute positions to match where the main container
14    // starts. This is necessary for handling multi-line nav headers, since
15    // that pushes the main container down.
16    var offset = $('body > .container').offset();
17    $('html').css('scroll-padding-top', offset.top + 'px');
18    $('.bs-sidebar.affix').css('top', offset.top + 'px');
19}
20
21$(document).ready(function() {
22
23    applyTopPadding();
24
25    var search_term = getSearchTerm(),
26        $search_modal = $('#mkdocs_search_modal'),
27        $keyboard_modal = $('#mkdocs_keyboard_modal');
28
29    if (search_term) {
30        $search_modal.modal();
31    }
32
33    // make sure search input gets autofocus everytime modal opens.
34    $search_modal.on('shown.bs.modal', function() {
35        $search_modal.find('#mkdocs-search-query').focus();
36    });
37
38    // Close search modal when result is selected
39    // The links get added later so listen to parent
40    $('#mkdocs-search-results').click(function(e) {
41        if ($(e.target).is('a')) {
42            $search_modal.modal('hide');
43        }
44    });
45
46    // Populate keyboard modal with proper Keys
47    $keyboard_modal.find('.help.shortcut kbd')[0].innerHTML = keyCodes[shortcuts.help];
48    $keyboard_modal.find('.prev.shortcut kbd')[0].innerHTML = keyCodes[shortcuts.previous];
49    $keyboard_modal.find('.next.shortcut kbd')[0].innerHTML = keyCodes[shortcuts.next];
50    $keyboard_modal.find('.search.shortcut kbd')[0].innerHTML = keyCodes[shortcuts.search];
51
52    // Keyboard navigation
53    document.addEventListener("keydown", function(e) {
54        if ($(e.target).is(':input')) return true;
55        var key = e.which || e.keyCode || window.event && window.event.keyCode;
56        var page;
57        switch (key) {
58            case shortcuts.next:
59                page = $('.navbar a[rel="next"]:first').prop('href');
60                break;
61            case shortcuts.previous:
62                page = $('.navbar a[rel="prev"]:first').prop('href');
63                break;
64            case shortcuts.search:
65                e.preventDefault();
66                $keyboard_modal.modal('hide');
67                $search_modal.modal('show');
68                $search_modal.find('#mkdocs-search-query').focus();
69                break;
70            case shortcuts.help:
71                $search_modal.modal('hide');
72                $keyboard_modal.modal('show');
73                break;
74            default: break;
75        }
76        if (page) {
77            $keyboard_modal.modal('hide');
78            window.location.href = page;
79        }
80    });
81
82    $('table').addClass('table table-striped table-hover');
83
84    // Improve the scrollspy behaviour when users click on a TOC item.
85    $(".bs-sidenav a").on("click", function() {
86        var clicked = this;
87        setTimeout(function() {
88            var active = $('.nav li.active a');
89            active = active[active.length - 1];
90            if (clicked !== active) {
91                $(active).parent().removeClass("active");
92                $(clicked).parent().addClass("active");
93            }
94        }, 50);
95    });
96
97    function showInnerDropdown(item) {
98        var popup = $(item).next('.dropdown-menu');
99        popup.addClass('show');
100        $(item).addClass('open');
101
102        // First, close any sibling dropdowns.
103        var container = $(item).parent().parent();
104        container.find('> .dropdown-submenu > a').each(function(i, el) {
105            if (el !== item) {
106                hideInnerDropdown(el);
107            }
108        });
109
110        var popupMargin = 10;
111        var maxBottom = $(window).height() - popupMargin;
112        var bounds = item.getBoundingClientRect();
113
114        popup.css('left', bounds.right + 'px');
115        if (bounds.top + popup.height() > maxBottom &&
116            bounds.top > $(window).height() / 2) {
117            popup.css({
118                'top': (bounds.bottom - popup.height()) + 'px',
119                'max-height': (bounds.bottom - popupMargin) + 'px',
120            });
121        } else {
122            popup.css({
123                'top': bounds.top + 'px',
124                'max-height': (maxBottom - bounds.top) + 'px',
125            });
126        }
127    }
128
129    function hideInnerDropdown(item) {
130        var popup = $(item).next('.dropdown-menu');
131        popup.removeClass('show');
132        $(item).removeClass('open');
133
134        popup.scrollTop(0);
135        popup.find('.dropdown-menu').scrollTop(0).removeClass('show');
136        popup.find('.dropdown-submenu > a').removeClass('open');
137    }
138
139    $('.dropdown-submenu > a').on('click', function(e) {
140        if ($(this).next('.dropdown-menu').hasClass('show')) {
141            hideInnerDropdown(this);
142        } else {
143            showInnerDropdown(this);
144        }
145
146        e.stopPropagation();
147        e.preventDefault();
148    });
149
150    $('.dropdown-menu').parent().on('hide.bs.dropdown', function(e) {
151        $(this).find('.dropdown-menu').scrollTop(0);
152        $(this).find('.dropdown-submenu > a').removeClass('open');
153        $(this).find('.dropdown-menu .dropdown-menu').removeClass('show');
154    });
155});
156
157$(window).on('resize', applyTopPadding);
158
159$('body').scrollspy({
160    target: '.bs-sidebar',
161    offset: 100
162});
163
164/* Prevent disabled links from causing a page reload */
165$("li.disabled a").click(function() {
166    event.preventDefault();
167});
168
169// See https://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes
170// We only list common keys below. Obscure keys are omitted and their use is discouraged.
171var keyCodes = {
172    8: 'backspace',
173    9: 'tab',
174    13: 'enter',
175    16: 'shift',
176    17: 'ctrl',
177    18: 'alt',
178    19: 'pause/break',
179    20: 'caps lock',
180    27: 'escape',
181    32: 'spacebar',
182    33: 'page up',
183    34: 'page down',
184    35: 'end',
185    36: 'home',
186    37: '&larr;',
187    38: '&uarr;',
188    39: '&rarr;',
189    40: '&darr;',
190    45: 'insert',
191    46: 'delete',
192    48: '0',
193    49: '1',
194    50: '2',
195    51: '3',
196    52: '4',
197    53: '5',
198    54: '6',
199    55: '7',
200    56: '8',
201    57: '9',
202    65: 'a',
203    66: 'b',
204    67: 'c',
205    68: 'd',
206    69: 'e',
207    70: 'f',
208    71: 'g',
209    72: 'h',
210    73: 'i',
211    74: 'j',
212    75: 'k',
213    76: 'l',
214    77: 'm',
215    78: 'n',
216    79: 'o',
217    80: 'p',
218    81: 'q',
219    82: 'r',
220    83: 's',
221    84: 't',
222    85: 'u',
223    86: 'v',
224    87: 'w',
225    88: 'x',
226    89: 'y',
227    90: 'z',
228    91: 'Left Windows Key / Left ⌘',
229    92: 'Right Windows Key',
230    93: 'Windows Menu / Right ⌘',
231    96: 'numpad 0',
232    97: 'numpad 1',
233    98: 'numpad 2',
234    99: 'numpad 3',
235    100: 'numpad 4',
236    101: 'numpad 5',
237    102: 'numpad 6',
238    103: 'numpad 7',
239    104: 'numpad 8',
240    105: 'numpad 9',
241    106: 'multiply',
242    107: 'add',
243    109: 'subtract',
244    110: 'decimal point',
245    111: 'divide',
246    112: 'f1',
247    113: 'f2',
248    114: 'f3',
249    115: 'f4',
250    116: 'f5',
251    117: 'f6',
252    118: 'f7',
253    119: 'f8',
254    120: 'f9',
255    121: 'f10',
256    122: 'f11',
257    123: 'f12',
258    124: 'f13',
259    125: 'f14',
260    126: 'f15',
261    127: 'f16',
262    128: 'f17',
263    129: 'f18',
264    130: 'f19',
265    131: 'f20',
266    132: 'f21',
267    133: 'f22',
268    134: 'f23',
269    135: 'f24',
270    144: 'num lock',
271    145: 'scroll lock',
272    186: '&semi;',
273    187: '&equals;',
274    188: '&comma;',
275    189: '&hyphen;',
276    190: '&period;',
277    191: '&quest;',
278    192: '&grave;',
279    219: '&lsqb;',
280    220: '&bsol;',
281    221: '&rsqb;',
282    222: '&apos;',
283};

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.