Add handlers for file and url inputs

This commit is contained in:
Ray Schamp 2015-05-06 10:18:15 -04:00
parent 34d59aab3e
commit ece03eb8c5
2 changed files with 23 additions and 2 deletions

View file

@ -41,7 +41,7 @@
<p><a href="">What is a .sbx file?</a></p>
</section>
<section>
<button>Browse for local file</button>
<button data-action="load-file">Browse for local file</button>
</section>
</dialog>
@ -52,7 +52,7 @@
<p><a href="">What is a ScratchX URL?</a></p>
</section>
<section>
<div class="input-plus-button">
<div class="input-plus-button" data-action="load-url">
<input type="text" placeholder="paste url..." />
<button>Open</button>
</div>

View file

@ -104,6 +104,27 @@ swfobject.switchOffAutoHideShow();
swfobject.embedSWF('Scratch.swf', 'editor', '100%', '100%', '11.7.0', 'libs/expressInstall.swf',
flashVars, params, null, handleEmbedStatus);
/* File uploads */
function sendFileToFlash() {
var file = this.files[0];
console.log("Got file for Flash", file);
}
$("[data-action='load-file']").click(function(e) {
$('<input type="file" />').on('change', sendFileToFlash).click();
});
function sendURLtoFlash(url) {
console.log("Got URL for Flash", url)
}
$("[data-action='load-url'] button").click(function(e) {
sendURLtoFlash($(e.target).siblings('input[type="text"]').val());
});
/* Page switching */
$("[data-staticlink]").click(function(e) {