<!doctype html>
<html>
<head>
<title>Random Emoji Equation Game - RJM Programming - November, 2016 ... Thanks to http://stackoverflow.com/questions/22006218/replace-emoji-unicode-symbol-using-regexp-in-javascript and http://xahlee.info/js/js_unicode_code_point.html</title>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=0.25, maximum-scale=8, user-scalable=yes">
<meta charset="utf-8" />
<link href='//www.rjmprogramming.com.au/PHP/emboss_h1.css' rel='stylesheet' type='text/css'>
<script type='text/javascript'>
// Thanks to http://stackoverflow.com/questions/22006218/replace-emoji-unicode-symbol-using-regexp-in-javascript
var firstbytes=['\ud83c', '\ud83d', '\ud83d'];
var srangebytes=['\udf00', '\udc00', '\ude80'];
var rsize=[0x00ff, 0x024f, 0x007f];
var erangebytes=['\udfff', '\ude4f', '\udeff'];
var limiting_range=[-1,-1];
var emoticon=[128512,128591];
var transport_map=[128640,128767];
var miscellaneous=[9728,9983];
var dingbats=[9984,10175];
var pictographs=[127744,128511];
var supplementary=[129280,129535];
var cnt=0;
var emailto='';
var firstemojilist=true;
var emojisaved=false;
var startemojilist=null;
var ouval="";
var oudelim="";
var fsize=location.search.split('size=')[1] ? (location.search.split('size=')[1]).split('&')[0] : '196';
var bcol=location.search.split('bcol=')[1] ? '#' + (location.search.split('bcol=')[1]).split('&')[0] : 'YELLOW';
var gameposition=-1;
var gamediv=null;
var gamedivih='';
var gamebits=["","","","=",""];
var urlbit="http://www.rjmprogramming.com.au/emoji_equation_game.html" + encodeURIComponent("?") + "emojilist" + encodeURIComponent("=");
var ubit="";
var cf = "bold 40px Impact";
var context;
var intext="";
var elem;
var pretoh="";
var wo=null;
var wsecs=0;
var clickthis="";
function clickthisnow() {
if (clickthis != "") document.getElementById(clickthis).click();
clickthis="";
}
function waitnow() {
wsecs++;
if (wsecs >= 10) {
if (wo) wo.close();
document.getElementById('iemail').click();
wsecs=0;
wo=null;
} else if (!wo.closed) {
wsecs++;
setTimeout(waitnow, 1000);
} else {
document.getElementById('iemail').click();
wsecs=0;
wo=null;
}
}
function placetext() {
elem=document.getElementById('mycanvas');
context = elem.getContext("2d");
context.font = cf;
context.strokeText(intext.replace(/ /g, " "), 10, 37);
context.fillText(intext.replace(/ /g, " "), 10, 37);
pretoh = elem.toDataURL("image/png",0);
}
function canvasize(intxt) {
intext=intxt;
setTimeout(placetext, 1000);
return "<canvas id='mycanvas' valign='top' width=365 height=50 style='border: 3px solid green; background-color:#ffffff;'></canvas>";
}
function signbit(huhs) {
var sbits, sbit;
if (huhs.trim() == "") {
sbits=gamediv.innerHTML.split('<');
gamediv.innerHTML=sbits[0] + huhs + ' ';
gamedivih=gamediv.innerHTML;
gamediv.innerHTML+='<span title="Waiting for you to pick an Emoji below">?</span>';
} else if (huhs.length > 1) {
sbits=gamediv.innerHTML.split('<');
sbit=sbits[0];
gamediv.innerHTML=canvasize(sbit) + ' <a id="xemail" style="text-decoration:underline;cursor:pointer;" onclick="alert(\'Get ready to Select All (Windows Ctrl-A, Mac OS X Cmd-A) and Copy (Windows Ctrl-C, Mac OS X Cmd-C) the next window then close it (or we will after 10 seconds) to Proceed to Email where you Paste (Windows Ctrl-V, Mac OS X Cmd-V) this into the Body section of the Email, after filling out a To email address, thanks. By the way, to save the Emoji Equation for yourself there would be a Windows right click or Mac OS X two finger gesture, over the image at the left, to achieve this. Could be your motto or logo perhaps?!\'); wo=window.open(pretoh,\'_blank\',\'top=50,left=50,width=500,height=200\'); setTimeout(waitnow,1000); " title="Pre Image Email">Email Your Emoji Equation Image to Someone</a><a href="mailto:?subject=Do%20You%20Like%20My%20Emoji%20Equation%3f%20%20%20' + encodeURIComponent(sbit.replace(/ /g, ' ')) + '&body=' + '" title="Email" id="iemail"> </a>' + '<br><a href="mailto:?subject=Do%20You%20Like%20My%20Emoji%20Equation%3f%20%20%20' + encodeURIComponent(sbit.replace(/ /g, ' ')) + '&body=' + ubit + '" title="Email" id="aemail">Email Your Emoji Equation Link to Someone</a>';
ubit="";
gamebits=["","","","=",""];
gameposition=-1;
gamedivih='';
if (huhs.indexOf('Image') != -1) {
clickthis="xemail";
} else if (huhs.indexOf('Link') != -1) {
clickthis="aemail";
}
setTimeout(clickthisnow, 1000);
} else {
gameposition++;
if (gamebits[gameposition] == "") {
gamebits[gameposition]=huhs;
ubit=ubit + encodeURIComponent(";") + huhs.replace("+","#1").replace("-","#2").replace("*","#3").replace("/","#4").replace("#","-");
} else {
ubit=ubit + encodeURIComponent(";") + "-5";
}
sbits=gamediv.innerHTML.split('<');
gamediv.innerHTML=sbits[0] + huhs + ' ';
gamedivih=gamediv.innerHTML;
gamediv.innerHTML+='<span title="Waiting for you to pick an Emoji below">?</span>';
gameposition++;
}
}
function game(thispostfw) {
if (!gamediv) {
gamediv=document.getElementById('game');
}
if (gamedivih == '') gamediv.innerHTML=gamedivih;
gamedivih=gamediv.innerHTML;
if (gamedivih == '') {
gameposition=0;
if (ubit != "") {
ubit=ubit + encodeURIComponent(";") + thispostfw;
} else {
ubit=urlbit + thispostfw;
}
gamebits[gameposition]+="" + thispostfw + ";";
gamediv.innerHTML = gamebits[gameposition] + ' <select onchange=" signbit(this.value); "><option value=>Please select option below ...</option><option value="+">+</option><option value="-">-</option><option value="*">*</option><option value="/">/</option><option value=" ">More Emojis Appended to Left</option></select>';
} else {
if (thispostfw != -1) {
ubit=ubit + encodeURIComponent(";") + thispostfw;
gamebits[gameposition]+="" + thispostfw + ";";
}
if (gameposition == 0) {
gamediv.innerHTML = gamebits[gameposition] + '<select onchange=" signbit(this.value); "><option value=>Please select option below ...</option><option value="+">+</option><option value="-">-</option><option value="*">*</option><option value="/">/</option><option value=" ">More Emojis Appended to Left Hand Emoji Set</option></select>';
gamedivih=gamediv.innerHTML;
} else if (gameposition == 2) {
gamediv.innerHTML = gamebits[0] + ' ' + gamebits[1] + ' ' + gamebits[2] + '<select onchange=" signbit(this.value); "><option value=>Please select option below ...</option><option value="=">=</option><option value=" ">More Emojis Appended to Second Emoji Set</option></select>';
gamedivih=gamediv.innerHTML;
} else if (gameposition == 4) {
gamediv.innerHTML = gamebits[0] + ' ' + gamebits[1] + ' ' + gamebits[2] + ' ' + gamebits[3] + ' ' + gamebits[4] + '<select onchange=" signbit(this.value); "><option value=>Please select option below ...</option><option value="Happy">Happy With That</option><option value="HappyImage">Email Your Emoji Equation Image to Someone</option><option value="HappyLink">Email Your Emoji Equation Link to Someone</option><option value=" ">More Emojis Appended to Right Hand Emoji Set</option></select>';
gamedivih=gamediv.innerHTML;
}
}
}
function aske() {
var tois=prompt("Who will you email your Emoji Slideshow to?", emailto);
if (tois) {
if (tois.indexOf('@') != -1) {
document.getElementById("to").value = tois;
document.getElementById("urlbig").value = encodeURIComponent("<!doctype html><html><head>" + document.head.innerHTML.replace(/'/g,"~").replace(/"/g,"`").replace(/&/g,"!!") + "</head><body onload=~ setInterval(dothis,3000);~>" + document.body.innerHTML.replace(/'/g,"~").replace(/"/g,"`").replace(/&/g,"!!") + "</body></html>");
//document.getElementById("urlbig").value = encodeURIComponent("<!doctype html><html><head><title>Random Emoji Equation Game - RJM Programming - October, 2016 ... Thanks to http://stackoverflow.com/questions/22006218/replace-emoji-unicode-symbol-using-regexp-in-javascript and http://xahlee.info/js/js_unicode_code_point.html</title><meta charset=utf-8 /><link href=//www.rjmprogramming.com.au/PHP/emboss_h1.css rel=stylesheet type=text/css></head><body>" + document.body.innerHTML.replace(/'/g,"~").replace(/"/g,"`").replace(/&/g,"!!") + "</body></html>");
document.getElementById("sendemail").click();
}
}
}
// Thanks to http://xahlee.info/js/js_unicode_code_point.html below
// returns a char's Unicode codepoint, of the char at index idx of string str
// 2013-07-16 from https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/charCodeAt
function fixedCharCodeAt (str, idx) {
// ex. fixedCharCodeAt ('\uD800\uDC00', 0); // 65536
// ex. fixedCharCodeAt ('\uD800\uDC00', 1); // 65536
idx = idx || 0;
var code = str.charCodeAt(idx);
var hi, low;
if (0xD800 <= code && code <= 0xDBFF) { // High surrogate (could change last hex to 0xDB7F to treat high private surrogates as single characters)
hi = code;
low = str.charCodeAt(idx+1);
if (isNaN(low)) {
throw 'High surrogate not followed by low surrogate in fixedCharCodeAt()';
}
return ((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000;
}
if (0xDC00 <= code && code <= 0xDFFF) { // Low surrogate
// We return false to allow loops to skip this iteration since should have already handled high surrogate above in the previous iteration
return false;
/*hi = str.charCodeAt(idx-1);
low = code;
return ((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000;*/
}
return code;
}
function dothis() {
var postfw=-1, fw=Math.floor((Math.random()*firstbytes.length)+0);
var zfw=Math.floor((Math.random() * 10) + 0);
//alert(zfw);
if (limiting_range[0] == -1 && limiting_range[1] == -1) {
if (eval(zfw) == 0) {
postfw=Math.floor((Math.random()*eval(miscellaneous[1] - miscellaneous[0])) + miscellaneous[0]);
//document.title='zero ' + postfw;
} else if (eval(zfw) == 1) {
postfw=Math.floor((Math.random()*eval(dingbats[1] - dingbats[0])) + dingbats[0]);
//document.title='one ' + postfw;
} else if (eval(zfw) == 2) {
postfw=Math.floor((Math.random()*eval(supplementary[1] - supplementary[0])) + supplementary[0]);
//document.title='two ' + postfw;
} else {
try {
postfw = eval(Math.floor((Math.random()*rsize[fw])+0) + (firstbytes[fw] + srangebytes[fw]).codePointAt(0)); //Math.floor((Math.random()*rsize[fw])+0));
} catch(e) {
postfw = eval(Math.floor((Math.random()*rsize[fw])+0) + fixedCharCodeAt((firstbytes[fw] + srangebytes[fw]), 0)); //Math.floor((Math.random()*rsize[fw])+0));
}
//document.title='three ' + postfw;
}
}
if (limiting_range[0] != -1 || limiting_range[1] != -1) {
while (eval(postfw) < eval(limiting_range[0]) || eval(postfw) > eval(limiting_range[1])) {
if (document.getElementById('ecat').value == 'miscellaneous' || document.getElementById('ecat').value == 'dingbats' || document.getElementById('ecat').value == 'supplementary') {
postfw=Math.floor((Math.random()*eval(limiting_range[1] - limiting_range[0])) + limiting_range[0]);
} else {
fw=Math.floor((Math.random()*firstbytes.length)+0);
try {
postfw = eval(Math.floor((Math.random()*rsize[fw])+0) + (firstbytes[fw] + srangebytes[fw]).codePointAt(0)); //Math.floor((Math.random()*rsize[fw])+0));
} catch(e) {
postfw = eval(Math.floor((Math.random()*rsize[fw])+0) + fixedCharCodeAt((firstbytes[fw] + srangebytes[fw]), 0)); //Math.floor((Math.random()*rsize[fw])+0));
}
}
}
}
if (bcol != "YELLOW") {
document.getElementById('myh4').innerHTML = '';
document.getElementById('re').innerHTML = ' ';
} else {
document.getElementById('myh4').innerHTML = 'Codepoint: <a onclick=" game(' + postfw + '); " title="No Google search" style="text-decoration:underline;">' + postfw + '</a>';
document.getElementById('re').innerHTML = '<a style=text-decoration:none; target=_blank onclick=" game(' + postfw + '); " title="Google search" href="https://www.google.com.au/?gfe_rd=cr&ei=X6rxV8GfFqzr8Aeo-5_4AQ&gws_rd=ssl#q=%26%23' + postfw + '">' + String.fromCodePoint(postfw) + '</a>';
cnt++;
if (eval(cnt) > 1200) {
cnt = 1;
document.getElementById('sessiontr').innerHTML = "";
ouval="";
oudelim="";
}
var carr=['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'];
var ired = Math.floor(Math.random() * 127);
var igreen = Math.floor(Math.random() * 127);
var iblue = Math.floor(Math.random() * 127);
var colhuh = '#f' + carr[Math.floor(eval(ired) % 16)] + 'f' + carr[Math.floor(eval(igreen) % 16)] + 'f' + carr[Math.floor(eval(iblue) % 16)]; // + carr[Math.floor(derived_sentences[sentencepick].length / 16)] + carr[Math.floor(derived_sentences[sentencepick].length % 16)] + carr[Math.floor(derived_sentences[sentencepick].length / 16)] + carr[Math.floor(derived_sentences[sentencepick].length % 16)]
document.getElementById('sessiontr').innerHTML += '<td id=td' + cnt + ' style="font-size:18px;background-color:' + colhuh + ';">' + document.getElementById('myh4').outerHTML + '<br>' + document.getElementById('re').outerHTML + '</td>';
ouval+=oudelim + postfw;
oudelim=",";
}
}
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 cookievalue(cname) {
var startcookie = document.cookie.split("; ");
for (var i=0; i<startcookie.length; i++) {
if (cname == startcookie[i].split("=")[0]) {
return startcookie[i].split("=")[1];
}
}
return "";
}
function getemojilist() {
if (firstemojilist) {
startemojilist = startcookiedom();
firstemojilist = false;
if (startemojilist) {
document.getElementById('myh1').innerHTML = document.getElementById('myh1').innerHTML.replace(' - ', '<a onclick=recallemoji(); title="Recall previous saved session emoji snapshot">🔂🍪</a> - ');
}
document.getElementById('ecat').value=(location.search.split('category=')[1] ? (location.search.split('category=')[1]).split('&')[0] : '');
if (document.getElementById('ecat').value != "") rangeize(document.getElementById('ecat').value);
}
return document.body.innerHTML;
}
function setemojilist(ourinval) {
startemojilist = "";
if (typeof ourinval=='object') {
startemojilist = ourinval.target.id;
} else if (typeof ourinval=='string') {
startemojilist = ourinval;
} else {
startemojilist = window.event.srcElement.id;
}
}
function expand(via) {
var postfw;
var carr=['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'];
var ired;
var igreen;
var iblue;
var colhuh;
if (via != "" && via != null) {
var obits=via.split(',');
ouval="";
oudelim="";
cnt = 1;
document.getElementById('sessiontr').innerHTML = "";
if (via.indexOf(' ') != -1) {
document.getElementById('sessiondiv').style.visibility='visible';
ouval=" ";
} else {
document.getElementById('sessiondiv').style.visibility='hidden';
}
for (var jcnt=0; jcnt<obits.length; jcnt++) {
postfw=eval(obits[jcnt].replace(' ','').replace(' ','').replace(' ','').replace(' ','').replace(' ',''));
document.getElementById('myh4').innerHTML = 'Codepoint: <a title="No Google search" onclick=" game(' + postfw + '); " style="text-decoration:underline;">' + postfw + '</a>';
document.getElementById('re').innerHTML = '<a style=text-decoration:none; target=_blank title="Google search" onclick=" game(' + postfw + '); " href="https://www.google.com.au/?gfe_rd=cr&ei=X6rxV8GfFqzr8Aeo-5_4AQ&gws_rd=ssl#q=%26%23' + postfw + '">' + String.fromCodePoint(postfw) + '</a>';
ired = Math.floor(Math.random() * 127);
igreen = Math.floor(Math.random() * 127);
iblue = Math.floor(Math.random() * 127);
colhuh = '#f' + carr[Math.floor(eval(ired) % 16)] + 'f' + carr[Math.floor(eval(igreen) % 16)] + 'f' + carr[Math.floor(eval(iblue) % 16)]; // + carr[Math.floor(derived_sentences[sentencepick].length / 16)] + carr[Math.floor(derived_sentences[sentencepick].length % 16)] + carr[Math.floor(derived_sentences[sentencepick].length / 16)] + carr[Math.floor(derived_sentences[sentencepick].length % 16)]
document.getElementById('sessiontr').innerHTML += '<td id=td' + cnt + ' style="font-size:18px;background-color:' + colhuh + ';">' + document.getElementById('myh4').outerHTML + '<br>' + document.getElementById('re').outerHTML + '</td>';
if (ouval == " ") {
ouval+=oudelim + postfw + " ";
} else {
ouval+=oudelim + postfw;
}
oudelim=",";
cnt++;
}
return "";
}
return document.body.innerHTML;
}
function recallemoji() {
expand(startemojilist);
emojisaved=true;
}
function startcookiedom() {
var startcookie;
var qtbits=document.URL.split('emojilist=');
var iqtb, qtb=decodeURIComponent(qtbits[1]).split(";");
startcookie = cookievalue("emojilist");
if (qtb.length > 1) {
for (iqtb=0; iqtb<qtb.length; iqtb++) {
if (qtb[iqtb].indexOf("-") == -1) {
game(eval(qtb[iqtb]));
} else if (qtb[iqtb] == "-1") {
signbit("+");
} else if (qtb[iqtb] == "-2") {
signbit("-");
} else if (qtb[iqtb] == "-3") {
signbit("*");
} else if (qtb[iqtb] == "-4") {
signbit("/");
} else if (qtb[iqtb] == "-5") {
signbit("=");
}
}
signbit("End of stuff");
for (iqtb=0; iqtb<qtb.length; iqtb++) {
if (qtb[iqtb].indexOf("-") == -1) {
window.open("https://www.google.com.au/?gfe_rd=cr&ei=X6rxV8GfFqzr8Aeo-5_4AQ&gws_rd=ssl#q=%26%23" + qtb[iqtb].trim(), "_blank");
}
}
if (startcookie == "") startcookie=decodeURIComponent(qtb[1].replace("-1;","").replace("-2;","").replace("-3;","").replace("-4;","").replace("-5;","").replace(/;/g,"; "));
}
if (firstemojilist) {
return startcookie;
} else if (startcookie) {
startemojilist = startcookie;
} else {
startemojilist = getemojilist();
}
setemojilist(startemojilist);
var alli = document.getElementsByTagName("input");
for (var i=0; i<alli.length; i++) {
if (alli[i].type == "button") {
alli[i].onclick = setemojilist;
}
}
}
function saveemoji() {
var expiredate = new Date();
expiredate.setYear(expiredate.getFullYear()+1);
if (!emojisaved) {
if (document.getElementById('sessiondiv').style.visibility == 'visible') ouval=(ouval + ' ').replace(',', ' ,');
document.cookie = "emojilist=" + ouval + ";expires=" + expiredate.toGMTString() + ';path=/';
startemojilist = cookievalue("emojilist");
}
emojisaved=true;
}
function rangeize(tval) {
if (tval == '') {
limiting_range=[-1,-1];
} else {
eval("limiting_range[0]=" + tval + "[0];");
eval("limiting_range[1]=" + tval + "[1];");
}
}
</script>
</head>
<body onunload=' saveemoji(); ' onload=" getemojilist(); setInterval(dothis,3000);">
<h1 id='myh1' style=text-align:center;width:100%;><select id='ecat' onchange='rangeize(this.value);'><option value=>Any</option><option value=emoticon>Emoticon 😀 to 🙏</option><option value=transport_map>Transport and Map 🚀 to </option><option value=miscellaneous>Miscellaneous ☀ to ⛿</option><option value=dingbats>Dingbats ✀ to ➿</option><option value=pictographs>Pictographs 🌀 to 🗿</option><option value=supplementary>Supplementary 🤀 to 🧿</option></select> Random Emoji Equation Game<a onclick="ouval+=' '; document.getElementById('sessiondiv').style.visibility='visible';cursor:pointer;" title='Access saved emojis'>➕➕</a><a title='Share via Email' onclick=' aske(); '>📧</a> <a onclick="emojisaved=false; saveemoji();" title="Save current session snapshot right here">💾🍪 </a> - RJM Programming - November, 2016</h1>
<h3 style=text-align:center;width:100%;>Thanks to <a target=_blank title='http://stackoverflow.com/questions/22006218/replace-emoji-unicode-symbol-using-regexp-in-javascript' href='http://stackoverflow.com/questions/22006218/replace-emoji-unicode-symbol-using-regexp-in-javascript'>http://stackoverflow.com/questions/22006218/replace-emoji-unicode-symbol-using-regexp-in-javascript</a> and <a target=_blank title='http://xahlee.info/js/js_unicode_code_point.html' href='http://xahlee.info/js/js_unicode_code_point.html'>http://xahlee.info/js/js_unicode_code_point.html</a></h3>
<div id='game' style=text-align:center;width:100%;></div>
<h4 id=myh4 style=text-align:center;width:100%;>Codepoint: </h4>
<script type='text/javascript'>
document.write("<div style=text-align:center;width:100%;height:800px;font-size:" + fsize + "px;background-color:" + bcol + ";padding-top:30px; id=reout><span id=re></span><br><div id=sessiondiv style='border:2px solid red;-webkit-overflow-scrolling:touch;overflow-x:scroll;visibility:hidden;'><table border=20 cellpadding=5 cellspacing=5><tbody id=sessiontbody><tr id=sessiontr></tr></tbody></table></div></div>");
</script>
<form target='emailer' id=emailform style=display:none; method='POST' action='http://www.rjmprogramming.com.au/HTMLCSS/legend_via_map.php'>
<input type='hidden' name=to id=to value=></input>
<input type='hidden' name=cc id=cc value=></input>
<input type='hidden' name=bcc id=bcc value=></input>
<input type='hidden' name=url id=url value=></input>
<input type='hidden' name=urlbig id=urlbig value=></input>
<input type='hidden' name=subject id=subject value='Emoji Slideshow via RJM Programming'></input>
<input type='submit' style=display:none; value='Email' id='sendemail'></input>
</form>
<iframe name=emailer id=emailer style=display:none; src='http://www.rjmprogramming.com.au/HTMLCSS/legend_via_map.php'></iframe>
</body>
</html>