Javascript simulated DOS window _ Javascript tutorial

Source: Internet
Author: User
Javascript: DOS window simulated by Javascript, Javascript tutorial Source code



South of summer
Script
Var timer;
Var win = window. createPopup ();
Var cmdIndex = 0;
Var closeMe = 0;
Var current1_window;
Function current1_focus (obj)
{
Current1_window = obj;
Obj. rows (0 ). cells (0 ). style. filter = "progid: DXImageTransform. microsoft. gradient (startColorStr = #0054E3, endColorStr = # 358DFB, GradientType = 1 )";
Obj. style. zIndex = cmdIndex ++;
}
Function CurrentCmdBlur (obj)
{
Var line = obj. getElementsByTagName ("P") [obj. getElementsByTagName ("P"). length-1];
Line. innerText = line. innerText. replace (/_ $ /,"");
Obj. rows (0 ). cells (0 ). style. filter = "progid: DXImageTransform. microsoft. gradient (startColorStr = #6B79B8, endColorStr = # 8C9ADB, GradientType = 1 )";
}
Function CloseButtonClick (src)
{
Var msg1 = "CLOSE? \ N "+
"System prompt: in fact, this is just a common cross, not used to close it ~~ @ O @ \ n "+
"C: \ WINDOWS \ system32> ";
Var paragraphs = src. parentNode. getElementsByTagName ("P ");
Paragraphs [paragraphs. length-1]. innerText = paragraphs [paragraphs. length-1]. innerText. replace (/_ $/, "") + msg1;
}
Function MaximizeButtonClick (src)
{
Var msg1 = "MAXIMIZE? \ N "+
"Error # o # \ n" +
"C: \ WINDOWS \ system32> ";
Var paragraphs = src. parentNode. getElementsByTagName ("P ");
Paragraphs [paragraphs. length-1]. innerText = paragraphs [paragraphs. length-1]. innerText. replace (/_ $/, "") + msg1;
CreateCmdWindow(win.doc ument. getElementById ("Frame "),
GetRandomNum(win.doc ument. body. clientWidth-400 ),
GetRandomNum(win.doc ument. body. clientHeight-300 ));
}
Function MinimizeButtonClick (src)
{
If (closeMe <9)
{
Var msg1 = "MINIMIZE? \ N "+
"Add ^-^ \ n" +
"C: \ WINDOWS \ system32> ";
Var paragraphs = src. parentNode. getElementsByTagName ("P ");
Paragraphs [paragraphs. length-1]. innerText = paragraphs [paragraphs. length-1]. innerText. replace (/_ $/, "") + msg1;
CloseMe ++;
}
Else
{
ClearTimeout (timer );
Win. hide ();
Invalid parameter Doc ument. body. style. display = "";
Too many Doc ument. body. innerHTML ="

";
SetTimeout ("Welcome (0)", 400 );
}
}

Function Welcome (n)
{
Var msg1 = "Welcome to 0009's blog ^_^ ";
Var msg2 = "Click Here ";
If (n <msg1.length)
{
Optional parameter Doc ument. getElementsByTagName ("P") [0]. innerText + = msg1.substr (n, 1 );
N ++;
SetTimeout ("Welcome (" + n + ")", 200 );
}
Else
{
Invalid Response Doc ument. getElementsByTagName ("P") [1]. innerHTML = msg2;
}
}

Function OpenWindow (height)
{
If (height <window. screen. availHeight)
{
Height + = 50;
If (height> = window. screen. availHeight)
{
Height = window. screen. availHeight;
Win. show (0, 0, window. screen. availWidth, window. screen. availHeight );
CreateCmdWindow(win.doc ument. getElementById ("Frame"), 10, 10 );
Wink (true );
}
Else
{
Win. show (0, 0, window. screen. availWidth, height );
}
}
Else if (! Win. isOpen)
{
Win. show (0, 0, window. screen. availWidth, window. screen. availHeight );
}
Timer = setTimeout ("OpenWindow (" + height + ")", 50 );
}

Function CreateCmdWindow (obj, left, top)
{
Var window = win.doc ument. createElement ("TABLE ");
Window. border = 1;
Window. className = "Cmd ";
Window. style. left = left;
Window. style. top = top;
Export window. style. zIndex = cmdIndex ++;
Var newRow = Window. insertRow ();
Var newCell = newRow. insertCell ();
NewCell. className = "Title ";
NewCell. innerHTML = "C: \ WINDOWS \ system32 \ cmd.exe <\/span>" +
"× <\/Button> "+
"□< \/Button> "+
"-<\/Button> ";
NewRow = Window. insertRow ();
NewCell = newRow. insertCell ();
NewCell. innerHTML = "" +
"

Microsoft windows xp [Version 5.1.2600] <\/p> "+
"

(C) Copyright 1985-2001 Microsoft Corp. <\/p> "+
"

<\/P> "+
"

C: \ WINDOWS \ system32> <\/p> "+
"<\/Div>" +
"";
Window. onactivate = function () {window. parent. current1_focus (this );}
Using window. ondeactivate = function () {window. parent. CurrentCmdBlur (this );}
Obj. appendChild (window );
}

Function Wink (show)
{
If (current1_window! = Undefined & current1_window! = Null)
{
Var line = current1_window. getElementsByTagName ("P") [current1_window. getElementsByTagName ("P"). length-1];
If (show)
{
Line. innerText + = "_";
}
Else
{
Line. innerText = line. innerText. replace (/_ $ /,"");
}
}
SetTimeout ("Wink (" +! Show + ")", 500 );
}

Function GetRandomNum (max)
{
Return parseInt (Math. random () * max + 1 );
}

Window. onload = function ()
{
Win.doc ument. body. innerHTML = "";
Win.document.appendChild(win.doc ument. createElement ("STYLE "));
Win.doc ument. styleSheets [0]. addRule ("body", "padding: 0px; margin: 0px ;");
Win.doc ument. styleSheets [0]. addRule ("# Frame", "width: 100%; height: 100%; background: #3A6EA5 ;");
Win.doc ument. styleSheets [0]. addRule (". cmd "," background: # fff; position: absolute; width: 670px; height: pixel PX; font-size: 10pt; color: # fff; cursor: default ;");
Win.doc ument. styleSheets [0]. addRule (". title "," filter: progid: DXImageTransform. microsoft. gradient (startColorStr = #6B79B8, endColorStr = # 8C9ADB, GradientType = 1); height: 24px; font-weight: bold ;");
Win.doc ument. styleSheets [0]. addRule (". Title span", "float: left; line-height: 20px ;");
Win.doc ument. styleSheets [0]. addRule (". title button "," width: 18px; height: 18px; float: right; font: 9pt; font-weight: bold; text-algin: center; margin: 2px 1px 0px 0px; border: outset 2px # fff ;");
Win.doc ument. styleSheets [0]. addRule (". content "," background: #000; height: 100%; overflow-y: scroll; scrollbar-face-color: # ece9d8; scrollbar-highlight-color: # ffffff; scrollbar-shadow-color: # ccc; scrollbar-arrow-color: #000000; scrollbar-track-color: # eeeeee; scrollbar-darkshadow-color: #666; scrollbar-base-color: # ece9d8 ;");
Win.doc ument. styleSheets [0]. addRule (". Content p", "margin: 0px; line-height: 16px ;");
Win.doc ument. styleSheets [0]. addRule (". Content. Adorn", "height: 4000px ;");
OpenWindow (0 );
}
Script


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.