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

Unified Diff: sky/examples/file-browser.sky

Issue 688413005: Convert the directory listing to run on top of the platform (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sky/framework/xmlhttprequest.sky » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/examples/file-browser.sky
diff --git a/sky/examples/file-browser.sky b/sky/examples/file-browser.sky
new file mode 100644
index 0000000000000000000000000000000000000000..6d02f84839cf6ae7de2171625a7ade9a99729370
--- /dev/null
+++ b/sky/examples/file-browser.sky
@@ -0,0 +1,41 @@
+<!--
+// 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>
+ <template repeat="{{ directory in directories }}">
rafaelw 2014/11/03 20:06:04 if you want this to work now, you can just do <te
+ <a href="{{ directory }}">{{ directory }}</a>
+ </template>
+ <template repeat="{{ file in files }}">
+ <a href="{{ file }}">{{ file }}</a>
+ </template>
+</template>
+<script>
+SkyElement({
+ name: 'file-browser',
+ url: '',
+ files: [],
+ directories: [],
+ attached: function() {
+ this.url = this.ownerDocument.URL;
+ var xhr = this.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();
+ }
+});
+</script>
« no previous file with comments | « no previous file | sky/framework/xmlhttprequest.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698