/*=======================================================================*\
|| ###################################################################### ||
|| # vBulletin 5.5.2
|| # ------------------------------------------------------------------ # ||
|| # Copyright 2000-2019 MH Sub I, LLC dba vBulletin. All Rights Reserved.  # ||
|| # This file may not be redistributed in whole or significant part.   # ||
|| # ----------------- VBULLETIN IS NOT FREE SOFTWARE ----------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html   # ||
|| ###################################################################### ||
\*========================================================================*/
window.vBulletin=window.vBulletin||{};window.vBulletin.phrase=window.vBulletin.phrase||{};window.vBulletin.phrase.precache=window.vBulletin.phrase.precache||[];window.vBulletin.phrase.precache=$.merge(window.vBulletin.phrase.precache,["aim","email_addresses_must_match","google_talk_im","icq","passwords_must_match","signature","signature_saved","skype","usersetting_signatures_link","yahoo_im","end_subscription","end_subscription_confirm","cancel","two_factor_authentication","mfa_enabled","mfa_verified","privacyconsent_withdraw_warning","withdraw_privacyconsent_and_logout",]);window.vBulletin.options=window.vBulletin.options||{};window.vBulletin.options.precache=window.vBulletin.options.precache||[];window.vBulletin.options.precache=$.merge(window.vBulletin.options.precache,["ctMaxChars"]);(function(D){window.vBulletin=window.vBulletin||{};var E=[".profile-settings-widget"];if(!vBulletin.pageHasSelectors(E)){return false}var A="usersettings";vBulletin.usersettings=vBulletin.usersettings||{};vBulletin.usersettings.signature;var B;function C(){D(".js-export-personal-data-form").submit();return false}vBulletin.usersettings.init=function(){D(".js-signature__edit").off("click").on("click",function(L){L.preventDefault();D("#editSignatureDialog").dialog({title:vBulletin.phrase.get("usersetting_signatures_link"),autoOpen:false,modal:true,resizable:false,closeOnEscape:false,showCloseButton:false,width:500,dialogClass:"signature-dialog-container dialog-container dialog-box",create:function(){var M=D(this),N=D(".js-editor",M);vBulletin.ckeditor.initEditor(N,{success:function(P){var O=vBulletin.ckeditor.getEditor(P);O.setData(N.prev(".js-editor-parsed-text").html(),function(){O.resetDirty()});M.on("dialogopen",function(){O.setData(D(".js-signature__preview").html(),function(){O.resetDirty()})})},error:function(){N.val(N.prev(".js-editor-parsed-text").html().replace(/<br\s*[\/]?>/gi,"\n")).data("orig-value",N.val());M.on("dialogopen",function(){N.val(D(".js-signature__preview").html().replace(/<br\s*[\/]?>/gi,"\n")).data("orig-value",N.val())})},hideLoadingDialog:true});D(".js-signature__cancel",M).off("click").on("click",function(O){var P=vBulletin.ckeditor.editorExists(N)?vBulletin.ckeditor.getEditor(N).checkDirty():N.val()!=N.data("orig-value");if(P){openConfirmDialog({title:vBulletin.phrase.get("cancel_edit"),message:vBulletin.phrase.get("all_changes_made_will_be_lost_would_you_like_to_continue"),iconType:"warning",onClickYes:function(){M.dialog("close")}})}else{M.dialog("close")}});D(".js-signature__submit",M).off("click").on("click",function(R){R.preventDefault();var O=vBulletin.ckeditor.editorExists(N)?vBulletin.ckeditor.getEditor(N).getData():N.val();var Q=[];D('input[name|="filedataids[]"]',M).each(function(){Q.push(D(this).val())});var P=function(S){D(".js-signature__preview").html(S);vBulletin.alert("signature","signature_saved");M.dialog("close")};vBulletin.AJAX({url:this.form.action,type:this.form.method,data:{signature:O,filedataids:Q},title_phrase:"signature",error_phrase:"error_saving_signature",success:P,emptyResponse:P,complete:function(){D("body").css("cursor","default")}});return false})}}).dialog("open");return false});var J=D(".js-mfa-reset"),I=J.closest("form"),H=D(".js-mfa-enable"),G=H.closest("form");var K=function(L){L.preventDefault();vBulletin.AJAX({call:"/ajax/api/user/resetMfaSecret",data:I.serializeArray(),success:function(N){D(".js-mfa-request-panel").addClass("h-hide");var Q=D(".js-mfa-secret-panels"),O=D(".js-mfa-qr-code"),M=O.parent().width(),P="otpauth://totp/"+escape(O.data("descrption"))+"?secret="+N.secret;Q.hide();Q.removeClass("h-hide");D(".js-mfa-secret-text").text(N.secret);O.html("");O.qrcode({width:M,height:M,text:P});Q.show("slow")},after_error:function(){I.find("input").not('[name="securitytoken"]').val("")}})};var F=function(L){L.preventDefault();vBulletin.AJAX({call:"/ajax/api/user/enableMfa",data:G.serializeArray(),success:function(M){vBulletin.alert("two_factor_authentication",(M.alreadyenabled?"mfa_verified":"mfa_enabled"));G.find('input[name="mfa_authcode"]').val("")},after_error:function(){G.find("input").not('[name="securitytoken"]').val("")}})};J.off("click").on("click",K);I.off("submit").on("submit",K);H.off("click").on("click",F);G.off("submit").on("submit",F);D(".js-export-personal-data").off("click",C).on("click",C)};D(document).ready(function(){D(".js-user-settings form").trigger("reset");vBulletin.usersettings.init();D(".b-form-select__select").selectBox();var L=window.vBulletin.options.get("ctMaxChars");D(".js-user-settings__reset").off("click").on("click",resetFormFields);setSelectedOption(D(".js-birth__month"),D("#bd_month"));D(".js-birth__month").selectBox().change(function(){D("#bd_day").val(D(".js-birth__day option:selected").val());updateDaySelectBox(D(".js-birth__day"),D(".js-birth__month").val())});D(".js-birth__year").off("blur").on("blur",function(){D("#bd_day").val(D(".js-birth__day option:selected").val());updateDaySelectBox(D(".js-birth__day"),D(".js-birth__month").val())});vBulletin.ajaxForm.apply(D("#profileSettings_form"),[{success:function(){window.location.reload(true)}}]);createDaySelectBox(D(".js-birth__day"));var Q=D(".js-user-settings .b-tabbed-pane__tabs").data("allow-history")==1,M=vBulletin.history.instance(Q),S=D(".js-module-top-anchor").attr("id");if(M.isEnabled()){var H=M.getState();if(!H||D.isEmptyObject(H.data)){var P=location.pathname.match(/\/(profile|account|privacy|notifications|subscriptions)\/?$/),R=(P&&P[1])||"profile",U={from:"tabs",tab:R};M.setDefaultState(U,document.title,location.href)}M.setStateChange(function(Z){var Y=M.getState();if(Y.data.from=="tabs"){M.log(Y.data,Y.title,Y.url);var X=B.tabbedPane("getSelectedTab"),W="#"+Y.data.tab+"Tab";if(X.children("a").prop("hash")!=W){var V=B.tabbedPane("findTabAnchorByHash",W).data("bypassPushState",true);B.tabbedPane("selectTab",V)}}},"tabs")}B=D(".b-tabbed-pane").tabbedPane({callback:function(Y,V){if(M.isEnabled()){if(!Y.data("bypassPushState")){var W={from:"tabs",tab:Y.data("url-path")},X=vBulletin.makeTabUrl(location.href,W.tab,false);M.pushState(W,document.title,X)}}D("select.b-form-select__select").selectBox();Y.data("bypassPushState",null)}});if(!M.isEnabled()){B.on("selectTab",function(W,V){location.href=vBulletin.makeTabUrl(location.href,D(V).data("url-path"),false,S);return false})}var J={aim:vBulletin.phrase.get("aim"),google:vBulletin.phrase.get("google_talk_im"),skype:vBulletin.phrase.get("skype"),yahoo:vBulletin.phrase.get("yahoo_im"),icq:vBulletin.phrase.get("icq")};var O=Object.keys(J).length;var F=function(V){var W=0;V.find(".selectBox.js-im").each(function(){var X=D(this).width();if(X>W){W=X}});return W};var I=function(W,V){W.find(".selectBox.js-im").each(function(){var X=D(this);X.width(V);X.find(".selectBox-label").css("width","auto")})};D(document).off("change",".selectBox.js-im").on("change",".selectBox.js-im",function(){$screenNamesContainer=D(this).closest(".js-screen-name__container");var V=F($screenNameContainer);updateProviders($screenNamesContainer,J);I($screenNameContainer,V)});setIMSelectedOption(D("select.js-im"),J);var G="b-icon b-icon__x-circle--light h-margin-horiz-l h-margin-bottom-xxs h-pointer h-left js-screen-name__remove";D(".js-screen-name__new").off("click").on("click",function(Z){Z.preventDefault();var X=D(this),a=D(this).parents(".js-screen-names").find(".js-screen-name__container"),V=a.find(".js-screen-name").length,Y=F(a);if(V<O){var W='<div class="h-margin-bottom-xs h-clearfix js-screen-name"> ';W+='<input type="text" name="user_screennames[]" class="js-user_screenname h-left b-form-input__input h-margin-right-l h-margin-bottom-s" value="" /> ';W+='<select name="user_im_providers[]" class="js-im--'+V+' js-im b-form-select__select h-left h-margin-bottom-s" data-orig-value-class="js-im--'+V+'"> ';W+=getAvailableIMs(a,J);W+="</select>";W+='<div class="b-form-input__accessory-container h-margin-bottom-s"> ';W+='<div class="'+G+'"></div> </div> </div> ';a.append(W);a.find(".js-im--"+V).selectBox();a.find(".js-user_screenname:last").focus();if(a.find(".js-screen-name").length>=O){X.hide()}updateProviders(a,J);I(a,Y)}});D(".js-screen-names").each(function(){$container=D(this);var V=F($container);I($container,V);if($container.find(".selectBox.js-im").length>=O){$container.find(".js-screen-name__new").hide()}});D(document).off("click",".js-screen-name__remove").on("click",".js-screen-name__remove",function(){var W=D(this).parents(".js-screen-name"),Y=D(this).closest(".js-screen-names"),X=F(Y),V=W.siblings(".js-screen-name").length;if(V<1){W.find(".js-user_screenname").val("")}else{W.find("select.js-im").selectBox("destroy");W.remove()}updateProviders(Y,J);I(Y,X);Y.find(".js-screen-name__new").show()});D("#new_useremail").off("focus."+A).on("focus."+A,function(V){V.preventDefault();D("#new_email_container").addClass("isActive").slideDown("3000")});D("#user_newpass").off("focus."+A).on("focus."+A,function(V){V.preventDefault();D("#new_pass_container").addClass("isActive").slideDown("3000")});D("#settingsErrorClose").off("click").on("click",function(){D("#settingsErrorDialog").dialog("close")});D("#accountSettings_form").ajaxForm({dataType:"json",beforeSubmit:function(X,V,W){return K()},success:function(X,Y,Z,W){if(X&&X.response&&X.response.newtoken){vBulletin.doReplaceSecurityToken(X.response.newtoken)}if(X&&X.response&&X.response.errors){var a=[];for(var V in X.response.errors){if(X.response.errors[V][0]!="exception_trace"&&X.response.errors[V][0]!="errormsg"){a.push(vBulletin.phrase.get(X.response.errors[V]))}}openAlertDialog({title:vBulletin.phrase.get("error"),message:a.join("<br />"),iconType:"warning"})}else{window.location.reload(true)}}});var K=function(){var V=D("#user_newpass"),d=D("#user_newpass2"),e=V.val(),b=d.val();var c=function(g,f){vBulletin.error("error",g,function(){f.focus()})};if(e||b){var Z=D("#user_currentpass");if(Z.val()==""){c("enter_current_password",Z[0]);return false}if(e!=b){c("passwords_must_match",V[0]);return false}}else{V.removeAttr("name");d.removeAttr("name")}var a=D("#new_useremail"),W=D("#new_useremail2"),X=a.val(),Y=W.val();if(X||Y){var Z=D("#user_currentpass");if(Z.val()==""){c("enter_current_password",Z[0]);return false}if(X!=Y){c("email_addresses_must_match",a[0]);return false}if(!isValidEmailAddress(a.val())){c("invalid_email_address",a[0]);return false}}else{a.removeAttr("name");W.removeAttr("name")}return true};T();function T(){var W=D("#ignorelist_container").val(),V=new vBulletin_Autocomplete(D("#ignorelist_container"),{apiClass:"user",minLength:D("#minuserlength").val(),maxItems:D("#maxitems").val()});if(W){W=W.split(",");D.each(W,function(X,Y){Y=D.trim(Y);V.addElement(Y)})}}D("#follower_request").off("change").on("change",function(){if(D(this).attr("checked")=="checked"){D("#general_followrequest").attr("checked",true)}});D(".js-usersetting-privacy-consent-checkbox").on("change",function(W){var V=this;if(!V.checked){openConfirmDialog({title:vBulletin.phrase.get("warning"),message:vBulletin.phrase.get("privacyconsent_withdraw_warning"),iconType:"warning",buttonLabel:{yesLabel:vBulletin.phrase.get("withdraw_privacyconsent_and_logout"),noLabel:vBulletin.phrase.get("cancel")},onClickYes:function(){D("body").css("cursor","wait");vBulletin.AJAX({call:"/profile/withdrawPrivacyConsent",data:{},complete:function(){D("body").css("cursor","auto")},success:function(X){if(X&&X.url){location.href=X.url}},})},onClickNo:function(){V.checked=true}})}});D("#general_followrequest").off("change").on("change",function(){if(!D(this).prop("checked")){D("#follower_request").prop("checked",false)}});var N=D("#subscriptionsTab");if(N.length>0){D(".js-subscription-cost",N).change(function(){var d=D(this).closest(".js-newsubscription_row"),X=D(this).find("option:selected").first(),Z=X.attr("data-currency"),a=d.attr("data-id"),W=X.attr("data-subid"),b=D(this).closest(".js-subscriptions_list"),Y=D(".js-order_confirm",N),c=D(".js-payment-form",N),V=D.parseJSON(d.attr("data-allowedapis"));D(this).selectBox("value","");D('<tr class="confirm_data"><td>'+X.attr("data-subtitle")+"</td><td>"+X.attr("data-duration")+"</td><td>"+X.attr("data-value")+"</td></tr>").appendTo(D(".js-order_confirm_table",Y));b.addClass("h-hide");Y.off("click",".js-subscription__remove").on("click",".js-subscription__remove",function(){D(".confirm_data",Y).remove();D(".js-paymentapi",Y).closest("label").removeClass("h-hide");D(".js-subscriptions-order",Y).prop("disabled",false);D(".js-subscription-cost",b).selectBox("value","");Y.addClass("h-hide");b.removeClass("h-hide");return false});Y.off("click",".js-paymentapi").on("click",".js-paymentapi",function(){D(".js-subscriptions-order",Y).prop("disabled",false)});D(".js-paymentapi",Y).each(function(){var e=D(this).attr("data-currency").split(",");if(D.inArray(Z,e)==-1||D.inArray(D(this).val(),V)==-1){D(this).closest("label").addClass("h-hide")}});Y.off("click",".js-subscriptions-order").on("click",".js-subscriptions-order",function(){D(".js-subscriptions-order",Y).prop("disabled",true);D("body").css("cursor","wait");vBulletin.AJAX({call:"/ajax/api/paidsubscription/placeorder",data:{subscriptionid:a,subscriptionsubid:W,paymentapiclass:D(".js-paymentapi:checked",Y).val(),currency:Z},complete:function(){D("body").css("cursor","auto")},success:function(e){c.html(e);Y.addClass("h-hide");b.addClass("h-hide");c.off("click",".js-subscription__cancel").on("click",".js-subscription__cancel",function(){c.html("").addClass("h-hide");D(".js-subscription__remove",Y).click();return false});c.removeClass("h-hide")},})});Y.removeClass("h-hide")});D(".js-subscription__end",N).click(function(){var V=D(this).attr("data-id"),W=D(this).closest("tr"),X=D(this).closest("table");openConfirmDialog({title:vBulletin.phrase.get("end_subscription"),message:vBulletin.phrase.get("end_subscription_confirm"),iconType:"warning",buttonLabel:{yesLabel:vBulletin.phrase.get("end_subscription"),noLabel:vBulletin.phrase.get("cancel")},onClickYes:function(){D("body").css("cursor","wait");vBulletin.AJAX({call:"/ajax/api/paidsubscription/endsubscription",data:{subscriptionid:V},complete:function(){D("body").css("cursor","auto")},success:function(Y){W.remove();if(X.find("tr").length<=1){X.closest(".js-existing-subscription-row").remove()}},emptyResponse:D.noop,api_error:D.noop})}});return false})}});createDaySelectBox=function(F){var H="",J=D(".js-birth__month").val(),I=D("#bd_year").val(),K=new Date(I,J,0);if(D("#bd_day").val()==""||D("#bd_day").val()==null){H+="<option name='day' value='' selected='selected'></option>"}for(var G=1;G<=K.getDate();G++){G=(G<10)?("0"+G):G;if(G==D("#bd_day").val()){H+="<option name='day' value='"+G+"' selected='selected'>"+G+"</option>"}else{H+="<option name='day' value='"+G+"'>"+G+"</option>"}}F.html(H);F.selectBox("destroy").selectBox()};updateDaySelectBox=function(F,J){var I=(D(".js-birth__year").val()!="")?D(".js-birth__year").val():0,K=new Date(I,J,0),H="";K=K.getDate();for(var G=1;G<=K;G++){G=(G<10)?("0"+G):G;H+="<option name='day' value='"+G+"'>"+G+"</option>"}updateSelectBox(F,H)};updateSelectBox=function(F,G,I){G=(G)?G:F.html();var H=F.attr("class").split(" ");F.selectBox("destroy");F.removeData("selectBoxControl");F.removeData("selectBoxSettings");F.html(G);if(D("#"+H[0]).val()!=undefined){F.val(D("#"+H[0]).val())}F.selectBox()};setSelectedOption=function(G,F){G.val(F.val())};setIMSelectedOption=function(F,H){var G="";D.each(F,function(L,J){var K=D(J).data("orig-value-class");G=D(J).parent().children(":input[type=hidden]."+K).val();D(J).val(G)});var I="";D.each(F,function(K,J){$screenNameContainer=D(F).closest(".js-screen-name__container");I=D(J).closest(".js-screen-name").find("select.js-im option:selected");D.each(D(I),function(L,M){if(D(J).val()!=D(M).val()){D(J).find("option[value= "+D(M).val()+"]").remove()}});updateProviders($screenNameContainer,H)})};getAvailableIMs=function(G,H){var F="";D.each(H,function(I,J){if(G.find("select.js-im option:selected[value= "+I+"]").length==0){F+="<option name='im_provider' value='"+I+"'> "+J+"</option>"}});return F};updateImSelectBox=function(F,G){F.selectBox("destroy");F.removeData("selectBoxControl");F.removeData("selectBoxSettings");F.html(G);F.selectBox()};updateProviders=function(G,F){G.find("select.js-im").each(function(J,H){var K=D(H).val(),I="";D.each(F,function(L,M){if(G.find("select.js-im option:selected[value= "+L+"]").length==0){I+="<option name='im_provider' value='"+L+"'>"+M+"</option>"}else{if(L==K){I+="<option name='im_provider' value='"+L+"' selected='selected'>"+M+"</option>"}}});updateImSelectBox(D(H),I)})};resetFormFields=function(){var F=D(this.form);setTimeout(function(){D("input",F).trigger("change");D("select.b-form-select__select",F).each(function(){updateSelectBox(D(this))})},100)}})(jQuery);