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
This commit is contained in:
parent
7866a4dffb
commit
7e6a655d5f
@ -14,17 +14,52 @@
|
||||
<div id="sReader_outputTextDiv">
|
||||
<p id="sReader_outputText"></p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="sReader_3rdPanel" style="left: 32px;">
|
||||
<center><p id="sReader_wordLog"></p></center>
|
||||
</div>
|
||||
|
||||
<script src="js/RSVP.js"></script>
|
||||
<script>
|
||||
debug = false;
|
||||
|
||||
debug = false;
|
||||
incoming = "";
|
||||
|
||||
function httpGet(theUrl)
|
||||
{
|
||||
// https://stackoverflow.com/a/4033310
|
||||
var xmlHttp = new XMLHttpRequest();
|
||||
xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
|
||||
xmlHttp.send( null );
|
||||
return xmlHttp.responseText;
|
||||
}
|
||||
|
||||
function checkIncoming()
|
||||
{
|
||||
newIncoming = httpGet("./input.dat?rand="+new Date().getTime() / 1000);
|
||||
firstrun = (incoming == "");
|
||||
if (incoming != newIncoming)
|
||||
{
|
||||
incoming = newIncoming;
|
||||
if (!firstrun)
|
||||
{
|
||||
sReader_printString(incoming);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onload()
|
||||
{
|
||||
sReader_printString("Loaded.");
|
||||
}
|
||||
|
||||
sReader_printString("Loaded. Ready to connect...");
|
||||
setInterval(
|
||||
function()
|
||||
{
|
||||
checkIncoming();
|
||||
}, 100
|
||||
);
|
||||
}
|
||||
|
||||
document.onload = onload();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
16
css/RSVP.css
16
css/RSVP.css
@ -56,4 +56,18 @@
|
||||
opacity: 0.00;
|
||||
baseline-shift: 0px;
|
||||
}
|
||||
}
|
||||
}
|
||||
#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;
|
||||
}
|
||||
|
||||
23
input.php
Normal file
23
input.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
if (isset($_GET["str"]))
|
||||
{
|
||||
file_put_contents("./input.dat", $_GET["str"]);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||
</head>
|
||||
<body>
|
||||
<form action="./input.php">
|
||||
<input name="str" type="text" id="input_str"></input>
|
||||
</form>
|
||||
<script>
|
||||
document.getElementById("input_str").focus();
|
||||
document.getElementById("input_str").select();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
24
js/RSVP.js
24
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 += "<br>";
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user