Skip to content

Commit 967ce3e

Browse files
committed
release 1.0.2
1 parent 8e16395 commit 967ce3e

File tree

2 files changed

+84
-56
lines changed

2 files changed

+84
-56
lines changed

public/public/js/update/update.js

Lines changed: 58 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,69 @@
1-
$(document).ready(function(){
2-
var $pc = $('#progressController');
3-
var $pCaption = $('.progress-bar p');
4-
var iProgress = document.getElementById('inactiveProgress');
5-
var aProgress = document.getElementById('activeProgress');
6-
var iProgressCTX = iProgress.getContext('2d');
1+
// $(document).ready(function(){
2+
// var $pc = $('#progressController');
3+
// var $pCaption = $('.progress-bar p');
4+
// var iProgress = document.getElementById('inactiveProgress');
5+
// var aProgress = document.getElementById('activeProgress');
6+
// var iProgressCTX = iProgress.getContext('2d');
7+
78

8-
9-
drawInactive(iProgressCTX);
10-
11-
$pc.on('change', function(){
12-
var percentage = $(this).val() / 100;
13-
console.log(percentage + '%');
14-
drawProgress(aProgress, percentage, $pCaption);
15-
});
9+
// drawInactive(iProgressCTX);
1610

17-
function drawInactive(iProgressCTX){
18-
iProgressCTX.lineCap = 'square';
11+
// $pc.on('change', function(){
12+
// var percentage = $(this).val() / 100;
13+
// console.log(percentage + '%');
14+
// drawProgress(aProgress, percentage, $pCaption);
15+
// });
16+
// });
1917

20-
//outer ring
21-
iProgressCTX.beginPath();
22-
iProgressCTX.lineWidth = 15;
23-
iProgressCTX.strokeStyle = '#e1e1e1';
24-
iProgressCTX.arc(137.5,137.5,129,0,2*Math.PI);
25-
iProgressCTX.stroke();
18+
// var $pc = $('#progressController');
19+
var $pCaption = $('.progress-bar p');
20+
var iProgress = document.getElementById('inactiveProgress');
21+
var aProgress = document.getElementById('activeProgress');
22+
var iProgressCTX = iProgress.getContext('2d');
23+
24+
$(document).ready(function(){
25+
drawInactive(iProgressCTX);
26+
});
2627

27-
//progress bar
28-
iProgressCTX.beginPath();
29-
iProgressCTX.lineWidth = 0;
30-
iProgressCTX.fillStyle = '#e6e6e6';
31-
iProgressCTX.arc(137.5,137.5,121,0,2*Math.PI);
32-
iProgressCTX.fill();
28+
function drawInactive(iProgressCTX){
29+
iProgressCTX.lineCap = 'square';
3330

34-
//progressbar caption
35-
iProgressCTX.beginPath();
36-
iProgressCTX.lineWidth = 0;
37-
iProgressCTX.fillStyle = '#fff';
38-
iProgressCTX.arc(137.5,137.5,100,0,2*Math.PI);
39-
iProgressCTX.fill();
31+
//outer ring
32+
iProgressCTX.beginPath();
33+
iProgressCTX.lineWidth = 15;
34+
iProgressCTX.strokeStyle = '#e1e1e1';
35+
iProgressCTX.arc(137.5,137.5,129,0,2*Math.PI);
36+
iProgressCTX.stroke();
4037

41-
}
42-
function drawProgress(bar, percentage, $pCaption){
43-
var barCTX = bar.getContext("2d");
44-
var quarterTurn = Math.PI / 2;
45-
var endingAngle = ((2*percentage) * Math.PI) - quarterTurn;
46-
var startingAngle = 0 - quarterTurn;
38+
//progress bar
39+
iProgressCTX.beginPath();
40+
iProgressCTX.lineWidth = 0;
41+
iProgressCTX.fillStyle = '#e6e6e6';
42+
iProgressCTX.arc(137.5,137.5,121,0,2*Math.PI);
43+
iProgressCTX.fill();
4744

48-
bar.width = bar.width;
49-
barCTX.lineCap = 'square';
45+
//progressbar caption
46+
iProgressCTX.beginPath();
47+
iProgressCTX.lineWidth = 0;
48+
iProgressCTX.fillStyle = '#fff';
49+
iProgressCTX.arc(137.5,137.5,100,0,2*Math.PI);
50+
iProgressCTX.fill();
5051

51-
barCTX.beginPath();
52-
barCTX.lineWidth = 20;
53-
barCTX.strokeStyle = '#76e1e5';
54-
barCTX.arc(137.5,137.5,111,startingAngle, endingAngle);
55-
barCTX.stroke();
52+
}
53+
function drawProgress(bar, percentage, $pCaption){
54+
var barCTX = bar.getContext("2d");
55+
var quarterTurn = Math.PI / 2;
56+
var endingAngle = ((2*percentage) * Math.PI) - quarterTurn;
57+
var startingAngle = 0 - quarterTurn;
5658

57-
$pCaption.text( (parseInt(percentage * 100, 10)) + '%');
58-
}
59+
bar.width = bar.width;
60+
barCTX.lineCap = 'square';
5961

60-
var percentage = $pc.val() / 100;
61-
drawProgress(aProgress, percentage, $pCaption);
62+
barCTX.beginPath();
63+
barCTX.lineWidth = 20;
64+
barCTX.strokeStyle = '#76e1e5';
65+
barCTX.arc(137.5,137.5,111,startingAngle, endingAngle);
66+
barCTX.stroke();
6267

63-
64-
});
68+
$pCaption.text( (parseInt(percentage * 100, 10)) + '%');
69+
}

public/update.html

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,23 @@
1414
<canvas id="activeProgress" class="progress-active" height="275px" width="275px"></canvas>
1515
<p>0%</p>
1616
</div>
17-
<div id="progressControllerContainer">
17+
<!-- <div id="progressControllerContainer">
1818
<input type="range" id="progressController" min="0" max="100" value="15" />
19-
</div>
19+
</div> -->
2020
</div>
2121
<script src='public/js/dep.min.js'></script>
2222
<script src="public/js/update/update.js"></script>
23+
<script type="text/javascript">
24+
var percentage = 0;
25+
// var $pc = $('#progressController');
26+
var $pCaption = $('.progress-bar p');
27+
var iProgress = document.getElementById('inactiveProgress');
28+
var aProgress = document.getElementById('activeProgress');
29+
var iProgressCTX = iProgress.getContext('2d');
30+
drawProgress(aProgress, percentage, $pCaption);
31+
32+
</script>
33+
2334
<script>
2435
/*
2536
@@ -74,6 +85,7 @@
7485
var newVersion = upd.download(function(error, filename) {
7586
if (!error) {
7687
console.log("download successfully");
88+
7789
// ------------- Step 3 -------------
7890
upd.unpack(filename, function(error, newAppPath) {
7991
if (!error) {
@@ -94,16 +106,27 @@
94106
upd.runInstaller(newAppPath, [upd.getAppPath(), upd.getAppExec()],{}); // 传递参数,启动下载下来的nwjs app(B)
95107
gui.App.quit(); // 关掉旧的app(A)
96108
}
109+
else {
110+
console.log("unpack failed");
111+
console.log(err);
112+
}
97113
}, manifest);
98114
}
99115
else {
100116
console.log("download failed");
101117
}
102118
}, manifest);
103119

120+
var loaded = 0;
104121
newVersion.on('data', function(chunk){
105-
var loaded = 0;
106122
loaded += chunk.length;
123+
var percentage = loaded / newVersion['content-length'];
124+
// console.log(percentage + "%");
125+
var $pCaption = $('.progress-bar p');
126+
var iProgress = document.getElementById('inactiveProgress');
127+
var aProgress = document.getElementById('activeProgress');
128+
var iProgressCTX = iProgress.getContext('2d');
129+
drawProgress(aProgress, percentage, $pCaption);
107130
// document.getElementById('loaded').innerHTML = "New version loading " + Math.floor(loaded / newVersion['content-length'] * 100) + '%';
108131
})
109132
}

0 commit comments

Comments
 (0)