From 7e6a655d5fc9c932a32088e532c742c4e2177c19 Mon Sep 17 00:00:00 2001 From: Joe Adams Date: Fri, 21 Jun 2019 20:35:08 +0100 Subject: [PATCH] Added proof of concept network input / output (polls input.dat), simple PHP input page Warning: A few vulnerabilities in this commit, don't use outside a test environment --- .htaccess | 1 + RSVPInterface.html | 49 +++++++++++++++++++++++++++++++++++++++------- css/RSVP.css | 16 ++++++++++++++- input.dat | 1 + input.php | 23 ++++++++++++++++++++++ js/RSVP.js | 24 ++++++++++++++++++----- 6 files changed, 101 insertions(+), 13 deletions(-) create mode 100644 .htaccess create mode 100644 input.dat create mode 100644 input.php diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..f289550 --- /dev/null +++ b/.htaccess @@ -0,0 +1 @@ +Header set Access-Control-Allow-Origin "*" diff --git a/RSVPInterface.html b/RSVPInterface.html index fd0f0a6..c1939bb 100644 --- a/RSVPInterface.html +++ b/RSVPInterface.html @@ -14,17 +14,52 @@

- + +
+

+
+ - \ No newline at end of file + diff --git a/css/RSVP.css b/css/RSVP.css index c459d79..4bd0c69 100644 --- a/css/RSVP.css +++ b/css/RSVP.css @@ -56,4 +56,18 @@ opacity: 0.00; baseline-shift: 0px; } -} \ No newline at end of file +} +#sReader_wordLog { + font-size: 0.2em; + color: #000; + opacity: 0.25; + display: inline-block; + text-align: left; +} +.sReader_3rdPanel { + position: absolute; + bottom: 32px; + width: 32%; + max-height: 32%; + overflow: hidden; +} diff --git a/input.dat b/input.dat new file mode 100644 index 0000000..af5626b --- /dev/null +++ b/input.dat @@ -0,0 +1 @@ +Hello, world! diff --git a/input.php b/input.php new file mode 100644 index 0000000..f5209cd --- /dev/null +++ b/input.php @@ -0,0 +1,23 @@ + + + + + + + +
+ +
+ + + diff --git a/js/RSVP.js b/js/RSVP.js index 9d3929b..728af03 100644 --- a/js/RSVP.js +++ b/js/RSVP.js @@ -19,6 +19,7 @@ function sReader_stripPunctuation(_word) stage = 0; // Keep track of how far we've gotten lookBehind = 0; // Keep track of no. of trailing symbols i = 0; // Loop counter + while (i<_word.length) { switch(stage) @@ -140,7 +141,7 @@ function sReader_calculateOrp(_word, _symbols = false) console.log("sReader_calculateOrp :: \""+ _word +"\""); console.log("sReader_calculateOrp :: "+ " ".repeat(orp-1) +"^"); } - + return orp; } @@ -170,6 +171,19 @@ function sReader_printWord(_word, _symbols = false, _iType = "Solid", _iSym = "^ document.getElementById("sReader_outputTextDiv").style.marginLeft = -1*((document.getElementById("sReader_outputText").clientWidth/_word.length)*orp) +"px"; // Not sure this was necessary, appeared when doing some CSS wrangling // TODO: @sumptum remove/clean up extra div if unnecessary + + htmlBuffer = document.getElementById("sReader_wordLog").innerHTML; + if (_iType == "Fade" || _iType == "Blink" ) + { + htmlBuffer += "
"; + } + else if (_iType == "Solid") + { + htmlBuffer += _word + " "; + } + document.getElementById("sReader_wordLog").innerHTML = htmlBuffer; + document.getElementById("sReader_wordLog").parentNode.parentNode.scrollTop = document.getElementById("sReader_wordLog").parentNode.parentNode.scrollHeight; + if (_hideText) { el = document.getElementsByClassName("sReader_text"); @@ -194,8 +208,8 @@ function sReader_printString(_str) // e.g. numerical / mathematical, although // the suitability of such data for RSVP is // debatable - - readingSpeed = 120; // Base reading speed in ms + + readingSpeed = 60; // Base reading speed in ms speedPenalty = 25; // Used to slow down for longer words // (applied per character) if (relativeSpeedPenalty) @@ -205,7 +219,7 @@ function sReader_printString(_str) str = _str.split(" "); // Get the printable parts of the string delays = 0; // Keep track of the accumulated delays - + for (let i=0; i<=str.length; ++i) { let subStr = str[i]; // New variable to stay in scope @@ -274,4 +288,4 @@ function sReader_printString(_str) } } } -} \ No newline at end of file +}