// combobox.js // External Javascript to extend some HTML like combobox.html allowing for a dynamically created HTML div element "combobox" (ie. dropdown + div contenteditable=true) // November, 2020 // Called via ... // // ... or dropdown populated example as per ... // class Droptext { constructor(combobox) { this.ele = document.createElement('div'); this.ele.id = ('' + combobox).split(';')[0]; if (('' + combobox).indexOf(';') != -1) { this.ele.setAttribute('data-dropinnards', ('' + combobox).split(';')[1]); this.ele.setAttribute('data-optionval', ""); this.ele.setAttribute('data-focusaway', ""); this.ele.setAttribute('contenteditable', true); this.ele.className = "combobox"; this.ele.innerHTML = ('' + combobox).split(';')[1]; // + ""; } } present() { return this.ele.outerHTML.replace('>"; // + ', it is a ' + this.dropinnards; } } var ihs, selconts=[], selcont='', mycombobox=null, obody=null, ofound=false, jiip=0, iip=0, obs=[], ihsobs=[], iqw=0, ihsuff='', isokay=true, ioff=0, alle=[], ialle=0, sparebody=null; ihs = ""; if (document.title != document.title.trim()) { ihsobs = (" ").split('?ddlist='); } else { ihsobs = (document.head.innerHTML + document.body.innerHTML).replace(/\&ddlist\=/g,'?ddlist=').split('?ddlist='); } if (ihsobs.length > 2) { ioff = -1; ihs = decodeURIComponent((document.head.innerHTML + document.body.innerHTML).replace('&ddlist=','?ddlist=').split('?ddlist=')[1].split('&')[0].split('"')[0].split("'")[0]); // + ','; if (document.URL.indexOf('ddlist=' + encodeURIComponent(ihs)) == -1) { if (document.URL.indexOf('?') == -1) { location.href = document.URL.split('#')[0] + '?ddlist=' + encodeURIComponent(ihs); ioff = -11; } else { location.href = document.URL.split('#')[0] + '&ddlist=' + encodeURIComponent(ihs); ioff = -11; } } else { document.title+=' '; } } else if (ihsobs.length == 2) { ioff = -1; } for (iqw=1; iqw<=eval(ioff + eval('' + ihsobs.length)); iqw++) { ihs=""; isokay=true; selconts = location.search.split('ddlist=')[1] ? (ihs + decodeURIComponent(location.search.split('ddlist=')[1].split('&')[0])).split(',') : (ihs + "").split(','); if ((document.head.innerHTML + document.body.innerHTML).replace(/\&ddlist\=/g,'?ddlist=').indexOf('?ddlist=') != -1) { ihs = decodeURIComponent((document.head.innerHTML + document.body.innerHTML).replace(/\&ddlist\=/g,'?ddlist=').split('?ddlist=')[iqw].split('&')[0].split('"')[0].split("'")[0]); // + ','; if (ihs.trim() != '') { selconts = ihs.split(','); } if (ihsobs.length > 2) { isokay = false; if (iqw > 1) { selconts = ihs.split(','); } if (1 == 1 || document.URL.indexOf('ddlist=' + encodeURIComponent(ihsobs[1].split('&')[0].split('"')[0].split("'")[0])) != -1) { isokay=true; } } } if (isokay) { console.log('yay ' + ioff + ' ' + ihsobs.length + ' ' + document.URL); } else { console.log('oops ' + ioff + ' ' + ihsobs.length + ' ' + document.URL + ' versus ' + 'ddlist=' + encodeURIComponent(ihsobs[1].split('&')[0].split('"')[0].split("'")[0])); } if (isokay) { if (selconts[0].indexOf('").replace(" name=selcombo>", " name=selcombo0>"); for (jiip=0; jiip' + selconts[jiip] + ''; } } selcont += ""; console.log('' + iqw + ':' + ihs + ' ' + selcont); if (mycombobox) { eval('mycombobox' + ihsuff + ' = new Contents("", selcont)'); } else { mycombobox = new Contents("", selcont); } } else { console.log('' + iqw + ';'); if (mycombobox) { eval('mycombobox' + ihsuff + ' = new Contents("", selconts[0])'); } else { mycombobox = new Contents("", selconts[0]); } } obody = document.body; sparebody=null; alle=document.getElementsByTagName('*'); for (ialle=0; ialle'; obody = document.getElementById('demo' + ihsuff); } } eval('obody.innerHTML += mycombobox' + ihsuff + '.show()'); document.title+=' '; } ihsuff='' + eval(0 + iqw); }