X-Git-Url: https://git.p6c8.net/jirafeau_mojo42.git/blobdiff_plain/6667b979aa92be3489dae7c9e6fa5da9cae39116..9112b0a083786d019161ec8296c2910527ae1570:/lib/functions_v7.js?ds=inline diff --git a/lib/functions_v7.js b/lib/functions_v7.js index 023c8e2..0e17b50 100644 --- a/lib/functions_v7.js +++ b/lib/functions_v7.js @@ -1,6 +1,7 @@ /* * Jirafeau, your web file repository * Copyright (C) 2015 Jerome Jutteau + * Copyright (C) 2015 Nicola Spanti (RyDroid) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -13,7 +14,7 @@ * 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 . + * along with this program. If not, see . */ function show_link (url, reference, delete_code, crypt_key, date) @@ -125,7 +126,7 @@ function hide_upload_progression () function upload_progress (e) { - if (!e.lengthComputable) + if (e == undefined || e == null || !e.lengthComputable) return; // Init time estimation if needed @@ -161,6 +162,9 @@ function control_selected_file_size(max_size, error_str) document.getElementById('options').style.display = ''; document.getElementById('send').style.display = ''; document.getElementById('error_pop').style.display = 'none'; + document.getElementById('file_select').style.left = 'inherit'; + document.getElementById('file_select').style.height = 'inherit'; + document.getElementById('file_select').style.opacity = '1'; } } @@ -178,6 +182,46 @@ function pop_failure (e) 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 @@ -201,19 +245,7 @@ function classic_upload (url, file, time, password, one_time, upload_password) 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()); } @@ -239,9 +271,7 @@ function classic_upload (url, file, time, password, one_time, upload_password) 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; @@ -301,7 +331,7 @@ function async_upload_start (url, max_size, file, time, password, one_time, uplo 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 @@ -384,19 +414,7 @@ function async_upload_end (code) 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()); } @@ -491,8 +509,7 @@ function upload_time_estimation_speed_string() } if (res == 0) return ''; - else - return res.toString() + ' ' + scale; + return res.toString() + ' ' + scale; } function milliseconds_to_time_string (milliseconds)