Saturday 30 March 2013

Matrix in html!!

Matrix in html!!

First open notepad
Paste this code in:

<script type="text/javascript">
// ------------------------------------------------------------------------------------
// Revision Matrix by Phobos
// ------------------------------------------------------------------------------------
var theinHTML;
var thelessstr;
var ascSt=22;
var ascEnd=126;
var numoflines = 28;


var lines = new Array();
var intervalID = new Array();
var subIntervalID = new Array();
var subIntervalID2 = new Array();
var scH = screen.height-220;
var scW = screen.width-50;
window.onload = createlines;
// -------------------------------------------------------------------------------------
//
var hD="0123456789ABCDEF";
function d2h(d)
{
var h = hD.substr(d&15,1);
while(d > 15)
{
d >>= 4;
h = hD.substr(d&15,1)+h;
}
return h;
}
// -------------------------------------------------------------------------------------
// Coded by Phobos
function line(length, maxlength, chars, speed, x)
{
this.length = length;
this.maxlength = maxlength;
this.chars = chars;
this.speed = speed;
this.x = x;
}
// -------------------------------------------------------------------------------------
// Coded by Phobos
function createlines()
{
// Coded by Phobos
for(var eachline = 0; eachline < numoflines; eachline++)
{
lines[eachline] = new line(0, Math.round(Math.random()*15+5), String.fromCharCode(Math.round(Math.random()*(ascEnd-ascSt)+ascSt)), Math.round(Math.random()*400+100), eachline*61);
}
// write the lines
for(var writelines = 0; writelines < numoflines; writelines++)
{
var newline = document.createElement("div");
newline.id = "char" + writelines;
newline.style.position = "absolute";
newline.style.top = "5px";
newline.style.left = lines[writelines].x + "px";
var firstchar = document.createElement("div");
var newcolor = d2h(Math.round(1/(lines[writelines].maxlength+1)*255));
if(newcolor.length == 1)
newcolor = "0" + newcolor;
firstchar.style.color = "#00"+newcolor+"00"
firstchar.innerHTML = lines[writelines].chars
newline.appendChild(firstchar);
document.body.appendChild(newline);
}
start();
}
// -------------------------------------------------------------------------------------
// Coded by Phobos
function start()
{
for(var pickastring = 0; pickastring < numoflines; pickastring++)
{
intervalID[pickastring] = setInterval("addchars("+pickastring+")", lines[pickastring].speed);
}
}
// -------------------------------------------------------------------------------------
// Coded by Phobos
function addchars(theline)
{
if(lines[theline].length >= lines[theline].maxlength)
{
clearInterval(intervalID[theline]);
subIntervalID[theline] = setInterval("movethestring("+theline+")", lines[theline].speed);
}
else
{
// Coded by Phobos
myRandomChar = String.fromCharCode(Math.round(Math.random()*(ascEnd-ascSt)+ascSt));
while(myRandomChar == "'" || myRandomChar == '"' || myRandomChar == "\\")
myRandomChar = String.fromCharCode(Math.round(Math.random()*(ascEnd-ascSt)+ascSt));
// Coded by Phobos
var newchar = document.createElement("div");
newchar.innerHTML = myRandomChar;
document.getElementById("char"+theline).appendChild(newchar);
// Coded by Phobos
var i;
for(i = 0; i <= lines[theline].length; i++)
{
var newcolor = d2h(Math.round((i+1)/(lines[theline].maxlength+1)*255));
newcolor = "" + newcolor;
if(newcolor.length == 1)
newcolor = "0" + newcolor;
document.getElementById("char"+theline).childNodes[i].style.color = "#00" + newcolor + "00";
document.getElementById("char"+theline).childNodes[i].style.fontWeight = "normal";
}
document.getElementById("char"+theline).childNodes[i].style.color = "#99FF99";
document.getElementById("char"+theline).childNodes[i].style.fontWeight = "bold";
// Coded by Phobos
lines[theline].length++;
}
}
// -------------------------------------------------------------------------------------
// Coded by Phobos
function movethestring(theline)
{
var topstringnum = document.getElementById("char"+theline).offsetTop;
if((topstringnum + (lines[theline].maxlength * 15)) >= scH)
{
clearInterval(subIntervalID[theline]);
subIntervalID2[theline] = setInterval("clearletters("+theline+")", lines[theline].speed);
}
else
{
// Coded by Phobos
myRandomChar = String.fromCharCode(Math.round(Math.random()*(ascEnd-ascSt)+ascSt));
while(myRandomChar=="'" || myRandomChar=='"' || myRandomChar=="\\")
myRandomChar = String.fromCharCode(Math.round(Math.random()*(ascEnd-ascSt)+ascSt));
var newchar = document.createElement("div");
newchar.innerHTML = myRandomChar;
document.getElementById("char"+theline).appendChild(newchar);
// Coded by Phobos
document.getElementById("char"+theline).removeChild(document.getElementById("char"+theline).childNodes[0]);
// Coded by Phobos
var i;
for(i = 0; i < lines[theline].length; i++)
{
var newcolor = d2h(Math.round((i+1)/(lines[theline].maxlength+1)*255));
newcolor = "" + newcolor;
if(newcolor.length == 1)
newcolor = "0" + newcolor;
document.getElementById("char"+theline).childNodes[i].style.color = "#00" + newcolor + "00";
document.getElementById("char"+theline).childNodes[i].style.fontWeight = "normal";
}
document.getElementById("char"+theline).childNodes[i].style.color = "#99FF99";
document.getElementById("char"+theline).childNodes[i].style.fontWeight = "bold";
// move
document.getElementById("char"+theline).style.top = (topstringnum+15) + "px";
}
}
// -------------------------------------------------------------------------------------
// Coded by Phobos
function clearletters(theline)
{
if(lines[theline].length <= -1)
{
clearInterval(subIntervalID2[theline]);
document.getElementById("char"+theline).style.top = 0;
intervalID[theline] = setInterval("addchars("+theline+")", lines[theline].speed);
}
else
{
// Coded by Phobos
document.getElementById("char"+theline).removeChild(document.getElementById("char"+theline).childNodes[document.getElementById("char"+theline).childNodes.length-1]);
// Coded by Phobos
var topstringnum = document.getElementById("char"+theline).offsetTop;
document.getElementById("char"+theline).style.top = topstringnum+15 + "px";
// Coded by Phobos
lines[theline].length--;
}
}
</script>



<style type="text/css">
body {
font: normal normal normal 10px/15px symbol,Rockwell;
color:#FFFFFF;
background-color:black;
margin:0;
padding:0;
}
body div {
text-align: center;
}
</style>





</body>
</html>
Save as Matrix.html
Now open it!!

No comments:

Post a Comment