6d5 < 9,11d7 < var notatend=false, clicked=false; < var prefix="", nothing="", cnotatend="", cnt=0; < 17,46c13 < //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(); --- > placeCaretAtEnd(document.getElementById("storyboard")); 53,140d19 < 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(/ /g,' ').indexOf(prefix.replace(/ /g,' ')) != -1) { < el.innerHTML=el.innerHTML.replace(/ /g,' ').replace(prefix.replace(/ /g,' '), prefix.replace(/ /g,' ') + isStart); < prefix+=isStart; < } else { < var words=prefix.replace(/ /g,' ').split(' '); < var firstgo=prefix.replace(/ /g,' '); //.replace(/ /g,' ').replace(words[0] + ' ',' '); < var origfg=prefix; < for (var iij=0; iij') != -1) { < document.getElementById("storyboard").innerHTML=document.getElementById("storyboard").innerHTML.replace(/\ \;\ \;\/g,'  
').replace(/\\ \;\ \;/g,'  
').replace(/\\/g,'  
').replace(/\\ \;\/g,'  
').replace(/\ \;\/g,' ').replace(/\ \/g,' ').replace(/\/g,''); < } < } < < } < < 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) { document.title='here'; notatend=true; document.getElementById('mynae').value='true'; } else { notatend=false; document.getElementById('mynae').value=''; } < return ('' + preCaretRange.toString()); //.length; < } < 158,167d36 < < function handleEvent(e) { < var keycode = (e.keyCode ? e.keyCode : e.which); < if (keycode == '13') { < if (navigator.userAgent.toLowerCase().indexOf('firefox') != -1 && !notatend) { < document.getElementById("storyboard").innerHTML+='
'; < } < } < //keepactive(); < } 173,196d41 < function fit() { < var ip=0; < if (navigator.userAgent.toLowerCase().indexOf('firefox') != -1) { < 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; < } < } < 203,205d47 < if (navigator.userAgent.toLowerCase().indexOf('firefox') != -1) { < wtw+='

Your Fairy Story follows ... good luck, and please double up on your Enter keys, optionally clicking helper links for Emoji placement ...

' + String.fromCharCode(13); < } else { 207d48 < } 209c50 < wtw+='
Once upon a time 
' + String.fromCharCode(13); --- > wtw+='
Once upon a time
' + String.fromCharCode(13); 211c52 < wtw+='
' + String.fromCharCode(13); --- > wtw+='
' + String.fromCharCode(13); 213c54 < wtw+='' + String.fromCharCode(13); --- > wtw+='' + String.fromCharCode(13); 215,217c56,58 < wtw+='' + String.fromCharCode(13); < wtw+='
' + String.fromCharCode(13); < wtw+='' + String.fromCharCode(13); --- > wtw+='' + String.fromCharCode(13); > wtw+='
' + String.fromCharCode(13); > wtw+='' + String.fromCharCode(13); 219,220c60,61 < wtw+='' + String.fromCharCode(13); < wtw+='
' + String.fromCharCode(13); --- > wtw+='' + String.fromCharCode(13); > wtw+='' + String.fromCharCode(13); 223,225d63 < wtw+='' + String.fromCharCode(13); < wtw+='' + String.fromCharCode(13); < wtw+='' + String.fromCharCode(13); 227d64 < setTimeout(fit,2000); 238,245d74 < if (top.document.getElementById('myprefix').value != '') { < clicked=false; < cnotatend=decodeURIComponent(bits[1]).substring(decodeURIComponent(bits[1]).indexOf('<')) + ' '; < top.document.getElementById('mywith').value=cnotatend; < //placeCaret(top.document.getElementById('storyboard'),decodeURIComponent(bits[1]).substring(decodeURIComponent(bits[1]).indexOf('<')) + ' '); < } else if (top.document.getElementById('mynae').value != '') { < top.document.getElementById('storyboard').innerHTML=decodeURIComponent(bits[1]).substring(decodeURIComponent(bits[1]).indexOf('<')) + ' ' + top.document.getElementById('storyboard').innerHTML; < } else { 247d75 < } 252,263c80,82 < if (top.document.getElementById('myprefix').value != '') { < clicked=false; < cnotatend=' '; < top.document.getElementById('mywith').value=cnotatend; < //placeCaret(top.document.getElementById('storyboard'),' '); < } else if (top.document.getElementById('mynae').value != '') { < top.document.getElementById('storyboard').innerHTML=' ' + top.document.getElementById('storyboard').innerHTML; < } else { < top.document.getElementById('storyboard').innerHTML+=' '; < } < if (top.document.getElementById('mytah')) top.document.getElementById('mytah').value='x'; < //placeCaretAtEnd(top.document.getElementById('storyboard')); --- > top.document.getElementById('storyboard').innerHTML+=' '; > if (top.document.getElementById('mytah')) top.document.getElementById('mytah').value='x'; > //placeCaretAtEnd(top.document.getElementById('storyboard'));