Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- (function(){
- let configurator = document.getElementById('configurator_json');
- let html = configurator.innerHTML;
- let json = JSON.parse(html);
- let all_pro_addons = 'all_pro_addons';
- let pro_addons_array = [];
- if (location.search.match(/gr_settings/) && getCookie(all_pro_addons)=="") {
- location.reload();
- };
- if (location.search.match(/gr_full_version/)) {
- let href = location.search.split("?&gr_full_version");
- setCookie('gr_full_version', 1, 7);
- location.href = location.origin + href[0];
- }; /*Ссылка версии со всеми допработами*/
- if (location.search.match(/gr_base_version/)) {
- let href = location.search.split("?&gr_base_version");
- if (getCookie(all_pro_addons)!="") {
- let json_cookie = getCookie(all_pro_addons);
- let json_array = JSON.parse(json_cookie);
- for (let i = json_array.length - 1; i >= 0; i--) {
- deleteCookie(json_array[i]);
- };
- };
- deleteCookie('full_price');
- deleteCookie('gr_full_version');
- deleteCookie('all_pro_addons');
- if (location.search.match(/gr_base_version/)) {
- location.href = location.origin + href[0];
- };
- }; /*Ссылка базовой версии без допработ*/
- if (getCookie(all_pro_addons)!="" && location.search.match(/gr_settings/)) {
- let json_cookie = getCookie(all_pro_addons);
- let json_array = JSON.parse(json_cookie);
- let href = location.search.split("?&gr_settings=1");
- if (location.search.match(/gr_settings/)) {
- for (let i = json_array.length - 1; i >= 0; i--) {
- deleteCookie(json_array[i]);
- };
- };
- deleteCookie('gr_full_version');
- if (location.search.match(/gr_settings/)) {
- location.href = location.origin + href[0];
- };
- }; /*Ссылка с базовой версии с допработами*/
- getSettingsParse(json);
- function getSettingsParse(json) {
- for (var key in json) {
- let result = key.match(/pro_/);
- let full_price = key.match(/full_price/);
- if (full_price) {
- let full_price_value = json[full_price];
- setCookie(full_price, full_price_value, 7);
- };
- if (result) {
- pro_addons_array.push(key);
- setCookie(key, 1, 7);
- };
- };
- if (location.search.match(/gr_settings/)) {
- let json_str = JSON.stringify(pro_addons_array);
- setCookie(all_pro_addons, json_str, 7);
- };
- }; /*Запись допработ в куки*/
- function ready() {
- let target = document.querySelector('body');
- let observer = new MutationObserver(function(mutations) {
- mutations.forEach(function(mutation) {
- if (document.querySelectorAll('.s3solution-panel-root').length>0) {
- if (getCookie('full_price') != "") {
- document.querySelector('.s3solution__item.s3solution__item--price strong').innerHTML = getCookie('full_price');
- };
- let site_id = configurator.getAttribute('data-site-id');
- let catalog_href = 'https://design.megagroup.ru/solution/' + site_id;
- let btn = '<a href="'+catalog_href+'" class="s3solution-panel__btn s3solution-panel__btn--order">Заказать сайт<div class="s3solution-panel-tooltip js-panel-tooltip">ID = '+site_id+'</div></a>';
- if (document.querySelectorAll('a.s3solution-panel__btn.s3solution-panel__btn--order').length<1) {
- document.querySelector('.s3solution-panel__btn.s3solution-panel__btn--order').insertAdjacentHTML('afterend', btn);
- };
- if (document.querySelectorAll('div.s3solution-panel__btn.s3solution-panel__btn--order').length>0) {
- document.querySelector('div.s3solution-panel__btn.s3solution-panel__btn--order').remove();
- };
- observer.disconnect();
- }
- });
- });
- let config = {
- attributes: true,
- childList: true,
- characterData: true
- };
- observer.observe(target, config);
- }; /*Отслеживание желтой панели и замена в ней цены с кнопкой*/
- document.addEventListener("DOMContentLoaded", ready);
- function setCookie(name, value, days = 7, path = '/') {
- const expires = new Date(Date.now() + days * 864e5).toUTCString()
- document.cookie = name + '=' + encodeURIComponent(value) + '; expires=' + expires + '; path=' + path
- };
- function getCookie(name) {
- return document.cookie.split('; ').reduce((r, v) => {
- const parts = v.split('=')
- return parts[0] === name ? decodeURIComponent(parts[1]) : r
- }, '')
- };
- function deleteCookie(name, path) {
- setCookie(name, '', -1, path)
- };
- })();
Add Comment
Please, Sign In to add comment