arkiwi_boilerplate/app/scripts/upload.js
2015-09-13 00:41:33 +02:00

61 lines
1.9 KiB
JavaScript

/*------------------------------------------------------------------------------------------------------------------------
@package: arkiwiJsBoilerplate
@author: cek
@www: arkiwi.oeg
@copyright: COPYRIGHT 18 cek
@license: MIT
=============================================================================
Filename: upload.js
=============================================================================
This file is the main entry point for js on the arkiwiJsBoilerplate app.
--------------------------------------------------------------------------------------------------------------------- */
/* MODIFICARE CON GLI URL DESIDERATI */
var ASSETSTORE = 'http://upload.arkiwi.org/arav_up_api';
var AGGREGATOR = 'http://www.arkiwi.org';
/*************************************/
var arkiwi = {};
var currentFileName = '';
$(document).ready(function () {
arkiwi = new ARKIWI.Arkiwi(AGGREGATOR, ASSETSTORE);
//prepara le cose per il finto input file
$('#displayedbrowsebutton').click(function () {
$('input[id=hiddenfileinput]').click();
});
$('input[id=hiddenfileinput]').change(function() {
$('#displayedfileinput').val($(this).val());
//this.files[0].size gets the size of your file.
$('#fileuploadtotal').text(this.files[0].size + ' bytes.');
currentFileName = this.files[0].name;
});
$('#uploadbutton').click(function() {
upload();
});
var callbacks = {
success: function(id) {
//$('#status').html('Session id ' + id);
console.log('DEBUG: Session id ' + id);
},
unauthorized: function() {
arkiwi.create(callbacks);
},
};
arkiwi.create(callbacks);
});
function upload() {
if ($('input[id=hiddenfileinput]').val() == '') {
alert('Select a file to upload.\n (KIKI non vuoi sostituirmi con qualcosa di meglio di un alert?)');
return false;
}
};