OLD | NEW |
---|---|
(Empty) | |
1 <!-- | |
2 // Copyright 2014 The Chromium Authors. All rights reserved. | |
3 // Use of this source code is governed by a BSD-style license that can be | |
4 // found in the LICENSE file. | |
5 --> | |
6 <import src="../framework/sky-element/sky-element.sky" as="SkyElement" /> | |
7 <import src="../framework/xmlhttprequest.sky" as="XMLHttpRequest" /> | |
8 | |
9 <template> | |
10 <style> | |
11 heading { | |
12 font-size: 16px; | |
13 } | |
14 </style> | |
15 <heading>File browser for {{ url }}</heading> | |
16 <template repeat="{{ directory in directories }}"> | |
rafaelw
2014/11/03 20:06:04
if you want this to work now, you can just do
<te
| |
17 <a href="{{ directory }}">{{ directory }}</a> | |
18 </template> | |
19 <template repeat="{{ file in files }}"> | |
20 <a href="{{ file }}">{{ file }}</a> | |
21 </template> | |
22 </template> | |
23 <script> | |
24 SkyElement({ | |
25 name: 'file-browser', | |
26 url: '', | |
27 files: [], | |
28 directories: [], | |
29 attached: function() { | |
30 this.url = this.ownerDocument.URL; | |
31 var xhr = this.xhr_ = new XMLHttpRequest(); | |
32 xhr.open('GET', this.url + '?format=json'); | |
33 xhr.onload = (function() { | |
34 var listing = JSON.parse(xhr.responseText); | |
35 this.files = listing.files; | |
36 this.directories = listing.directories; | |
37 }).bind(this); | |
38 xhr.send(); | |
39 } | |
40 }); | |
41 </script> | |
OLD | NEW |