(function(e,t){"use strict";function i(){r.add_btn=t(n.getElementById("addip"));r.new_ip=n.getElementById("newip");r.ip_list_wrap=n.getElementById("ip_list");r.empty_ip=t(n.getElementById("ip_list_empty"));r.restrict_radio=n.getElementById("blog-restricted");r.table=t(n.getElementById("rsa-send-to-login")).closest("table");r.redirect_choice=n.getElementById("rsa-redirect-visitor");r.message_choice=n.getElementById("rsa-display-message");r.page_choice=n.getElementById("rsa-unblocked-page");r.redirect_fields=t(n.querySelectorAll(".rsa_redirect_field")).closest("tr");r.message_field=t(n.getElementById("rsa_message")).closest("tr");r.page_field=t(n.getElementById("rsa_page")).closest("tr");if(!n.getElementById("blog-restricted").checked){r.table.hide()}if(!n.getElementById("rsa-redirect-visitor").checked){r.redirect_fields.hide()}if(!n.getElementById("rsa-display-message").checked){r.message_field.hide()}if(!n.getElementById("rsa-unblocked-page").checked){r.page_field.hide()}t(n.querySelectorAll("#rsa_handle_fields input")).on("change",function(){if(r.redirect_choice.checked){r.redirect_fields.show()}else{r.redirect_fields.hide()}if(r.message_choice.checked){r.message_field.show()}else{r.message_field.hide()}if(r.page_choice.checked){r.page_field.show()}else{r.page_field.hide()}});t(n.querySelectorAll(".option-site-visibility input")).on("change",function(){if(r.restrict_radio.checked){r.table.show()}else{r.table.hide()}});r.add_btn.on("click",function(){s(r.new_ip.value)});var e=n.getElementById("rsa_myip");if(null!==e){t(e).on("click",function(){s(t(this).data("myip"))})}t(r.ip_list_wrap).on("click",".remove_btn",function(){t(this.parentNode).slideUp(250,function(){t(this).remove()})})}function s(e){if(t.trim(e)==""){return false}var i=600;r.add_btn.attr("disabled","disabled");var s=t(n.querySelectorAll("#ip_list input"));for(var o=0,u=s.length;o<s.length;o++){if(s[o].value==e){t(s[o]).parent().effect("shake",i);r.add_btn.removeAttr("disabled");return false}}jQuery.post(ajaxurl,{action:"rsa_ip_check",ip_address:e},function(n){if(n){t(r.new_ip.parentNode).effect("shake",i);r.add_btn.removeAttr("disabled");return false}else{var s=r.empty_ip.clone().appendTo(r.ip_list_wrap);s.children("input").val(e);s.removeAttr("id").slideDown(250);if(e==r.new_ip.value){t(r.new_ip).val("")}r.add_btn.removeAttr("disabled");return true}})}var n=e.document;var r={add_btn:"",new_ip:"",ip_list_wrap:"",empty_ip:"",restrict_radio:"",table:"",redirect_choice:"",message_choice:"",page_choice:"",redirect_fields:"",message_field:"",page_field:""};i()})(window,jQuery)