1(function () { 2 'use strict'; 3 4 function initAreaList(areaEl, region2optionEls) { 5 var i; 6 var length; 7 var childEls = areaEl.children; 8 var optgroupEl; 9 var optionEl; 10 var documentFragment; 11 var toBeRemoved = []; 12 13 for (i = 0, length = childEls.length; i < length; i++) { 14 optgroupEl = childEls[i]; 15 16 if (optgroupEl.nodeName.toUpperCase() !== 'OPTGROUP') { 17 continue; 18 } 19 20 documentFragment = document.createDocumentFragment(); 21 22 while (optgroupEl.firstElementChild) { 23 optionEl = optgroupEl.firstElementChild; 24 documentFragment.appendChild(optionEl); 25 } 26 27 region2optionEls[optgroupEl.label] = documentFragment; 28 toBeRemoved.push(optgroupEl); 29 } 30 31 32 for (i = 0, length = toBeRemoved.length; i < length; i++) { 33 areaEl.removeChild(toBeRemoved[i]); 34 } 35 } 36 37 function updateAreaList(areaEl, region2optionEls, region) { 38 while (areaEl.childElementCount > 1) { 39 areaEl.removeChild(areaEl.lastElementChild); 40 } 41 42 if (region !== '') { 43 if (!region2optionEls.hasOwnProperty(region)) { 44 throw new Error('Unexpected region value: ' + region); 45 } 46 areaEl.appendChild(region2optionEls[region].cloneNode(true)); 47 } 48 } 49 50 function init() { 51 var region2optionEls = {}; 52 var regionEl = document.getElementById('region'); 53 var areaEl = document.getElementById('area'); 54 var buttonEl = document.querySelector('.network-select__paging'); 55 56 if (!regionEl || !areaEl || !buttonEl) { 57 return; 58 } 59 60 initAreaList(areaEl, region2optionEls); 61 62 regionEl.addEventListener('change', function () { 63 updateAreaList(areaEl, region2optionEls, regionEl.value); 64 areaEl.options[0].selected = true; 65 }); 66 67 buttonEl.addEventListener('click', function () { 68 location.href = areaEl.value; 69 }); 70 71 updateAreaList(areaEl, region2optionEls, regionEl.value); 72 } 73 74 init(); 75}());
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.