aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/assets/js/menu.js
blob: a43b1820c19d17ebe61294ad441c6a89fc6a45e8 (plain)
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
//click menu and move contents to main view
if (!window.hasOwnProperty('frost_menu')) {
  console.log('Registering frost_menu');
  window.frost_menu = true;
  var viewport = document.querySelector('#viewport');
  var root = document.querySelector('#root');
  if (!viewport) console.log('Menu.js: viewport is null');
  if (!root) console.log('Menu.js: root is null');
  var y = new MutationObserver(function(mutations) {
    viewport.removeAttribute('style');
    root.removeAttribute('style');
  });
  y.observe(viewport, {
    attributes: true
  });
  y.observe(root, {
    attributes: true
  });
  var x = new MutationObserver(function(mutations) {
    var menu = document.querySelector('.mSideMenu');
    if (menu !== null) {
      x.disconnect();
      console.log('Found side menu');
      while (root.firstChild)
        root.removeChild(root.firstChild);
      while (menu.childNodes.length) {
        console.log('append');
        viewport.appendChild(menu.childNodes[0]);
      }
      if (typeof Frost !== 'undefined') Frost.emit(0);
      setTimeout(function() {
        y.disconnect();
        console.log('Unhook styler');
      }, 500);
    }
  });
  var jewel = document.querySelector('#mJewelNav');
  if (!jewel) console.log('Menu.js: jewel is null');
  x.observe(jewel, {
    childList: true,
    subtree: true
  });
  var menuA = document.querySelector('#bookmarks_jewel').querySelector('a');
  if (!menuA) console.log('Menu.js: jewel is null')
  menuA.click();
}