-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
52 lines (52 loc) · 1 KB
/
index.html
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
<!DOCTYPE HTML>
<html>
<head>
<title>
use event-source to make a progress bar of demo
</title>
<meta name="author" content="zsdroid">
<meta charset="utf-8">
<script src="EventSource.js">
</script>
<script>
var _$ = id =>
{
return document.querySelector(id);
};
window.onload = function()
{
_EventSource("demo.php",
[
{
//Custom Event
event:'ProgressEvent',
callback:(data,event) =>
{
_$(".progressInfo").innerHTML = data[0];
_$(".progress").value = data[0];
_$('.text').innerHTML += data[1] + ' => progress ' + data[0] + '%' + '<br />';
console.log(event,event.dataArray);
},
}
,
{
//default Event
callback:data => {}
}
]);
}
</script>
</head>
<body>
<div class="info">
<progress class="progress" max="100" value="0">
</progress>
<span class="progressInfo">
0
</span>%
<br />
<span class="text">
</span>
</div>
</body>
</html>