FANDOM


/** Text Type Writer version 1.0 (TTW) **/
var rotated = false;
var rotation_index = 0;
var delay_typing = 10;
var rotation_chars_array = ['|', '/', '-', '\\', '|'];
var message_object = document.getElementById("TTW_text");
var message = message_object.innerHTML;
var message_index = 0;
var stop_writing = null;

update("");

function rotate() {
if(rotation_index <= rotation_chars_array.length - 1) {
removeLast();
update(message_object.innerHTML + rotation_chars_array[rotation_index]);
rotation_index++;
} else {
rotation_index = 0;
rotated = true;
}
}

function removeLast() {
var old_text = message_object.innerHTML;
var new_text = "";

if(old_text.length > 0) {
new_text = old_text.substr(0, old_text.length - 1);
}

update(new_text);
}

function update(text) {
message_object.innerHTML = text;
}

function replay() {
rotated = false;
rotation_index = 0;
message_index = 0;
stop_writing = null;

update("");
textTypeWriter();
}

function typeChar() {
update(message_object.innerHTML + message.charAt(message_index) + "-");
message_index++;
}

function sleep(ms){
var now = new Date();
now.setTime(now.getTime() + ms);
while (new Date().getTime() < now.getTime());
}

function textTypeWriter() {
if(message_index <= message.length) {
if(rotated) {
removeLast();
typeChar();
rotated = !rotated;
} else {
rotate();
}
stop_writing = setTimeout("textTypeWriter()", delay_typing);
} else {
removeLast();
clearTimeout(stop_writing);
sleep(3000);
replay();
}
}

document.body.onload = textTypeWriter;

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.