File: site.js

package info (click to toggle)
node-neo-async 2.6.2%2B~cs3.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,460 kB
  • sloc: javascript: 30,370; makefile: 18
file content (108 lines) | stat: -rw-r--r-- 3,070 bytes parent folder | download | duplicates (2)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* global anchors */

// add anchor links to headers
anchors.options.placement = 'left';
anchors.add('h3');

// Filter UI
var tocElements = document.getElementById('toc')
  .getElementsByTagName('li');

document.getElementById('filter-input')
  .addEventListener('keyup', function (e) {

    var i, element, children;

    // enter key
    if (e.keyCode === 13) {
      // go to the first displayed item in the toc
      for (i = 0; i < tocElements.length; i++) {
        element = tocElements[i];
        if (!element.classList.contains('display-none')) {
          location.replace(element.firstChild.href);
          return e.preventDefault();
        }
      }
    }

    var match = function () {
      return true;
    };

    var value = this.value.toLowerCase();

    if (!value.match(/^\s*$/)) {
      match = function (element) {
        return element.firstChild.innerHTML.toLowerCase().indexOf(value) !== -1;
      };
    }

    for (i = 0; i < tocElements.length; i++) {
      element = tocElements[i];
      children = Array.from(element.getElementsByTagName('li'));
      if (match(element) || children.some(match)) {
        element.classList.remove('display-none');
      } else {
        element.classList.add('display-none');
      }
    }
  });

var toggles = document.getElementsByClassName('toggle-step-sibling');
for (var i = 0; i < toggles.length; i++) {
  toggles[i].addEventListener('click', toggleStepSibling);
}

function toggleStepSibling() {
  var stepSibling = this.parentNode.parentNode.parentNode.getElementsByClassName('toggle-target')[0];
  var klass = 'display-none';
  if (stepSibling.classList.contains(klass)) {
    stepSibling.classList.remove(klass);
    stepSibling.innerHTML = '▾';
  } else {
    stepSibling.classList.add(klass);
    stepSibling.innerHTML = '▸';
  }
}

var items = document.getElementsByClassName('toggle-sibling');
for (var j = 0; j < items.length; j++) {
  items[j].addEventListener('click', toggleSibling);
}

function toggleSibling() {
  var stepSibling = this.parentNode.getElementsByClassName('toggle-target')[0];
  var icon = this.getElementsByClassName('icon')[0];
  var klass = 'display-none';
  if (stepSibling.classList.contains(klass)) {
    stepSibling.classList.remove(klass);
    icon.innerHTML = '▾';
  } else {
    stepSibling.classList.add(klass);
    icon.innerHTML = '▸';
  }
}

function showHashTarget(targetId) {
  var hashTarget = document.getElementById(targetId);
  // new target is hidden
  if (hashTarget && hashTarget.offsetHeight === 0 &&
    hashTarget.parentNode.parentNode.classList.contains('display-none')) {
    hashTarget.parentNode.parentNode.classList.remove('display-none');
  }
}

window.addEventListener('hashchange', function() {
  showHashTarget(location.hash.substring(1));
});

showHashTarget(location.hash.substring(1));

var toclinks = document.getElementsByClassName('pre-open');
for (var k = 0; k < toclinks.length; k++) {
  toclinks[k].addEventListener('mousedown', preOpen, false);
}

function preOpen() {
  showHashTarget(this.hash.substring(1));
}