// 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', encodeURIComponent(('' + combobox).split(';')[1].replace('");
this.ele.setAttribute('data-focusaway', " ");
this.ele.setAttribute('contenteditable', true);
this.ele.className = "combobox";
this.ele.title = "Can use keyboard to add options to dropdowns of this ComboBox";
if (('' + combobox).indexOf(' ') != -1) {
this.ele.innerHTML = ('' + combobox).split(';')[1].split('')[0].replace(''; // + " ";
} else {
this.ele.innerHTML = ('' + combobox).split(';')[1].replace(''; // + " ";
}
}
}
present() {
var teo=this.ele.outerHTML.replace('>');
//if (seles.length == 1) { seles.push(''); }
//if (seles[1].indexOf('')[0], '');
//} else {
return teo;
//}
}
}
class Contents extends Droptext {
constructor(combobox, mod) {
if (('' + combobox) == '') {
var iinn=0;
while (document.getElementById('combobox' + iinn)) {
iinn++;
}
combobox = 'combobox' + iinn;
}
super((combobox + ';' + mod));
this.dropinnards = mod;
}
show() {
return this.present() + " "; // + ', it is a ' + this.dropinnards;
}
}
function askaboutsort(iw, iwc) {
var ioselo=null;
var sels=[], isels=0;
var curval='';
var ansis='';
var contarr=[], icont=0, incont='';
var ris='O';
sels=document.getElementsByTagName('select');
for (isels=0; isels');
contarr.sort();
ansis=prompt('Do you want to sort Ascending or Descending column or restore Original order ' + iwc + '? ... A or D or O', '');
} else {
ris='A';
ioselo.setAttribute('data-content', encodeURIComponent(ioselo.innerHTML));
contarr=decodeURIComponent(ioselo.getAttribute('data-content')).split(' ');
contarr.sort();
ansis=prompt('Do you want to sort Ascending or Descending column ' + iwc + '? ... A or D', '');
}
if (ansis == null) { ansis = ''; }
if ((ansis + ' ').toUpperCase().substring(0,1) == 'A') {
for (icont=0; icont';
}
ioselo.innerHTML=incont;
ioselo.value=curval;
} else if ((ansis + ' ').toUpperCase().substring(0,1) == 'D') {
for (icont=eval(-1 + contarr.length); icont>=0; icont--) {
incont+=contarr[icont] + '';
}
ioselo.innerHTML=incont;
ioselo.value=curval;
} else if ((ansis + ' ').toUpperCase().substring(0,1) == ris) {
ioselo.innerHTML=decodeURIComponent(ioselo.getAttribute('data-content'));
ioselo.value=curval;
}
}
}
function thprompts() {
var wasih='';
var ths=document.getElementsByTagName('th');
for (var iths=0; iths' + wasih + '';
}
}
}
function woit(sthis) {
if (sthis.value.indexOf(String.fromCharCode(104) + String.fromCharCode(116) + String.fromCharCode(116) + String.fromCharCode(112)) == 0) {
window.open(sthis.value,'_blank','top=100,left=100,width=600,height=600');
}
if (sthis.outerHTML.indexOf(' data-content=') != -1) {
if (decodeURIComponent(sthis.getAttribute('data-content')).replace(/\ value\=\"/g, ' value=').replace(/\ value\=\'/g, ' value=').indexOf(' value=' + sthis.value) == -1) {
sthis.setAttribute('data-content', sthis.getAttribute('data-content') + encodeURIComponent('' + sthis.options[sthis.selectedIndex].text + ' '))
}
}
}
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 && (document.head.innerHTML + document.body.innerHTML).indexOf('?just=one') == -1) {
if (document.URL.indexOf('?') == -1) {
if (ihs.indexOf('/wiki/') == -1) { location.href = document.URL.split('#')[0] + '?ddlist=' + encodeURIComponent(ihs); }
ioff = -11;
} else {
if (ihs.indexOf('/wiki/') == -1) { 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 + "Red Blue Yellow ").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) {
thprompts();
if (selconts[0].indexOf('").replace(" name=selcombo>", " name=selcombo0>");
selcont = ("").replace(" name=selcombo>", " name=selcombo0>");
for (jiip=0; jiip' + selconts[jiip].split('|')[1].replace(/\_/g,' ').replace(/\'/g,'`') + '';
} else {
selcont += '' + selconts[jiip].split('/')[eval(-1 + selconts[jiip].split('/').length)].replace(/\_/g,' ').replace(/\'/g,'`') + ' ';
}
} else {
selcont += '' + selconts[jiip].split('/')[eval(-1 + selconts[jiip].split('/').length)].replace(/\_/g,' ').replace(/\'/g,'`') + ' ';
}
} else if (selconts[jiip].toLowerCase().indexOf('|') != -1) {
selcont += '' + selconts[jiip].split('|')[1].replace(/\_/g,' ').replace(/\'/g,'`') + ' ';
} else {
selcont += '' + selconts[jiip].replace(/\'/g,'`') + ' ';
}
}
}
//selcont = selcont.replace('') != -1 && alle[ialle].outerHTML.indexOf('script') == -1) {
sparebody=alle[ialle];
}
}
if (sparebody) {
obody = sparebody;
} else if (document.getElementById('demo' + ihsuff)) {
obody = document.getElementById('demo' + ihsuff);
} else {
ofound = false;
obs = document.getElementsByTagName('div');
for (iip=0; iip';
obody = document.getElementById('demo' + ihsuff);
}
}
eval('obody.innerHTML += mycombobox' + ihsuff + '.show()');
//thprompts();
document.title+=' ';
}
ihsuff='' + eval(0 + iqw);
}