/*
* Jirafeau, your web file repository
* Copyright (C) 2015 Jerome Jutteau <j.jutteau@gmail.com>
+ * Copyright (C) 2015 Nicola Spanti (RyDroid) <dev@nicola-spanti.info>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
function show_link (url, reference, delete_code, crypt_key, date)
function upload_progress (e)
{
- if (!e.lengthComputable)
+ if (e == undefined || e == null || !e.lengthComputable)
return;
// Init time estimation if needed
document.getElementById('send').style.display = '';
}
+function add_time_string_to_date(d, time)
+{
+ if(typeof(d) != 'object' || !(d instanceof Date))
+ {
+ return false;
+ }
+
+ if (time == 'minute')
+ {
+ d.setSeconds (d.getSeconds() + 60);
+ return true;
+ }
+ if (time == 'hour')
+ {
+ d.setSeconds (d.getSeconds() + 3600);
+ return true;
+ }
+ if (time == 'day')
+ {
+ d.setSeconds (d.getSeconds() + 86400);
+ return true;
+ }
+ if (time == 'week')
+ {
+ d.setSeconds (d.getSeconds() + 604800);
+ return true;
+ }
+ if (time == 'month')
+ {
+ d.setSeconds (d.getSeconds() + 2419200);
+ return true;
+ }
+ if (time == 'year')
+ {
+ d.setSeconds (d.getSeconds() + 29030400);
+ return true;
+ }
+ return false;
+}
+
function classic_upload (url, file, time, password, one_time, upload_password)
{
// Delay time estimation init as we can't have file size
if (time != 'none')
{
var d = new Date();
- if (time == 'minute')
- d.setSeconds (d.getSeconds() + 60);
- else if (time == 'hour')
- d.setSeconds (d.getSeconds() + 3600);
- else if (time == 'day')
- d.setSeconds (d.getSeconds() + 86400);
- else if (time == 'week')
- d.setSeconds (d.getSeconds() + 604800);
- else if (time == 'month')
- d.setSeconds (d.getSeconds() + 2419200);
- else if (time == 'year')
- d.setSeconds (d.getSeconds() + 29030400);
- else
+ if(!add_time_string_to_date(d, time))
return;
show_link (url, res[0], res[1], res[2], d.toString());
}
function check_html5_file_api ()
{
- if (window.File && window.FileReader && window.FileList && window.Blob)
- return true;
- return false;
+ return window.File && window.FileReader && window.FileList && window.Blob;
}
var async_global_transfered = 0;
function async_upload_progress (e)
{
- if (!e.lengthComputable && async_global_file.size != 0)
+ if (e == undefined || e == null || !e.lengthComputable && async_global_file.size != 0)
return;
// Compute percentage
if (async_global_time != 'none')
{
var d = new Date();
- if (async_global_time == 'minute')
- d.setSeconds (d.getSeconds() + 60);
- else if (async_global_time == 'hour')
- d.setSeconds (d.getSeconds() + 3600);
- else if (async_global_time == 'day')
- d.setSeconds (d.getSeconds() + 86400);
- else if (async_global_time == 'week')
- d.setSeconds (d.getSeconds() + 604800);
- else if (async_global_time == 'month')
- d.setSeconds (d.getSeconds() + 2419200);
- else if (async_global_time == 'year')
- d.setSeconds (d.getSeconds() + 29030400);
- else
+ if(!add_time_string_to_date(d, async_global_time))
return;
show_link (async_global_url, res[0], res[1], res[2], d.toString());
}
}
if (res == 0)
return '';
- else
- return res.toString() + ' ' + scale;
+ return res.toString() + ' ' + scale;
}
function milliseconds_to_time_string (milliseconds)