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
|
function choicePageChanger(value, keyCode){
document.location.href = value['detail']['choice']['value'];
}
function initChoicesMenu(obj) {
var w = document.createElement('div');
w.classList.add(...obj.wrapper_classes);
var s = document.createElement('select');
s.classList.add('form-control');
s.setAttribute("name", obj.choices_name);
s.setAttribute("id", obj.choices_id);
w.appendChild(s);
var c = document.getElementById('choices-container');
c.appendChild(w);
var choices_holder = s
var choices = new Choices(choices_holder, {
itemSelectText: '',
choices: obj.data,
});
obj.replace_el.classList.add('hide');
choices_holder.addEventListener('choice', choicePageChanger);
}
document.addEventListener("DOMContentLoaded", function () {
if (typeof(document.getElementById('body-notebook')) != 'undefined' && document.getElementById('body-notebook') != null) {
if (typeof(document.getElementById('choices-container')) != 'undefined' && document.getElementById('choices-container') != null) {
initChoicesMenu({
data: window.nbdata,
wrapper_classes: ['choices-wrapper', 'choices-wrapper-notebooks'],
replace_el: document.getElementById('notebook-list'),
choices_name: "choices-notebooks",
choices_id: "choices-notebooks"
});
initChoicesMenu({
data: window.tagdata,
wrapper_classes: ['choices-wrapper', 'choices-wrapper-tags'],
replace_el: document.getElementById('tags-list'),
choices_name: "choices-tags",
choices_id: "choices-tags"
});
}
}
});
|