Skip to main content

Служебные скрипты FM

https://fitnessmama.school/pl/cms/layout/update?id=29679#js 

HTML

<!-- WhatsApp-Tlgt Web -->
$(function(){
    window.isMobile = /Mobile|webOS|BlackBerry|IEMobile|MeeGo|mini|Fennec|Windows Phone|Android|iP(ad|od|hone)/i.test(navigator.userAgent);
    var nint = setInterval(function() {
        if($('#whatsapp_button').length == 0) {
            if($(".user-phone-widget").length) {
                var phone = $('.user-phone span[data-reactid=".0.1.1.0.0.2.5.2"]').text().replace(/\D+/g,'');
                if(phone[0] == 3 && phone.length == 10) phone = "39"+phone;
                if(phone[0] == 9 && phone.length == 10) phone = "7"+phone;
                if(phone[0] == 8 && phone.length == 11) phone = "7"+phone.slice(1);
                phone = "+"+phone;
                $(".user-phone-widget").after(`
                <span>
                <button id="whatsapp_button" class="btn btn-sm btn-default" onclick="window.open((window.isMobile ? 'https://wa.me/' : 'https://web.whatsapp.com/send?phone=') + '${phone}')" style="
                margin: 3px 0;
                background-color: #25D366;
                color: white;
                padding: 4px 5px;
                border: none;
                border-radius: 30px;
                height: 22px;
                "><svg aria-hidden="true" focusable="false" data-prefix="fab" data-icon="whatsapp" class="svg-inline--fa fa-whatsapp fa-w-14" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" style="width: 12px;"><path fill="currentColor" d="M380.9 97.1C339 55.1 283.2 32 223.9 32c-122.4 0-222 99.6-222 222 0 39.1 10.2 77.3 29.6 111L0 480l117.7-30.9c32.4 17.7 68.9 27 106.1 27h.1c122.3 0 224.1-99.6 224.1-222 0-59.3-25.2-115-67.1-157zm-157 341.6c-33.2 0-65.7-8.9-94-25.7l-6.7-4-69.8 18.3L72 359.2l-4.4-7c-18.5-29.4-28.2-63.3-28.2-98.2 0-101.7 82.8-184.5 184.6-184.5 49.3 0 95.6 19.2 130.4 54.1 34.8 34.9 56.2 81.2 56.1 130.5 0 101.8-84.9 184.6-186.6 184.6zm101.2-138.2c-5.5-2.8-32.8-16.2-37.9-18-5.1-1.9-8.8-2.8-12.5 2.8-3.7 5.6-14.3 18-17.6 21.8-3.2 3.7-6.5 4.2-12 1.4-32.6-16.3-54-29.1-75.5-66-5.7-9.8 5.7-9.1 16.3-30.3 1.8-3.7.9-6.9-.5-9.7-1.4-2.8-12.5-30.1-17.1-41.2-4.5-10.8-9.1-9.3-12.5-9.5-3.2-.2-6.9-.2-10.6-.2-3.7 0-9.7 1.4-14.8 6.9-5.1 5.6-19.4 19-19.4 46.3 0 27.3 19.9 53.7 22.6 57.4 2.8 3.7 39.1 59.7 94.8 83.8 35.2 15.2 49 16.5 66.6 13.9 10.7-1.6 32.8-13.4 37.4-26.4 4.6-13 4.6-24.1 3.2-26.4-1.3-2.5-5-3.9-10.5-6.6z"></path></svg>
                </button>
                <button id="whatsapp_button" class="btn btn-sm btn-default" onclick="window.open(('https://t.me/') + '${phone}')" style="
                padding: 4px 5px;    
                border: none;    
                height: 22px;
                width: 22px;
                background: url(https://upload.wikimedia.org/wikipedia/commons/8/82/Telegram_logo.svg);
                background-size: cover;
                background-repeat: no-repeat;
                ">

                </span>`);
            }
        }
    },50);
});
<!-- WhatsApp-Tlgt Web -->

<!-- Превью в хранилище -->

<!-- Превью в хранилище -->
if(window.location.href.indexOf('/fileservice/control/account/') > -1) {
    $(function(){
        $('#w5-container table tr').each(function(i, row){
            let filetype = $(row).find("td:nth-child(4)").text().trim();
            let filelink = $(row).find("td:nth-child(3) a").attr("href");
            if(["изображение", "image"].indexOf(filetype) > -1) {
                let thumb_img = "";
                if([".gif", ".svg"].indexOf(filelink.substring(filelink.length - 4)) == -1) {
                    let regex = /(.*)\/fileservice\/file\/download(?:\/.*\/)(\d*)\/.*\/(\d*)\/.*\/((?:.*)\w{32}[^\/]*)/gm;
                    let thumb_subst = `$1/fileservice/file/thumbnail/h/$4/s/200x/a/$2/sc/$3`;
                    thumb_img = filelink.replace(regex, thumb_subst);
                } else {
                    thumb_img = filelink;
                }
                $(row).find("td:nth-child(3)").append('<img src="'+thumb_img+'" style="display:block;max-width:200px;" />');
            } else if(["видео", "video"].indexOf(filetype) > -1 || !isNaN(parseInt(filetype))) {
                $(row).find("td:nth-child(3)").append('<video controls src="'+filelink+'" style="display:block;width:200px;height:112px;" />');
            }
        });
    });
}
<!-- Превью в хранилище -->

<!--  Показ ссылки для скачивания, при загрузке файла в ФХ -->
$(()=>{ if(window.location.href.indexOf('/fileservice/control/account/storage') > -1) {
    $('.uploadify-container').data('uploadifive').settings.onUploadComplete = function (e, res) {
        let $item = e.queueItem;
        let link = '/fileservice/control/account/file-by-hash?hash='+res+'&from=storage'
        $item.find('.fileinfo').html(` <a target="_blank" href="${link}">${res}</a> `,);
        $.get(link,(data)=>{
            var pageDom = $('<x/>').append($.parseHTML(data));
            newlink = pageDom.find('input.form-control[type="text"]').val();
            let linke = document.createElement('div');
            let linkc = document.createElement('a');
            $item.find('.filename').before(linke, linkc);
            $(linke).html(newlink)
            .css({"position":"absolute","left":"-99999px"});
            $(linkc).html('<i class="fa fa-clipboard" aria-hidden="true"></i> ')
            .css({"cursor":"pointer"})
            .on('click', function(){
                selectElement(linke);  
                $(linke).select();
                document.execCommand('copy');  
                let that = this;
                $(that).css('color','#ff00db');
                setTimeout(()=>{
                    $(that).css('color','');
                },1000);  
            });
        });
        function selectElement(element) {
            if (window.getSelection) {
                var sel = window.getSelection();
                sel.removeAllRanges();
                var range = document.createRange();
                range.selectNodeContents(element);
                sel.addRange(range);
            } else if (document.selection) {
                var textRange = document.body.createTextRange();
                textRange.moveToElementText(element);
                textRange.select();
            }
        }
    }
    }});
<!--  Показ ссылки для скачивания, при загрузке файла в ФХ -->

<!--  Добавляет возможность перетаскивать блоки настроек в редакторе страниц и уроков -->

if(
window.location.pathname.indexOf("/pl/cms/page/editor") > -1 || 
(
window.location.pathname == "/pl/teach/control/lesson/view" && 
window.location.search.indexOf("editMode=1") > -1
)
) {
    $( document ).ajaxSuccess(function( event, xhr, settings ) {
        if ( settings.url.indexOf("/pl/lite/block/get-setting") > -1 || settings.url.indexOf("/pl/lite/block/settings") > -1) {
            setTimeout(()=>{
                $('.setting-editor-popover, .block-style-popover')
                .draggable({ handle: '.popover-title', cancel: '.btn, input' })
                .find('.popover-title').css({'cursor':'move'});
            });
        }
    });
}

//РЕКЛАМНАЯ ПЛАШКА

// Чтобы исключить отображение для определенной страницы, добавьте путь в массив excludedPages через запятую.
// Например: ["/cms/system/login", "/another/page", "/some/other/page"];

const excludedPages = ["/voting_concurs_baza", "/waitlist_campaign_ticket", "/cms/system/login", "/pl/webinar/show", "/postura_login", "/giftshop", "/live12", "/cadou_personalizat"]; 
if (!excludedPages.includes(window.location.pathname)) {

	var chek = $('#ltBlock2055000206, #ltBlock2055000208, #ltBlock2055000229, #ltBlock2055000232'); // ID формы виджета
	var cookie_max_age = 24 * 60 * 60; //Время жизни cookie в секундах.
	var delay = 1; //Задержка показа в миллисекундах, 1000 = 1 секунде.

	if (getCookie('popup_per_day') !== 'true') {
    	setTimeout(function() {


    	    if (chek.length == 0 && !window.location.href.includes('/widget/')) {
        	    if ($('.gc-main-content').hasClass('with-left-menu')) {
            	    $('.gc-main-content').append('<div class="info-banner menu"><a href="https://fitnessmama.school/plaska_link" target="_blank"><img class="img-responsive banner" src="https://fitnessmama.school/plaska"></a></div>');
            	} else {
                	$('.gc-main-content').append('<div class="info-banner"><a href="https://fitnessmama.school/plaska_link" target="_blank"><img class="img-responsive banner" src="https://fitnessmama.school/plaska"></a></div>');
            	}
        	} else {
            	console.log('на странице форма с ГК');

        	}

        	$('.info-banner').append('<div class="close-mybtn"></div>');
      		$('.close-mybtn').click(function() {
      	    $('.info-banner').hide();
       	    setCookie('popup_per_day', 'true', { 'max-age': cookie_max_age });
       	 });
   	 }, delay);
 	};
};

//FUNCTIONS
function getCookie(name) {
    var matches = document.cookie.match(new RegExp(
    "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
    ));
    return matches ? decodeURIComponent(matches[1]) : undefined;
}

function setCookie(name, value, options = {}) {

    options = {
        path: '/',
            secure: true,
            // при необходимости добавьте другие значения по умолчанию
            ...options
    };

    if (options.expires instanceof Date) {
        options.expires = options.expires.toUTCString();
    }

    var updatedCookie = encodeURIComponent(name) + "=" + encodeURIComponent(value);

    for (var optionKey in options) {
        updatedCookie += "; " + optionKey;
        var optionValue = options[optionKey];
        if (optionValue !== true) {
            updatedCookie += "=" + optionValue;
        }
    }

    document.cookie = updatedCookie;
}

CSS  

/* убрать баннер */
.common-banner-wrapper {
  display:none!important;
}

/* Стили для Баннер как у Геткурс */
  .info-banner {
    width: 400px; /*ширина изображения */ 
    height:120px; /*высота изображения */ 
    display: block; 
    position: fixed; 
    bottom: 10px; 
    left: 10px; 
    Z-index: 9;
        overflow: hidden;
        padding: 20px;
  }
  .info-banner.menu {
    width: 400px; /*ширина изображения */ 
    height:120px; /*высота изображения */ 
    display: block; 
    position: fixed; 
    bottom: 20px; 
    left: 90px; 
    Z-index: 999;
        overflow: hidden;
        padding: 20px;
  }
    .info-banner img.banner {
        border-radius: 16px; /*радиус скругления изображения*/ 
        box-shadow: 0 0 6px 2px #00000069; /*настройки тени*/
    }
.close-mybtn {
    cursor: pointer;
    position: absolute;
    width: 25px;
    height: 25px;
    top: 10px;
    right: 10px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 10px 1px #00000038;
}

.close-mybtn:before {
    content: '✕';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    color: #000;
    font-weight: bold;
    line-height: 1;
    font-size: 14px;
    padding: 6px  6.5px;
}

  @media (max-width:  920px) {
    .info-banner {
      width: 100%; /*ширина изображения */ 
      height:auto; /*высота изображения */ 
      bottom: 10px; 
      left: 0px; 
    }
    .info-banner.menu {
      width: 100%; /*ширина изображения */ 
      height:auto; /*высота изображения */  
      bottom: 50px; 
      left: 0px; 
  }
  }
/* Стили для Баннер как у Геткурс */