// 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 ...
//
// Check for proper PHP recall setting of correct select element value
var divautoc='';
var divarr=[], divarrl=[], divarru=[];
var ths=[], thsihorig=[], thsih=[];
var lastdivo=null;
var lastdivid='';
if (!String.fromCodePoint) { // thanks to http://xahlee.info/js/js_unicode_code_point.html
// ES6 Unicode Shims 0.1 , © 2012 Steven Levithan , MIT License
String.fromCodePoint = function fromCodePoint () {
var chars = [], point, offset, units, i;
for (i = 0; i < arguments.length; ++i) {
point = arguments[i];
offset = point - 0x10000;
units = point > 0xFFFF ? [0xD800 + (offset >> 10), 0xDC00 + (offset & 0x3FF)] : [point];
chars.push(String.fromCharCode.apply(null, units));
}
return chars.join("");
}
}
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];
lastn=divarr[ij];
} else if (found && divarr[ij].toUpperCase().indexOf((atoih.split('')[1] + wasc).toUpperCase()) != 0) {
foundlist=foundlist;
} else if (found) {
if (divarr[ij] != lastn) { lastn=divarr[ij]; foundlist+='`' + divarr[ij]; }
}
} else {
if (!found && divarr[ij].toUpperCase().indexOf((atoih + wasc).toUpperCase()) == 0) {
found=true;
foundlist='';
lastn=nosq(divarr[ij]);
butcnt++;
} else if (found && divarr[ij].toUpperCase().indexOf((atoih + wasc).toUpperCase()) != 0) {
foundlist=foundlist;
} else if (found && foundlist.indexOf('') == -1) {
if (nosq(divarr[ij]) != lastn) { lastn=nosq(divarr[ij]); foundlist+='`' + ''; }
butcnt++;
}
}
}
if (atoih.indexOf('') != -1) {
//document.title=(' ' + wasc + ' Foundlist (via ' + atoih.split('')[1] + wasc + ')=' + foundlist);
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('viapcontent').style.opacity='1.0';
document.getElementById('viapcontent').style.zIndex='7';
}
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('viapcontent').innerHTML=ifmdo(foundlist.replace(/\`/g,''));
} else {
document.getElementById('viapcontent').innerHTML=ifmdo(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);
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('viapcontent').style.opacity='0.7';
document.getElementById('viapcontent').style.zIndex='-7';
}
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('viapcontent').style.opacity='1.0';
document.getElementById('viapcontent').style.zIndex='7';
}
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('viapcontent').innerHTML=ifmdo(foundlist.replace(/\`/g,''));
} else {
document.getElementById('viapcontent').innerHTML=ifmdo(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 ifmdo(inbrs) {
var isn=true;
var thenu='';
var thes='';
if (5 == 5 || navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
//alert(98);
for (var ijh=1; ijh<=lastdivid.length; ijh++) {
if (isn && lastdivid.slice(-ijh).substring(0,1) >= '0' && lastdivid.slice(-ijh).substring(0,1) <= '9') {
thenu='' + lastdivid.slice(-ijh).substring(0,1) + thenu;
} else if (lastdivid.slice(-ijh).substring(0,1) < '0' || lastdivid.slice(-ijh).substring(0,1) > '9') {
if (ijh == 1) { thenu='0'; }
isn=false;
}
}
thenu=eval('' + thenu);
//alert(lastdivid + ' gets us ' + eval(-1 + eval('' + thenu)));
//alert(inbrs);
if (document.getElementById('th' + eval(0 + thenu))) {
if (thsih[eval(0 + thenu)].indexOf('<') > 0) { thes=thsih[eval(0 + thenu)].replace(thsih[eval(0 + thenu)].split('<')[0],''); }
document.getElementById('th' + eval(0 + thenu)).innerHTML='' + inbrs.replace(/\ id\=/g,' value=').replace(/\ onclick\=/g,' data-onclick=').replace(/atwo\(/g,'athree(this,').replace(/\
/g,'').replace(/\<\!\-\-br\-\-\>/g,'').replace(/\' + thes;
}
}
return inbrs;
}
function onc(othis) {
if (othis.value.trim().length > 0) {
if (document.getElementById(othis.value)) {
document.getElementById(othis.value).click();
} else if (othis.innerHTML.indexOf(' value="' + othis.value + '" ') != -1) {
if (othis.innerHTML.split(' value="' + othis.value + '" ')[1].split('>')[0].indexOf('click="') != -1) {
eval(othis.innerHTML.split(' value="' + othis.value + '" ')[1].split('click="')[1].split('"')[0].replace('athree(this,','atwo('));
} else {
eval(othis.innerHTML.split(' value="' + othis.value + '" ')[0].split('<')[eval(-1 + othis.innerHTML.split(' value="' + othis.value + '" ')[0].split('<').length)].split('click="')[1].split('"')[0].replace('athree(this,','atwo('));
}
}
var iparent='' + othis.id.replace('selth','');
othis.value=' ';
var realih=thsih[eval('' + iparent)].split('<')[0];
//document.getElementById('th' + iparent).innerHTML=thsih[eval('' + iparent)].substring(eval('' + realih.length)).replace('>. <','>' + realih + '<');
document.getElementById('th' + iparent).innerHTML=thsihorig[eval('' + iparent)];
}
}
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];
lastn=divarr[ij];
} else if (found && divarr[ij].toUpperCase().indexOf((atoih.split('')[1] + wasc).toUpperCase()) != 0) {
foundlist=foundlist;
} else if (found) {
if (divarr[ij] != lastn) { lastn=divarr[ij]; foundlist+='`' + divarr[ij]; }
}
} else {
if (!found && divarr[ij].toUpperCase().indexOf((atoih + wasc).toUpperCase()) == 0) {
found=true;
//foundlist='';
foundlist='';
lastn=nosq(divarr[ij]);
butcnt++;
} else if (found && divarr[ij].toUpperCase().indexOf((atoih + wasc).toUpperCase()) != 0) {
foundlist=foundlist;
} else if (found && foundlist.indexOf('') == -1) {
//foundlist+='`' + '';
if (nosq(divarr[ij]) != lastn) { lastn=nosq(divarr[ij]); foundlist+='`' + ''; }
butcnt++;
}
}
}
if (atoih.indexOf('') != -1) {
//document.title+=(' ' + wasc + ' foundlist (via ' + atoih.split('')[1] + ')=' + foundlist);
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('viapcontent').style.opacity='1.0';
document.getElementById('viapcontent').style.zIndex='7';
}
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('viapcontent').innerHTML=ifmdo(foundlist.replace(/\`/g,''));
} else {
document.getElementById('viapcontent').innerHTML=ifmdo(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);
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('viapcontent').style.opacity='1.0';
document.getElementById('viapcontent').style.zIndex='7';
}
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('viapcontent').innerHTML=ifmdo(foundlist.replace(/\`/g,''));
} else {
document.getElementById('viapcontent').innerHTML=ifmdo(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') != -1) {
iti=gebtns[ig].innerHTML.split('')[0].split('>')[1];
thsihorig.push(iti + gebtns[ig].innerHTML);
thsih.push(iti + gebtns[ig].innerHTML.replace(' style="',' style="width:10px;display:inline-block;').replace('>' + iti + '<','>. <'));
} else {
thsih.push(gebtns[ig].innerHTML);
}
}
}
}
function lookviapcontent() {
var iti='';
if (5 == 5 || navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
if (ths.length == 0) {
setTimeout(postlook, 2000);
if (1 == 7) {
var gebtns=document.getElementsByTagName('th');
for (var ig=0; ig') != -1) {
iti=gebtns[ig].innerHTML.split('')[0].split('>')[1];
thsih.push(iti + gebtns[ig].innerHTML.replace(' style="',' style="width:10px;display:inline-block;').replace('>' + iti + '<','>.<'));
} else {
thsih.push(gebtns[ig].innerHTML);
}
}
}
//alert('' + thsih.length);
//alert(thsih[eval(-1 + thsih.length)] + ' ... ' + gebtns[eval(-1 + thsih.length)].outerHTML);
}
}
if (document.getElementById('viapcontent').innerHTML == '' && document.URL.indexOf('.php?') == -1) {
setTimeout(lookviapcontent, 1000);
} else if (document.URL.indexOf('.php?') == -1) {
divautoc=decodeURIComponent(document.getElementById('viapcontent').innerHTML);
//alert(divautoc);
divarr=divautoc.split('`');
divarr.sort();
divarru=divautoc.toUpperCase().split('`');
divarru.sort();
divarrl=divautoc.toLowerCase().split('`');
divarrl.sort();
//for (var iz=0; iz');
document.getElementById('viapcontent').style.position='fixed';
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('viapcontent').style.opacity='0.7';
document.getElementById('viapcontent').style.zIndex='-7';
}
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('viapcontent').style.left='0%';
document.getElementById('viapcontent').style.top='350px';
} else {
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='';
}
function fixmobilewidth() {
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
var rectt=document.getElementsByTagName('table')[0].getBoundingClientRect();
//alert('before:' + navigator.userAgent + ' table width=' + rectt.width + ' has screen.width=' + screen.width + ' and window.innerWidth=' + window.innerWidth);
//document.getElementById("myviewport").setAttribute("content", "width=device-width, initial-scale=0.85, minimum-scale=0.1, maximum-scale=8, user-scalable=yes");
//alert(eval(-0.35 + eval('' + (window.orientation == 0 ? window.innerHeight: window.innerWidth)) / eval('' + rectt.width)));
document.getElementById("myviewport").setAttribute("content", "width=device-width, initial-scale=" + eval(-0.35 + eval('' + (window.orientation == 0 ? window.innerHeight: window.innerWidth)) / eval('' + rectt.width)) + ", minimum-scale=0.1, maximum-scale=8, user-scalable=yes");
//alert('after:' + navigator.userAgent + ' table width=' + rectt.width + ' has screen.width=' + screen.width + ' and window.innerWidth=' + window.innerWidth);
}
}
if (1 == 2) { setTimeout(fixmobilewidth, 5000); }
setTimeout(lookviapcontent, 1000);