-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtimerbar.js
144 lines (127 loc) · 4.79 KB
/
timerbar.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// Timer Bar - Version 1.0
// Author: Brian Gosselin of http://scriptasylum.com
// Script featured on http://www.dynamicdrive.com
var loadedcolor='blue' ; // PROGRESS BAR COLOR
var unloadedcolor='lightgrey'; // COLOR OF UNLOADED AREA
var bordercolor='navy'; // COLOR OF THE BORDER
var barheight=30; // HEIGHT OF PROGRESS BAR IN PIXELS
var barwidth=400; // WIDTH OF THE BAR IN PIXELS
var waitTime=20; // NUMBER OF SECONDS FOR PROGRESSBAR
var clickCount = 0;
// THE FUNCTION BELOW CONTAINS THE ACTION(S) TAKEN ONCE BAR REACHES 100%.
// IF NO ACTION IS DESIRED, TAKE EVERYTHING OUT FROM BETWEEN THE CURLY BRACES ({})
// BUT LEAVE THE FUNCTION NAME AND CURLY BRACES IN PLACE.
// PRESENTLY, IT IS SET TO DO NOTHING, BUT CAN BE CHANGED EASILY.
// TO CAUSE A REDIRECT TO ANOTHER PAGE, INSERT THE FOLLOWING LINE:
// window.location="http://redirect_page.html";
// JUST CHANGE THE ACTUAL URL OF COURSE :)
var action=function()
{
if (loaded == (10 * waitTime) && clickCount == 1) {
levelup();
return false;
}
else if (loaded == (10 * waitTime) && gameOver == false && clickCount == 0) {
alert("Download Complete")
} else if (clickCount == 1) {
openTerminal();
loaded = 0;
progressBarInit();
} else {
clickCount++;
progressBarInit();
}
}
function openTerminal(){
el = document.getElementById("terminal");
el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
el2 = document.getElementById("command");
el2.style.visibility = (el2.style.visibility == "visible") ? "hidden" : "visible";
document.getElementById('txtBox').focus();
}
function incrementCount() {
clickCount++;
alert();
}
//*****************************************************//
//********** DO NOT EDIT BEYOND THIS POINT **********//
//*****************************************************//
var ns4;
var ie4;
var blocksize;
var loaded;
var PBouter;
var PBdone;
var PBbckgnd;
var Pid;
function draw() {
ns4=(document.layers)?true:false;
ie4=(document.all)?true:false;
blocksize=(barwidth-2)/waitTime/10;
loaded=0;
Pid=0;
txt='';
if(ns4){
txt+='<table border=0 cellpadding=0 cellspacing=0><tr><td>hello world';
txt+='<ilayer name="PBouter" visibility="hide" height="'+barheight+'" width="'+barwidth+'" onmouseup="hidebar()" onclick="clickCount++; alert(clickCount)"><p>hello world</p>';
txt+='<layer width="'+barwidth+'" height="'+barheight+'" bgcolor="'+bordercolor+'" top="0" left="0"><p>hello world</p></layer>';
txt+='<layer width="'+(barwidth-2)+'" height="'+(barheight-2)+'" bgcolor="'+unloadedcolor+'" top="1" left="1"><p>hello world</p></layer>';
txt+='<layer name="PBdone" width="'+(barwidth-2)+'" height="'+(barheight-2)+'" bgcolor="'+loadedcolor+'" top="1" left="1"><p>hello world</p></layer>';
txt+='</ilayer>';
txt+='</td></tr></table>';
}else{
txt+='<div id="PBouter" onmouseup="hidebar()" onclick="clickCount++; alert(clickCount)" style="position:relative; visibility:hidden; background-color:'+bordercolor+'; width:'+barwidth+'px; height:'+barheight+'px;">';
txt+='<div style="position:absolute; top:1px; left:1px; width:'+(barwidth-2)+'px; height:'+(barheight-2)+'px; background-color:'+unloadedcolor+'; font-size:1px;"></div>';
txt+='<div id="PBdone" style="position:absolute; top:1px; left:1px; width:0px; height:'+(barheight-2)+'px; background-color:'+loadedcolor+'; font-size:1px;"></div>';
txt+='</div>';
}
document.getElementById('timebar').innerHTML = txt;
}
function incrCount(){
window.status="Loading...";
loaded++;
if(loaded<0)loaded=0;
if(loaded>=waitTime*10){
clearInterval(Pid);
loaded=waitTime*10;
setTimeout('hidebar()',100);
}
resizeEl(PBdone, 0, blocksize*loaded, barheight-2, 0);
}
function hidebar(){
clearInterval(Pid);
window.status='';
//if(ns4)PBouter.visibility="hide";
//else PBouter.style.visibility="hidden";
action();
}
//THIS FUNCTION BY MIKE HALL OF BRAINJAR.COM
function findlayer(name,doc){
var i,layer;
for(i=0;i<doc.layers.length;i++){
layer=doc.layers[i];
if(layer.name==name)return layer;
if(layer.document.layers.length>0)
if((layer=findlayer(name,layer.document))!=null)
return layer;
}
return null;
}
function progressBarInit(){
draw();
PBouter=(ns4)?findlayer('PBouter',document):(ie4)?document.all['PBouter']:document.getElementById('PBouter');
PBdone=(ns4)?PBouter.document.layers['PBdone']:(ie4)?document.all['PBdone']:document.getElementById('PBdone');
resizeEl(PBdone,0,0,barheight-2,0);
if(ns4)PBouter.visibility="show";
else PBouter.style.visibility="visible";
Pid=setInterval('incrCount()',95);
}
function resizeEl(id,t,r,b,l){
if(ns4){
id.clip.left=l;
id.clip.top=t;
id.clip.right=r;
id.clip.bottom=b;
}else id.style.width=r+'px';
}
window.onload=progressBarInit;