-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathupdater2.html
More file actions
235 lines (205 loc) · 6.01 KB
/
Copy pathupdater2.html
File metadata and controls
235 lines (205 loc) · 6.01 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
<!DOCTYPE html>
<html>
<input value="HTML/JS update" onclick="move()" style="width: 120px; height: 20px;"
type="button"> <progress id="pHTML" value="0" max="100"></progress><br>
<input value="FirmWare update" onclick="uFirmWare('pFirmWare')" style="width: 120px; height: 20px;"
type="button"> <progress id="pFirmWare" value="0" max="100"></progress><br>
<style>
#myProgress {
width: 100%;
height: 30px;
position: relative;
background-color: #ddd;
}
#myBar {
background-color: #4CAF50;
width: 10px;
height: 30px;
position: absolute;
}
</style>
<body >
<h1>JavaScript Progress Bar</h1>
<div id="myProgress">
<div id="myBar"></div>
</div>
<br>
<button onclick="move()">Click Me</button>
</body>
</html>
<script>
var elem = document.getElementById("myBar");
var elem2 = document.getElementById("pHTML");
elem2.value=0;
var width = 0;
//init_frame();
//var id = setInterval(frame(), 10);
_URL='https://raw.githubusercontent.com/bbasil2012/SSLAC16/main/latest/';
_HTML='data/index.txt';
_FirmWare='bin/4mb/version';
sURL="http://192.168.4.1/upload"
var intfiles;
var i;
var data_blob;
//var pHTMP=document.getElementById('pHTML');
//var elem = document.getElementById("myBar");
//var width = 0;
//function init_frame(){
// alert("init");
// frame();
// id= setInterval(frame(), 10);
// }
// frame();
//var id = setInterval(frame, 10);
//alert(pHTML);
//function set_prg(value){
// pHTML.value = value*10;
// }
//setInterval (set_prg(),100);
get_intfiles(_URL,_HTML);
//alert(i);
//for (i=0;i<10;i++){
//console.log(i);
//document.getElementById('pHTML').value = i*10;
//setTimeout(5000);
//setTimeout(get_blob(intfiles[i],i),1000);
//width=i;
//}
// get_blob(intfiles[0],0);
//pHTML.value=10;
//get_blob(intfiles[1],1);
///i++;
//pHTML.value=20;
// get_blob(intfiles[2],2);
//i++;
//pHTML.value=30;
//get_blob(intfiles[3],3);
//i++;
//pHTML.value=40;
//get_blob(intfiles[4],4);
//pHTML.value=50;
//get_blob(intfiles[5],5);
//pHTML.value=60;
//get_blob(intfiles[6],6);
//pHTML.value=70;
//get_blob(intfiles[7],7);
//pHTML.value=80;
//get_blob(intfiles[8],8);
//pHTML.value=90;
//get_blob(intfiles[9],9);
//pHTML.value=100;
//alert(i);
//get_blob(_URL+"bin/4mb/0x0-SSLAC16-v0.35rev5.bin",100);
function Complete_intfiles(evt) {
//alert(this.responseText);
intfiles=JSON.parse(this.response);
}
function Complete_blob(evt){
var data_blob= new Blob;
data_blob=this.response;
var fd = new FormData();
console.log("data len:"+data_blob.length+"<>"+intfiles[width]);
fd.append("afile", data_blob,intfiles[width]);
//fd.append("filename",intfiles[width])
//var blob = new Blob();
//blob=data_blob;
//alert(blob);
//fd.append("file-name",data_blob,"text.txt");
if (window.XMLHttpRequest){
var xmlhttp_u=new XMLHttpRequest();
}else{
var xmlhttp_u=new ActiveXObject('Microsoft.XMLHTTP');
}
//var fd = new FormData();
//fd.append("afile", _data,intfiles[index]);
//console.log(fd.getAll());
setTimeout(xmlhttp_u.open('POST', sURL,false));
setTimeout(xmlhttp_u.send(fd));
width++;
//console.log("Complete"+data.length+"<>"+i);
//this.return=100;
//upload_blob(data_blob);
//console.log(this.responseURL);
}
function get_intfiles(uURL,uFileName) {
var resp;
if (window.XMLHttpRequest){
var xmlhttp=new XMLHttpRequest();
}else{
var xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.addEventListener("load", Complete_intfiles, false);
xmlhttp.open('GET', uURL+uFileName,false);
xmlhttp.send();
}
//function upload_blob(_data,index){
//console.log("Uploading:"+intfiles[index]+" "+_data.length+" bytes");
//if (window.XMLHttpRequest){
// var xmlhttp=new XMLHttpRequest();
// }else{
// var xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
//}
//var fd = new FormData();
//fd.append("afile", _data,intfiles[index]);
//console.log(fd.getAll());
//xmlhttp.open('POST', sURL,false);
//xmlhttp.send(_data);
//pHTML.value=i*10;
//}
//function get_blob(uFileName,index){
// if (window.XMLHttpRequest){
// var xmlhttp=new XMLHttpRequest();
// }else{
// var xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
// }
// xmlhttp.addEventListener("load", Complete_blob, false);
//xmlhttp.responseType = "blob";
// xmlhttp.open('GET',_URL+"data/"+uFileName,false);
// xmlhttp.overrideMimeType('text/plain; charset=x-user-defined');
//xmlhttp.responseType = "blob";
//xmlhttp.responseType = 'arraybuffer';
// xmlhttp.send();
// console.log(index);
//pHTML.value=index;
//set_prg(index);
// }
function move() {
var elem = document.getElementById("myBar");
var width = 0;
var id = setInterval(frame, 10);
function frame() {
//console.log("frame>"+width);
if (width == intfiles.length) {
clearInterval(id);
alert("Well Done");
//console.log("clean");
} else {
//****************************************************************
if (window.XMLHttpRequest){
var xmlhttp=new XMLHttpRequest();
}else{
var xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.addEventListener("load", Complete_blob, false);
//xmlhttp.responseType = "blob";
setTimeout(xmlhttp.open('GET',_URL+"data/"+intfiles[width]));
//xmlhttp.overrideMimeType('text/plain; charset=x-user-defined');
xmlhttp.responseType = "blob";
//xmlhttp.responseType = 'arraybuffer';
setTimeout(xmlhttp.send());
console.log(width);
//get_blob(intfiles[width],width);
//****************************************************************
//width++;
elem.style.width = (width+1)*10 + '%';
elem2.value=(width+1)*10;
//alert(fd.afile);
//console.log(fd.length);
//*******************************************************************
//upload_blob(fd,width);
//********************************************************************
width++;
}
}
}
</script>