function captchaVerify(n){$.post("/Captcha/Verify",{response:n}).done(function(n){n===!0&&$('.field-validation-error[data-valmsg-for="g-recaptcha-response"]').text("")})}function oVal(){var n=$("form.o-val").data("validator"),t;n!==undefined&&n!==null&&(t=n.settings,t.onkeyup=function(n){var t=$(n),i,r;(!t.is("[data-old]")||t.data("old")!==t.val()||t.hasClass("o-changed"))&&(i=t.closest(".form-group"),r=i.find(".field-validation-error"),t.removeClass("input-validation-error"),i.removeClass("has-error"),r.removeClass("field-validation-error").addClass("field-validation-valid").text(""),t.addClass("o-changed"))},t.highlight=function(n,t,i){var r=$(n),u=r.closest(".form-group");r.addClass(t).removeClass(i);u.addClass("has-error");r.data("old",r.val())})}function checkEmailConfirmation(n){$.post(n).done(function(n){n.redirect&&(window.top.location=n.redirect)}).always(function(){setTimeout(function(){checkEmailConfirmation(n)},2e3)})}function changeSmsAuth(n){$("#SmsAuthForm #IsSmsAuthOn").val(n);$("#SmsAuthForm").submit()}function phoneCodeResendWaitTimerStart(n){window.phoneCodeResendWaitTime=+n;phoneCodeResendWaitTimerCallback();window.phoneCodeResendWaitTimeIntervalHandle=setInterval(phoneCodeResendWaitTimerCallback,1e3)}function phoneCodeResendWaitTimerCallback(){var n;if(window.phoneCodeResendWaitTime--,n=$("#send-phone-code"),window.phoneCodeResendWaitTime<1){try{clearInterval(window.phoneCodeResendWaitTimeIntervalHandle)}catch(f){}n.text(n.data("resend")).prop("disabled",!1);return}var i=window.phoneCodeResendWaitTime,t=~~(i/60),r=i%60,u=""+(t>0?t+":":"")+(t<1||r>9?"":"0")+r;n.text(n.data("wait")+" "+u).prop("disabled",!0)}$(function(){$(".lang").click(function(n){var t,i;n.preventDefault();t=$(this).data("lang");$.cookie("lang",t,{expires:365,path:"/"});i=""+window.location.pathname+window.location.search+window.location.hash;window.location="/Lang?returnUrl="+encodeURIComponent(i)})});$(function(){function o(){var t=$(this),n=$("#consumer-check-url-block");$.trim(t.val())===$.trim(n.data("old"))?n.show():n.hide()}var t,e,i,n,r,u,f;oVal();$("a.delete-alias, a.cancel-alias").click(function(n){var t,i,r,u;(n.preventDefault(),t=$(this),confirm(t.data("confirmation")))&&(i=t.closest("tr"),r=t.closest("table"),i.addClass("ajax-loading"),u=t.text(),t.text(r.data("processing")),$.post(t.attr("href")).done(function(n){n.Status&&i.remove();window.top.location.reload()}).fail(function(){alert(r.data("network-error"));window.top.location.reload()}).always(function(){t.text(u);i.removeClass("ajax-loading")}))});$("a.make-primary-alias").click(function(n){var t,r,i;(n.preventDefault(),t=$(this),confirm(t.data("confirmation")))&&(r=t.closest("tr"),i=t.closest("table"),r.addClass("ajax-loading"),t.text(i.data("processing")),$.post(t.attr("href")).done(function(){window.top.location.reload()}).fail(function(){alert(i.data("network-error"));window.top.location.reload()}))});t=$("#confirm-email-form");t.length&&(e=t.data("ajax-url"),setTimeout(function(){checkEmailConfirmation(e)},2e3));$("#NewClientSecret").click(function(n){var t,i;(n.preventDefault(),t=$(this),confirm(t.data("confirmation")))&&(i=t.text(),t.text(t.data("processing")).prop("disabled",!0),$.get(t.data("url")).done(function(n){n.Status&&n.ClientSecret?$("#ClientSecret").val(n.ClientSecret):alert(t.data("network-error"))}).fail(function(){alert(t.data("network-error"))}).always(function(){t.text(i).prop("disabled",!1)}))});$("#consumer-url-check").click(function(n){n.preventDefault();var t=$(this);t.text(t.data("processing")).prop("disabled",!0);$.post(t.prop("href")).done(function(n){n.Status===!0?window.top.location.reload():alert(t.data("network-error"))}).fail(function(){alert(t.data("network-error"));window.top.location.reload()})});i=$(".consumer-project-web-site");i.change(o);i.keyup(o);$("#consumer-set-to-localhost").click(function(n){n.preventDefault();$("#ProjectWebSite").val("http://localhost/").change()});n=$("#permissions-block");n.on("click",".permission-revoke",function(t){t.preventDefault();var i=$(this);confirm(i.data("confirmation"))&&(i.text(n.data("processing")).prop("disabled",!0),$.post(i.prop("href")).fail(function(){alert(n.data("network-error"))}).always(function(){window.top.location.reload()}))});$("#SmsAuthForm #btnOn").click(function(){changeSmsAuth(!0)});$("#SmsAuthForm #btnOff").click(function(){changeSmsAuth(!1)});$(".wm-set-phone").click(function(n){n.preventDefault();var t=$(this);confirm(t.data("confirm"))&&(t.attr("disabled",!0),$.ajax({type:"POST",url:t.data("url"),data:{Alias:t.data("alias"),Wmid:t.data("wmid"),Phone:t.data("phone")}}).done(function(n){n.Status?(t.hide(),window.top.location.reload()):n.Message?alert(n.Message):alert(t.data("error"))}).fail(function(){alert(t.data("error"))}).always(function(){t.attr("disabled",!1)}))});r=$("input.jq-focus");r.length&&setTimeout(function(){r.focus()},200);$("#update_captcha_image").click(function(n){n.preventDefault();var t=$("#captcha");console.log("captca image update");t.prop("src",t.data("src")+"?"+new Date)});$("#send-phone-code").click(function(n){n.preventDefault();var t=$(this),i=t.closest("div");t.text(t.data("resend")).prop("disabled",!0);try{clearInterval(window.phoneCodeResendWaitTimeIntervalHandle)}catch(n){}i.addClass("ajax-loading");$.post(t.data("url")).done(function(n){n.redirect?window.top.location=n.redirect:n.waitSeconds!==undefined?($("#phone-sent-success-alert-container").toggle(n.status),+n.waitSeconds>0&&phoneCodeResendWaitTimerStart(+n.waitSeconds)):(alert(t.data("error")),t.text(t.data("resend")).prop("disabled",!1))}).fail(function(){alert(t.data("error"));t.text(t.data("resend")).prop("disabled",!1)}).always(function(){i.removeClass("ajax-loading")})});u=$("#send-phone-code[data-wait-seconds]");u.length&&(f=+u.data("wait-seconds"),f>0&&phoneCodeResendWaitTimerStart(f))})