X-Git-Url: https://git.p6c8.net/jirafeau/jirafeau.git/blobdiff_plain/08b9270797ef139d44343187cfa545a145021d83..0c273fa9debe16278ffd6e06875435c6a3e882cb:/lib/functions.js.php diff --git a/lib/functions.js.php b/lib/functions.js.php index b178f4f..efa82e5 100644 --- a/lib/functions.js.php +++ b/lib/functions.js.php @@ -346,6 +346,7 @@ function control_selected_file_size(max_size, error_str) // display options document.getElementById('options').style.display = 'block'; document.getElementById('send').style.display = 'block'; + document.getElementById('send').disabled = false; document.getElementById('error_pop').style.display = 'none'; document.getElementById('send').focus(); } @@ -355,12 +356,19 @@ function control_selected_file_size(max_size, error_str) // just warns the user before they submit a doomed upload. function control_selected_file_extension(disallowed_extensions, error_str) { - f_name = document.getElementById('file_select').files[0].name; + f_name = document.getElementById('file_select').files[0].name.replace(/[\s.]+$/, ''); f_ext = f_name.includes('.') ? f_name.split('.').pop().toLowerCase() : ''; if (disallowed_extensions.includes(f_ext)) { - pop_failure(error_str); - document.getElementById('send').style.display = 'none'; + // control_selected_file_size runs first: keep its error, if any, and add ours + var error_pop = document.getElementById('error_pop'); + if (error_pop.style.display === 'none') + pop_failure(error_str); + else + error_pop.innerHTML += '
' + error_str; + // keep the button visible but disabled so the user sees it is forbidden + document.getElementById('send').style.display = 'block'; + document.getElementById('send').disabled = true; } }