added uploading, still not working...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-02-11 02:46:14 +04:00
parent 5edcebce62
commit f2b5d069c0

View File

@ -761,6 +761,7 @@ $(document).ready(function(){
</p>
<p>
<a id="downloader" download="magazine.json">download magazine...</a>
<input type="file" id="upload" name="files[]"/>
</p>
<hr noshade color="silver">
@ -1002,7 +1003,7 @@ $(document).ready(function(){
loadSettings()
// setup the link...
// setup download link...
$('#downloader')
.attr('href','data:text/octet-stream;base64,'+btoa(
JSON.stringify(buildJSON(true, true))
@ -1010,6 +1011,33 @@ $(document).ready(function(){
// entities with actual chars...
.replace(//g, '&ndash;')))
// upload...
function handleFileSelect(evt) {
var files = evt.target.files; // FileList object
// Loop through the FileList and render image files as thumbnails.
for (var i = 0, f; f = files[i]; i++) {
var reader = new FileReader();
// Closure to capture the file information.
reader.onload = (function(theFile) {
return function(e) {
console.log('loading...')
console.log($.parseJSON(e.target.result))
loadJSON($.parseJSON(e.target.result), true)
console.log('done.')
};
})(f);
// Read in the image file as a data URL.
reader.readAsText(f);
}
}
$('#upload').on('change', handleFileSelect);
</script>
</div>
</div>