File manager - Edit - /home/autoph/public_html/projects/tickets-autohub/public/js/authentication/forms/create.js
Back
(function(){ "use strict"; var fileInput; var addCategory; var catId; function clearFileInput(){ $('._clearFile').on('click', function(e){ e.preventDefault(); var fileNameDisplay = $('#fileName'); if($('input[name="_attachmentTicket"]').prop('files').length > 0){ $('input[name="_attachmentTicket"]').val(null); fileNameDisplay.text('No file selected'); $('#fileIcon').html(''); } else { toastRWithTime("no attachment to clear","error"); } }); } function showLoading() { Swal.fire({ title: 'Loading', text: 'Please wait...', allowOutsideClick: false, showConfirmButton: false, didOpen: () => { Swal.showLoading(); } }); } function submit(){ $('._downloadableForm').on('submit', function(e){ e.preventDefault(); var formData = new FormData(); catId = $('[name="_Subcategory"]').val() || 246; if($('input[name="_attachmentTicket"]').prop('files').length > 0){ fileInput = $('input[name="_attachmentTicket"]').prop('files')[0]; formData.append("attachment",fileInput,fileInput.name); } formData.append("_filename",$('[name="_filename"]').val()); formData.append("_desc",$('[name="_filename"]').val()); showLoading(); $.ajax({ type: "POST", url: "/dl-forms/store", dataType: 'json', data: formData, processData: false, contentType: false, headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, success: function(result){ if(result.status == 201) { swal.close(); swal.fire({ icon: result.message, title: 'Success', text: result.message, allowOutsideClick: false, showConfirmButton: true, }); $('._downloadableForm')[0].reset(); $('#create_form_modal').modal('hide'); window.location.href = "/dl-forms"; } }, error: function(error){ swal.close(); console.log(error); toastRWithTime(error.responseJSON.message,"error"); } }); }); } $(function(){ clearFileInput(); submit(); }); $('#_attachmentTicket').change(function() { var fileName = $(this).val().split('\\').pop(); var fileExtension = fileName.split('.').pop().toLowerCase(); var fileIcon = ''; // Determine the icon based on file extension switch (fileExtension) { case 'pdf': fileIcon = '<i class="fa fa-file-pdf-o" style="color: red;"></i>'; break; case 'xlsx': case 'xls': fileIcon = '<i class="fa fa-file-excel-o" style="color: green;"></i>'; break; case 'jpg': case 'jpeg': case 'png': fileIcon = '<i class="fa fa-file-image-o" style="color: blue;"></i>'; break; default: fileIcon = '<i class="fa fa-file-o" style="color: gray;"></i>'; break; } // Update the icon and file name display $('#fileIcon').html(fileIcon); $('#fileName').text(fileName ? fileName : "No file selected"); }); })();
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings