// combometer.js // External Javascript to extend some HTML like combometer.html allowing for a dynamically created HTML div element "combometer" (ie. meter + div contenteditable=true) // November, 2020 // Called via ... // // ... or dropdown populated example as per ... // class Metervalue { constructor(combometer) { this.ele = document.createElement('div'); this.ele.id = ('' + combometer).split(';')[0]; if (('' + combometer).indexOf(';') != -1) { console.log(combometer); this.ele.setAttribute('data-meterinnards', encodeURIComponent(('' + combometer).split(';')[1].replace('"); this.ele.setAttribute('contenteditable', true); this.ele.className = "combometer"; this.ele.title = "Can use keyboard to set value of meter of this ComboMeter"; } } present() { var teo=this.ele.outerHTML; //.replace('>'); //if (seles.length == 1) { seles.push(''); } //if (seles[1].indexOf('')[0], ''); //} else { return teo; //} } } class Contents extends Metervalue { constructor(combometer, mod) { if (('' + combometer) == '') { var iinn=0; while (document.getElementById('combometer' + iinn)) { iinn++; } combometer = 'combometer' + iinn; } super((combometer + ';' + mod)); this.meterinnards = mod; } show() { var tp=this.present(); if (document.body.innerHTML.indexOf('') != -1) { document.body.innerHTML=document.body.innerHTML.replace('','' + alltogether.split('')[1] + ''); } if (document.body.innerHTML.indexOf('') != -1) { document.body.innerHTML=document.body.innerHTML.replace('','' + tp.replace('>',' onblur=" var odiv=event.target; var optval=event.target.getAttribute(' + "'" + 'data-optionval' + "'" + '); var fway=event.target.getAttribute(' + "'" + 'data-focusaway' + "'" + '); var umytype=event.target.innerHTML; var alltogether=decodeURIComponent(event.target.getAttribute(' + "'" + 'data-meterinnards' + "'" + ')).split(String.fromCharCode(60) + ' + "'" + '/meter' + "'" + ')[0]; if (umytype.trim().length == 0) { console.log(1); odiv.innerHTML = decodeURIComponent(event.target.getAttribute(' + "'" + 'data-meterinnards' + "'" + ')); } else if (alltogether.indexOf(String.fromCharCode(62) + umytype + String.fromCharCode(60)) != -1) { console.log(2); odiv.innerHTML = alltogether.replace(String.fromCharCode(62) + umytype + String.fromCharCode(60), ' + "' selected'" + ' + String.fromCharCode(62) + umytype + String.fromCharCode(60)) + event.target.getAttribute(' + "'" + 'data-focusaway' + "'" + '); } else { alltogether+=optval.replace(String.fromCharCode(39), String.fromCharCode(39) + umytype).replace(String.fromCharCode(62), String.fromCharCode(62) + umytype); alltogether+=String.fromCharCode(60) + ' + "'" + '/meter' + "'" + ' + String.fromCharCode(62); console.log(3); console.log(fway); odiv.innerHTML = fway; console.log(4); console.log(umytype); odiv.innerHTML = umy(alltogether,umytype).replace(String.fromCharCode(62) + umytype + String.fromCharCode(60), ' + "' selected'" + ' + String.fromCharCode(62) + umytype + String.fromCharCode(60)) + event.target.getAttribute(' + "'" + 'data-focusaway' + "'" + '); odiv.setAttribute(' + "'" + 'data-meterinnards' + "'" + ',encodeURIComponent(alltogether)); } " onkeypress=" event.target.setAttribute(' + "'" + 'data-sofar' + "'" + ', event.target.innerHTML); " onkeydown=" if (event.target.innerHTML.indexOf(String.fromCharCode(60)) != -1) { event.target.innerHTML=' + "''" + '; } ">' + decodeURIComponent(tp.split(' data-meterinnards="')[1].split('"')[0]) + '') + ''); } console.log(tp.replace('>', ' onblur=" var odiv=event.target; var optval=event.target.getAttribute(' + "'" + 'data-optionval' + "'" + '); var fway=event.target.getAttribute(' + "'" + 'data-focusaway' + "'" + '); var umytype=event.target.innerHTML; var alltogether=decodeURIComponent(event.target.getAttribute(' + "'" + 'data-meterinnards' + "'" + ')).split(String.fromCharCode(60) + ' + "'" + '/meter' + "'" + ')[0]; if (umytype.trim().length == 0) { console.log(1); odiv.innerHTML = decodeURIComponent(event.target.getAttribute(' + "'" + 'data-meterinnards' + "'" + ')); } else if (alltogether.indexOf(String.fromCharCode(62) + umytype + String.fromCharCode(60)) != -1) { console.log(2); odiv.innerHTML = alltogether.replace(String.fromCharCode(62) + umytype + String.fromCharCode(60), ' + "' selected'" + ' + String.fromCharCode(62) + umytype + String.fromCharCode(60)) + event.target.getAttribute(' + "'" + 'data-focusaway' + "'" + '); } else { alltogether+=optval.replace(String.fromCharCode(39), String.fromCharCode(39) + umytype).replace(String.fromCharCode(62), String.fromCharCode(62) + umytype); alltogether+=String.fromCharCode(60) + ' + "'" + '/meter' + "'" + ' + String.fromCharCode(62); console.log(3); console.log(fway); odiv.innerHTML = fway; console.log(4); odiv.innerHTML = umy(alltogether,umytype).replace(String.fromCharCode(62) + umytype + String.fromCharCode(60), ' + "' selected'" + ' + String.fromCharCode(62) + umytype + String.fromCharCode(60)) + event.target.getAttribute(' + "'" + 'data-focusaway' + "'" + '); odiv.setAttribute(' + "'" + 'data-meterinnards' + "'" + ',encodeURIComponent(alltogether)); } " onkeypress=" event.target.setAttribute(' + "'" + 'data-sofar' + "'" + ', event.target.innerHTML); " onkeydown=" if (event.target.innerHTML.indexOf(String.fromCharCode(60)) != -1) { event.target.innerHTML=' + "''" + '; } ">' + decodeURIComponent(tp.split(' data-meterinnards="')[1].split('"')[0]) + '')); return tp.replace('>',' onblur=" var odiv=event.target; var optval=event.target.getAttribute(' + "'" + 'data-optionval' + "'" + '); var fway=event.target.getAttribute(' + "'" + 'data-focusaway' + "'" + '); var umytype=event.target.innerHTML; var alltogether=decodeURIComponent(event.target.getAttribute(' + "'" + 'data-meterinnards' + "'" + ')).split(String.fromCharCode(60) + ' + "'" + '/meter' + "'" + ')[0]; if (umytype.trim().length == 0) { console.log(1); odiv.innerHTML = decodeURIComponent(event.target.getAttribute(' + "'" + 'data-meterinnards' + "'" + ')); } else if (alltogether.indexOf(String.fromCharCode(62) + umytype + String.fromCharCode(60)) != -1) { console.log(2); odiv.innerHTML = alltogether.replace(String.fromCharCode(62) + umytype + String.fromCharCode(60), ' + "' selected'" + ' + String.fromCharCode(62) + umytype + String.fromCharCode(60)) + event.target.getAttribute(' + "'" + 'data-focusaway' + "'" + '); } else { alltogether+=optval.replace(String.fromCharCode(39), String.fromCharCode(39) + umytype).replace(String.fromCharCode(62), String.fromCharCode(62) + umytype); alltogether+=String.fromCharCode(60) + ' + "'" + '/meter' + "'" + ' + String.fromCharCode(62); console.log(3); console.log(fway); odiv.innerHTML = fway; console.log(4); odiv.innerHTML = umy(alltogether,umytype).replace(String.fromCharCode(62) + umytype + String.fromCharCode(60), ' + "' selected'" + ' + String.fromCharCode(62) + umytype + String.fromCharCode(60)) + event.target.getAttribute(' + "'" + 'data-focusaway' + "'" + '); odiv.setAttribute(' + "'" + 'data-meterinnards' + "'" + ',encodeURIComponent(alltogether)); } " onkeypress=" event.target.setAttribute(' + "'" + 'data-sofar' + "'" + ', event.target.innerHTML); " onkeydown=" if (event.target.innerHTML.indexOf(String.fromCharCode(60)) != -1) { event.target.innerHTML=' + "''" + '; } ">' + decodeURIComponent(tp.split(' data-meterinnards="')[1].split('"')[0]) + '') + ""; // + ', it is a ' + this.meterinnards; } } function umy(all_together,umy_type) { var itr=0; var retall=all_together; if (umy_type.indexOf('<') == -1) { var dlm='"', numsbit='', inumsbit=0; var valsare=all_together.split(' value="'); if (valsare.length == 1) { dlm="'"; valsare=all_together.split(" value='"); } if (valsare.length == 1) { dlm=""; valsare=all_together.split(" value="); } if (valsare.length > 1) { console.log('umy_type=' + umy_type); console.log('dlm=' + dlm + ' preretall=' + all_together); retall=valsare[0]; // + " value=" + dlm; for (itr=1; itr= '0' && valsare[itr].substring(inumsbit).substring(0,1) <= '9')) { inumsbit++; } retall+=umy_type + valsare[itr].substring(inumsbit); console.log('interim_retall=' + retall); } if (dlm != '') { dlm=""; valsare=retall.split(" value="); if (valsare.length > 1) { console.log('dlm=' + dlm + ' pre_retall=' + retall); retall=valsare[0]; // + " value=" + dlm; for (itr=1; itr= '0' && valsare[itr].substring(inumsbit).substring(0,1) <= '9')) { inumsbit++; } retall+=umy_type + valsare[itr].substring(inumsbit); console.log('interimretall=' + retall); } } } } } console.log('retall=' + retall); return retall.replace(/\ VALUE\=/g, ' value='); } function myownspeed(et) { var etv=et.value; var j=0; var mqs=document.getElementsByTagName('marquee'); for (j=0; j= 0) { //et.style.backgroundImage="linear-gradient( 90deg, green, green, green, green, green)"; mqs[j].behavior='' + mqs[j].title; } else { //et.style.backgroundImage="linear-gradient( 90deg, orange, orange, orange, orange, orange)"; mqs[j].behavior='' + mqs[j].getAttribute('data-alt'); } mqs[j].scrollAmount='' + Math.abs(eval('' + etv)); } } function myownfraction(event) { if (event.target.value) { if (('' + event.target.value).indexOf('<') == -1 && document.getElementById('combometer' + ('' + event.target.id).replace('mtcombo',''))) { var x=0, y=0; if (event.clientX || event.clientY) { x = event.clientX; y = event.clientY; } else { x = event.pageX; y = event.pageY; } var rect = event.target.getBoundingClientRect(), varn=0, vard=0, iv=0; //alert('x=' + x + ' and left=' + Math.round(rect.left)); if (eval('' + x) >= eval('' + rect.left) && eval('' + x) <= eval('' + eval('' + Math.round(rect.left)) + eval('' + Math.round(rect.width)))) { varn = eval('' + eval('' + x) - eval('' + Math.round(rect.left))); vard = eval('' + Math.round(rect.width)); for (iv=Math.min(Math.abs(varn),Math.abs(vard)); iv>=2; iv--) { if (eval(Math.abs(varn) % iv) == 0 && eval(Math.abs(vard) % iv) == 0) { varn /= iv; vard /= iv; } } event.target.value=eval(eval('' + event.target.min) + eval(eval(eval('' + event.target.max) - eval('' + event.target.min)) * eval('' + varn) / eval('' + vard))); if (event.target.title.indexOf(' value=') != -1) { event.target.title=event.target.title.split(' value=')[0].trim('"') + ' value=' + ('' + event.target.value).split('<')[0].split('"')[0]; } if (event.target.innerHTML.indexOf(' value=') != -1) { event.target.innerHTML=event.target.innerHTML.split(' value=')[0].trim('"') + ' value=' + ('' + event.target.value).split('<')[0].split('"')[0]; } if (document.getElementById(('' + event.target.id).replace('mtcombo','mt_combo'))) { document.getElementById(('' + event.target.id).replace('mtcombo','mt_combo')).value=event.target.value; } //myownspeed(event.target); } document.getElementById('combometer' + ('' + event.target.id).replace('mtcombo','')).setAttribute('data-meterinnards', encodeURIComponent(document.getElementById('combometer' + ('' + event.target.id).replace('mtcombo','')).innerHTML)); } } } 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('meter'); 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 reportit() { var repis=''; var ths=document.getElementsByTagName('meter'); for (var iths=1; iths<=ths.length; iths++) { repis+='ComboMeter ' + iths + ' value=' + ths[eval(-1 + iths)].value + ' ' + String.fromCharCode(10); } alert(repis); return false; } 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('')) } } } var ihs, selconts=[], selcont='', mycombometer=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('?mtlist='); } else { ihsobs = (document.head.innerHTML + document.body.innerHTML).replace(/\&mtlist\=/g,'?mtlist=').split('?mtlist='); } if (ihsobs.length > 2) { ioff = -1; ihs = decodeURIComponent((document.head.innerHTML + document.body.innerHTML).replace('&mtlist=','?mtlist=').split('?mtlist=')[1].split('&')[0].split('"')[0].split("'")[0]); // + ','; if (document.URL.indexOf('mtlist=' + 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] + '?mtlist=' + encodeURIComponent(ihs); } ioff = -11; } else { if (ihs.indexOf('/wiki/') == -1) { location.href = document.URL.split('#')[0] + '&mtlist=' + 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('mtlist=')[1] ? (ihs + decodeURIComponent(location.search.split('mtlist=')[1].split('&')[0])).split(',') : (ihs + "").split(','); if ((document.head.innerHTML + document.body.innerHTML).replace(/\&mtlist\=/g,'?mtlist=').indexOf('?mtlist=') != -1) { ihs = decodeURIComponent((document.head.innerHTML + document.body.innerHTML).replace(/\&mtlist\=/g,'?mtlist=').split('?mtlist=')[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('mtlist=' + 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 ' + 'mtlist=' + encodeURIComponent(ihsobs[1].split('&')[0].split('"')[0].split("'")[0])); } if (isokay) { //thprompts(); if (selconts[0].indexOf('").replace(" name=mtcombo>", " name=mtcombo0>"); selcont = ("").replace(" name=mtcombo id=mtcombo value=" + selconts[0] + " min=" + selconts[1] + " max=" + selconts[2] + ">", " name=mtcombo0 id=mtcombo0 value=" + selconts[0] + " min=" + selconts[1] + " max=" + selconts[2] + ">"); //selcont = selcont.replace('