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
@ -15,16 +15,51 @@
|
|||||||
<p id="sReader_outputText"></p>
|
<p id="sReader_outputText"></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="sReader_3rdPanel" style="left: 32px;">
|
||||||
|
<center><p id="sReader_wordLog"></p></center>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script src="js/RSVP.js"></script>
|
<script src="js/RSVP.js"></script>
|
||||||
<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()
|
function onload()
|
||||||
{
|
{
|
||||||
sReader_printString("Loaded.");
|
sReader_printString("Loaded. Ready to connect...");
|
||||||
}
|
setInterval(
|
||||||
|
function()
|
||||||
|
{
|
||||||
|
checkIncoming();
|
||||||
|
}, 100
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
document.onload = onload();
|
document.onload = onload();
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
14
css/RSVP.css
14
css/RSVP.css
@ -57,3 +57,17 @@
|
|||||||
baseline-shift: 0px;
|
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>
|
||||||
16
js/RSVP.js
16
js/RSVP.js
@ -19,6 +19,7 @@ function sReader_stripPunctuation(_word)
|
|||||||
stage = 0; // Keep track of how far we've gotten
|
stage = 0; // Keep track of how far we've gotten
|
||||||
lookBehind = 0; // Keep track of no. of trailing symbols
|
lookBehind = 0; // Keep track of no. of trailing symbols
|
||||||
i = 0; // Loop counter
|
i = 0; // Loop counter
|
||||||
|
|
||||||
while (i<_word.length)
|
while (i<_word.length)
|
||||||
{
|
{
|
||||||
switch(stage)
|
switch(stage)
|
||||||
@ -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";
|
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
|
// Not sure this was necessary, appeared when doing some CSS wrangling
|
||||||
// TODO: @sumptum remove/clean up extra div if unnecessary
|
// 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)
|
if (_hideText)
|
||||||
{
|
{
|
||||||
el = document.getElementsByClassName("sReader_text");
|
el = document.getElementsByClassName("sReader_text");
|
||||||
@ -195,7 +209,7 @@ function sReader_printString(_str)
|
|||||||
// the suitability of such data for RSVP is
|
// the suitability of such data for RSVP is
|
||||||
// debatable
|
// debatable
|
||||||
|
|
||||||
readingSpeed = 120; // Base reading speed in ms
|
readingSpeed = 60; // Base reading speed in ms
|
||||||
speedPenalty = 25; // Used to slow down for longer words
|
speedPenalty = 25; // Used to slow down for longer words
|
||||||
// (applied per character)
|
// (applied per character)
|
||||||
if (relativeSpeedPenalty)
|
if (relativeSpeedPenalty)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user