summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2008-12-28 12:12:18 (GMT)
committer Jaromil <jaromil@dyne.org>2009-03-22 15:06:15 (GMT)
commit43574db80e848693b4fb18f2e0b16db9c631facc (patch)
treeffe1052cee85ded3a609e22d6c4dc2af51ae48f5
parent61e4ebc097add7e01c88ef8ddd7bbfc8b32af47e (diff)
added speed & cleaned indenting
-rw-r--r--tbt-typewriter.js21
1 files changed, 14 insertions, 7 deletions
diff --git a/tbt-typewriter.js b/tbt-typewriter.js
index 473fd64..99a4e52 100644
--- a/tbt-typewriter.js
+++ b/tbt-typewriter.js
@@ -3,9 +3,10 @@
// GNU GPL
-function TBT() {
+function TBT() {
this.setRowCarriageReturn = setRowCarriageReturn;
this.setXhtml = setXhtml;
+ this.setSpeed = setSpeed;
this.startTyping = startTyping;
this.feed = feed;
var currentChar;
@@ -23,7 +24,13 @@ function TBT() {
var cc;
var rowcr=0; // config option; do a CR (\r) when moving the cursor up/down
var xhtml=0; // html or xhtml
+ var speed=1; // time factor.
+ function setSpeed(s) {
+ if (s> 0.01 && s< 20) this.speed=s;
+ else speed=1.0;
+ }
+
function setXhtml(onoff) {
xhtml=onoff?true:false;
}
@@ -55,7 +62,7 @@ function TBT() {
// text render buffer
render_text = "";
- setTimeout(this.feed, recording[currentChar][1] );
+ setTimeout(this.feed, speed*recording[currentChar][1] );
}
function feed() {
@@ -102,12 +109,12 @@ function TBT() {
case 257: // UP
if(row <= 0) break;
cur_y--; row--;
- if (rowcr) { col=0; cur_x=0; }
+ if (rowcr) { col=0; cur_x=0; }
break;
case 258: // DOWN
if(row >= text.length) break;
cur_y++; row++;
- if (rowcr) { col=0; cur_x=0; }
+ if (rowcr) { col=0; cur_x=0; }
break;
case 259: // LEFT
if(cur_x <= 0) break;
@@ -186,12 +193,12 @@ function TBT() {
delete text[cr];
delete text;
- // end of text
+ // end of text
} else {
- // RECURSION IS TIME -jrml 31jan2007
- setTimeout(feed, recording[currentChar][1] );
+ // RECURSION IS TIME -jrml 31jan2007
+ setTimeout(feed, speed*recording[currentChar][1] );
}
}
}