$(document).ready(function(){ var $form_group_prefix = '_form_group_for_'; var $field_prefix = 'form_field_'; var $error_class = 'has-error animated rubberBand'; var s = ''; var p = 'C-10-380CSM'; var id = '1765734586'; var fileName = ''; var filesList = []; window.mivauploadformHtml = ``; $('body').append(mivauploadformHtml); setTimeout(function(){ $('#mivauploadmodal-1765734586').modal({ show:false, keyboard:true, backdrop:'static', }); },10); $('#mivafileupload').closest('.product_attribute_container').html(``); $('body').on('click','#openUploadModal-1765734586',function(e){ e.preventDefault(); var email = ''; var el = null; $('#__product_attr_col input, #__product_attr_col select').each(function(){ if($(this).hasClass('email-field')){ email = $(this).val(); el = $(this); } }); if(email!=""){ $('#email-1765734586').val(); } $('#mivauploadmodal-1765734586').modal('show'); }); $('body').on('click','#submitdyn-1765734586',function(){ var email = $('#email-1765734586').val().trim(); if(email == ''){ showError("please enter your email address"); return; } if(!validate_email(email)){ showError("please enter a valid email address"); return; } $('#__product_attr_col input, #__product_attr_col select').each(function(){ if($(this).hasClass('email-field')){ $(this).val(email); } }); if($('#filetoupload-1765734586').val()==''){ showError("please add your file for upload"); return; } fileName = $('#filetoupload-1765734586').val(); sendData(); }); function validate_email(email) { if(email==''){return false;} var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(email); } function field_error($this,$message=''){ if($message!=''){ alert($message); } var $id = $this.attr('id'); var $p = $this.closest('.form-group'); $('#'+$form_group_prefix+$id).addClass($error_class); $this.focus(); $this.select(); if($p){ $('html, body').animate({ scrollTop: $p.offset().top-40 }, 200); } return false; } function sendData(){ var formData = new FormData($('#mivafileuploadform-1765734586')[0]); var loc = `https://www.all-stickers.com/stickercom/miva-upload-2/index.php?_s=${s}&product=${p}`; if(window.location.hostname == 'localhost'){ loc = `http://localhost/stickercom/miva-upload-2/index.php?_s=${s}&product=${p}`; } $('#message-1765734586').html(`

Uploading Please wait

`); $('#container-1765734586').hide(); $.ajax({ url: loc, type: 'POST', async: true, data: formData, cache: false, contentType: false, processData: false, timeout: 60000, error: function (data) { // console.error(data); // endProgress(); // closeModal(); // progressTimer = 0; // waitingForResponse = false; // alert("A server error has occurred"); console.error(data); }, complete: function (data) { // setTimeout(function(){ // if(waitingForResponse){ // waitingForResponse = false; // endProgress(); // closeModal(); // progressTimer = 0; // } // },100); console.log("COMPLETE", data); $('#container-1765734586').show(); }, success: function (data){ // waitingForResponse = false; $('#container-1765734586').show(); console.log(data); if(typeof data == 'string'){ data = JSON.parse(data); } console.log(data); if(!data.status){ showError(data.message); } else { $("#message-1765734586").html(`
Your File was uploaded Successfully, you can upload more files if needed just select a new file below. To complete your order close this window and continue filling out your information. We will send you an artwork proof for your approval before processing your payment.
`); $('#filetoupload-1765734586').val(''); $('#submitdyn-1765734586').html("Upload another file"); var t = fileName.split("\\"); filesList.push(t[t.length-1]); fileName = ''; $("#filelist-1765734586").html(`

Files uploaded

`); } // formSuccess(data); }, }); } function showError(message){ $("#message-1765734586").html(`
${message}
`); } });