JavaScript
语言:
JaveScriptBabelCoffeeScript
确定
! function() {
"use strict";
function txtTyper() {
if (idx <= str.length) {
if (str.charAt(idx) == '
while (str.charAt(idx) != '>' || str.charAt(idx + 1) == '
idx++
}
if (str.charAt(idx) == '&' && str.charAt(idx + 1) != ' ') {
while (str.charAt(idx) != ';') idx++;
idx++;
}
var tmp0 = str.slice(0, idx);
var tmp1 = str.charAt(idx++);
idObj.innerHTML = '' + tmp0 + '' + tmp1 + '_';
if (idx < str.length) {
setTimeout(function() {
txtTyper();
}, 120);
} else {
sound = false;
}
}
}
var str = "
---- beginning of transmission ----
Who bears the greater blame
for the encroachment of tyranny:
those who plan to smother our freedoms tomorrow,
or those who act to smother our questions today?
---- end of transmission ----
";
var sound = true;
var idx = 0;
var idObj = document.getElementById('ttl0');
if (window.Audio) {
var notlogical = new Audio('/uploads/151101/sing.mp3');
notlogical.addEventListener('ended', function() {
this.currentTime = 0;
if (sound) this.play();
}, false);
notlogical.play();
}
txtTyper();
}();