jQuery(document).ready(function(){function e(e){for(var r=void 0!=e&&0!=e?e:5,a="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=0;r>n;n++)a+=t.charAt(Math.floor(Math.random()*t.length));return a}function r(e){for(var r,t=e.target.files||e.dataTransfer.files,n=0;r=t[n];n++)a(r,e.target)}function a(r,a){var t=jQuery(a),n=jQuery(a).parents(".arm_import_user_form"),i=(t.attr("class"),t.attr("data-file_size"),new XMLHttpRequest),o=(r.type,r.name.lastIndexOf(".")),s=r.name.substring(o+1);s=s.toLowerCase();var u=t.attr("data-msg-invalid"),l=jQuery('input[name="_wpnonce"]').val();void 0==u&&(u="Sorry, this file type is not permitted for security reasons.");var d=["csv","xls","xlsx","xml"];if(-1===jQuery.inArray(s,d))return alert(u),t.val(""),!1;if(i.upload){jQuery("#arm_user_import_btn").attr("disabled","disabled"),jQuery(".arm_loader_img_import_user").show();var m=e(6),p=r.name.lastIndexOf("."),_=r.name.substring(p+1),f=/.*(?=\.)/.exec(r.name),c="armImportUser"+m+"_"+f,y=c.replace(/[^\w\s]/gi,"").replace(/ /g,"")+"."+_;i.open("POST",__ARMAJAXURL,!0),i.setRequestHeader("X_FILENAME",y),i.setRequestHeader("X-FILENAME",y);var v=new FormData;v.append("armfileselect",r),v.append("action","arm_import_user"),v.append("_wpnonce",l),i.send(v),i.onreadystatechange=function(){if(4==i.readyState&&200==i.status){var e=i.responseText;n.find("input.arm_file_url").val(e)}else 200!=i.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").on("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()}})})});