update.html
12.1 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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
<!doctype html>
<html lang="en" ng-app="myApp">
<head>
<title>犀牛更新</title>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta http-equiv="Expires" content="0" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-store" />
<meta http-equiv="Pragma" content="no-cache" />
<meta name="renderer" content="webkit|ie-comp|ie-stand" />
<meta name="data-xns" content="p0002" />
<meta name="description" content="犀牛认证平台" />
<meta name="author" content="犀牛网络" />
<link rel="stylesheet" href="./styles/undate.css"/>
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
<script type="text/javascript" src="../vender/base/base.min.js"></script>
<script>if (window.module) module = window.module;</script>
<script type="text/javascript" src="../dist/scripts/global.min.js"></script>
<!--<script type="text/javascript" src="dist/scripts/local.min.js"></script>-->
<script type="text/javascript">
var i = 0;
var res = 0;
var context = null;
var total_width = 250;
var total_height = 10;
var initial_x = 0;
var initial_y = 0;
var radius = total_height/2;
window.onload = function() {
var elem = document.getElementById('myCanvas');
if (!elem || !elem.getContext) {
return;
}
context = elem.getContext('2d');
if (!context) {
return;
}
// set font
context.font = "16px Verdana";
// Blue gradient for progress bar
var progress_lingrad = context.createLinearGradient(0,initial_y+total_height,0,0);
progress_lingrad.addColorStop(0, '#3399ff');
//progress_lingrad.addColorStop(0.4, '#3399ff');
progress_lingrad.addColorStop(1, '#3399ff');
context.fillStyle = progress_lingrad;
//draw();
res = setInterval(draw, 30);
}
function draw() {
// i+=1;
// Clear everything before drawing
if(i > total_width)
{
clearInterval(res);
i = total_width;
}
context.clearRect(initial_x-5,initial_y-5,total_width+15,total_height+80);
progressLayerRect(context, initial_x, initial_y, total_width, total_height, radius);
progressBarRect(context, initial_x, initial_y, i, total_height, radius, total_width);
progressText(context, initial_x, initial_y, i, total_height, radius, total_width );
// if (i>=total_width) {
// clearInterval(res);
// }
}
/**
* Draws a rounded rectangle.
* @param {CanvasContext} ctx
* @param {Number} x The top left x coordinate
* @param {Number} y The top left y coordinate
* @param {Number} width The width of the rectangle
* @param {Number} height The height of the rectangle
* @param {Number} radius The corner radius;
*/
function roundRect(ctx, x, y, width, height, radius) {
ctx.beginPath();
ctx.moveTo(x + radius, y);
ctx.lineTo(x + width - radius, y);
ctx.arc(x+width-radius, y+radius, radius, -Math.PI/2, Math.PI/2, false);
ctx.lineTo(x + radius, y + height);
ctx.arc(x+radius, y+radius, radius, Math.PI/2, 3*Math.PI/2, false);
ctx.closePath();
ctx.fill();
}
/**
* Draws a rounded rectangle.
* @param {CanvasContext} ctx
* @param {Number} x The top left x coordinate
* @param {Number} y The top left y coordinate
* @param {Number} width The width of the rectangle
* @param {Number} height The height of the rectangle
* @param {Number} radius The corner radius;
*/
function roundInsetRect(ctx, x, y, width, height, radius) {
ctx.beginPath();
// Draw huge anti-clockwise box
ctx.moveTo(1000, 1000);
ctx.lineTo(1000, -1000);
ctx.lineTo(-1000, -1000);
ctx.lineTo(-1000, 1000);
ctx.lineTo(1000, 1000);
ctx.moveTo(x + radius, y);
ctx.lineTo(x + width - radius, y);
ctx.arc(x+width-radius, y+radius, radius, -Math.PI/2, Math.PI/2, false);
ctx.lineTo(x + radius, y + height);
ctx.arc(x+radius, y+radius, radius, Math.PI/2, 3*Math.PI/2, false);
ctx.closePath();
ctx.fill();
}
function progressLayerRect(ctx, x, y, width, height, radius) {
ctx.save();
// Set shadows to make some depth
ctx.shadowOffsetX = 2;
ctx.shadowOffsetY = 2;
ctx.shadowBlur = 5;
ctx.shadowColor = '#666';
// Create initial grey layer
ctx.fillStyle = 'rgba(189,189,189,1)';
roundRect(ctx, x, y, width, height, radius);
// Overlay with gradient
ctx.shadowColor = 'rgba(0,0,0,0)'
var lingrad = ctx.createLinearGradient(0,y+height,0,0);
lingrad.addColorStop(0, 'rgba(255,255,255, 0.1)');
lingrad.addColorStop(0.4, 'rgba(255,255,255, 0.7)');
lingrad.addColorStop(1, 'rgba(255,255,255,0.4)');
ctx.fillStyle = lingrad;
roundRect(ctx, x, y, width, height, radius);
ctx.fillStyle = 'white';
//roundInsetRect(ctx, x, y, width, height, radius);
ctx.restore();
}
/**
* Draws a half-rounded progress bar to properly fill rounded under-layer
* @param {CanvasContext} ctx
* @param {Number} x The top left x coordinate
* @param {Number} y The top left y coordinate
* @param {Number} width The width of the bar
* @param {Number} height The height of the bar
* @param {Number} radius The corner radius;
* @param {Number} max The under-layer total width;
*/
function progressBarRect(ctx, x, y, width, height, radius, max) {
// var to store offset for proper filling when inside rounded area
var offset = 0;
ctx.beginPath();
if (width<radius) {
offset = radius - Math.sqrt(Math.pow(radius,2)-Math.pow((radius-width),2));
ctx.moveTo(x + width, y+offset);
ctx.lineTo(x + width, y+height-offset);
ctx.arc(x + radius, y + radius, radius, Math.PI - Math.acos((radius - width) / radius), Math.PI + Math.acos((radius - width) / radius), false);
}
else if (width+radius>max) {
offset = radius - Math.sqrt(Math.pow(radius,2)-Math.pow((radius - (max-width)),2));
ctx.moveTo(x + radius, y);
ctx.lineTo(x + width, y);
ctx.arc(x+max-radius, y + radius, radius, -Math.PI/2, -Math.acos((radius - (max-width)) / radius), false);
ctx.lineTo(x + width, y+height-offset);
ctx.arc(x+max-radius, y + radius, radius, Math.acos((radius - (max-width)) / radius), Math.PI/2, false);
ctx.lineTo(x + radius, y + height);
ctx.arc(x+radius, y+radius, radius, Math.PI/2, 3*Math.PI/2, false);
}
else {
ctx.moveTo(x + radius, y);
ctx.lineTo(x + width, y);
ctx.lineTo(x + width, y + height);
ctx.lineTo(x + radius, y + height);
ctx.arc(x+radius, y+radius, radius, Math.PI/2, 3*Math.PI/2, false);
}
ctx.closePath();
ctx.fill();
// draw progress bar right border shadow
if (width<max-1) {
ctx.save();
ctx.shadowOffsetX = 1;
ctx.shadowBlur = 1;
ctx.shadowColor = '#666';
if (width+radius>max)
offset = offset+1;
ctx.fillRect(x+width,y+offset,1,total_height-offset*2);
ctx.restore();
}
}
/**
* Draws properly-positioned progress bar percent text
* @param {CanvasContext} ctx
* @param {Number} x The top left x coordinate
* @param {Number} y The top left y coordinate
* @param {Number} width The width of the bar
* @param {Number} height The height of the bar
* @param {Number} radius The corner radius;
* @param {Number} max The under-layer total width;
*/
function progressText(ctx, x, y, width, height, radius, max) {
ctx.save();
ctx.fillStyle = 'white';
var text = "";
if(i == total_width)
{
text = "更新完成";
}
else
{
text = "更新" + Math.floor(width/max*100)+"%...";
}
var text_width = ctx.measureText(text).width;
var text_x = x+width-text_width-radius/2;
if (width<=radius+text_width) {
text_x = x+radius/2;
}
ctx.font="18px 微软雅黑";
context.fillStyle = "#3399ff"; // text color
ctx.fillText(text, 90, y+60);
ctx.restore();
}
</script>
</head>
<body class="xn-undate-body" ng-app="myApp" ng-controller="bodyController" >
<div id="div_bg" class="xn-undate-layout">
<div class="xn-text-center">
<img src="./images/logo-md.png" width="65px" height="35px" >
<img src="./images/auth-title.png" height="27">
</div>
<p></p>
<div style="width:340px; height:300px;background-color: white;">
<div ng-show="div_update">
<div class="xn-undate-title" >软件更新</div>
<div class="undate-line clearfix"><div class="undate-lable" >更新日期:</div><div class="xn-undate-data" ng-bind = "update.date"></div></div>
<div class="undate-line clearfix"><div class="undate-lable" >当前版本:</div><div class="xn-undate-data" ng-bind = "update.localVersion"></div></div>
<div class="undate-line clearfix"><div class="undate-lable" >更新版本:</div><div class="xn-undate-data" ng-bind = "update.remoteVersion"></div></div>
<div class="undate-line clearfix"><div class="undate-lable" >更新内容:</div></div>
<div class="undate-line clearfix">
<pre class="undate-pre" ng-bind="update.content">
</pre>
</div>
<div class="undate-line clearfix">
<input type="submit" class="undate-btn undate-btn-def" ng-click="click_cancel()" value="下次再说">
<input type="submit" class="undate-btn " ng-click="click_update()" value="立即更新">
</div>
</div>
<div ng-show="div_updating">
<canvas id="myCanvas" class="progress" style="top:120px;position: relative;left:45px;" width="300px" ></canvas>
</div>
<div ng-show="div_update_finish" style="text-align: center ;padding-top: 60px;">
<img src="images/update_success.png" width="91px" height="100px" >
<p class="line_height" ><span style="left:20px;top:130px ;font-family: '微软雅黑';color: #0a0a0a;" >更新完成</span></p>
<button ng-click="click_close()" style="width:80px;height:30px;background-color:rgb(51,153,255);color: #f0f0f0;font-family: '微软雅黑';border: none;font-weight:bold;">
关闭</button>
</div>
</div>
</div>
<script src="./update.js"></script>
</body>
</html>