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); } 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" }); }