mirror of
https://github.com/flutter/flutter
synced 2024-10-13 11:42:54 +00:00
cfd21dfd13
We could do something much more sophisticated for deploy in the future. Also add #!mojo:sky_viewer to .sky file demos R=abarth@chromium.org Review URL: https://codereview.chromium.org/885653006
46 lines
1.2 KiB
Plaintext
46 lines
1.2 KiB
Plaintext
#!mojo mojo:sky_viewer
|
|
<!--
|
|
// 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" />
|
|
|
|
<sky-element name="file-browser">
|
|
<template>
|
|
<style>
|
|
heading {
|
|
font-size: 16px;
|
|
}
|
|
</style>
|
|
<heading>File browser for {{ url }}</heading>
|
|
<template repeat="{{ directories }}">
|
|
<a href="{{}}">{{}}</a>
|
|
</template>
|
|
<template repeat="{{ files }}">
|
|
<a href="{{}}">{{}}</a>
|
|
</template>
|
|
</template>
|
|
<script>
|
|
module.exports = class extends SkyElement {
|
|
created() {
|
|
this.url = '';
|
|
this.files = [];
|
|
this.directories = [];
|
|
}
|
|
attached() {
|
|
this.url = this.ownerDocument.URL;
|
|
var xhr = new XMLHttpRequest();
|
|
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();
|
|
}
|
|
}.register();
|
|
</script>
|
|
</sky-element>
|