zoukankan
html css js c++ java
[转] 用 JAVASCRIPT模拟的DOS界面
<
html
>
<
head
>
<
title
>
JavaScript-DOS
</
title
>
<
script
>
var
timer;
var
win
=
window.createPopup();
var
cmdIndex
=
0
;
var
closeMe
=
0
;
var
currentCmdWindow;
function
CurrentCmdFocus(obj)
{
currentCmdWindow
=
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\n
"
+
"
Attention: Unabled CloseICO @o@\n\n
"
+
"
C:\\WINDOWS\\system32>
"
;
var
paragraphs
=
src.parentNode.parentNode.parentNode.getElementsByTagName(
"
P
"
);
paragraphs[paragraphs.length
-
1
].innerText
=
paragraphs[paragraphs.length
-
1
].innerText.replace(
/
_$
/
,
""
)
+
msg1;
}
function
MaximizeButtonClick(src)
{
var
msg1
=
"
MAXIMIZE?\n\n
"
+
"
Error #o#\n\n
"
+
"
C:\\WINDOWS\\system32>
"
;
var
paragraphs
=
src.parentNode.parentNode.parentNode.getElementsByTagName(
"
P
"
);
paragraphs[paragraphs.length
-
1
].innerText
=
paragraphs[paragraphs.length
-
1
].innerText.replace(
/
_$
/
,
""
)
+
msg1;
CreateCmdWindow(win.document.getElementById(
"
Frame
"
),
GetRandomNum(win.document.body.clientWidth
-
400
),
GetRandomNum(win.document.body.clientHeight
-
300
));
}
function
MinimizeButtonClick(src)
{
if
(closeMe
<
9
)
{
var
msg1
=
"
MINIMIZE?\n\n
"
+
"
try more time ! ^-^\n\n
"
+
"
C:\\WINDOWS\\system32>
"
;
var
paragraphs
=
src.parentNode.parentNode.parentNode.getElementsByTagName(
"
P
"
);
paragraphs[paragraphs.length
-
1
].innerText
=
paragraphs[paragraphs.length
-
1
].innerText.replace(
/
_$
/
,
""
)
+
msg1;
closeMe
++
;
}
else
{
clearTimeout(timer);
win.hide();
window.document.body.style.display
=
""
;
window.document.body.innerHTML
=
"
<div style=\
"
font:32pt;font
-
weight:bold;color:#BE5100;\
"
><p></p><p></p></div>
"
;
setTimeout(
"
Welcome(0)
"
,
400
);
}
}
function
Welcome(n)
{
var
msg1
=
"
Welcome to 0009's blog ^_^
"
;
var
msg2
=
"
<a href=\
"
http:
//
0009.cnblogs.com\">Click Here</a>";
if
(n
<
msg1.length)
{
window.document.getElementsByTagName(
"
P
"
)[
0
].innerText
+=
msg1.substr(n,
1
);
n
++
;
setTimeout(
"
Welcome(
"
+
n
+
"
)
"
,
200
);
}
else
{
window.document.getElementsByTagName(
"
P
"
)[
1
].innerHTML
=
msg2;
}
}
function
OpenCmdWindow(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.document.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(
"
OpenCmdWindow(
"
+
height
+
"
)
"
,
50
);
}
function
CreateCmdWindow(obj, left, top)
{
var
cmdWindow
=
win.document.createElement(
"
TABLE
"
);
cmdWindow.border
=
1
;
cmdWindow.className
=
"
Cmd
"
;
cmdWindow.style.left
=
left;
cmdWindow.style.top
=
top;
cmdWindow.style.zIndex
=
cmdIndex
++
;
var
newRow
=
cmdWindow.insertRow();
var
newCell
=
newRow.insertCell();
newCell.className
=
"
Title
"
;
newCell.innerHTML
=
"
<span> C:\\WINDOWS\\system32\\cmd.exe<\/span>
"
+
"
<button onclick=\
"
window.parent.CloseButtonClick(
this
);\
"
>×<\/button>
"
+
"
<button onclick=\
"
window.parent.MaximizeButtonClick(
this
);\
"
>□<\/button>
"
+
"
<button onclick=\
"
window.parent.MinimizeButtonClick(
this
);\
"
>-<\/button>
"
;
newRow
=
cmdWindow.insertRow();
newCell
=
newRow.insertCell();
newCell.innerHTML
=
"
<div class=\
"
Content\
"
>
"
+
"
<p>Microsoft Windows XP [Version 5.1.2600]<\/p>
"
+
"
<p>(C) Copyright 1985-2001 Microsoft Corp.<\/p>
"
+
"
<p> <\/p>
"
+
"
<p>C:\\WINDOWS\\system32><\/p>
"
+
"
<div class=\
"
Adorn\
"
><\/div>
"
+
"
</div>
"
;
cmdWindow.onactivate
=
function
()
{ window.parent.CurrentCmdFocus(
this
); }
cmdWindow.ondeactivate
=
function
()
{ window.parent.CurrentCmdBlur(
this
); }
obj.appendChild(cmdWindow);
}
function
Wink(show)
{
if
(currentCmdWindow
!=
undefined
&&
currentCmdWindow
!=
null
)
{
var
line
=
currentCmdWindow.getElementsByTagName(
"
P
"
)[currentCmdWindow.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.document.body.innerHTML
=
"
<div id=\
"
Frame\
"
onselectstart=\
"
return
false
;\
"
></div>
"
;
win.document.appendChild(win.document.createElement(
"
STYLE
"
));
win.document.styleSheets[
0
].addRule(
"
body
"
,
"
padding: 0px; margin: 0px;
"
);
win.document.styleSheets[
0
].addRule(
"
#Frame
"
,
"
100%; height: 100%; background: #3A6EA5;
"
);
win.document.styleSheets[
0
].addRule(
"
.Cmd
"
,
"
background: #fff; position: absolute; 670px; height: 440px; font-size: 10pt; color: #fff; cursor: default;
"
);
win.document.styleSheets[
0
].addRule(
"
.Title
"
,
"
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr=#6B79B8,endColorStr=#8C9ADB,GradientType=1); height: 24px; font-weight: bold;
"
);
win.document.styleSheets[
0
].addRule(
"
.Title span
"
,
"
float: left; line-height: 20px;
"
);
win.document.styleSheets[
0
].addRule(
"
.Title button
"
,
"
18px; height: 18px; float: right; font: 9pt; font-weight: bold; text-algin: center; margin: 2px 1px 0px 0px; border: outset 2px #fff;
"
);
win.document.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.document.styleSheets[
0
].addRule(
"
.Content p
"
,
"
margin: 0px; line-height: 16px;
"
);
win.document.styleSheets[
0
].addRule(
"
.Content .Adorn
"
,
"
height: 4000px;
"
);
OpenCmdWindow(
0
);
}
</
script
>
</
head
>
<
body
style
="display: none;"
></
body
>
</
html
>
查看全文
相关阅读:
博客园的第一篇博客
I-如何办好比赛
塞特斯玛斯塔
字典序最大的子序列
百练POJ 1657:Distance on Chessboard
百练POJ2750:鸡兔同笼
HDU3790最短路径问题
HDU 2544最短路Dijkstra算法
快速幂【倍增+二分】
树的高度
原文地址:https://www.cnblogs.com/temptation/p/815010.html
最新文章
Navicat for mysql 远程连接 mySql数据库10061错误问题
python移位操作困惑
jquery $(document).ready() 与window.onload的区别
Chrome扩展程序 后台js与前台js数据交互
js javascript 判断字符串是否包含某字符串,String对象中查找子字符,indexOf
关于Chrome扩展程序开发 popup.html页面通过jsonp的方式与服务端交互问题
HTML5基本语法规则
SQL Server中的implicit_transactions
SQL Server压缩数据库文件
使用非1433端口时启用namepipe会报错
热门文章
openssl加密敏感信息
设置tomcat的默认首页
python中在自动化运维的应用
加载USB驱动以挂载移动硬盘
交互式shell与非交互式shell
nc 命令的使用
通过swappiness内核参数调节swap使用
JSON.parse()和JSON.stringify()
hdu-6230 主席树/树状数组+离线
hdu-6231 二分
Copyright © 2011-2022 走看看