1/* 2* On all our proposition and modification form we authorize the upload of three PDF 3* Just one <input type="file"> is present. 4* When a valid PDF is set in the first input we display the next and so one until 3 5* */ 6 7 8ready = (callback) => { 9 if (document.readyState !== 'loading') { 10 callback() 11 } else { 12 document.addEventListener('DOMContentLoaded', callback) 13 } 14} 15 16ready(() => { 17 document.querySelectorAll('.js-file-pdf').forEach(input => { 18 input.addEventListener('input', function () { 19 const allowedExtensions = ['pdf']; 20 const file = this.files[0]; 21 22 const label = this.closest('.files').querySelector('.acf-label'); 23 24 const errorDiv = label.nextElementSibling; 25 if (errorDiv && errorDiv.classList.contains('js-error_message_pdf_file')) { 26 errorDiv.remove() 27 input.classList.remove('error') 28 } 29 30 if (file) { 31 const fileExtension = file.name.split('.').pop().toLowerCase(); 32 33 if (!allowedExtensions.includes(fileExtension)) { 34 input.classList.add('error') 35 36 // Créer une nouvelle div d'erreur 37 let newErrorDiv = document.createElement('div'); 38 newErrorDiv.className = 'acf-notice -error acf-error-message js-error_message_pdf_file'; 39 40 // Ajouter un <p> à l'intérieur de la div d'erreur 41 let errorText = document.createElement('p');
42 errorText.innerText = "L'extension autorisée n'est pas respectée, veuillez sélectionner un autre fichier."; 43 newErrorDiv.appendChild(errorText); 44 45 label.after(newErrorDiv) 46 47 this.value = '' 48 } 49 } 50 }) 51 }) 52 53 let $filesContainer = document.querySelectorAll('.acf-field.files') 54 55 for (let i = 0; i < 2; i++) { 56 !!$filesContainer[i] && ( 57 $filesContainer[i].addEventListener('input', function () { 58 59 let $input = $filesContainer[i].querySelector('input') 60 if (!$input.classList.contains('error')) { 61 $filesContainer[i].nextElementSibling.classList.remove('hide') 62 } 63 }) 64 ) 65 } 66})
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.