-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3ca11f
commit 2c1789f
Showing
6 changed files
with
1,257 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
$(function () { | ||
var $dropZone = $("html"); | ||
var $filePicker = $("#filePicker"); | ||
function handleFiles(files) { | ||
// only use the first file. | ||
file = files[0]; | ||
console.log(file) | ||
var reader = new FileReader(); | ||
|
||
reader.onload = (function(filename) { // finished reading file data. | ||
return function(e2) { | ||
$("#displayArea").empty(); | ||
var fsHeight = $("#fileSelect").outerHeight(); | ||
showGame(textToGame(e2.target.result, filename), $("#displayArea"), null, -fsHeight, true, false, true); | ||
}; | ||
})(file.name); | ||
reader.readAsText(file); // start reading the file data. | ||
} | ||
|
||
$dropZone.on('dragover', function(e) { | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
}); | ||
$dropZone.on('drop', function(e) { | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
var files = e.originalEvent.dataTransfer.files; // Array of all files | ||
handleFiles(files) | ||
}); | ||
$filePicker.on('change', function(e) { | ||
var files = e.target.files | ||
handleFiles(files) | ||
}); | ||
}) |
Oops, something went wrong.