PageSourceSearch

https://sweb.ru/scripts/reusable/rig/rig.min.js?nc=2026100101

js sweb.ru collected 2026-10-02 04:01:42 UTC 18,527 bytes, 1 lines download raw bytes

1var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);const _RigSelect=class _RigSelect{constructor(selector,openButtonSelector=".js-rig-open",desktopLayout=!1){this.elementSelector=selector,this.elementCardsSelector=`${this.elementSelector} .rig-cards__item`,this.elementCardsContainerSelector=`${this.elementSelector} .rig-cards`,this.openButtonSelector=openButtonSelector,this.desktopLayout=desktopLayout,this.currentButtonId=null,this.panelWidth=800,this.prevWindowWidth=$(window).width(),this.bindEvents()}bindEvents(){const self=this;$(document).on("click",`${this.openButtonSelector}`,function(event){if($(this).hasClass("vds-ui-card__select-btn_disabled")===!1){const isPopup=event.target.id.includes("popup");_RigSelect.closeAllRigPanel(),self.currentButtonId=$(this).attr("id"),$(`#${self.currentButtonId}`).addClass("selected"),isPopup&&($(_RigSelect.basePopupLeftPanelSelector).css("overflow","initial"),$(self.elementSelector).detach().appendTo($(event.target).closest(_RigSelect.basePopupButtonContainerSelector))),self.calculateRigCoords($(event.target),isPopup),event.stopPropagation()}}),$(window).on("resize",function(){const windowWidth=$(window).width();Math.abs(windowWidth-self.prevWindowWidth)>100&&(_RigSelect.closeAllRigPanel(),self.prevWindowWidth=windowWidth)}),$(document).on("click",function(event){$(event.target).closest(self.elementSelector).length||self.closeRigPanel()}),$(document).on("click",`${self.elementCardsSelector}`,function(){self.closeRigPanel(),$(self.elementCardsSelector).removeClass("selected"),$(this).addClass("selected")})}static calculatePanelWidth(screenWidth,cardWidth,shouldUseOpenCardWidth,$btn){const windowWidth=$(window).width(),breakpoints={small:560,medium:800,large:960},panelWidths={small:windowWidth>=330?cardWidth:280,medium:412,large:540,xlarge:$btn.data("xlarge_width")?$btn.data("xlarge_width"):800};let panelWidth;return shouldUseOpenCardWidth?panelWidth=panelWidths.small:screenWidth<breakpoints.medium?panelWidth=panelWidths.medium:screenWidth<breakpoints.large?panelWidth=panelWidths.large:panelWidth=panelWidths.xlarge,panelWidth}calculateRigCoords($btn,isPopup){const buttonOffset=$btn.offset(),buttonWidth=$btn.outerWidth(),buttonHeight=$btn.outerHeight(),$card=$(`${$btn.data("card_selector")}`),openCardWidth=!!$btn.data("open_card_width"),screenWidth=$(window).width(),shouldUseOpenCardWidth=screenWidth<560||openCardWidth;this.panelWidth=_RigSelect.calculatePanelWidth(screenWidth,$card.width(),shouldUseOpenCardWidth,$btn);let panelLeft=buttonOffset.left+buttonWidth/2;const windowWidth=screenWidth;panelLeft<this.panelWidth/2?panelLeft+=this.panelWidth/2-panelLeft+20:panelLeft>windowWidth-this.panelWidth/2&&(panelLeft+=windowWidth-this.panelWidth/2-panelLeft-20);const $rigCardsItems=$(`${this.elementSelector} .rig-cards`),$rigWrapper=$(`${this.elementSelector} .rig-wrapper`),$rigContainer=$(`${this.elementSelector} .rig__container`);this.desktopLayout&&$(`#${this.currentButtonId}`).data("desktop")!==!1&&(this.panelWidth>=412||this.panelWidth==="max-content")?($rigCardsItems.addClass("desktop"),$rigWrapper.addClass("desktop"),$rigContainer.addClass("desktop"),$rigCardsItems.removeClass("mobile"),$rigWrapper.removeClass("mobile"),$rigContainer.removeClass("mobile")):($rigCardsItems.addClass("mobile"),$rigWrapper.addClass("mobile"),$rigContainer.addClass("mobile"),$rigCardsItems.removeClass("desktop"),$rigWrapper.removeClass("desktop"),$rigContainer.removeClass("desktop")),$(this.elementSelector).addClass("open").css({top:isPopup?buttonHeight+10:buttonOffset.top+buttonHeight+10,left:isPopup?"50%":shouldUseOpenCardWidth&&$card.length>0?$card.offset().left+$card.width()/2:panelLeft,width:isPopup?windowWidth>=330?$btn.closest(".popup_hosting_left").outerWidth():280:this.panelWidth,zIndex:1e11})}filterElementsByType(typesToShow=[]){if(!typesToShow.length)return;document.querySelectorAll(this.elementCardsSelector).forEach(element=>{element.classList.toggle("rig-cards__item_hidden",typesToShow.includes(element.dataset.type))})}closeRigPanel(){$(`#${this.currentButtonId}`).removeClass("selected"),$(this.elementSelector).removeClass("open").css({zIndex:0}),$(this.elementSelector).detach().appendTo("body")}static closeAllRigPanel(){$(`${_RigSelect.baseOpenButtonSelector}`).removeClass("selected"),$(_RigSelect.baseClassSelector).removeClass("open").css({zIndex:0}),$(_RigSelect.baseClassSelector).detach().appendTo("body"),$(".rig__filter-list").filter(".slick-initialized").slick("unslick")}
1toggleDisabled(cardSelector,value){const input=$(`${cardSelector} ${this.openButtonSelector}`);value?input.addClass("vds-ui-card__select-btn_disabled"):input.removeClass("vds-ui-card__select-btn_disabled")}static initializingSlider(slider,initialSlide){const $leftGradient=slider.prev(".rig__filter-gradient-left"),$rightGradient=slider.next(".rig__filter-gradient-right");$(".rig__filter-item").addClass("slider"),$(".rig__filter-list").css({paddingTop:"0",paddingBottom:"0"}),$(slider).on("beforeChange",function(event,slick,currentSlide,nextSlide){nextSlide===0?$(slider).slick("slickSetOption","centerMode",!1):$(slider).slick("slickSetOption","centerMode",!0)}),$(slider).on("init reInit afterChange",function(event,slick,currentSlide,nextSlide){if(event.type==="init"&&initialSlide===0){$leftGradient.hide(),$rightGradient.show();return}currentSlide===0?($leftGradient.hide(),$rightGradient.show()):currentSlide===slick.slideCount-1?($leftGradient.show(),$rightGradient.hide()):($leftGradient.show(),$rightGradient.show())}),$(slider).hasClass("slick-initialized")&&$(slider).slick("unslick"),$(slider).slick({infinite:!1,centerMode:initialSlide!==0,centerPadding:"1px",slidesToScroll:2,arrows:!1,variableWidth:!0,speed:100,draggable:!0,initialSlide,slickSetOption:!1}),$(slider).on("destroy",function(){$leftGradient.hide(),$rightGradient.hide(),$(".rig__filter-item").removeClass("slider"),$(".rig__filter-list").css({paddingTop:"12px",paddingBottom:"12px"})})}logicState(){}};__publicField(_RigSelect,"baseClassSelector",".rig"),__publicField(_RigSelect,"baseOpenButtonSelector",".vds-ui-card__select-btn"),__publicField(_RigSelect,"basePopupButtonContainerSelector",".vds-popup__row"),__publicField(_RigSelect,"basePopupLeftPanelSelector",".popup_hosting_left");let RigSelect=_RigSelect;class RigSelectDatacenter extends RigSelect{constructor(inputs,planInputSelector){super("#js-rig-datacenter",".js-rig-open-datacenter",!0),this.inputs=inputs,this.planInputSelector=planInputSelector,this.logicState()}setLabel(label,cardSelector){$(`${cardSelector} ${this.openButtonSelector}`).text(label)}logicState(){super.logicState();const self=this;$(document).on("click",`${this.openButtonSelector}`,function(){const cardSelector=$(`#${self.currentButtonId}`).data("card_selector"),planBillingId=$(`${cardSelector} ${self.planInputSelector}`).val(),planDatacenters=VdsHelpers.getPlanById(planBillingId).datacenters,selectedDatacenterId=self.inputs.getValue(cardSelector);$(self.elementCardsSelector).each(function(){const dataId=+$(this).data("id"),shouldBeHidden=!planDatacenters.includes(dataId);$(this).show(),shouldBeHidden&&$(this).hide()}),$(self.elementCardsSelector).removeClass("selected"),$(`${self.elementCardsSelector}[data-id="${selectedDatacenterId}"]`).addClass("selected")}),$(document).on("click",`${self.elementCardsSelector}`,function(){const $btn=$(`#${self.currentButtonId}`);self.inputs.setValue($btn.data("card_selector"),$(this).data("id"))})}}class RigSelectPlan extends RigSelect{constructor(inputs){super("#js-rig-plan",".js-rig-open-plan",!0),this.filterItemsSelector="#js-rig-plan .rig__filter-item",this.filterContainerSelector="#js-rig-plan .rig__filter-list",this.inputs=inputs,this.logicState(),this.hideEmptyCategories()}hideEmptyCategories(){const self=this;$(document).ready(function(){$(self.filterItemsSelector).each(function(){const category=$(this).data("value");$(`${self.elementCardsSelector}[data-vpscategory="${category}"]`).length||$(this).hide()})})}setLabel(label,cardSelector){$(`${cardSelector} ${this.openButtonSelector}`).text(label)}logicState(){super.logicState();const self=this;$(document).on("click",`${this.openButtonSelector}`,function(event){const cardSelector=$(`#${self.currentButtonId}`).data("card_selector"),selectedPlanBillingId=self.inputs.getValue(cardSelector),selectedPlan=VdsHelpers.getPlanById(selectedPlanBillingId);$(self.elementCardsSelector).removeClass("selected"),$(`${self.elementCardsSelector}[data-billingId="${selectedPlanBillingId}"]`).addClass("selected");const initCategoryId=selectedPlan.category===null?"nvme":selectedPlan.category;self.panelWidth>=412||RigSelect.initializingSlider($(`${self.filterContainerSelector}`));const sliderIndex=+$(`${self.filterItemsSelector}[data-value="${initCategoryId}"]`).addClass("selected").data("slick-index");self.setCategory(initCategoryId,sliderIndex)}),$(document).on("click",`${self.elementCardsSelector}`,function(){const $btn=$(`#${self.currentButtonId}`);
1self.inputs.setValue($btn.data("card_selector"),$(this).data("billingid"))}),$(document).on("click",`${this.filterItemsSelector}`,function(){const index=+$(this).data("slick-index"),categoryId=$(this).data("value");self.setCategory(categoryId,index)})}setCategory(categoryId,index=1){$(this.filterContainerSelector).hasClass("slick-initialized")&&$(this.filterContainerSelector).slick("slickGoTo",index),$(this.filterItemsSelector).removeClass("active"),$(`${this.filterItemsSelector}[data-value="${categoryId}"]`).addClass("active"),$(this.elementCardsSelector).hide(),$(`${this.elementCardsSelector}[data-vpscategory="${categoryId}"]`).show(),$(`${this.elementCardsSelector}[data-vpscategory=""]`).show(),$(`${this.elementCardsSelector}.hidden`).hide()}closeRigPanel(){super.closeRigPanel()}}class RigSelectIp extends RigSelect{constructor(inputs){super("#js-rig-ip",".js-rig-open-ip",!0),this.inputs=inputs,this.logicState()}setLabel(label,cardSelector){$(`${cardSelector} ${this.openButtonSelector}`).text(label)}logicState(){super.logicState();const self=this;$(document).on("click",`${this.openButtonSelector}`,function(){const $btn=$(`#${self.currentButtonId}`),cardSelector=$btn.data("card_selector"),selectedIpId=self.inputs.getValue(cardSelector);$(self.elementCardsSelector).removeClass("selected"),$(`${self.elementCardsSelector}[data-id="${selectedIpId}"]`).addClass("selected"),self.filterElementsByPlanType($btn.data("plan-type"))}),$(document).on("click",`${self.elementCardsSelector}`,function(){const $btn=$(`#${self.currentButtonId}`);self.inputs.setValue($btn.data("card_selector"),$(this).data("id"))})}closeRigPanel(){super.closeRigPanel()}filterElementsByPlanType(planType){const cards=document.querySelectorAll(this.elementCardsSelector),ipTypeToShow=planType==="abroad"?"abroad":"home";cards.forEach(card=>{card.classList.toggle("rig-cards__item_hidden",!!card.dataset.type&&card.dataset.type!==ipTypeToShow)}),this.updateCategoryVisibility()}updateCategoryVisibility(){const wrappers=document.querySelectorAll(`${this.elementSelector} .rig-wrapper`),wrappersWithAvailableIp=[];wrappers.forEach(wrapper=>{const visibleCards=wrapper.querySelectorAll(".rig-cards__item:not(.rig-cards__item_hidden)"),visibleIpCards=wrapper.querySelectorAll(".rig-cards__item:not(.rig-cards__item_hidden)[data-type]");wrapper.hidden=visibleCards.length===0,visibleIpCards.length>0&&wrappersWithAvailableIp.push(wrapper)}),wrappers.forEach(wrapper=>{const title=wrapper.querySelector(".rig-wrapper__title");title&&(title.hidden=wrappersWithAvailableIp.length<2||!wrappersWithAvailableIp.includes(wrapper))})}}class RigSelectPanel extends RigSelect{constructor(inputs,planInputSelector){super("#js-rig-panel",".js-rig-open-panel",!0),this.filterItemsSelector="#js-rig-panel .rig__filter-item",this.filterContainerSelector="#js-rig-panel .rig__filter-list",this.inputs=inputs,this.planInputSelector=planInputSelector,this.preloadImages(),this.logicState()}preloadImages(){selectPanel.map(panel=>panel.logo_img).forEach(url=>{const img=new Image;img.src=`//s.sweb.ru/img/vps/logos/panel/${url}`})}toggleDisabled(cardSelector,value){const input=$(`${cardSelector} ${this.openButtonSelector}`);value?input.addClass("vds-ui-card__select-btn_disabled"):input.removeClass("vds-ui-card__select-btn_disabled")}setLabel(label,cardSelector){$(`${cardSelector} ${this.openButtonSelector}`).text(label)}logicState(){super.logicState();const self=this;$(document).on("click",`${this.openButtonSelector}`,function(){const $btn=$(`#${self.currentButtonId}`);if($btn.hasClass("vds-ui-card__select-btn_disabled")===!1){const cardSelector=$btn.data("card_selector"),$planInput=$(`${cardSelector} ${self.planInputSelector}`);let availablePanels=[];if($planInput.data("kit")===!0){const ram=$planInput.data("ram"),disk=$planInput.data("disk");availablePanels=VdsHelpers.getAvailablePanelsByChar(ram,disk)}else{const planBillingId=$planInput.val(),planId=VdsHelpers.getPlanById(planBillingId).plan_id;availablePanels=VdsHelpers.getAvailablePanelsByPlanId(planId)}const selectedPanelId=self.inputs.getValue(cardSelector),selectedPanel=VdsHelpers.getPanelById(selectedPanelId),selectedAppCategory=$(`${cardSelector}
1 ${self.inputs.inputSelector}`).data("app_category_id");if(selectedAppCategory){$(`${self.filterContainerSelector}`).hide(),$(self.elementCardsSelector).removeClass("selected"),$(`${self.elementCardsSelector}[data-id="${selectedPanelId}"]`).addClass("selected"),self.setCategory(selectedAppCategory);return}else $(`${self.filterContainerSelector}`).show();const availablePanelsIds=availablePanels.map(panel=>panel.id),availableCategoriesIds=[...new Set(availablePanels.map(panel=>panel.app_category_id).filter(id=>id!==null))];$(self.filterItemsSelector).each(function(item){$(this).show();const appCategory=$(this).data("value");availableCategoriesIds.includes(appCategory.toString())||$(this).hide()}),$(self.elementCardsSelector).removeClass("selected"),$(`${self.elementCardsSelector}[data-id="${selectedPanelId}"]`).addClass("selected");const initCategoryId=selectedPanel.app_category_id===null?"1":selectedPanel.app_category_id;$(self.elementCardsSelector).each(function(){const dataId=$(this).data("id"),shouldBeHidden=!availablePanelsIds.includes(dataId.toString());$(this).removeClass("hidden"),shouldBeHidden&&$(this).addClass("hidden")}),self.panelWidth>=412||RigSelect.initializingSlider($(`${self.filterContainerSelector}`));const sliderIndex=+$(`${self.filterItemsSelector}[data-value="${initCategoryId}"]`).addClass("selected").data("slick-index");self.setCategory(initCategoryId,sliderIndex)}}),$(document).on("click",`${this.filterItemsSelector}`,function(){const index=+$(this).data("slick-index"),categoryId=$(this).data("value");self.setCategory(categoryId,index)}),$(document).on("click",`${self.elementCardsSelector}`,function(){const $btn=$(`#${self.currentButtonId}`);self.inputs.setValue($btn.data("card_selector"),$(this).data("id"))})}setCategory(categoryId,index=1){$(this.filterContainerSelector).hasClass("slick-initialized")&&$(this.filterContainerSelector).slick("slickGoTo",index),$(this.filterItemsSelector).removeClass("active"),$(`${this.filterItemsSelector}[data-value="${categoryId}"]`).addClass("active"),$(this.elementCardsSelector).hide(),$(`${this.elementCardsSelector}[data-app_category_id="${categoryId}"]`).show(),$(`${this.elementCardsSelector}[data-app_category_id=""]`).show(),$(`${this.elementCardsSelector}.hidden`).hide()}closeRigPanel(){super.closeRigPanel()}}class RigSelectOs extends RigSelect{constructor(inputs,panelInputSelector,planInputSelector){super("#js-rig-os",".js-rig-open-os",!0),this.inputs=inputs,this.panelInputSelector=panelInputSelector,this.planInputSelector=planInputSelector,this.preloadImages(),this.logicState()}preloadImages(){selectOs.map(panel=>panel.logo_img).forEach(url=>{const img=new Image;img.src=`//s.sweb.ru/img/vps/logos/os/${url}`})}setLabel(label,cardSelector){$(`${cardSelector} ${this.openButtonSelector}`).text(label)}logicState(){super.logicState();const self=this;$(document).on("click",`${this.openButtonSelector}`,function(){const cardSelector=$(`#${self.currentButtonId}`).data("card_selector"),selectedPanelId=$(`${cardSelector} ${self.panelInputSelector}`).val(),selectedPanel=VdsHelpers.getPanelById(selectedPanelId),selectedOsId=self.inputs.getValue(cardSelector),$planInput=$(`${cardSelector} ${self.planInputSelector}`);let ram,disk,allowCustomImage=!0;if($planInput.data("kit")===!0)ram=$planInput.data("ram"),disk=$planInput.data("disk");else{const planBillingId=$planInput.val(),plan=VdsHelpers.getPlanById(planBillingId);ram=+plan.ram/1024,disk=+plan.disk,allowCustomImage=plan?.category!=="abroad"}const availableOsIds=VdsHelpers.getAvailableOsList({ram,disk,selectedPanel}).map(os=>+os.id),elements=$(self.elementCardsSelector).toArray();elements.forEach(el=>{const $el=$(el);$el.removeClass("disabled selected"),availableOsIds.includes(+$el.data("id"))||$el.addClass("disabled"),!allowCustomImage&&$el.attr("data-name")==="custom-image"&&$el.addClass("disabled")});const sorted=self.sortByPriority(elements,"ubuntu");$(self.elementCardsContainerSelector).empty(),sorted.forEach(el=>{$(self.elementCardsContainerSelector).append(el)}),selectedOsId&&$(`${self.elementCardsSelector}[data-id="${selectedOsId}"]`).addClass("selected")}),$(document).on("click",`${self.elementCardsSelector}`,function(){if($(this).hasClass("disabled"))return;const $btn=$(`#${self.currentButtonId}`);
1self.inputs.setValue($btn.data("card_selector"),$(this).data("id"))})}sortByPriority(elements,priorityPanel){return $(elements).get().sort(function(a,b){const aName=$(a).attr("data-name"),bName=$(b).attr("data-name");if(aName==="custom-image")return 1;if(bName==="custom-image")return-1;const aDisabled=$(a).hasClass("disabled"),bDisabled=$(b).hasClass("disabled");function extractVersion(name){const versionMatch=name.match(/\d+(\.\d+)+/);return versionMatch?versionMatch[0]:""}const aVersion=extractVersion(aName),bVersion=extractVersion(bName);if(aDisabled&&!bDisabled)return 1;if(!aDisabled&&bDisabled||aName===bName&&aName.includes(priorityPanel))return-1;if(aName===bName&&bName.includes(priorityPanel))return 1;const nameComparison=bName.localeCompare(aName);return nameComparison!==0?nameComparison:aVersion>bVersion?-1:aVersion<bVersion?1:0})}}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.