Skip to content

Commit

Permalink
refactor: load JS code from <script> html tags
Browse files Browse the repository at this point in the history
  • Loading branch information
azmeuk committed Feb 21, 2024
1 parent f297817 commit d0dabf7
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -381,62 +381,58 @@ function createNCFilePicker() {

let ncfilepicker = null;

if (!nc_locator || !nc_login || !nc_token) {
printout_message({ type: 'error', title: 'Nextcloud connexion', data: "La connexion avec votre Nextcloud n'est pas fonctionnelle, les options associées sont désactivées"});
}

document.addEventListener('DOMContentLoaded', () => {

Dropzone.autoDiscover = false;
var dropzone_conf = {
paramName: 'dropzoneFiles',
//autoProcessQueue: false,
//uploadMultiple: true,
//chunking: false,
//forceChunking: false,
chunking: true,
forceChunking: true,
maxFilesize: 20, // megabytes
acceptedFiles: accepted_files,
dictRemoveFile: 'Supprimer',
dictDefaultMessage: 'Cliquer ou glisser-déposer les fichiers à ajouter',
addRemoveLinks: true,
parallelUploads: 10,
chunkSize: 1000000, // bytes
init: function() {
this.on("removedfile", file => {
console.log('removed file from dropzone');
});
this.on('success', file => {
setTimeout(() => {link_file_to_meeting(file.name, 'dropzone')}, this.getUploadingFiles().length * 1000);
setTimeout(() => {this.removeFile(file)}, 1000);
});
this.on('error', (file, message) => {
close_dialog('dropzone');
printout_message({ type: 'error', title: 'Le téléversement du fichier « '+file.name+' » a échoué.', data: message});
this.removeFile(file);
});
if (!nc_locator || !nc_login || !nc_token) {
printout_message({ type: 'error', title: 'Nextcloud connexion', data: "La connexion avec votre Nextcloud n'est pas fonctionnelle, les options associées sont désactivées"});
}
}
var dropper = new Dropzone("form#dropper", dropzone_conf);

Dropzone.autoDiscover = false;
var dropzone_conf = {
paramName: 'dropzoneFiles',
//autoProcessQueue: false,
//uploadMultiple: true,
//chunking: false,
//forceChunking: false,
chunking: true,
forceChunking: true,
maxFilesize: 20, // megabytes
acceptedFiles: accepted_files,
dictRemoveFile: 'Supprimer',
dictDefaultMessage: 'Cliquer ou glisser-déposer les fichiers à ajouter',
addRemoveLinks: true,
parallelUploads: 10,
chunkSize: 1000000, // bytes
init: function() {
this.on("removedfile", file => {
console.log('removed file from dropzone');
});
this.on('success', file => {
setTimeout(() => {link_file_to_meeting(file.name, 'dropzone')}, this.getUploadingFiles().length * 1000);
setTimeout(() => {this.removeFile(file)}, 1000);
});
this.on('error', (file, message) => {
close_dialog('dropzone');
printout_message({ type: 'error', title: 'Le téléversement du fichier « '+file.name+' » a échoué.', data: message});
this.removeFile(file);
});
}
}
var dropper = new Dropzone("form#dropper", dropzone_conf);

document.addEventListener('DOMContentLoaded', (event) => {
import('/static/js/filePickerWrapper.js').then(() => {
createNCFilePicker()
});
})

var form_files = document.getElementById('meeting-form');
var form_files = document.getElementById('meeting-form');

form_files.addEventListener('submit', (e) => {
form_files.addEventListener('submit', (e) => {
e.preventDefault();

e.preventDefault();
var formData = new FormData(form_files);

var formData = new FormData(form_files);
var name = `${formData.get('url')}`;
var from = `depuis URL`;

var name = `${formData.get('url')}`;
var from = `depuis URL`;
add_URL_file(name, from);

add_URL_file(name, from);
});

});
createNCFilePicker()
})
3 changes: 2 additions & 1 deletion web/b3desk/templates/meeting/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
const add_meeting_files_url = "{{ url_for("meeting_files.add_meeting_files", meeting=meeting) }}";
const delete_meeting_file_url = "{{ url_for("meeting_files.delete_meeting_file") }}";
const accepted_files = "{{ config.ACCEPTED_FILES_CLIENT_SIDE }}";
{% include 'meeting/meeting.js' %}
</script>
<script src="{{ url_for("static", filename="js/filePickerWrapper.js") }}"></script>
<script src="{{ url_for("static", filename="js/meeting.js") }}"></script>
{% endblock %}
3 changes: 2 additions & 1 deletion web/b3desk/templates/meeting/filesform.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
const add_meeting_files_url = "{{ url_for("meeting_files.add_meeting_files", meeting=meeting) }}";
const delete_meeting_file_url = "{{ url_for("meeting_files.delete_meeting_file") }}";
const accepted_files = "{{ config.ACCEPTED_FILES_CLIENT_SIDE }}";
{% include 'meeting/meeting.js' %}
</script>
<script src="{{ url_for("static", filename="js/filePickerWrapper.js") }}"></script>
<script src="{{ url_for("static", filename="js/meeting.js") }}"></script>
{% endblock %}
3 changes: 2 additions & 1 deletion web/b3desk/templates/meeting/recordings.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ <h3>
const add_meeting_files_url = "{{ url_for("meeting_files.add_meeting_files", meeting=meeting) }}";
const delete_meeting_file_url = "{{ url_for("meeting_files.delete_meeting_file") }}";
const accepted_files = "{{ config.ACCEPTED_FILES_CLIENT_SIDE }}";
{% include 'meeting/meeting.js' %}
</script>
<script src="{{ url_for("static", filename="js/filePickerWrapper.js") }}"></script>
<script src="{{ url_for("static", filename="js/meeting.js") }}"></script>
{% endblock %}
3 changes: 2 additions & 1 deletion web/b3desk/templates/meeting/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
const add_meeting_files_url = "{{ url_for("meeting_files.add_meeting_files", meeting=meeting) }}";
const delete_meeting_file_url = "{{ url_for("meeting_files.delete_meeting_file") }}";
const accepted_files = "{{ config.ACCEPTED_FILES_CLIENT_SIDE }}";
{% include 'meeting/meeting.js' %}
</script>
<script src="{{ url_for("static", filename="js/filePickerWrapper.js") }}"></script>
<script src="{{ url_for("static", filename="js/meeting.js") }}"></script>
{% endblock %}

0 comments on commit d0dabf7

Please sign in to comment.