<!doctype html>
<html>
<head>
<title>Random Emoji Slideshow - 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 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';

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 Slideshow - 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 target=_blank title="Google search" href="https://www.google.com.au/?gfe_rd=cr&ei=X6rxV8GfFqzr8Aeo-5_4AQ&gws_rd=ssl#q=%26%23' + postfw + '">' + postfw + '</a>';
document.getElementById('re').innerHTML = '<a style=text-decoration:none; target=_blank 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 target=_blank title="Google search" href="https://www.google.com.au/?gfe_rd=cr&ei=X6rxV8GfFqzr8Aeo-5_4AQ&gws_rd=ssl#q=%26%23' + postfw + '">' + postfw + '</a>';
document.getElementById('re').innerHTML = '<a style=text-decoration:none; target=_blank 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>';
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 = cookievalue("emojilist");
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 Slideshow<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 - October, 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>
<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>