1// ! import nothing 2// ! no "document ready" code, only functions 3 4class AdmSelectUtils { 5 // NB: select tags must be initialized in JS to prevent FF default behaviour 6 static selectByValue(tag, value) { 7 if (!tag || 'undefined' === typeof tag.options) { 8 console.error('tag not found: ' + tag) 9 return; 10 } 11 12 for (let option, index = 0; index < tag.options.length; ++index) { 13 option = tag.options[index]; 14 if (option.value == value) { 15 tag.selectedIndex = index; 16 break; 17 } 18 } 19 } 20 21 static selectValueFromTagId(tagId, value) { 22 const tag = document.getElementById(tagId); 23 if (tag) { 24 AdmSelectUtils.selectByValue(tag, value); 25 } 26 } 27 28 // NB: select tags must be initialized in JS to prevent FF default behaviour 29 static selectByText(tag, text) { 30 if (!tag || 'undefined' === typeof tag.options) { 31 return; 32 } 33 34 for (let option, index = 0; index < tag.options.length; ++index) { 35 option = tag.options[index]; 36 if (option.text.trim() == text) { 37 tag.selectedIndex = index; 38 break; 39 } 40 } 41 } 42 43 static selectedValueByTagId(tagId) { 44 const tag = document.getElementById(tagId); 45 return tag ? tag.options[tag.selectedIndex].value : null; 46 } 47 48 static selectedValueByTag(tag) { 49 return tag ? tag.options[tag.selectedIndex].value : null; 50 } 51 52 static selectedTextByTagId(tagId) { 53 const tag = document.getElementById(tagId); 54 return tag ? tag.options[tag.selectedIndex].text : null; 55 } 56} 57 58export default AdmSelectUtils;
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.