Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: appengine/swarming/elements/res/imp/common/pageable-data-demo.html

Issue 2408743002: Move elements/ to ui/ (Closed)
Patch Set: rebase again Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!--
2 Copyright 2016 The LUCI Authors. All rights reserved.
3 Use of this source code is governed under the Apache License, Version 2.0
4 that can be found in the LICENSE file.
5
6 -->
7 <!DOCTYPE html>
8 <html>
9 <head>
10 <title>pageable-data Demo</title>
11 <meta charset="utf-8">
12 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
13 <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial- scale=1, user-scalable=yes">
14 <script src="../bower_components/webcomponentsjs/webcomponents-lite.js"></scri pt>
15 <script src="../../../node_modules/skia-common-js/common.js"></script>
16 <script src="/res/js/common.js"></script>
17 <script src="/res/js/alias.js"></script>
18 <script src="../../../node_modules/sinon/pkg/sinon-1.17.5.js"></script>
19
20
21 <script type="text/javascript" charset="utf-8">
22 sinon.format = function(object) {return JSON.stringify(object);}
23 sinon.log = function(message) {console.log(message);};
24 var server = sinon.fakeServer.create();
25 server.autoRespond = true;
26 // server.autoRespondAfter = 1000;
27
28 var data = [];
29 for (var i = 0; i < 27; i++) {
30 data.push({alpha: Math.random(), beta: Math.random(), gamma: i});
31 }
32
33 var MAX = 20;
34
35 server.respondWith("GET", /^\/get.*/, function(request){
36 console.log("Request: ",request);
37
38 var query = request.url.substring(request.url.indexOf('?') + 1);
39 var params = sk.query.toObject(query,{cursor:-1, limit:-1});
40 console.log(query, params);
41 start = params.cursor || 0;
42 var limit = params.limit || MAX;
43 end = start + Math.min(limit, MAX);
44 var resp = {
45 "data": data.slice(start, end)
46 }
47 if (end < data.length) {
48 resp["cursor"] = end;
49 }
50 request.respond(200, {"Content-Type":"application/json"},JSON.stringify( resp));
51 });
52
53 </script>
54 <link rel="import" href="/res/imp/bower_components/polymer/polymer.html">
55 <link rel="import" href="pageable-data.html">
56 </head>
57 <body>
58
59 <dom-module id="pageable-data-demo">
60 <template>
61 <style>
62 :host {
63 display: block;
64 }
65 </style>
66 <div>Busy: [[busy]]</div>
67 <template is="dom-repeat" items="{{items}}" as="item">
68 <div>[[item.gamma]] [[item.alpha]]</div>
69 </template>
70
71 <pageable-data
72 id="pd"
73 busy="{{busy}}"
74 output="{{items}}"
75 parse="[[_parse]]">
76 </pageable-data>
77
78 </template>
79 <script>
80 Polymer({
81 is: 'pageable-data-demo',
82
83 properties: {
84 _parse: {
85 type: Function,
86 value: function() {
87 return function(json) {
88 console.log("hello parse");
89 return json.data;
90 };
91 },
92 },
93 },
94
95 attached: function(){
96 this.$.pd.load("/get?foo=bar", {"X-Testing":"foobar"}, 10);
97 },
98
99 });
100 </script>
101 </dom-module>
102
103 <pageable-data-demo></pageable-data-demo>
104
105 </body>
106 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698