PageSourceSearch

https://www.graphicsjs.org/_core/js/src/pages/history/index.js

js graphicsjs.org collected 2026-09-25 21:44:49 UTC 1,683 bytes, 58 lines download raw bytes

1import 'bootstrap/js/collapse';
2
3$(document).on(
4  'shown.bs.collapse',
5  '#accordion .panel-collapse',
6  /** @this {*} */function handler() {
7    const url = window.location.href;
8
9    const $panel = $(this);
10    const $panelHeading = $panel.prev();
11    const $navbar = $('.header');
12
13    const $version = $panel.attr('id').match(/\d+/g).join('.');
14    const pattern = `?version=${$version}`;
15    const historyStr = 'history/';
16
17    if (window.location.href.indexOf(pattern) === -1) {
18      window.history
19        .pushState(
20          null,
21          null,
22          url.substr(0, url.indexOf(historyStr) + historyStr.length) + pattern
23        );
24    }
25
26    setTimeout(() => $('html, body').animate({
27      scrollTop: $panelHeading.offset().top - $navbar.height()
28    }, 400), 400);
29  }
30);
31
32window.addEventListener('load', () => {
33  const url = window.location.href;
34  const pattern = /#version=|\?version=/;
35  const versionToCollapse = url
36    .slice(url.indexOf(url.match(pattern)))
37    .replace(/\./g, '_').match(/([0-9]+)_([0-9]+)_([0-9]+)/);
38  const $accordion = $('.version').find('#accordion');
39
40  if (!$accordion.find('.panel-collapse.collapse').hasClass('in')) {
41    let idToCollapse = '';
42    const idLastVersion = `#${$('#accordion').find('[data-toggle="collapse"]').first().attr('id')}`;
43
44    if ($(versionToCollapse).length) {
45      if (url.indexOf(url.match(pattern)) !== -1) {
46        idToCollapse = `#heading${versionToCollapse[0]}`;
47
48        if ($(idToCollapse).length) {
49          $(idToCollapse).trigger('click');
50        } else {
51          $(idLastVersion).trigger('click');
52        }
53      }
54    } else {
55      $(idLastVersion).trigger('click');
56    }
57  }
58});

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.