<!doctype html>
<html>
<head>
<title>Emoji Background Text - RJM Programming - October, 2018</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<style>
* { font-family: 'Courier New'; margin: 0 0 0 0; padding: 0 0 0 0; display: 'block'; border: 1px solid transparent; }
</style>
<script type='text/javascript'>

var nexti=2, resti=0;
var into='rest ';
var intoo=null;
var incap='dc';
var incapo=null;
var intosuffix='';
var cps=['11088','128301','127756','127968','127765','9728.65039', '9986', '128240', '129304'];
var lastl=0;


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("");
}
}



function fixwhatisthere() {
var rect, choice, nih='', cid='', fs='', top='', left='', m=0, recttop='', rectleft='', divsuffix='', cmd='';
var fsstop=[], fssleft=[], fssw=[], fssh=[];
var ets=['div','h1','h2','h3','h4','p','span'];
var aos, iaos, naos, j, k;
for (naos=0; naos<ets.length; naos++) {
aos=document.getElementsByTagName(ets[naos]);
for (iaos=0; iaos<aos.length; iaos++) {
if (aos[iaos].innerHTML.length > 0) {
fs=('' + eval(('' + window.getComputedStyle(aos[iaos]).getPropertyValue('font-size')).split('px')[0] / 2 + 0.5)).split('.')[0] + 'px';
rect=aos[iaos].getBoundingClientRect();
fsstop.push(('' + rect.top).replace('px','') + 'px');
fssleft.push(('' + rect.left).replace('px','') + 'px');
fssw.push(('' + rect.width).replace('px','') + 'px');
fssh.push(('' + rect.height).replace('px','') + 'px');
//aos[iaos].style.position='absolute';
//aos[iaos].style.top=('' + rect.top).replace('px','') + 'px';
//aos[iaos].style.left=('' + rect.left).replace('px','') + 'px';
} else if (('' + aos[iaos].id) == incap || (incapo == null && aos[iaos].outerHTML.toLowerCase().replace(/\"/g,'').replace(/\'/g,'').indexOf('contenteditable=true') != -1)) {
if (('' + aos[iaos].id) == incap) {
incap=incap;
} else {
incapo=aos[iaos];
if (aos[iaos].outerHTML.toLowerCase().indexOf(' onkeydown=') == -1) {
aos[iaos].onkeydown=preaddto;
}
if (aos[iaos].outerHTML.toLowerCase().indexOf(' onkeypress=') == -1) {
aos[iaos].onkeypress=preaddto;
}
if (('' + aos[iaos].id) != '') {
incap=('' + aos[iaos].id) + ' ';
} else {
incap=' ';
}
}
fs=('' + eval(('' + window.getComputedStyle(aos[iaos]).getPropertyValue('font-size')).split('px')[0] / 2)).split('.')[0] + 'px';
resti=fsstop.length;
rect=aos[iaos].getBoundingClientRect();
//alert(rect.top + ' ... ' + rect.height);
m++;
fsstop.push(('' + rect.top).replace('px','') + 'px');
fssleft.push(('' + rect.left).replace('px','') + 'px');
fssw.push(('' + rect.width).replace('px','') + 'px');
fssh.push(('' + rect.height).replace('px','') + 'px');
var xx=('' + window.getComputedStyle(aos[iaos]).getPropertyValue('font-size')).split('px')[0];
var ix=eval(13 + eval(('' + eval(xx / 2)).split('.')[0]));
var iix=0, jjx=0;
var thistop=eval(('' + rect.top).replace('px','').split('.')[0]);
while (iix < eval('' + eval(('' + rect.height).replace('px','')))) {
divsuffix+='<div id=eb_' + incap.trim() + jjx + ' style="opacity:1.0;margin-top:' + ('' + eval(('' + fs).split('px')[0] / 2)).split('.')[0] + 'px;width:100%;font-size:' + fs + ';position:absolute;top:' + thistop + 'px;left:' + ('' + rect.left).replace('px','').split('.')[0] + 'px;"></div>';
//alert(divsuffix);
jjx++;
iix+=eval('' + ix);
thistop+=eval('' + ix);
}
} else if (('' + aos[iaos].id) == into.trim()) {
into=into.trim();
intoo=null;
} else if (ets[naos] == 'div' && into.trim() != into) {
intoo=aos[iaos];
}
}
}
if (intoo != null && into.trim() != into) {
if (intoo.outerHTML.indexOf("opacity:") == -1) {
intoo.style.opacity='0.5';
}
}
for (naos=0; naos<ets.length; naos++) {
aos=document.getElementsByTagName(ets[naos]);
for (iaos=0; iaos<aos.length; iaos++) {
if (aos[iaos].innerHTML.length > 0) {
fs=('' + eval(('' + window.getComputedStyle(aos[iaos]).getPropertyValue('font-size')).split('px')[0] / 2 + 0.5)).split('.')[0] + 'px';
//rect=aos[iaos].getClientRects(); //BoundingClientRect();
recttop=fsstop[m];
rectleft=fssleft[m];
//alert(recttop + ' height=' + fssh[m]);
m++;
nih='';
for (j=0; j<aos[iaos].innerHTML.length; j++) {
choice=Math.floor(Math.random() * cps.length);
cmd='';
for (k=0; k<cps[choice].split('.').length; k++) {
//for (k=0; k<1; k++) {
if (aos[iaos].innerHTML.substring(j, eval(1+j)) == ' ') {
if (eval(1 + k) == cps[choice].split('.').length) {
nih+='&nbsp;';
}
} else if (aos[iaos].innerHTML.substring(j, eval(1+j)) < ' ') {
if (eval(1 + k) == cps[choice].split('.').length) {
nih+=aos[iaos].innerHTML.substring(j, eval(1+j));
}
} else if (cmd == '' && eval(1 + k) == cps[choice].split('.').length) {
nih+=String.fromCodePoint(eval('' + cps[choice].split('.')[k]));
} else if (eval(1 + k) != cps[choice].split('.').length) {
if (cmd == '') {
cmd="nih+=String.fromCodePoint(" + eval('' + cps[choice].split('.')[k]) + ")";
} else {
cmd=cmd.replace(')', ',' + eval('' + cps[choice].split('.')[k]) + ')');
}
} else if (eval(1 + k) == cps[choice].split('.').length) {
if (cmd == '') {
nih+=String.fromCodePoint(eval('' + cps[choice].split('.')[k]));
} else {
cmd=cmd.replace(')', ',' + eval('' + cps[choice].split('.')[k]) + ')');
//alert(cmd);
eval(cmd);
}
}
}
}
if (('' + aos[iaos].id) == '') {
cid='';
} else {
cid=' id="eb_' + ('' + aos[iaos].id) + '"';
}
if (intosuffix == '' && intoo != null) {
intoo.style.fontSize=fs;
intoo.innerHTML='<div' + cid + ' style="margin-top:' + eval(('' + fs).split('px')[0] / 3) + 'px;width:100%;font-size:' + fs + ';position:absolute;top:' + ('' + recttop).replace('px','').split('.')[0] + 'px;left:' + ('' + rectleft).replace('px','').split('.')[0] + 'px;">' + nih + '</div><div id=' + into.trim() + nexti + ' style="width:100%;margin-top:' + eval(('' + fs).split('px')[0] / 3) + 'px;"></div>';
} else {
document.getElementById(into.trim() + intosuffix).style.fontSize=fs;
document.getElementById(into.trim() + intosuffix).innerHTML='<div' + cid + ' style="margin-top:' + eval(('' + fs).split('px')[0] / 3) + 'px;width:100%;font-size:' + fs + ';position:absolute;top:' + ('' + recttop).replace('px','').split('.')[0] + 'px;left:' + ('' + rectleft).replace('px','').split('.')[0] + 'px;">' + nih + '</div><div id=' + into.trim() + nexti + ' style="width:100%;margin-top:' + eval(('' + fs).split('px')[0] / 3) + 'px;"></div>';
}
aos[iaos].style.opacity="1.0";
intosuffix='' + nexti;
nexti++;
}
}
}
//alert(into + intosuffix + ':' + divsuffix);
if (intosuffix == '' && intoo != null) {
//alert(divsuffix);
intoo.innerHTML=divsuffix;
} else {
document.getElementById(into.trim() + intosuffix).innerHTML=divsuffix;
}
if (incap.trim() != '' && incap == incap.trim()) {
document.getElementById(incap).focus();
} else {
incapo.focus();
}
}

function preaddto() {
addto(1);
}

function addto(mode) {
var nih='', choice=0, ix=0, sus='', cmd='';
var dcih;
if (incap.trim() != '' && incap == incap.trim()) {
dcih=document.getElementById(incap).innerHTML;
} else {
dcih=incapo.innerHTML;
}
//document.title=dcih;
//if (dcih.indexOf('X') != -1) { alert(dcih); }
// <div>ghjfjhgfjhgf hfgdhgfdhgf</div><div>gfdhgfdhgfd hgfdghfdhgfd</div><div>gX<br></div>
dcih=dcih.replace(/\<div\>\<br\>\<\/div\>/g,'<div> <br></div>'); //String.fromCharCode(10)); // huh
var dcihs=dcih.split('<br></div');
if (dcihs.length > 1) {
//alert('hERE');
for (var ii=eval(-2 + dcihs.length); ii>=0; ii--) {
sus=dcihs[ii].split('<div>')[eval(-1 + dcihs[ii].split('<div>').length)];
//alert('sus=' + sus);
if (1 == 7 && sus != '' && dcih.indexOf('<div><br></div><div>' + sus + '<br></div>') != -1) {
dcih=dcih.replace('<div><br></div><div>' + sus + '<br></div>', String.fromCharCode(10) + sus);
ii--;
} else {
dcih=dcih.replace('<div>' + sus + '<br></div>', String.fromCharCode(10) + sus);
}
}
}
dcih=dcih.replace(/\<\/div\>\<div\>/g,String.fromCharCode(10)).replace(/\<br\>/g, ''); // huh
if (dcih.replace(/\<div\>\<br\>\<\/div\>/g,String.fromCharCode(10)).replace(/\<div\>/g,'').replace(/\<\/div\>\<br\>/g,'').replace(/\<\/div\>/g,'').replace(/ \<br\>/g,String.fromCharCode(32)).length == lastl) {
lastl=lastl;
} else {
lastl=dcih.replace(/\<div\>\<br\>\<\/div\>/g,String.fromCharCode(10)).replace(/\<div\>/g,'').replace(/\<\/div\>\<br\>/g,'').replace(/\<\/div\>/g,'').replace(/ \<br\>/g,String.fromCharCode(32)).length;
//if (dcih.indexOf(String.fromCharCode(13)) != -1) { alert(13); }
//if (dcih.indexOf(String.fromCharCode(10)) != -1) { alert(10); }
//if (dcih.indexOf('<br>') != -1) { alert('' + mode + ':' + dcih); }
for (var j=0; j<dcih.replace(/\<div\>\<br\>\<\/div\>/g,String.fromCharCode(10)).replace(/\<div\>/g,'').replace(/\<\/div\>\<br\>/g,'').replace(/\<\/div\>/g,'').replace(/ \<br\>/g,String.fromCharCode(32)).length; j++) {
choice=Math.floor(Math.random() * cps.length);
cmd='';
for (k=0; k<cps[choice].split('.').length; k++) {
//for (var k=0; k<1; k++) {
if (dcih.replace(/\<div\>\<br\>\<\/div\>/g,String.fromCharCode(10)).replace(/\<div\>/g,'').replace(/\<\/div\>\<br\>/g,'').replace(/\<\/div\>/g,'').replace(/ \<br\>/g,String.fromCharCode(32)).substring(j, eval(1+j)) == ' ') {
if (eval(1 + k) == cps[choice].split('.').length) {
nih+='&nbsp;';
}
} else if (dcih.replace(/\<div\>\<br\>\<\/div\>/g,String.fromCharCode(10)).replace(/\<div\>/g,'').replace(/\<\/div\>\<br\>/g,'').replace(/\<\/div\>/g,'').replace(/\<br\>/g,String.fromCharCode(10)).substring(j, eval(1+j)) == String.fromCharCode(10)) {
if (eval(1 + k) == cps[choice].split('.').length) {
document.getElementById('eb_' + incap.trim() + ix).innerHTML=nih;
//alert('' + mode + ':' + dcih); //alert('here ' + nih);
//nih+=String.fromCharCode(10); //'<br>';
nih='';
ix++;
}
} else if (dcih.replace(/\<div\>\<br\>\<\/div\>/g,String.fromCharCode(10)).replace(/\<div\>/g,'').replace(/\<\/div\>\<br\>/g,'').replace(/\<\/div\>/g,'').replace(/ \<br\>/g,String.fromCharCode(32)).substring(j, eval(1+j)) == String.fromCharCode(13)) {
if (eval(1 + k) == cps[choice].split('.').length) {
document.getElementById('eb_' + incap.trim() + ix).innerHTML=nih;
//alert('Here ' + nih);
//nih+=String.fromCharCode(10); //'<br>';
nih='';
ix++;
}
} else if (cmd == '' && eval(1 + k) == cps[choice].split('.').length) {
nih+=String.fromCodePoint(eval('' + cps[choice].split('.')[k]));
} else if (eval(1 + k) != cps[choice].split('.').length) {
if (cmd == '') {
cmd="nih+=String.fromCodePoint(" + eval('' + cps[choice].split('.')[k]) + ")";
} else {
cmd=cmd.replace(')', ',' + eval('' + cps[choice].split('.')[k]) + ')');
}
} else if (eval(1 + k) == cps[choice].split('.').length) {
if (cmd == '') {
nih+=String.fromCodePoint(eval('' + cps[choice].split('.')[k]));
} else {
cmd=cmd.replace(')', ',' + eval('' + cps[choice].split('.')[k]) + ')');
//alert(cmd);
eval(cmd);
}
}
}
}
//if (ix != 0) { document.title=('' + ix + ':' + nih); }
document.getElementById('eb_' + incap.trim() + ix).innerHTML=nih;
}
}
</script>
</head>
<body onload='fixwhatisthere();'>
<h1>Emoji Background Text</h1><br>
<h3>RJM Programming - October, 2018</h3><br>
<h4>Feel free to see Emoji Background to the Text you write below ...</h4><br><br>
<div onkeypress='addto(1);' onkeydown='addto(2);' id=dc style='background-color:transparent;opacity:1.0;width:95%;height:70vh;border:3px solid green;' contenteditable=true></div>
<div id=rest style="width:100%;opacity:0.5;"></div>
</body>
</html>