var Typer = {
text: null,
accessCountimer:null,
index:0,
speed:1,
file:"",
init: function() {
accessCountimer = setInterval(function() {
Typer.updLstChr();
}, 500);
$.get(Typer.file, function(data) {
Typer.text = data;
Typer.text = Typer.text.slice(0, Typer.text.length - 1);
});
},
content: function(){
return $("#console").html();
},
write: function(str){
$("#console").append(str);
return false;
},
addText: function(key) {
if(Typer.text) {
var cont = Typer.content();
if(cont.substring(cont.length - 1, cont.length) == "|") {
$("#console").html($("#console").html().substring(0, cont.length - 1));
}
if(key.keyCode != 8) {
Typer.index += Typer.speed;
} else {
if(Typer.index > 0) {
Typer.index-=Typer.speed;
}
}
var text = Typer.text.substring(0, Typer.index)
var rtn = new RegExp("\n", "g");
$("#console").html(text.replace(rtn, "
"));
window.scrollBy(0, 50);
}
if ( key.preventDefault && key.keyCode != 122 ) {
key.preventDefault()
};
if(key.keyCode != 122) {
key.returnValue = false;
}
},
updLstChr: function() {
var cont = this.content();
if(cont.substring(cont.length - 1, cont.length) == "|") {
$("#console").html($("#console").html().substring(0, cont.length - 1));
} else {
this.write("|");
}
}
}
function replaceUrls(text) {
var http = text.indexOf("http://");
var space = text.indexOf(".me ", http);
if (space != -1) {
var url = text.slice(http, space-1);
return text.replace(url, "" + url + "");
} else {
return text
}
}
Typer.speed=3;
Typer.file="ektorwin.txt";
Typer.init();
var timer = setInterval("t();", 30);
function t() {
Typer.addText({"keyCode": 123748});
if (Typer.index > Typer.text.length) {
clearInterval(timer);
}
}