forked from googlearchive/core-ajax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo-progress.html
65 lines (61 loc) · 1.69 KB
/
demo-progress.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
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html>
<head>
<script src="../webcomponentsjs/webcomponents.js" debug></script>
<meta charset="utf-8">
<title>Race condition</title>
</head>
<body>
<link rel="import" href="core-ajax.html">
<link rel="import" href="../paper-progress/paper-progress.html">
<polymer-element name="progress-test">
<template>
<core-ajax
id="ajax" auto
url="http://httpbin.org/drip"
params="{{ {numbytes: numbytes, duration:5} }}"
response="{{response}}"
progress="{{progress}}"
loading="{{loading}}"
></core-ajax>
<!--
Ordinarily you'd gate on progress.lengthComputable, but we know the
length in this case (and httpbin sadly doesn't return a
Content-Length header for this requesthere).
https://github.com/kennethreitz/httpbin/pull/160
-->
<div>
<button on-click="{{restart}}">Restart</button>
<template if="{{loading}}">
Loading...
</template>
<template if="{{!loading}}">
Loaded!
</template>
</div>
<template if="{{loading && progress.loaded}}">
<paper-progress
value="{{progress.loaded}}"
min="0"
max="{{numbytes}}">
</paper-progress><br>
</template>
</template>
<script>
Polymer('progress-test', {
loading: true,
i: 0,
numbytes: 1000,
pretty: function(i) {
return JSON.stringify(i, null, 2);
},
restart: function() {
this.$.ajax.abort();
this.$.ajax.go();
}
});
</script>
</polymer-element>
<progress-test></progress-test>
</body>
</html>