2014-11-03 20:53:38 +00:00
|
|
|
<!--
|
|
|
|
// Copyright 2014 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
-->
|
|
|
|
<import src="../framework/sky-element/sky-element.sky" as="SkyElement" />
|
|
|
|
<import src="../framework/xmlhttprequest.sky" as="XMLHttpRequest" />
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<style>
|
|
|
|
heading {
|
|
|
|
font-size: 16px;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<heading>File browser for {{ url }}</heading>
|
2014-11-04 23:21:57 +00:00
|
|
|
<template repeat="{{ directories }}">
|
|
|
|
<a href="{{}}">{{}}</a>
|
2014-11-03 20:53:38 +00:00
|
|
|
</template>
|
2014-11-04 23:21:57 +00:00
|
|
|
<template repeat="{{ files }}">
|
|
|
|
<a href="{{}}">{{}}</a>
|
2014-11-03 20:53:38 +00:00
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
SkyElement({
|
|
|
|
name: 'file-browser',
|
|
|
|
url: '',
|
|
|
|
files: [],
|
|
|
|
directories: [],
|
|
|
|
attached: function() {
|
|
|
|
this.url = this.ownerDocument.URL;
|
2014-11-04 03:05:48 +00:00
|
|
|
var xhr = new XMLHttpRequest();
|
2014-11-03 20:53:38 +00:00
|
|
|
xhr.open('GET', this.url + '?format=json');
|
|
|
|
xhr.onload = (function() {
|
|
|
|
var listing = JSON.parse(xhr.responseText);
|
|
|
|
this.files = listing.files;
|
|
|
|
this.directories = listing.directories;
|
|
|
|
}).bind(this);
|
|
|
|
xhr.send();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|