function sReader_randomTimer() { el = document.querySelectorAll("#sReader_outputText .indicator .i"); for (i=0; i 0) { for (i=0; i= (main.length - lookBehind)) { post += main.charAt(i); } } main = main.slice(0, -lookBehind); } returnVal = [pre, main, post]; return returnVal; } function sReader_calculateOrp(_word, _symbols = false) { //// Naive approximation of Spritz's ORP algorithm //// //// wordCount -> wordCenter -> ORP //// (deviation from center) -> deviation with //// ceil() on center // // 1 -> 1.0 -> 1 ( 0.0) -> 0 // 2 -> 1.5 -> 2 (+0.5) -> 0 // 3 -> 2.0 -> 2 ( 0.0) -> 0 // 4 -> 2.5 -> 2 (-0.5) -> -1 // 5 -> 3.0 -> 2 (-1.0) -> -1 // 6 -> 3.5 -> 3 (-0.5) -> -1 // 7 -> 4.0 -> 3 (-1.0) -> -1 // 8 -> 4.5 -> 3 (-1.5) -> -2 // 9 -> 5.0 -> 3 (-2.0) -> -2 // 10 -> 5.5 -> 4 (-1.5) -> -2 // 11 -> 6.0 -> 4 (-2.0) -> -2 // 12 -> 6.5 -> 4 (-2.5) -> -3 // 13 -> 7.0 -> 4 (-3.0) -> -3 // //// Punctuation appears to be ignored (prepended/appended //// without affecting ORP). //// Using floor() or floats the pattern is confusing as //// it appears to both ascend and descend in integer //// steps. Using rounding doesn't help, but using ceil //// there appears to be a pattern of $ (n-(n%4))/4 $. //// Switching to German gives us a few longer words, //// and it appears to hold true for all the examples I //// ran through. if (_symbols) { strippedWord = ["", _word, ""]; } else { strippedWord = sReader_stripPunctuation(_word); } wordCount = strippedWord[1].length; wordCenter = (wordCount+1)/2; orpBias = -1*(wordCount - wordCount%4)/4; orp = Math.ceil(wordCenter) + orpBias; orp += strippedWord[0].length; if (debug) { console.log("sReader_calculateOrp :: \""+ strippedWord[0] +"\", \""+ strippedWord[1] +"\", \""+ strippedWord[2] +"\""); console.log("sReader_calculateOrp :: \""+ _word +"\""); console.log("sReader_calculateOrp :: "+ " ".repeat(orp-1) +"^"); } return orp; } function sReader_printWord(_word, _symbols = false, _iType = "Solid", _iSym = "^", _iCount = 1, _hideText = false) { indicator = true; orp = sReader_calculateOrp(_word, _symbols); word = [_word.slice(0, orp-1), _word.charAt(orp-1), _word.slice(orp, _word.length)]; htmlBuffer = ''+ word[0].trim() +''+ ''+ word[1].trim() +''+ ''+ word[2].trim() +''+ '
' ; if (indicator) { indicatorBuffer = ''+ _iSym +''; htmlBuffer += ''+ " ".repeat(orp-1) + indicatorBuffer.repeat(_iCount) +''; } document.getElementById("sReader_outputText").innerHTML = htmlBuffer; document.getElementById("sReader_outputTextDiv").style.marginLeft = -1*((document.getElementById("sReader_outputText").clientWidth/_word.length)*orp) +"px"; if (_hideText) { el = document.getElementsByClassName("sReader_text"); for (i=0; i 0) { delays += (subStr.length)*speedPenalty; } } } } function printHelloWorld() { setInterval( function() { sReader_printWord("Hello,"); setTimeout( function() { sReader_printWord("world!"); }, 1000 ); }, 2000 ); }