-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathmulti-processing.html
More file actions
214 lines (132 loc) · 7.68 KB
/
multi-processing.html
File metadata and controls
214 lines (132 loc) · 7.68 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<!DOCTYPE html>
<html>
<head>
<title>Progress Bar: Multi-Processing Sample (Javascript)</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="keywords" content="Progress, Bar, Javascript, UI, Library, Widgets, Plugins, Component, jQuery, Multi, Sparklines">
<meta name="description" content="(Javascript) Multiple progress bar control and tiny chart (sparkline) Features; initial-mode, multi-processing, categorical-processing, limit-lines">
<meta name="author" content="Bugra OZDEN">
<link rel="stylesheet" href="css/lib/control/progressbar.css" />
<script type="text/javascript" src="lib/control/progressbar.min.js"></script>
<style type="text/css">
#my-progressbar-container {
position: relative;
width: 200px; /* my-progressbar width */
padding: 20px 5px 20px 5px; /* Space for progresbar-texts */
background-color: transparent;
}
.progressbar-text {
position: absolute;
font-family: Arial;
font-size: 10px;
color: #333333;
}
.progressbar-text.top-right {
top:5px;
right:7px;
}
.progressbar-text.top-left {
top:5px;
left:7px;
}
.progressbar-text.bottom-right {
bottom:5px;
right:7px;
}
.progressbar-text.bottom-left {
bottom:5px;
left:7px;
}
</style>
<script type="text/javascript">
var progressBar; //my component object
window.onload = function(){
//INIT function
// ###
// Create New ProgressBar
// ###
progressBar = new ProgressBar("my-progressbar", {'width':'200px', 'height':'6px'});
// ###
// Create Total Process
// ###
// Method 1:
//progressBarItem = {};
//progressBarItem[ProgressBar.OPTION_NAME.ITEM_ID] = "totalProcess";
//progressBar.createItem( progressBarItem );
// Method 2:
progressBar.createItem( "totalProcess" );
// ###
// Create Current Process
// ###
progressBarItem = {};
progressBarItem[ProgressBar.OPTION_NAME.ITEM_ID] = "currentProcess";
progressBarItem[ProgressBar.OPTION_NAME.OPACITY] = 0.8;
progressBarItem[ProgressBar.OPTION_NAME.POSITION] = ProgressBar.OPTION_VALUE.POSITION.ABSOLUTE;
progressBarItem[ProgressBar.OPTION_NAME.COLOR_ID] = ProgressBar.OPTION_VALUE.COLOR_ID.WHITE;
progressBar.createItem(progressBarItem);
// ###
//Event Listener
// ###
// Event listener (COMPLETED)
progressBar.getElement().addEventListener(ProgressBar.EVENT.COMPLETED,
function($event){
//Which itemID?
switch($event.detail.itemID){
//current process completed (white)
case 'currentProcess':
var randomValue = progressBar.getPercent('totalProcess') + (Math.random()*20) + 1;
//Set percent values
progressBar.setPercent(randomValue, 'totalProcess');
setTimeout(function(){ progressBar.setPercent(0, 'currentProcess'); }, 500);
break;
//All completed (blue)
case 'totalProcess':
clearTimeout(window.playMultiProcessingTimer);
setTimeout(function(){
document.getElementById('my-progressbar-text3').innerHTML = "";
document.getElementById('my-progressbar-text1').innerHTML = "Multi-Processing";
},500);
break;
}
});
//Event listener: CHANGED
progressBar.getElement().addEventListener(ProgressBar.EVENT.CHANGED,
function($event){
//Which itemID?
switch($event.detail.itemID){
//current process completed (white)
case 'currentProcess':
document.getElementById('my-progressbar-text3').innerHTML = $event.detail.me.getPercent($event.detail.itemID) + '%';
break;
//All completed (blue)
case 'totalProcess':
document.getElementById('my-progressbar-text4').innerHTML = '<strong>Total</strong> ' + $event.detail.me.getPercent($event.detail.itemID) + '%';
break;
}
});
//Play the demo
playMultiProcessing();
}
//Play the animation
function playMultiProcessing() {
window.playMultiProcessingTimer = setTimeout(playMultiProcessing, (Math.random()*1000)+100 );
if(progressBar.getPercent('currentProcess') != 100){
//Set percent value (itemID:currentProcess)
var randomValue = progressBar.getPercent('currentProcess') + parseInt((Math.random()*20) + 1);
progressBar.setPercent(randomValue, 'currentProcess');
}
};
</script>
</head>
<body>
<h2>Progress Bar: Multi-Processing Sample (Javascript)</h2>
<div id="my-progressbar-container">
<div id="my-progressbar-text1" class="progressbar-text top-left">Multi-Processing...</div>
<div id="my-progressbar-text2" class="progressbar-text top-right"></div>
<div id="my-progressbar"></div>
<div id="my-progressbar-text3" class="progressbar-text bottom-left">0%</div>
<div id="my-progressbar-text4" class="progressbar-text bottom-right"><strong>Total</strong> 0%</div>
</div>
</body>
</html>