// wikiautocompletion.js
// External Javascript to extend some HTML like wikiautocompletion.htm allowing for a dynamically created HTML div element "wikiautocompletion" (ie. dropdown + div contenteditable=true)
// November, 2020
// Called via ...
//
// ... or dropdown populated example as per ...
//
var divautoc='';
var divarr=[], divarrl=[], divarru=[];
var lastdivo=null;
var lastdivid='';
class Droptext {
constructor(wikiautocompletion) {
this.ele = document.createElement('div');
this.ele.id = ('' + wikiautocompletion).split(';')[0];
if (('' + wikiautocompletion).indexOf(';') != -1) {
this.ele.setAttribute('data-dropinnards', encodeURIComponent(('' + wikiautocompletion).split(';')[1].replace('') != -1) {
this.ele.innerHTML = ('' + wikiautocompletion).split(';')[1].split('')[0].replace(''; // + "";
} else {
this.ele.innerHTML = ('' + wikiautocompletion).split(';')[1].replace(''; // + "";
}
}
}
present() {
var teo=this.ele.outerHTML.replace('>')[1] + wasc).toUpperCase()) == 0) {
found=true;
foundlist=divarr[ij];
} else if (found && divarr[ij].toUpperCase().indexOf((atoih.split('')[1] + wasc).toUpperCase()) != 0) {
foundlist=foundlist;
} else if (found) {
foundlist+='`' + divarr[ij];
}
} else {
if (!found && divarr[ij].toUpperCase().indexOf((atoih + wasc).toUpperCase()) == 0) {
found=true;
foundlist='';
} else if (found && divarr[ij].toUpperCase().indexOf((atoih + wasc).toUpperCase()) != 0) {
foundlist=foundlist;
} else if (found && foundlist.indexOf('') == -1) {
foundlist+='`' + '';
}
}
}
if (atoih.indexOf('') != -1) {
//document.title=(' ' + wasc + ' Foundlist (via ' + atoih.split('')[1] + wasc + ')=' + foundlist);
document.getElementById('viapcontent').innerHTML=foundlist.replace(/\`/g,'
');
if (document.getElementById('itable')) { if (1 == 6) { document.getElementById('itable').name='itable'; } document.getElementById('itable').value=btoa(document.getElementsByTagName('table')[0].outerHTML); }
} else {
//document.title=(' ' + wasc + ' Foundlist (via ' + atoih + wasc + ')=' + foundlist);
document.getElementById('viapcontent').innerHTML=foundlist.replace(/\`/g,'
');
if (document.getElementById('itable')) { if (1 == 6) { document.getElementById('itable').name='itable'; } document.getElementById('itable').value=btoa(document.getElementsByTagName('table')[0].outerHTML); }
}
}
return atoih;
}
function andmore(wv) {
var amr='';
var sels=document.getElementsByTagName('select');
for (var isls=0; isls') != -1 && divarr.length > 0) {
if (atoih.split('')[1].trim() == '' && lastdivo.innerHTML.indexOf('ion id=') != -1) {
lastdivo.innerHTML=lastdivo.innerHTML.replace(/\ion id\=/g, 'ion data-id=');
//lastdivo.setAttribute('data-dropinnards', encodeURIComponent(lastdivo.innerHTML));
atoih=ato.target.innerHTML;
}
} else if (atoih.trim() == '' && divarr.length > 0 && lastdivo.innerHTML.indexOf('ion id=') != -1) {
lastdivo.innerHTML=lastdivo.innerHTML.replace(/\ion id\=/g, 'ion data-id=');
//lastdivo.setAttribute('data-dropinnards', encodeURIComponent(lastdivo.innerHTML));
atoih=ato.target.innerHTML;
}
if ((atoih + wasc) != '' && divarr.length > 0) { //document.getElementById('viapcontent').innerHTML != '') {
var found=false, foundlist='';
for (var ij=0; ij') != -1) {
if (!found && divarr[ij].toUpperCase().indexOf((atoih.split('')[1] + wasc).toUpperCase()) == 0) {
found=true;
foundlist=divarr[ij];
} else if (found && divarr[ij].toUpperCase().indexOf((atoih.split('')[1] + wasc).toUpperCase()) != 0) {
foundlist=foundlist;
} else if (found) {
foundlist+='`' + divarr[ij];
}
} else {
if (!found && divarr[ij].toUpperCase().indexOf((atoih + wasc).toUpperCase()) == 0) {
found=true;
//foundlist='';
foundlist='';
} else if (found && divarr[ij].toUpperCase().indexOf((atoih + wasc).toUpperCase()) != 0) {
foundlist=foundlist;
} else if (found && foundlist.indexOf('') == -1) {
foundlist+='`' + '';
}
}
}
if (atoih.indexOf('') != -1) {
//document.title+=(' ' + wasc + ' foundlist (via ' + atoih.split('')[1] + ')=' + foundlist);
document.getElementById('viapcontent').innerHTML=foundlist.replace(/\`/g,'
');
if (document.getElementById('itable')) { if (1 == 6) { document.getElementById('itable').name='itable'; } document.getElementById('itable').value=btoa(document.getElementsByTagName('table')[0].outerHTML); }
} else {
//document.title+=(' ' + wasc + ' foundlist (via ' + atoih + wasc + ')=' + foundlist);
document.getElementById('viapcontent').innerHTML=foundlist.replace(/\`/g,'
');
if (document.getElementById('itable')) { if (1 == 6) { document.getElementById('itable').name='itable'; } document.getElementById('itable').value=btoa(document.getElementsByTagName('table')[0].outerHTML); }
}
}
return atoih;
}
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(''))
}
}
if (document.getElementById('inavigate')) { if (('' + document.getElementById('inavigate').name).replace('null','').replace('undefined','') != '') { document.getElementById('inavigate').value=sthis.value + '`' + ('' + sthis.name).replace('null','').replace('undefined',''); } }
if (document.getElementById('itable')) { if (1 == 6) { document.getElementById('itable').name='itable'; } document.getElementById('itable').value=btoa(document.getElementsByTagName('table')[0].outerHTML); }
}
var ihs, selconts=[], selcont='', mywikiautocompletion=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;
var selxsuff="";
if (document.URL.indexOf('.php') != -1) { selxsuff=''; }
selconts = location.search.split('ddlist=')[1] ? (ihs + decodeURIComponent(location.search.split('ddlist=')[1].split('&')[0])).split(',') : (ihs + selxsuff).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 += '';
}
} else {
selcont += '';
}
} else if (selconts[jiip].toLowerCase().indexOf('|') != -1) {
selcont += '';
} else {
selcont += '';
}
}
}
//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');
var obsl=obs.length;
for (iip=0; iip';
obody = document.getElementById('demo' + ihsuff);
}
}
eval('obody.innerHTML += mywikiautocompletion' + ihsuff + '.show()');
//thprompts();
document.title+=' ';
if (document.URL.indexOf('.php?') != -1) {
var selsl=document.getElementsByTagName('select');
for (var islx=1; islx');
document.getElementById('viapcontent').style.position='fixed';
document.getElementById('viapcontent').style.left='40%';
document.getElementById('viapcontent').style.top='100px';
document.getElementById('viapcontent').style.display='block';
if (document.getElementById('adot')) {
if (document.getElementById('adot').innerHTML != '.') {
if (document.getElementById('idot')) {
document.getElementById('idot').value=document.getElementById('adot').innerHTML.substring(0,eval(-1 + document.getElementById('adot').innerHTML.length)).replace(' regarding List Of ','');
} else {
document.getElementById('myform').innerHTML+='';
}
}
}
if (document.URL.indexOf('.php') != -1 && document.URL.indexOf('.php?') == -1) {
document.getElementById('myform').method='POST';
document.getElementById('myform').action=document.URL.split('?')[0].split('#')[0].replace('.html','.php').replace('.htm','.php');
document.getElementById('itable').name='itable';
document.getElementById('icontent').name='icontent';
document.getElementById('icontent').value=divautoc;
document.getElementById('itable').value=btoa(document.getElementsByTagName('table')[0].outerHTML);
if (document.getElementById('inavigate')) {
document.getElementById('inavigate').name='inavigate';
}
}
if (document.getElementById('isubmit')) {
document.getElementById('isubmit').value='Navigate';
}
setTimeout(mthen,5000);
}
}
function mthen() {
document.getElementById('viapcontent').innerHTML='';
}
setTimeout(lookviapcontent, 1000);