aboutsummaryrefslogtreecommitdiff
path: root/haddock-api/resources/html/js-src/init.ts
blob: 4a58b86788e3ef2d687708b78cb874920ab91cfb (plain) (blame)
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
import * as styleMenu from "./style-menu";
import * as detailsHelper from "./details-helper";
import * as quickJump from "./quick-jump";

function onDomReady(callback: () => void) {
  if (document.readyState === 'interactive') {
    callback();
  } else {
    document.addEventListener('readystatechange', () => {
      if (document.readyState === 'interactive') {
        callback();
      }
    });
  }
}

onDomReady(() => {
  document.body.classList.add('js-enabled');
  styleMenu.init();
  detailsHelper.init();
  let head = document.getElementById('head');
  let baseURL = ".";
  if (head !== null) {
    baseURL = head.getAttribute('data-base-url') || '.';
  }
  quickJump.init(baseURL);
});