Skip to content

Commit

Permalink
Merge pull request #521 from moevm/520_fix_button_upld
Browse files Browse the repository at this point in the history
fix button upload
  • Loading branch information
HadronCollider authored Mar 29, 2024
2 parents cfdcc7f + d4b0a11 commit 7262350
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/templates/upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<script>
const file_upload_limit = {{ config.MAX_CONTENT_LENGTH | tojson }};
const file_type = "{{file_type}}";
const two_files_info = {{ current_user.two_files | tojson }};
</script>
<div class="col-11 col-sm-8 col-md-5 col-lg-4 my-auto">
<h3 class="text-center ins" id="upload_title">{{ upload_title }}</h3>
Expand Down
25 changes: 18 additions & 7 deletions assets/scripts/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,30 @@ const resetFileUpload = () => {
};

const changeUploadButton = () => {
if (pdf_uploaded || file_uploaded) {
const pdf_size = pdf_file_input.prop("files")[0]?.size || 0;
if (two_files_info) {
if (pdf_uploaded || file_uploaded) {
const pdf_size = pdf_file_input.prop("files")[0]?.size || 0;
const file_size = file_input.prop("files")[0]?.size || 0;
if (pdf_size + file_size <= file_upload_limit) {
if (file_uploaded)
upload_button.prop("disabled", false);
} else {
showSizeExceedMessage();
resetFileUpload();
upload_button.prop("disabled", true);
}
} else {
upload_button.prop("disabled", true);
}
} else {
const file_size = file_input.prop("files")[0]?.size || 0;
if (pdf_size + file_size <= file_upload_limit) {
if (file_uploaded)
upload_button.prop("disabled", false);
if (file_size <= file_upload_limit) {
upload_button.prop("disabled", false);
} else {
showSizeExceedMessage();
resetFileUpload();
upload_button.prop("disabled", true);
}
} else {
upload_button.prop("disabled", true);
}
};

Expand Down

0 comments on commit 7262350

Please sign in to comment.