<?php
 // fairy_story_assistant.php
 // Updated in December, 2020
 // RJM Programming
 if (file_exists('../PHP/spsup.htm')) {
     if (date("U",filemtime('../PHP/spsup.htm')) <= (time() - 300)) {
        file_put_contents('../PHP/spsup.htm', '');
     }
 }
 $punctsel="<select id=punsel onchange=\"if (this.value.trim().length > 0) { ontosb(this); }\"><option value=\"\">Punctuation</option>";
 $punctsel.="<option value=\".\">.</option>";
 $punctsel.="<option value=\"?\">?</option>";
 $punctsel.="<option value=\"!\">!</option>";
 $punctsel.="<option value=\",\">,</option>";
 $punctsel.="<option value=\":\">:</option>";
 $punctsel.="<option value=\";\">;</option>";
 $punctsel.="<option value=\"(\">(</option>";
 $punctsel.="<option value=\")\">)</option>";
 $punctsel.="<option value=\"[\">[</option>";
 $punctsel.="<option value=\"]\">]</option>";
 $punctsel.="<option value=\"{\">{</option>";
 $punctsel.="<option value=\"}\">}</option>";
 $punctsel.="<option value=\"@\">@</option>";
 $punctsel.="<option value=\"&\">&</option>";
 $punctsel.="<option value=\"%\">%</option>";
 $punctsel.="<option value=\"$\">$</option>";
 $punctsel.="<option value=\"*\">*</option>";
 $punctsel.="<option value=\"^\">^</option>";
 $punctsel.="<option value=\"+\">+</option>";
 $punctsel.="<option value=\"=\">=</option>";
 $punctsel.="<option value=\"-\">-</option>";
 $punctsel.="<option value=\"_\">_</option>";
 $punctsel.="<option value=\"|\">|</option>";
 $punctsel.="<option value=\"/\">/</option>";
 $punctsel.="<option value=\"\\\\\">&#92;</option>";
 $punctsel.="<option value=\"~\">~</option>";
 $punctsel.="<option value=\"`\">`</option>";
 $punctsel.="<option value=\"<\">&lt;</option>";
 $punctsel.="<option value=\">\">&gt;</option>";
 $punctsel.="<option id=squote value=\"\">&apos;</option>";
 $punctsel.="<option id=dquote value=\"\">&quot;</option>";
 $punctsel.="</select> and/or ";
 exec("sort -n /usr/share/dict/propernames > " . dirname(__FILE__) . "/propernames.txt");
 $nameslist=explode("\n", file_get_contents(dirname(__FILE__) . "/propernames.txt"));
 unlink(dirname(__FILE__) . "/propernames.txt");
 exec("sort -n /usr/share/dict/connectives > " . dirname(__FILE__) . "/connectives.txt");
 $conslist=explode("\n", file_get_contents(dirname(__FILE__) . "/connectives.txt"));
 unlink(dirname(__FILE__) . "/connectives.txt");
 $namesselihsuffix="";
 for ($ii=0; $ii<sizeof($nameslist); $ii++) {
   $namesselihsuffix.='<option value="' . $nameslist[$ii] . '">' . $nameslist[$ii] . '</option>';
 } 
 $consselihsuffix="";
 for ($ii=0; $ii<sizeof($conslist); $ii++) {
   if ($conslist[$ii] == "i") {
   $consselihsuffix.='<option value=' . str_replace('"i"','"I"','"' . $conslist[$ii] . '"') . str_replace('>i<','>I<','>' . $conslist[$ii] . '<') . '/option>';
   } else if (trim($conslist[$ii]) != "") {
   $consselihsuffix.='<option value="' . $conslist[$ii] . '">' . $conslist[$ii] . '</option>';
   $consselihsuffix.='<option value="' . strtoupper(substr($conslist[$ii],0,1)) . substr($conslist[$ii],1) . '">' . strtoupper(substr($conslist[$ii],0,1)) . substr($conslist[$ii],1) . '</option>';
   }
 }
?>
<html>
<head>
<meta charset="UTF-8">
<link href="//afeld.github.io/emoji-css/emoji.css" rel="stylesheet">
<title>Fairy Story Paste Helper - RJM Programming - March, 2018</title>

<script type='text/javascript'>

var randis=-1, randi=-1, randsofar='', fullrandis='';
var notatend=false, clicked=false;
var prefix="", nothing="", cnotatend="", cnt=0, cah=false, curss=0;
var snapshots=[];
var onethousand=1000;

if (document.URL.toLowerCase().indexOf('http:') == 0) {
  randi=Math.floor(Math.random() * 198765432);
  fullrandis='?rand=' + randi;
}

function ontosb(tvn) {
  var qprefix="";
  if ((" " + top.document.getElementById("storyboard").innerHTML).replace(/\&nbsp\;/g," ").slice(-1) != " " && ( ((tvn.value + " ").substring(0,1) >= "0" && (tvn.value + " ").substring(0,1) <= "9") || ((tvn.value + " ").substring(0,1) >= "A" && (tvn.value + " ").substring(0,1) <= "Z") || ((tvn.value + " ").substring(0,1) >= "a" && (tvn.value + " ").substring(0,1) <= "z") ) ) {
   qprefix=" ";
  }
  top.document.getElementById("storyboard").innerHTML+=qprefix + tvn.value + "&nbsp;";
  tvn.value="";
  placeCaretAtEnd(top.document.getElementById('storyboard'));
  top.document.getElementById("storyboard").focus();
}

function getss(incis) {
  var iis=eval('' + curss);
  iis+=eval('' + incis);
  if (iis >= 0 && iis < snapshots.length) {
    curss=iis;
    document.getElementById("storyboard").innerHTML=snapshots[curss];
  }
}

function issetgetcp() {
<?php 
  if (isset($_GET['getcp'])) { echo "\n return true; \n"; } else {  echo "\n return false; \n"; }
?>
}

function nocah() {
  if (cah && (navigator.userAgent.toLowerCase().indexOf('firefox') != -1 || issetgetcp())) {
    cah=false;
    document.getElementById('eemail').click();
  } else {
    cah=false;
  }
}

function pcae() {
 if (document.getElementById('mytass').value != '') {
 document.getElementById('mytass').value = '';
 if ((navigator.userAgent.toLowerCase().indexOf('firefox') == -1 || issetgetcp())) {
  if (document.getElementById("storyboard").innerHTML != snapshots[curss]) {
   curss=snapshots.length;
   snapshots.push(document.getElementById("storyboard").innerHTML);
  }
 }
 }
 if (document.getElementById("storyboard")) {
  if (document.getElementById('mytah')) {
 if (snapshots.length == 0) {
   snapshots.push(document.getElementById("storyboard").innerHTML);
 } else if (snapshots.length == 1) {
   if (snapshots[0] == "") snapshots[0]=document.getElementById("storyboard").innerHTML;
 }
   if (document.getElementById('mytah').value != '') {
     document.getElementById('mytah').value='';
     //placeCaretAtEnd(document.getElementById("storyboard"));
   if (document.getElementById('myprefix')) {
     prefix=document.getElementById('myprefix').value;
   }
   if (document.getElementById('mywith')) {
     cnotatend=document.getElementById('mywith').value;
   }
   if (document.getElementById('mynae')) {
   if (document.getElementById('mynae').value != '') {
     notatend=true;
     document.getElementById('mynae').value='';
   }
   }
     if (prefix != "" || notatend == true) clicked=false;
     if (prefix == "") {
     placeCaret(document.getElementById("storyboard"), notatend);
     } else if (cnotatend != "") {
     cnt=1;
     placeCaret(document.getElementById("storyboard"), cnotatend);
     cnotatend="";
     } else {
     cnt++;
     if (cnt == 3) {
     prefix="";
     placeCaret(document.getElementById("storyboard"), notatend);
     }
     }
     notatend=false;
   } else {
     fixfirefox();
   }
  }
 }
 setTimeout(pcae,3000);
}

function placeCaret(el, isStart) { // thanks to https://stackoverflow.com/questions/4233265/contenteditable-set-caret-at-the-end-of-the-text-cross-browser
  if (!clicked || 1 == 1) {
   if (document.getElementById('myprefix')) {
     prefix=document.getElementById('myprefix').value;
     document.getElementById('myprefix').value="";
   }
   if (document.getElementById('mywith')) {
     cnotatend=document.getElementById('mywith').value;
     if (cnotatend != "" && prefix != "") isStart=cnotatend;
     document.getElementById('mywith').value="";
   }
   if (prefix != "") {
    if (el.innerHTML.indexOf(prefix) != -1) {
    el.innerHTML=el.innerHTML.replace(prefix, prefix + isStart);
    prefix+=isStart;
    } else if (el.innerHTML.replace(/&nbsp;/g,' ').indexOf(prefix.replace(/&nbsp;/g,' ')) != -1) {
    el.innerHTML=el.innerHTML.replace(/&nbsp;/g,' ').replace(prefix.replace(/&nbsp;/g,' '), prefix.replace(/&nbsp;/g,' ') + isStart);
    prefix+=isStart;
    } else {
    var words=prefix.replace(/&nbsp;/g,' ').split(' ');
    var firstgo=prefix.replace(/&nbsp;/g,' '); //.replace(/&nbsp;/g,' ').replace(words[0] + ' ',' ');
    var origfg=prefix;
    for (var iij=0; iij<words.length; iij++) {
      if (origfg == prefix) {
      firstgo=firstgo.replace(/&nbsp;/g,' ').replace(words[iij] + ' ',' ');
      //alert('|' + firstgo + '| ... ' + el.innerHTML.replace(/&nbsp;/g,' ').indexOf(firstgo) + ' vs |' + el.innerHTML.replace(/&nbsp;/g,' ') + '|');
      if (el.innerHTML.replace(/&nbsp;/g,' ').indexOf(firstgo) != -1) {
      if (firstgo.trim() != '') {
    el.innerHTML=el.innerHTML.replace(/&nbsp;/g,' ').replace(firstgo.replace(/&nbsp;/g,' '), firstgo.replace(/&nbsp;/g,' ') + isStart);
      prefix=firstgo.replace(/&nbsp;/g,' ');
      }
      } else if (el.innerHTML.replace(/&nbsp;/g,' ').indexOf(firstgo.trim()) != -1) {
      if (firstgo.trim() != '') {
    el.innerHTML=el.innerHTML.replace(/&nbsp;/g,' ').replace(firstgo.replace(/&nbsp;/g,' ').trim(), firstgo.replace(/&nbsp;/g,' ').trim() + isStart);
      prefix=firstgo.replace(/&nbsp;/g,' ').trim();
      }
      }
      }
    }
    prefix+=isStart;
    }
   } else if (1 == 2 && navigator.userAgent.toLowerCase().indexOf('firefox') != -1) {
    el=el;
   } else if (!cah) {
    el.focus();
    if (typeof window.getSelection != "undefined"
            && typeof document.createRange != "undefined") {
        var range = document.createRange();
        range.selectNodeContents(el);
        range.collapse(isStart);
        clicked=false;
        var sel = window.getSelection();
        sel.removeAllRanges();
        sel.addRange(range);
    } else if (typeof document.body.createTextRange != "undefined") {
        var textRange = document.body.createTextRange();
        textRange.moveToElementText(el);
        textRange.collapse(isStart);
        clicked=false;
        textRange.select();
    }
   }
  }
  clicked=false;
}

function fixfirefox() {

if ((navigator.userAgent.toLowerCase().indexOf('firefox') != -1 || issetgetcp()) && !cah) {
 if (document.getElementById("storyboard").innerHTML.indexOf('<br>') != -1) {
    document.getElementById("storyboard").innerHTML=document.getElementById("storyboard").innerHTML.replace(/\&nbsp\;\&nbsp\;\<br\>/g,'&nbsp;&nbsp;<BR>').replace(/\<br\>\&nbsp\;\&nbsp\;/g,'&nbsp;&nbsp;<BR>').replace(/\<br\>\<br\>/g,'&nbsp;&nbsp;<BR>').replace(/\<br\>\&nbsp\;\<br\>/g,'&nbsp;&nbsp;<BR>').replace(/\&nbsp\;\<br\>/g,'&nbsp;').replace(/\ \<br\>/g,'&nbsp;').replace(/\<br\>/g,'');
 }
 if (document.getElementById("storyboard").innerHTML != snapshots[curss]) {
 curss=snapshots.length;
 snapshots.push(document.getElementById("storyboard").innerHTML);
 }
 //document.title='fhere' + snapshots.length;
}

}

function getCaretPositionString() {  // https://stackoverflow.com/questions/48946330/angular5-get-cursor-position-in-a-contenteditable-div-using-innerhtml-and-pipe
    var element = document.querySelector('#storyboard');
    var range = window.getSelection().getRangeAt(0);
    var preCaretRange = range.cloneRange();
    preCaretRange.selectNodeContents(element);
    preCaretRange.setEnd(range.endContainer, range.endOffset);
    document.getElementById('myprefix').value=preCaretRange.toString();
    //alert('|' + ('' + preCaretRange.toString()) + '|');
    if (('' + preCaretRange.toString()).length == 0) { notatend=true; document.getElementById('mynae').value='true'; } else { notatend=false; document.getElementById('mynae').value='';    }
    return ('' + preCaretRange.toString()); //.length;
}

function placeCaretAtEnd(el) { // thanks to https://stackoverflow.com/questions/4233265/contenteditable-set-caret-at-the-end-of-the-text-cross-browser
    el.focus();
    if (typeof window.getSelection != "undefined"
            && typeof document.createRange != "undefined") {
        var range = document.createRange();
        range.selectNodeContents(el);
        range.collapse(false);
        var sel = window.getSelection();
        sel.removeAllRanges();
        sel.addRange(range);
    } else if (typeof document.body.createTextRange != "undefined") {
        var textRange = document.body.createTextRange();
        textRange.moveToElementText(el);
        textRange.collapse(false);
        textRange.select();
    }
}

function handleEnter(e) {
    var keycode = (e.keyCode ? e.keyCode : e.which);
    if (keycode == '13') {
if ((navigator.userAgent.toLowerCase().indexOf('firefox') != -1 || issetgetcp()) && !notatend && !cah) {
    document.getElementById("storyboard").innerHTML+='<br>';
}
    }
    //keepactive();
}


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 quotestuff() {
  if (document.getElementById('squote')) {
    document.getElementById('squote').value=String.fromCharCode(39);
  }
  if (document.getElementById('dquote')) {
    document.getElementById('dquote').value=String.fromCharCode(34);
  }
}

</script>
</head>
<body onload=quotestuff();>
<script type='text/javascript'>

var topwo=null;

function fit() {
var ip=0;
if ((navigator.userAgent.toLowerCase().indexOf('firefox') != -1 || issetgetcp())) {
  ip=0;
} else {
  document.getElementById('storyboard').focus();
}
  if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
     document.getElementById('mytah').value='x';
  }
}

function keepactive() {
  if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
     document.getElementById('mytah').value=document.getElementById('mytah').value;
  } else {
     document.getElementById('mytah').value='x';
     document.getElementById('mynae').value='';
     document.getElementById('myprefix').value='';
     prefix='';
     notatend=false;
  }
}

function checkioq(iois) {
  if (iois != null) {
    console.log(1);
    var aconto = (iois.contentWindow || iois.contentDocument);
    if (aconto != null) {
    console.log(11);
   try {
    console.log(111);
     if (aconto.document) { aconto = aconto.document; }
     var xemojicont=aconto.body.innerHTML;
     if (xemojicont.length > 0) {
     //document.getElementById('superceeder').style.display='block';
     //top.location.href=document.URL.split('#')[0].split('?')[0].replace(/^\/\//g,'https:').replace('.html','.php').replace('.htm','.php').replace('.htm','.php').replace('http:','https:');

     if (!window.top && window.parent) {
    console.log(2);
     parent.location.href=document.URL.split('#')[0].split('?')[0].replace(/^\/\//g,'https:').replace('.html','.php').replace('.htm','.php').replace('.htm','.php').replace('http:','https:');
    console.log(22);
     } else if (window.top && top.document.URL.replace('/ITblog','/wordpress').indexOf('/wordpress') == -1) {
    console.log(3);
     alert(document.URL.split('#')[0].split('?')[0].replace(/^\/\//g,'https:').replace('.html','.php').replace('.htm','.php').replace('.htm','.php').replace('http:','https:'));
     top.location.href=document.URL.split('#')[0].split('?')[0].replace(/^\/\//g,'https:').replace('.html','.php').replace('.htm','.php').replace('.htm','.php').replace('http:','https:');
    console.log(33);
     } else if (window.top && window.parent && top.document != parent.document) {
    console.log(4);
     parent.location.href=document.URL.split('#')[0].split('?')[0].replace(/^\/\//g,'https:').replace('.html','.php').replace('.htm','.php').replace('.htm','.php').replace('http:','https:');
    console.log(44);
     }

     } else {
     document.getElementById('topdetails').setAttribute("open");
     }
   } catch(eee) {
     document.getElementById('topdetails').setAttribute("open");
   }
   } else {
     document.getElementById('topdetails').setAttribute("open");
   }
  } else {
     document.getElementById('topdetails').setAttribute("open");
  }
}

 function checkdmc(iois) {
  var newstuffis='', newrelps=[];
  var ftdelim='';
  var finaltranscript='';
  var ijk=0;
  if (iois != null) {
    var aconto = (iois.contentWindow || iois.contentDocument);
    if (aconto != null) {
     if (aconto.document) { aconto = aconto.document; }
     if (aconto.body != null) {
       if (aconto.body.innerHTML != randsofar) {
         if (randsofar != '') {
          if (aconto.body.innerHTML.indexOf(randsofar) != -1) {
           newstuffis=aconto.body.innerHTML.split(randsofar)[1];
          }
         }
         randsofar=aconto.body.innerHTML;
         if (newstuffis == '') { newstuffis=randsofar; } 
         if (randis != -1 && newstuffis.replace(/\ style\=\"display\:none\;\"/g,'').indexOf('<p id="' + randis + '">') != -1) {
           newrelps=newstuffis.replace(/\ style\=\"display\:none\;\"/g,'').split('<p id="' + randis + '">');
           for (ijk=1; ijk<newrelps.length; ijk++) {
             if (finaltranscript == '') {
               finaltranscript=newrelps[ijk].split('</p>')[0];
             } else {
               finaltranscript+=' ' + newrelps[ijk].split('</p>')[0];
             }
           }
           
           if (('' + document.getElementById('storyboard').innerHTML.trim() + '~').indexOf((finaltranscript + '~')) == -1) {
           if (document.getElementById('storyboard').innerHTML != '' && document.getElementById('storyboard').innerHTML == document.getElementById('storyboard').innerHTML.trim() && finaltranscript.substring(0,1) != ' ') {
           ftdelim=' ';
           }
           console.log('PREhere with ' + finaltranscript);
           document.getElementById('storyboard').innerHTML=document.getElementById('storyboard').innerHTML + ftdelim + finaltranscript;
           console.log('POSthere with ' + finaltranscript);
           }
           
         }
       }
     }
    }
  }
}

function topwolook() {
  var ftdelim='';
  var finaltranscript='';
  if (topwo) {
    if (document.URL.toLowerCase().indexOf('http:') == 0) {
    onethousand=3000;
    if (!document.getElementById('ifdmcif')) {
      document.getElementById('dmcif').innerHTML='<iframe id=ifdmcif onload=checkdmc(this); style=display:none; src=../PHP/spsup.htm?rnd=' + Math.floor(Math.random() * 1987654234) + '></iframe>';
    } else {
      document.getElementById('ifdmcif').src='../PHP/spsup.htm?rnd=' + Math.floor(Math.random() * 1987654234);
    }
    } else {
    console.log(topwo.document.title);
    var mon=topwo.document.getElementById('theblurbgoes');
    //var sb=topwo.document.getElementById('start_button');
    if (typeof(mon) != "undefined") { //topwo.document.getElementById('theblurbgoes')) {
     //if (('' + topwo.document.getElementById('theblurbgoes').title) != '' && topwo.document.getElementById('theblurbgoes').value.trim() != '') {
     if (topwo.document.getElementById('theblurbgoes').value.trim() != '') {
     finaltranscript=topwo.document.getElementById('theblurbgoes').value;
     topwo.document.getElementById('theblurbgoes').value=' ';
           if (('' + document.getElementById('storyboard').innerHTML.trim() + '~').indexOf((finaltranscript + '~')) == -1) {
           if (document.getElementById('storyboard').innerHTML != '' && document.getElementById('storyboard').innerHTML == document.getElementById('storyboard').innerHTML.trim() && finaltranscript.substring(0,1) != ' ') {
           ftdelim=' ';
           }
           console.log('PRehere with ' + finaltranscript);
           document.getElementById('storyboard').innerHTML=document.getElementById('storyboard').innerHTML + ftdelim + finaltranscript;
           console.log('POsthere with ' + finaltranscript);
           //if (typeof(sb) != "undefined") { topwo.document.getElementById('start_button').click(); }
           }
     //} else if (topwo.document.getElementById('theblurbgoes').value == ' ') {
           //topwo.document.getElementById('theblurbgoes').value='';
           //if (typeof(sb) != "undefined") { topwo.document.getElementById('start_button').click(); }
     }
     }
    }
  }
  setTimeout(topwolook,onethousand);
}

function modeofuse() {
  var wtw='';
  var bits=document.URL.split('?emoji=');
  if (document.URL.indexOf('?') == -1) {
  if (document.URL.indexOf('.htm') != -1) {
wtw+='<iframe style="z-index:9;display:none;width:100%;height:100vh;" id=superceeder onload=checkioq(this); src="' + document.URL.split('#')[0].split('?')[0].replace('.html','.php').replace('.htm','.php') + '"></iframe>';
wtw+='<details id=topdetails><summary></summary>';
  }
wtw+='<h1>Fairy Story Paste Helper<a style="cursor:pointer;text-decoration:none;" onclick="setTimeout(topwolook,5000); randis=randi; topwo=window.open(' + "'" + 'https://www.rjmprogramming.com.au/PHP/speech_supervisor.php' + fullrandis + "','_blank','top=320,left=350,width=900,height=500');" + '" title="Speech to Text Supervisor">&#127908;</a><a target="_self" href="//www.rjmprogramming.com.au/PHP/emoticon_keyboard_shortcuts.php" title="Home">.</a></h1>' + String.fromCharCode(13);
wtw+='<h3>RJM Programming - March, 2018</h3>' + String.fromCharCode(13);
if ((navigator.userAgent.toLowerCase().indexOf('firefox') != -1 || issetgetcp())) {
wtw+='<h4>Your Fairy Story follows <a title=Undo onclick=getss(-1); style=text-decoration:underline;cursor:pointer;>&#10134;</a><a title=Redo onclick=getss(1); style=text-decoration:underline;cursor:pointer;>&#10133;</a> ... good luck, and please double up on your Enter keys,  optionally clicking helper links for <select id=namesel onchange=\"if (this.value.trim().length > 0) { ontosb(this); }\"><option value=\"\">Name</option><?php echo $namesselihsuffix; ?></select> and/or <select id=consel onchange=\"if (this.value.trim().length > 0) { ontosb(this); }\"><option value=\"\">Connectives</option><?php echo $consselihsuffix; ?></select> and/or <?php echo $punctsel; ?>Emoji <a target=_blank title="Other ways to paste Emojis" href="//www.google.com.au/search?q=emoji+keyboard+shortcuts&ie=utf-8&oe=utf-8&client=firefox-b-ab&gfe_rd=cr&dcr=0&ei=x7JKWsrFGcHN8gfBy5rABw">placement</a> ... <span title="Share via Email and you can Copy the work below and Paste into the email body" style="text-decoration:underline;cursor:pointer;" onclick="cah=true; setTimeout(nocah,7000);">&#128231; via &#128203;</span><a id="eemail" href="mailto:?subject=My%20Fairy%20Story" title="Share via Email and you can Copy the work below and Paste into the email body"></a> ...</h4>' + String.fromCharCode(13);
} else {
wtw+='<h4>Your Fairy Story follows <a title=Undo onclick=getss(-1); style=text-decoration:underline;cursor:pointer;>&#10134;</a><a title=Redo onclick=getss(1); style=text-decoration:underline;cursor:pointer;>&#10133;</a> ... good luck, optionally clicking helper links for <select id=namesel onchange=\"if (this.value.trim().length > 0) { ontosb(this); }\"><option value=\"\">Name</option><?php echo $namesselihsuffix; ?></select> and/or <select id=consel onchange=\"if (this.value.trim().length > 0) { ontosb(this); }\"><option value=\"\">Connectives</option><?php echo $consselihsuffix; ?></select> and/or <?php echo $punctsel; ?>Emoji <a target=_blank title="Other ways to paste Emojis" href="//www.google.com.au/search?q=emoji+keyboard+shortcuts&ie=utf-8&oe=utf-8&client=firefox-b-ab&gfe_rd=cr&dcr=0&ei=x7JKWsrFGcHN8gfBy5rABw">placement</a> ... <a onclick="cah=true; setTimeout(nocah,7000);" id="eemail" href="mailto:?subject=My%20Fairy%20Story" title="Share via Email and you can Copy the work below and Paste into the email body">&#128231; via &#128203;</a> ...</h4>' + String.fromCharCode(13);
}
wtw+='' + String.fromCharCode(13);
wtw+='<div onkeydown="keepactive();" onclick="if (!cah) { prefix=nothing; clicked=true; prefix=getCaretPositionString(); } " contenteditable="true" style="background-color:yellow;width:98%;height:200px;border:10px groove red;padding:3px 3px 3px 3px;" id="storyboard">Once upon a time&nbsp;</div>' + String.fromCharCode(13);
wtw+='' + String.fromCharCode(13);
wtw+='<details open><summary></summary><table style="width:100%;height:260px;" border=2><tr>' + String.fromCharCode(13);
wtw+='<td style="vertical-align:top;width:48%;background-color:pink;">' + String.fromCharCode(13);

var underscore='_';
<?php
if ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443) {
  echo "\n underscore='_'; \n";
}
?>

wtw+='<iframe id="fsac1" style="width:100%;height:260px;" src="//www.rjmprogramming.com.au/PHP/emoticon' + underscore + 'keyboard_shortcuts.php?iframeplease=y&inans=skull%2Cghost%2Calien%2Cimp%2Cangel%2Cprincess%2Ccrystal_ball%2Cjapanese_ogre%2Cspace_invader%2Cjapanese_goblin&outans=Skull%2CGhost%2CAlien%2CAngry+Face+with+Horns%2CBaby+Angel%2CPriness%2CCrystal+Ball%2COgre%2CAlien+Monster%2CGoblin&heading=Fairy+Story+Characters&subheading=Helper&urlprefix=http%3A%2F%2Fwww.rjmprogramming.com.au%2FHTMLCSS%2F' + document.URL.split('#')[0].split('?')[0].split('/')[eval(-1 + document.URL.split('#')[0].split('?')[0].split('/').length)] + '%3Femoji%3D&rand=2033817289"></iframe>' + String.fromCharCode(13);
wtw+='</td><td style="vertical-align:top;width:48%;background-color:orange;">' + String.fromCharCode(13);
wtw+='<iframe id="fsac2" style="width:100%;height:260px;" src="//www.rjmprogramming.com.au/PHP/emoticon' + underscore + 'keyboard_shortcuts.php?iframeplease=y&inans=man&outans=&heading=Fairy+Story+People&subheading=Helper&urlprefix=http%3A%2F%2Fwww.rjmprogramming.com.au%2FHTMLCSS%2F' + document.URL.split('#')[0].split('?')[0].split('/')[eval(-1 + document.URL.split('#')[0].split('?')[0].split('/').length)] + '%3Femoji%3D&rand=311259562"></iframe>' + String.fromCharCode(13);
wtw+='</td></tr></table></details><details open><summary></summary><table style="width:100%;height:260px;" border=2><tr><td style="vertical-align:top;width:48%;background-color:cyan;">' + String.fromCharCode(13);
wtw+='<iframe id="fsac3" style="width:100%;height:260px;" src="//www.rjmprogramming.com.au/PHP/emoticon' + underscore + 'keyboard_shortcuts.php?iframeplease=y&inans=clock&outans=&heading=Fairy+Story+Times&subheading=Helper&urlprefix=http%3A%2F%2Fwww.rjmprogramming.com.au%2FHTMLCSS%2F' + document.URL.split('#')[0].split('?')[0].split('/')[eval(-1 + document.URL.split('#')[0].split('?')[0].split('/').length)] + '%3Femoji%3D&rand=1390790034"></iframe>' + String.fromCharCode(13);
wtw+='</td><td style="vertical-align:top;width:48%;background-color:magenta;">' + String.fromCharCode(13);
wtw+='<iframe id="fsac4" style="width:100%;height:260px;" src="//www.rjmprogramming.com.au/PHP/emoticon' + underscore + 'keyboard_shortcuts.php?iframeplease=y&inans=automobile%2Cvehicle%2Ctractor%2Cambulance%2Cbicycle%2Cpolice%2Cconstruction%2Ctraffic%2Ctruck%2Ctram%2Cbus%2Chelicopter%2Cboat%2Cplane%2C&outans=&heading=Fairy+Story+Transport&subheading=Helper&urlprefix=http%3A%2F%2Fwww.rjmprogramming.com.au%2FHTMLCSS%2F' + document.URL.split('#')[0].split('?')[0].split('/')[eval(-1 + document.URL.split('#')[0].split('?')[0].split('/').length)] + '%3Femoji%3D&rand=285342407"></iframe>' + String.fromCharCode(13);

wtw+='</td></tr></table></details>' + String.fromCharCode(13);
wtw+='' + String.fromCharCode(13);
wtw+='<textarea style="display:none;" rows=1 cols=120 id="mytah" value=""></textarea>' + String.fromCharCode(13);
wtw+='<textarea style="display:none;" rows=1 cols=120 id="myprefix" value=""></textarea>' + String.fromCharCode(13);
wtw+='<textarea style="display:none;" rows=1 cols=120 id="mywith" value=""></textarea>' + String.fromCharCode(13);
wtw+='<textarea style="display:none;" rows=1 cols=120 id="mynae" value=""></textarea>' + String.fromCharCode(13);
wtw+='<textarea style="display:none;" rows=1 cols=120 id="mytass" value=""></textarea>' + String.fromCharCode(13);
  if (document.URL.indexOf('.htm') != -1) {
wtw+='</details>';
  }
   document.write(wtw);
   setTimeout(fit,2000);
   pcae();
  } else if (bits.length == 2) {
   var rest="", cn="";
   if ((decodeURIComponent(bits[1]) + " ").substring(0,1) == "/") {
    rest=decodeURIComponent(bits[1]).substring(1).split('&')[0].split('#')[0].split('<')[0];
   } else {
    rest=decodeURIComponent(bits[1]).split('&')[0].split('#')[0].split('<')[0];
   }
   if (decodeURIComponent(bits[1]).indexOf('<') != -1) {
    if (top.document.getElementById('storyboard')) {
      if (top.document.getElementById('myprefix').value != '') {
      clicked=false;
      cnotatend=cn; //decodeURIComponent(bits[1]).substring(decodeURIComponent(bits[1]).indexOf('<')) + '&nbsp;';
      top.document.getElementById('mywith').value=cnotatend;
      //placeCaret(top.document.getElementById('storyboard'),decodeURIComponent(bits[1]).substring(decodeURIComponent(bits[1]).indexOf('<')) + '&nbsp;');
      } else if (top.document.getElementById('mynae').value != '') {
      top.document.getElementById('storyboard').innerHTML=decodeURIComponent(bits[1]).substring(decodeURIComponent(bits[1]).indexOf('<')) + '&nbsp;' + top.document.getElementById('storyboard').innerHTML;
      if (navigator.userAgent.toLowerCase().indexOf('firefox') == -1 && !issetgetcp()) top.document.getElementById('mytass').value='x';
      } else {
      top.document.getElementById('storyboard').innerHTML+=decodeURIComponent(bits[1]).substring(decodeURIComponent(bits[1]).indexOf('<')) + '&nbsp;';
      if (navigator.userAgent.toLowerCase().indexOf('firefox') == -1 && !issetgetcp()) top.document.getElementById('mytass').value='x';
      }
      if (top.document.getElementById('mytah')) top.document.getElementById('mytah').value='x';
      //placeCaretAtEnd(top.document.getElementById('storyboard'));
    } 
   } else if (top.document.getElementById('storyboard')) {
   if ((navigator.userAgent.toLowerCase().indexOf('firefox') != -1 || issetgetcp())) {
<?php
   $agent="";
   if (isset($_SERVER['HTTP_USER_AGENT'])) {
    $agent = $_SERVER['HTTP_USER_AGENT'];
   }
if (1 == 1 || strstr(strtolower($agent), strtolower('Firefox'))) {
   $words=explode(" ",str_replace('~','',str_replace('~apple~','red-apple','~' . explode("_",str_replace("+","-",str_replace(" ","-",urldecode($_GET['emoji'])))) . '~')));
   $emojiterracont=file_get_contents("http://emojiterra.com/" . str_replace("+","-",str_replace(" ","-",str_replace('~','',str_replace('~apple~','red-apple','~' . urldecode($_GET['emoji']) . '~')))));
   $parts=explode('HTML dec</td><td', $emojiterracont);
   if (sizeof($parts) > 1) {
     $subparts=str_replace('&amp;','&',explode('>',explode('<', $parts[1])[0])[1]);
     if (isset($_GET['getcp'])) {
     echo "\n cn=String.fromCodePoint(" . str_replace(";",",",str_replace("&#","",str_replace(";;","",($subparts . ";")))) . ");   if (top.document.getElementById('myta')) { top.document.getElementById('myta').value+=String.fromCodePoint(" . str_replace(";",",",str_replace("&#","",str_replace(";;","",($subparts . ";")))) . "); if (1 == 1) { cn=''; } }  \n";
     } else {
     echo "\n cn='" . $subparts . "'; \n";
     }
   } else if (sizeof($words) > 1) {
   $emojiterracont=file_get_contents("http://emojiterra.com/" . $words[-1 + sizeof($words)]);
   $parts=explode('HTML dec</td><td', $emojiterracont);
   if (sizeof($parts) > 1) {
     $subparts=str_replace('&amp;','&',explode('>',explode('<', $parts[1])[0])[1]);
     if (isset($_GET['getcp'])) {
     echo "\n cn=String.fromCodePoint(" . str_replace(";",",",str_replace("&#","",str_replace(";;","",($subparts . ";")))) . ");  if (top.document.getElementById('myta')) { top.document.getElementById('myta').value+=String.fromCodePoint(" . str_replace(";",",",str_replace("&#","",str_replace(";;","",($subparts . ";")))) . "); if (15 == 15) { cn=''; }  }   \n";
     } else {
     echo "\n cn='" . $subparts . "'; \n";
     }
   } else {
     if (isset($_GET['getcp'])) {
     echo "\n cn='';   \n";
     } else {
     echo "\n cn='<i class=\"em em-' + rest.replace(/\+/g,'_').replace(/\ /g,'_') + '\"></i>&nbsp;'; \n";
     }
   }
   } else {
     if (isset($_GET['getcp'])) {
     echo "\n cn='';   \n";
     } else {
     echo "\n cn='<i class=\"em em-' + rest.replace(/\+/g,'_').replace(/\ /g,'_') + '\"></i>&nbsp;'; \n";
     }
   }
} else {
     if (isset($_GET['getcp'])) {
     echo "\n cn='';   \n";
     } else {
     echo "\n cn='<i class=\"em em-' + rest.replace(/\+/g,'_').replace(/\ /g,'_') + '\"></i>&nbsp;'; \n";
     }
}
?>
      cnotatend=cn; //'<i class="em em-' + rest.replace(/\+/g,'_').replace(/\ /g,'_') + '"></i>&nbsp;';
      } else {
      cnotatend='<i class="em em-' + rest.replace(/\+/g,'_').replace(/\ /g,'_') + '"></i>&nbsp;';
      }
      if (top.document.getElementById('storyboard')) {
      if (top.document.getElementById('myprefix').value != '') {
      clicked=false;
      top.document.getElementById('mywith').value=cnotatend;
      //placeCaret(top.document.getElementById('storyboard'),'<i class="em em-' + rest.replace(/\+/g,'_').replace(/\ /g,'_') + '"></i>&nbsp;');
      } else if (top.document.getElementById('mynae').value != '') {
      top.document.getElementById('storyboard').innerHTML=cnotatend + top.document.getElementById('storyboard').innerHTML;
      if (navigator.userAgent.toLowerCase().indexOf('firefox') == -1 && !issetgetcp()) top.document.getElementById('mytass').value='x';
      } else {
      top.document.getElementById('storyboard').innerHTML+=cnotatend;
      if (navigator.userAgent.toLowerCase().indexOf('firefox') == -1 && !issetgetcp()) top.document.getElementById('mytass').value='x';
      }
      if (top.document.getElementById('mytah')) top.document.getElementById('mytah').value='x';
      //placeCaretAtEnd(top.document.getElementById('storyboard'));
      } 
   } else if (top.document.getElementById('myfeedback')) {
   if ((navigator.userAgent.toLowerCase().indexOf('firefox') != -1 || issetgetcp()) || top.document.getElementById('myfeedback')) {
<?php
   $agent="";
   if (isset($_SERVER['HTTP_USER_AGENT'])) {
    $agent = $_SERVER['HTTP_USER_AGENT'];
   }
if (1 == 1 || strstr(strtolower($agent), strtolower('Firefox'))) {
   $words=explode(" ",str_replace('~','',str_replace('~apple~','red-apple','~' . explode("_",str_replace("+","-",str_replace(" ","-",urldecode($_GET['emoji'])))) . '~')));
   $emojiterracont=file_get_contents("http://emojiterra.com/" . str_replace("+","-",str_replace(" ","-",str_replace('~','',str_replace('~apple~','red-apple','~' . urldecode($_GET['emoji']) . '~')))));
   $parts=explode(' JSON</td><td', $emojiterracont);
   if (sizeof($parts) > 1) {
     $subparts=str_replace('&amp;','&',explode('>',explode('<', $parts[1])[0])[1]);
     $ssparts=explode(';',$subparts);
     if (sizeof($ssparts) > 2) {
     $huh="";
     $huhz="";
     for ($iy=0; $iy<(-1 + sizeof($ssparts)); $iy++) {
     $huh.=htmlentities($ssparts[$iy] . ';');
     $huhz.=($ssparts[$iy] . ';');
     }
     if (isset($_GET['getcp'])) {
     echo "\n cn=String.fromCodePoint(" . str_replace(";",",",str_replace("&#","",str_replace(";;","",($huhz . ";")))) . ");  if (top.document.getElementById('myta')) { top.document.getElementById('myta').value+=String.fromCodePoint(" . str_replace(";",",",str_replace("&#","",str_replace(";;","",($huhz . ";")))) . "); if (12 == 12) { cn=''; }  }   \n";
     } else {
     echo "\n cn='" . $huh . "'; \n";
     }
     } else {
     if (isset($_GET['getcp'])) {
   $parts=explode('HTML dec</td><td', $emojiterracont);
   if (sizeof($parts) > 1) {
     $subparts=str_replace('&amp;','&',explode('>',explode('<', $parts[1])[0])[1]);
   }
     echo "\n cn=String.fromCodePoint(" . str_replace(";",",",str_replace("&#","",str_replace(";;","",(($subparts) . ";")))) . ");  if (top.document.getElementById('myta')) { top.document.getElementById('myta').value+=String.fromCodePoint(" . str_replace(";",",",str_replace("&#","",str_replace(";;","",(($subparts) . ";")))) . "); if (19 == 19) { cn=''; }  }   \n";
     } else {
     echo "\n cn='" . htmlentities($subparts) . "'; \n";
     }
     }
   } else if (sizeof($words) > 1) {
   $emojiterracont=file_get_contents("http://emojiterra.com/" . $words[-1 + sizeof($words)]);
   $parts=explode(' JSON</td><td', $emojiterracont);
   if (sizeof($parts) > 1) {
     $subparts=str_replace('&amp;','&',explode('>',explode('<', $parts[1])[0])[1]);
     $ssparts=explode(';',$subparts);
     if (sizeof($ssparts) > 2) {
     $huh="";
     $huhz="";
     for ($iy=0; $iy<(-1 + sizeof($ssparts)); $iy++) {
     $huh.=htmlentities($ssparts[$iy] . ';');
     $huhz.=($ssparts[$iy] . ';');
     }
     if (isset($_GET['getcp'])) {
     echo "\n cn=String.fromCodePoint(" . str_replace(";",",",str_replace("&#","",str_replace(";;","",($huhz . ";")))) . ");  if (top.document.getElementById('myta')) { top.document.getElementById('myta').value+=String.fromCodePoint(" . str_replace(";",",",str_replace("&#","",str_replace(";;","",($huhz . ";")))) . "); if (111 == 111) { cn=''; }  }   \n";
     } else {
     echo "\n cn='" . $huh . "'; \n";
     }
     } else {
     if (isset($_GET['getcp'])) {
     echo "\n cn=String.fromCodePoint(" . str_replace(";",",",str_replace("&#","",str_replace(";;","",(($subparts) . ";")))) . ");  if (top.document.getElementById('myta')) { top.document.getElementById('myta').value+=String.fromCodePoint(" . str_replace(";",",",str_replace("&#","",str_replace(";;","",(($subparts) . ";")))) . "); if (145 == 145) { cn=''; }  }   \n";
     } else {
     echo "\n cn='" . htmlentities($subparts) . "'; \n";
     }
     }
   } else {
     if (isset($_GET['getcp'])) {
     echo "\n cn='';   \n";
     } else {
     echo "\n cn='<i class=\"em em-' + rest.replace(/\+/g,'_').replace(/\ /g,'_') + '\"></i>&nbsp;'; \n";
     }
   }
   } else {
     if (isset($_GET['getcp'])) {
     echo "\n cn='';   \n";
     } else {
     echo "\n cn='<i class=\"em em-' + rest.replace(/\+/g,'_').replace(/\ /g,'_') + '\"></i>&nbsp;'; \n";
     }
   }
} else {
     if (isset($_GET['getcp'])) {
     echo "\n cn='';   \n";
     } else {
     echo "\n cn='<i class=\"em em-' + rest.replace(/\+/g,'_').replace(/\ /g,'_') + '\"></i>&nbsp;'; \n";
     }
}
?>
      cnotatend=cn; //'<i class="em em-' + rest.replace(/\+/g,'_').replace(/\ /g,'_') + '"></i>&nbsp;';
      } else {
      cnotatend='<i class="em em-' + rest.replace(/\+/g,'_').replace(/\ /g,'_') + '"></i>&nbsp;';
      }
      //var myfvz=top.document.getElementById('myfeedback').value;
      //top.document.getElementById('myfeedback').value='';
      //alert(myfvz + cnotatend);
      //top.document.getElementById('myfeedback').innerHTML=cnotatend;
      if (cnotatend.indexOf('<') == -1) {
      if (top.document.getElementById('myfeedback').value != '') {
      var mtv=top.document.getElementById('myfeedback').value;
      top.document.getElementById('dmyfeedback').innerHTML=mtv + cnotatend;
      top.document.getElementById('myfeedback').value='';
      top.document.getElementById('ddmyfeedback').innerHTML='<textarea style="color=lightgray;width:200px;" rows=6 cols=40 id="myfeedback" title="Feedback" value="" onchange=" pseudo_sentence=this.value; placetext(); " onblur=" pseudo_sentence=this.value;  placetext(); ">' + mtv.replace(/\ /g,'&nbsp;') + cnotatend + '</textarea>';
      } else {
      top.document.getElementById('myfeedback').innerHTML+=cnotatend;
      }
      } else {
      top.document.getElementById('dmyfeedback').innerHTML+=cnotatend;
      }
   }
  }
}

modeofuse();
</script>

<!--h1>Fairy Story Paste Helper</h1>
<h3>RJM Programming - March, 2018</h3>
<h4>Your Fairy Story follows ... good luck ...</h4>

<div contenteditable="true" style="width:100%;height:200px;border:1px solid red;" id="storyboard">Once upon a time</div>

<table style="width:100%;height:300px;" border=2><tr>
<td style="width:48%;">
<iframe id="fsac1" style="width:100%;height:300px;" src="//www.rjmprogramming.com.au/PHP/emoticon_keyboard_shortcuts.php?iframeplease=y&inans=skull%2Cghost%2Calien%2Cimp%2Cangel%2Cprincess%2Ccrystal_ball%2Cjapanese_ogre%2Cspace_invader%2Cjapanese_goblin&outans=Skull%2CGhost%2CAlien%2CAngry+Face+with+Horns%2CBaby+Angel%2CPriness%2CCrystal+Ball%2COgre%2CAlien+Monster%2CGoblin&heading=Fairy+Story+Characters&subheading=Helper&urlprefix=https%3A%2F%2Fwww.rjmprogramming.com.au%2FHTMLCSS%2Ffairy_story_assistant.html&rand=2033817289"></iframe>
</td><td style="width:48%;">
<iframe id="fsac2" style="width:100%;height:300px;" src="//www.rjmprogramming.com.au/PHP/emoticon_keyboard_shortcuts.php?iframeplease=y&inans=man&outans=&heading=Fairy+Story+People&subheading=Helper&urlprefix=https%3A%2F%2Fwww.rjmprogramming.com.au%2FHTMLCSS%2Ffairy_story_assistant.html&rand=311259562"></iframe>
</td></tr><tr><td style="width:48%;">
<iframe id="fsac3" style="width:100%;height:300px;" src="//www.rjmprogramming.com.au/PHP/emoticon_keyboard_shortcuts.php?iframeplease=y&inans=clock&outans=&heading=Fairy+Story+Times&subheading=Helper&urlprefix=https%3A%2F%2Fwww.rjmprogramming.com.au%2FHTMLCSS%2Ffairy_story_assistant.html&rand=1390790034"></iframe>
</td><td style="width:48%;">
<iframe id="fsac4" style="width:100%;height:300px;" src="//www.rjmprogramming.com.au/PHP/emoticon_keyboard_shortcuts.php?iframeplease=y&inans=automobile%2Cvehicle%2Ctractor%2Cambulance%2Cbicycle%2Cpolice%2Cconstruction%2Ctraffic%2Ctruck%2Ctram%2Cbus%2Chelicopter%2Cboat%2Cplane%2C&outans=&heading=Fairy+Story+Transport&subheading=Helper&urlprefix=https%3A%2F%2Fwww.rjmprogramming.com.au%2FHTMLCSS%2Ffairy_story_assistant.html&rand=285342407"></iframe>
</td></tr></table>

<textarea style="display:none;" rows=1 cols=120 id="mytah" value=""></textarea-->

<div id=dmcif style='display:none;'></div>
</body>
</html>
