forked from DaisyCream/CFCweb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
loading.js
executable file
·96 lines (84 loc) · 2.1 KB
/
loading.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
/**
* Created by DaisyCream on 2015/8/15.
*/
LOADING = function(){};
LOADING.IMG_ARRAY=[
"png/arrow_left.png",
"png/arrow_right.png",
"png/CFC.png",
"png/cloud1.png",
"png/cloud2.png",
"png/GGLG2.png",
"png/home.png",
"png/joinCommit.png",
"png/joinCommit_click.png",
"png/jump.png",
"png/logo.png",
"png/manPhoto.png",
"png/nav_bg.png",
"png/people_man.png",
"png/rail.png",
"png/show.png",
"png/title.png",
"png/window_big.png",
"png/work1.png",
"png/work2.png",
"png/work3.png",
"png/work4.png",
"png/work5.png",
"png/work6.png",
"png/work7.png",
"png/work8.png",
"png/work9.png",
"png/work10.png"
];
function $$(target){
return document.getElementById(target);
}
LOADING.HiddenAll = function(){
$$("page1").style.display = "none";
$$("page2").style.display = "none";
$$("page3").style.display = "none";
};
LOADING.DisplayAll = function(){
$$("page1").style.display = "block";
$$("page2").style.display = "block";
$$("page3").style.display = "block";
};
LOADING.Start = function(){
LOADING.HiddenAll();
$$("loading").style.display = "block";
LOADING.loadImg();
};
LOADING.End = function(){
LOADING.DisplayAll();
$$("loading").style.display = "none";
};
/***
*
*/
LOADING.preSum = 0;
LOADING.preAll = 0;
LOADING.preLong = 200/LOADING.IMG_ARRAY.length;
LOADING.preNum = (100/LOADING.IMG_ARRAY.length);
LOADING.index = 0;
LOADING.loadImg = function() {
if (LOADING.index >= LOADING.IMG_ARRAY.length){
LOADING.preSum=200;
$$("loadingBar").style.width = LOADING.preSum+"px";
$$("loadingNum").innerHTML = "100%";
LOADING.End();
return;
}
var img = new Image();
img.src = LOADING.IMG_ARRAY[LOADING.index];
img.onload = function(){
LOADING.preAll+=LOADING.preNum;
LOADING.preSum+=LOADING.preLong;
$$("loadingBar").style.width = LOADING.preSum+"px";
$$("loadingNum").innerHTML = LOADING.preAll.toFixed(2)+"%";
LOADING.index++;
LOADING.loadImg();
};
};
LOADING.Start();