jQuery(document).ready(function(){function e(e){for(var r=void 0!=e&&0!=e?e:5,a="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=0;r>i;i++)a+=t.charAt(Math.floor(Math.random()*t.length));return a}function r(e){for(var r,t=e.target.files||e.dataTransfer.files,i=0;r=t[i];i++)a(r,e.target)}function a(r,a){var t=jQuery(a),i=jQuery(a).parents(".arm_import_user_form"),n=(t.attr("class"),t.attr("data-file_size"),new XMLHttpRequest),s=(r.type,r.name.lastIndexOf(".")),o=r.name.substring(s+1);o=o.toLowerCase();var u=t.attr("data-msg-invalid");void 0==u&&(u="Sorry, this file type is not permitted for security reasons.");var l=["csv","xls","xlsx","xml"];if(-1===jQuery.inArray(o,l))return alert(u),t.val(""),!1;if(n.upload){jQuery("#arm_user_import_btn").attr("disabled","disabled"),jQuery(".arm_loader_img_import_user").show();var d=e(6),m=r.name.lastIndexOf("."),_=r.name.substring(m+1),f=/.*(?=\.)/.exec(r.name),p="armImportUser"+d+"_"+f,c=p.replace(/[^\w\s]/gi,"").replace(/ /g,"")+"."+_;n.open("POST",__ARMAJAXURL+"?action=arm_import_user",!0),n.setRequestHeader("X_FILENAME",c),n.setRequestHeader("X-FILENAME",c),n.send(r),n.onreadystatechange=function(){if(4==n.readyState&&200==n.status){var e=n.responseText;i.find("input.arm_file_url").val(e)}else 200!=n.status&&alert("There is an error in uploading file, Please try again");return jQuery("#arm_user_import_btn").removeAttr("disabled"),jQuery(".arm_loader_img_import_user").hide(),!1}}else alert("There is an error in uploading file, Please try again"),t.val("");return!1}window.File&&window.FileList&&window.FileReader,jQuery(".armImportUpload").each(function(e,a){a.addEventListener("change",r,!1)}),jQuery(".armRemoveImport").click(function(){var e=(jQuery(this).parents(".arm_import_user_form"),jQuery(this).attr("data-import"));""!=e&&jQuery.ajax({type:"POST",url:__ARMAJAXURL,data:"action=arm_remove_uploaded_file&file_name="+e+"&type=import_user",success:function(){window.location.reload()}})})});