1var arr = []; 2 3if(typeof SELECT_DATA == 'undefined') { 4 SELECT_DATA = []; 5} 6 7for(var i in SELECT_DATA) { 8 // Copy to avoid referencing. 9 var item = SELECT_DATA[i].item; 10 11 arr[i] = SELECT_DATA[i]; 12 arr[i].item = []; 13 14 for(var x in item) { 15 arr[i].item[x] = item[x]; 16 } 17} 18 19SELECT_DATA = arr; 20 21function selectActions() { 22 var select_base = document.querySelector('#select-base'); 23 24 select_base.onchange = function (event) { 25 var select = event.target; 26 var selected = select.options[select.selectedIndex]; 27 var index = selected.dataset.index; 28 var items = SELECT_DATA[index].item; 29 30 var secondaryElement = document.querySelector('#select-secondary'); 31 secondaryElement.innerHTML = ''; 32 33 items.unshift({ 34 id: null, 35 name: 'Choose a field guide.' 36 }); 37 38 for (var i in items) { 39 var option = document.createElement('option'); 40 option.text = items[i].name.replace(/&/g, '&').replace(/&/g, '&').replace(/$#8217;/g, '\''); 41 option.value = items[i].id; 42 option.dataset.index = i; 43 44 secondaryElement.appendChild(option); 45 } 46 }; 47} 48 49function selectSubmission() { 50 document.querySelector('button.cs-submit').onclick = function (event) { 51 event.preventDefault(); 52 53 var items = SELECT_DATA; 54 var targetUrl = ''; 55 var hubEl = document.querySelectorAll('select[name=choose_hub]'); 56 57 for (var i in hubEl) { 58 if (typeof hubEl[i] !== 'object') { 59 break; 60 } 61 62 if (hubEl[i].selectedOptions.length <= 0) { 63 continue; 64 } 65 66 var index = hubEl[i].selectedOptions[0].dataset.index; 67 68 if (typeof index === 'undefined') { 69 continue; 70 } 71 72 if (typeof items[index].permalink !== 'undefined') { 73 targetUrl = items[index].permalink; 74 } 75 76 if (typeof items[index].item !== 'undefined') { 77 items = items[index].item; 78 } 79 } 80 81 window.location.replace(targetUrl); 82 }; 83} 84 85function init() { 86 var select_base = document.querySelector('#select-base'); 87 88 if (!select_base) { 89 return; 90 } 91 92 selectActions(); 93 selectSubmission(); 94}; 95 96init();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.