How do I adapt the snippet to work in Mozilla?

The site is implemented a change of cities through a snippet. Works in all browsers except Mozilla, but even where it works it happens with intermittent glitches, when the cities stop changing for a while, and it does not depend on any user actions, an absolute random. No errors in JS in the developer window.
The call looks like this:

        <a href="#block-views-cities-block" data-toggle="modal" data-target="#block-views-cities-block" class="colorbox-inline">
            <img src="/assets/images/cyti.png" alt="city">[[!getGEOInfo? &type=`city`]]
            [[!+gl.real.country.id:select=`122=Алматы&36=Минск`:else=`[[!+gl.real.region.id:select=`524925=Москва&536199=Санкт-Петербург&826294=Владимир&553899=Калуга&501165=Ростов-на-Дону&1496745=Новосибирск&578853=Уфа&703883=Крым`:else=`Москва`]]`]]
       </a>

Snippet:

        <?php
    $regionId = $modx->getPlaceholder('gl.real.region.id');     
    $regionName = $modx->getPlaceholder('gl.real.region.name_ru');   

    $arrCity = array(
        524894 => 'Москва',
        524925 => 'Москва',
        536203 => 'Санкт-Петербург',
        826294 => 'Владимир',
        1490542 => 'Екатеринбург',
        553899 => 'Калуга',
        1496745 => 'Новосибирск',
        578853 => 'Уфа',
        501165 => 'Ростов-на-Дону',
        542415 => 'Краснодар',
        487839 => 'Ставрополь',
        472039 => 'Воронеж',
        479119 => 'Ульяновск',
        484048 => 'Казань',
        499068 => 'Самара',
        36 => 'Минск',
        122 => 'Алматы',
        703883 => 'Крым',
        2027748 => 'Благовещенск',
        2026639 => 'Биробиджан',
        2013162 => 'Якутск',
        2022890 => 'Хабаровск',
        2021851 => 'Комсомольск-на-Амуре',
        2121529 => 'Южно-Сахалинск',
        2125072 => 'Петропавловск-Камчатский',
        2123627 => 'Магадан',
        2013348 => 'Владивосток',
        2019528 => 'Находка',
        2014006 => 'Уссурийск',
        1488754 => 'Тюмень',
        1490624 => 'Сургут',
        524304 => 'Мурманск',
        581043 => 'Архангельск',
        545854 => 'Сыктывкар',
        567293 => 'Махачкала'
    );

    $arrPhones = array(
        524894 => '+7 (495) 128-11-33',
        524925 => '+7 (495) 128-11-33',
        536203 => '+7 (812) 603-70-74',
        826294 => '+7 (4922) 49-45-95 ', 
        1490542 => '+7 (343) 302-08-19', 
        553899 => '+7 (4842) 27-86-65', 
        1496745 => '+7 (383) 235-97-97', 
        578853 => '+7 (347) 225-75-28', 
        501165 => '+7 (863) 333-52-96', 
        542415 => '+7 (861) 212-10-51', 
        487839 => '+7 (865) 257-76-79', 
        472039 => '+7 (473) 212-26-68', 
        479119 => '+7 (8422) 31-51-67', 
        484048 => '+7 (843) 207-09-57', 
        499068 => '+7 (846) 219-26-86',
        36 => '+375(44) 794-19-17',
        122 => '+7 (727) 350-61-00',
        703883 => '+7 (800) 350-08-74',
        2027748 => '+7 (383) 235-97-97',
        2026639 => '+7 (383) 235-97-97',
        2013162 => '+7 (383) 235-97-97',
        2022890 => '+7 (383) 235-97-97',
        2021851 => '+7 (383) 235-97-97',
        2121529 => '+7 (383) 235-97-97',
        2125072 => '+7 (383) 235-97-97',
        2123627 => '+7 (383) 235-97-97',
        2013348 => '+7 (383) 235-97-97',
        2019528 => '+7 (383) 235-97-97',
        2014006 => '+7 (383) 235-97-97',
        1488754 => '+7 (3452) 39-65-53',
        1490624 => '+7 (3452) 39-65-53',
        524304 => '+7 (812) 603-70-74',
        581043 => '+7 (812) 603-70-74',
        545854 => '+7 (812) 603-70-74',
        567293 => '+7 (863) 333-52-96'
    );

    $arrPrice = array(
        524894 => 1,
        524925 => 1,
        536203 => 1,
        826294 => 1,
        1490542 => 1.05,
        553899 => 1,
        1496745 => 1.15,
        578853 => 1.05,
        501165 => 1.05,
        542415 => 1.05,
        487839 => 1.05,
        472039 => 1,
        479119 => 1.05,
        484048 => 1.05,
        499068 => 1.05,
        36 => 1,
        122 => 1.1,
        703883 => 1.1,
        2027748 => 1.32,
        2026639 => 1.32,
        2013162 => 1.32,
        2022890 => 1.37,
        2021851 => 1.37,
        2121529 => 1.37,
        2125072 => 1.37,
        2123627 => 1.37,
        2013348 => 1.37,
        2019528 => 1.37,
        2014006 => 1.37,
        1488754 => 1.1,
        1490624 => 1.15,
        524304 => 1.1,
        581043 => 1.1,
        545854 => 1.1,
        567293 => 1.15
    );

    $arrSesCity = array(
        1 => array('Москва', '+7 (495) 128-11-33', 26, 1),
        2 => array('Санкт-Петербург', '+7 (812) 603-70-74', 84, 1),
        3 => array('Владимир', '+7 (4922) 49-45-95 ', 85, 1),
        4 => array('Екатеринбург', '+7 (343) 302-08-19', 86, 1.05),
        5 => array('Калуга', '+7 (4842) 27-86-65', 87, 1),
        6 => array('Новосибирск', '+7 (383) 235-97-97', 93, 1.15),
        7 => array('Уфа', '+7 (347) 225-75-28', 96,  1.05),
        8 => array('Ростов-на-Дону', '+7 (863) 333-52-96', 94,  1.05),
        9 => array('Краснодар', '+7 (861) 212-10-51', 694,  1.05),
        10 => array('Ставрополь', '+7 (865) 257-76-79', 694,  1.05),
        11 => array('Воронеж', '+7 (473) 212-26-68', 681, 1),
        12 => array('Ульяновск', '+7 (8422) 31-51-67', 616, 1.05),
        13 => array('Казань', '+7 (843) 207-09-57', 615, 1.05),
        14 => array('Самара', '+7 (846) 219-26-86', 691, 1.05),
        15 => array('Минск', '+375(44) 794-19-17', 92, 1),
        16 => array('Алматы', '+7 (727) 350-61-00', 95, 1.1),
        17 => array('Крым', '+7 (800) 350-08-74', 1002, 1.1),
        18 => array('Благовещенск', '+7 (383) 235-97-97', 999, 1.32),
        19 => array('Биробиджан', '+7 (383) 235-97-97', 999, 1.32),
        20 => array('Якутск', '+7 (383) 235-97-97', 999, 1.32),
        21 => array('Хабаровск', '+7 (383) 235-97-97', 999, 1.37),
        22 => array('Комсомольск-на-Амуре', '+7 (383) 235-97-97', 999, 1.37),
        23 => array('Южно-Сахалинск', '+7 (383) 235-97-97', 999, 1.37),
        24 => array('Петропавловск-Камчатский', '+7 (383) 235-97-97', 999, 1.37),
        25 => array('Магадан', '+7 (383) 235-97-97', 999, 1.37),
        26 => array('Владивосток', '+7 (383) 235-97-97', 999, 1.37),
        27 => array('Находка', '+7 (383) 235-97-97', 999, 1.37),
        28 => array('Уссурийск', '+7 (383) 235-97-97', 999, 1.37),
        29 => array('Тюмень', '+7 (3452) 39-65-53', 999, 1.1),
        30 => array('Сургут', '+7 (3452) 39-65-53', 999, 1.15),
        31 => array('Мурманск', '+7 (812) 603-70-74', 999, 1.1),
        32 => array('Архангельск', '+7 (812) 603-70-74', 999, 1.1),
        33 => array('Сыктывкар', '+7 (812) 603-70-74', 999, 1.1),
        34 => array('Махачкала', '+7 (863) 333-52-96', 999, 1.15)
    );

    if(!empty($_SESSION['select_city'])){
        $city = $arrSesCity[$_SESSION['select_city'[0];
    } else if($arrCity[$regionId]){
        $city = $arrCity[$regionId];
    } else {
        $city = 'Москва';
    }

    if(!empty($_SESSION['select_city'])){
        $price = $arrSesCity[$_SESSION['select_city'[3];
    } else if($arrPrice[$regionId]){
        $price = $arrPrice[$regionId];
    } else {
        $price = 1;
    }

    if(!empty($_SESSION['select_city'])){
        $phone = $arrSesCity[$_SESSION['select_city'[1];
    } else if($arrPhones[$regionId]){
        $phone = $arrPhones[$regionId];
    } else {
        $phone = '+7 (495) 128-11-33';
    }

    if($type == 'city') {
        echo $city;
    } else if($type == 'phone') {
        echo $phone;
    }
     else if($type == 'check2') {
        if (!($_SESSION['select_city_first_modal'])) {
            echo 1;
            $_SESSION['select_city_first_modal']=1;
        }
    }
     else if($type =='check') {
        if (!($_SESSION['select_city'])) {
            switch ($city) {
                case 'Москва':
                    $_SESSION['select_city']=1;
                    break;
                case 'Санкт-Петербург':
                    $_SESSION['select_city']=2;
                    break;
                case 'Владимир':
                    $_SESSION['select_city']=3;
                    break;
                case 'Екатеринбург':
                    $_SESSION['select_city']=4;
                    break;
                case 'Калуга':
                    $_SESSION['select_city']=5;
                    break;
                case 'Новосибирск':
                    $_SESSION['select_city']=6;
                    break;
                case 'Уфа':
                    $_SESSION['select_city']=7;
                    break;
                case 'Ростов-на-Дону':
                    $_SESSION['select_city']=8;
                    break;
                case 'Краснодар':
                    $_SESSION['select_city']=9;
                    break;
                case 'Ставрополь':
                    $_SESSION['select_city']=10;
                    break;
                case 'Воронеж':
                    $_SESSION['select_city']=11;
                    break;
                case 'Ульяновск':
                    $_SESSION['select_city']=12;
                    break;
                case 'Казань':
                    $_SESSION['select_city']=13;
                    break;
                case 'Самара':
                    $_SESSION['select_city']=14;
                    break;
                case 'Минск':
                    $_SESSION['select_city']=15;
                    break;
                case 'Алматы':
                    $_SESSION['select_city']=16;
                    break;
                case 'Крым':
                    $_SESSION['select_city']=17;
                    break;
                case 'Благовещенск':
                    $_SESSION['select_city']=18;
                    break;
                case 'Биробиджан':
                    $_SESSION['select_city']=19;
                    break;
                case 'Якутск':
                    $_SESSION['select_city']=20;
                    break;
                case 'Хабаровск':
                    $_SESSION['select_city']=21;
                    break;
                case 'Комсомольск-на-Амуре':
                    $_SESSION['select_city']=22;
                    break;
                case 'Южно-Сахалинск':
                    $_SESSION['select_city']=23;
                    break;
                case 'Петропавловск-Камчатский':
                    $_SESSION['select_city']=24;
                    break;
                case 'Магадан':
                    $_SESSION['select_city']=25;
                    break;
                case 'Владивосток':
                    $_SESSION['select_city']=26;
                    break;
                case 'Находка':
                    $_SESSION['select_city']=27;
                    break;
                case 'Уссурийск':
                    $_SESSION['select_city']=28;
                    break;
                case 'Тюмень':
                    $_SESSION['select_city']=29;
                    break;
                case 'Сургут':
                    $_SESSION['select_city']=30;
                    break;
                case 'Мурманск':
                    $_SESSION['select_city']=31;
                    break;
                case 'Архангельск':
                    $_SESSION['select_city']=32;
                    break;
                case 'Сыктывкар':
                    $_SESSION['select_city']=33;
                    break;
                case 'Махачкала':
                    $_SESSION['select_city']=34;
                    break;
            }
        }
    }
    else if($type == 'test') {
        echo $regionId.'   '.$regionName;
    }
    else if($type == 'price') {
        echo $price;
    } else if($type == 'phoneF') {
        
        $f = preg_replace ("/[^0-9+]/","",$phone);
        
        echo $f;
    } else if($type == 'id') {
        if(!empty($_SESSION['select_city']) && !empty($arrSesCity[$_SESSION['select_city'[2])){
            echo ($arrSesCity[$_SESSION['select_city'[2]);
        } else {
            echo '26';
        }
    }

Handler in JS:

    (function ($) {
    $.browser = {};
//=====================
    /*--------------------------------------------------------------------------------------*/
       var ReCaptchaCallback = function () {
                // alert('Hello,I am fine');
                $('.g-recaptcha').each(function (index, el) {
                    grecaptcha.render(el, {'sitekey': '6Lf4NCcUAAAAACB89puSRNf3Rmr9tv3zziNVjPJP'});
                    // console.log(grecaptcha);
                });
                
            };
    
     setCity = function (id) {
		 
            var city_name = $('#block-views-cities-block').find('.act-select-city[data-id=' + id + ']').attr('data-city-name');
            //var city_phone = $('#block-views-cities-block').find('.act-select-city[data-id=' + id + '] .call_phone_1_1').text();

			
			//alert(city_name);
			//alert(city_phone);
			

            localStorage.setItem('city_id', id);
            $.cookie('city_id', id, { expires: 120 });
            localStorage.setItem('city_name', city_name);
            localStorage.setItem('city_phone', city_phone);
            setPhoneToHtml();
            deferReload();
            window.location.reload();
			
			
        };
        
    getLocation = function () {
       
        /*
        $.getJSON('//freegeoip.net/json/?callback=?', function (data) {
	

            var lat = JSON.stringify(data.latitude);
            var lng = JSON.stringify(data.longitude);

			

            if (   ((53.27 < lat) && (lat < 55.31)) && ((33.405 < lng) && (lng < 37.22))  ) {
                //Kaluga
                setCity(212);
            } else if (((54.45 < lat) && (lat < 56.94)) && ((35.148 < lng) && (lng < 40.08))) {
                //Moscow
                setCity(77);
            } else if (
                    ((55.17 < lat) && (lat < 56.776)) && ((38.465 < lng) && (lng < 42.926)) ||
                    ((50.17 < lat) && (lat < 58.776)) && ((41.465 < lng) && (lng < 46.926)) ||
                    ((50.17 < lat) && (lat < 52.776)) && ((46.465 < lng) && (lng < 49.926)) ||
                    ((40.17 < lat) && (lat < 51.776)) && ((46.465 < lng) && (lng < 86.926)) ||
                    ((50.17 < lat) && (lat < 54.776)) && ((61.465 < lng) && (lng < 78.926))
                    ) {
                //Vladimir
                setCity(168);
            } else if (((51.509 < lat) && (lat < 55.7125)) && ((23.6123 < lng) && (lng < 31.41265))) {
                //Belarus
                setCity(323);
            } else if (
                    ((45.93 < lat) && (lat < 49.97)) && ((38.3888 < lng) && (lng < 44.18)) ||
                    ((43.93 < lat) && (lat < 46.97)) && ((32.3888 < lng) && (lng < 36.18)) ||
                    ((40.93 < lat) && (lat < 51.97)) && ((37.3888 < lng) && (lng < 48.18))
                    || ((46.3888 < lat) && (lat < 50.18)) && ((35.3888 < lng) && (lng < 37.18))
                    ) {
                //Rostov
                setCity(353);

            } else if (
                    ((55.45 < lat) && (lat < 61.18)) && ((27.91 < lng) && (lng < 35.36)) ||
                    ((58.45 < lat) && (lat < 70)) && ((25.91 < lng) && (lng < 63.36))
                    ) {
                //Piter
                setCity(167);
            } else  if (
                    ((51.56 < lat) && (lat < 56.43)) && ((53.41 < lng) && (lng < 59.70)) ||
                    ((52.56 < lat) && (lat < 57.43)) && ((47.41 < lng) && (lng < 54.70)) ||
                    ((52.56 < lat) && (lat < 64.43)) && ((46.041 < lng) && (lng < 70.70)) ||
                    ((61.56 < lat) && (lat < 73.43)) && ((59.41 < lng) && (lng < 85.70))
                    ) {
                //Ufa
                setCity(203);
            } else  if (
                    ((53.52 < lat) && (lat < 57.17)) && ((75.14 < lng) && (lng < 89.23)) ||
                    ((50.52 < lat) && (lat < 77.17)) && ((71.14 < lng) && (lng < 178.23)) ||
                    ((42.52 < lat) && (lat < 53.17)) && ((87.14 < lng) && (lng < 144.23))
                    ) {
                //Novosibirsk
                setCity(204);
            } else {
                window.setTimeout(function () {
                    $.colorbox({inline: true, href: '#block-views-cities-block'});
                    localStorage.setItem('cityWindowShown', 1);
                }, 2000);
            }
            localStorage.setItem('nav', 1);
        });
        */
    }
    
    
    
    setTimeout(function () {
        localStorage.setItem('nav', 'null');
    }, 604800000); //60480000

    /*--------------------------------------------------------------------------------------*/

	
	

    checkLocation = function () {
        
		
		
		
		var nav = localStorage.getItem('nav');
        var city_name = localStorage.getItem('city_name');

		
		//getLocation();
		
		
        if (!nav || nav == 'undefined' || nav == 'null') {		
            getLocation();
        } else {
        }
		
		
		
    }


    /*--------------------------------------------------------------------------------------*/



    setPhoneToHtml = function () {
        var phone = localStorage.getItem('city_phone');
        // console.log(phone);
        var city_name = localStorage.getItem('city_name');
        // console.log(city_name);
        if (!phone || !city_name || phone == 'undefined' || city_name == 'null') {
            phone = $('#block-views-cities-block a[data-id="' + localStorage.getItem('city_id') + '"]').find('.phone-container').html();
            city_name = $('#block-views-cities-block a[data-id="' + localStorage.getItem('city_id') + '"]').data('city-name');
            localStorage.setItem('city_name', city_name);
            localStorage.setItem('city_phone', phone);
        }

        if (city_name && phone) {
            $('#block-views-cities-block-1 .views-field-field-shop-city a').html('<img src="/assets/images/cyti.png" alt="city">' + city_name);
            $('#block-views-cities-block-1 .views-field-field-phone .field-content').html(phone);
//            $('#block-block-8 .content p:last').html('<a href="tel:'+phone.replace(/<\/span>|<span class="call_phone_1_1 roistat499_tn">|\-|\s|\(|\)/gi,'')+'">'+phone+'</a>');
            $('#block-block-8 .content p:last').html('<a href="tel:'+phone.replace(/<\/span>|<span class="call_phone_1_1">|\-|\s|\(|\)/gi,'')+'">'+phone+'</a>');
            $('#block-block-1').find('.citi-name').html('<img src="/assets/images/cyti.png" alt="city">' + city_name);
            $('#block-block-1').find('.call_phone_1').html(phone);
          //setActiveCityMenu();
          //console.log(city_name);
          //console.log(phone);
          //
          setCityIdToSession();
          $('#block-views-cities-block').modal('hide');
        }

    };

    setCityIdToSession = function () {
        $(document).trigger('cityIdSavedToSession');
    }

    deferReload = function () {
        //$(document).on('cityIdSavedToSession', function (e) {
         window.location.reload();
        //});
    }


    $(function () {
        if (Modernizr.localstorage) {
            if (localStorage.getItem('cityWindowShown')) {
                setPhoneToHtml();
            } else {
                window.setTimeout(function () {
                    // $.colorbox({inline: true, href: '#block-views-cities-block'});
                    localStorage.setItem('cityWindowShown', 1);
                }, 2000);
            }
        }
    });

            // Find all the secure links inside context that do not have our processed
            // class.
            $('.follow-links a').on('click', function (e) {
                e.preventDefault();
                window.open($(this).attr('href'), '_blank');
            });

            $("a[href^='http://']").attr("target", "_blank").addClass('external-link');

   


            if (!$('.tabs-wrapp .mdl-tabs__tab.is-active').length) {
                $('.tabs-wrapp .mdl-tabs__tab').first().addClass('is-active');
                $('.tabs-wrapp .mdl-tabs__panel').first().addClass('is-active');
            }

            $(document).on('contextmenu', '#cboxContent img', function () {
                
				//return false;
				
				return true;
				
            });

            $.each($('.page-node .field-name-body'), function (i, el) {
                $(el).find('.readmore-el').wrapAll('<div class="readmore-container">');
            });
            $('.readmore-container').readmore({
                moreLink: '<a href="#">Подробнее</a>',
                lessLink: '<a href="#">Свернуть</a>'
            });

            //------------------------------------------------------------------------------------------------------------.

            $('#sidebar-first').find(' .form-item.form-type-bef-link:has(a.active)').addClass('active active-trail');
            $('#sidebar-first').find(' li:has(a.active)').addClass('active active-trail');
            $('#sidebar-first').find(' .form-item.form-type-bef-link:has(a.active)').addClass('active active-trail');
            $('#colorbox').find('#cboxClose').appendTo('#otzuv-node-form #edit-actions--2');
           //=====================

            checkLocation();

            $('.cbox-close-link').click(function () {
                $(this).closest('#colorbox').find('#cboxClose').click();
            });
            $('.act-select-city').click(function (e) {
                e.preventDefault();
                // console.log(localStorage);
                $.cookie('city_id', $(this).data('id'), { expires: 120 });
                localStorage.setItem('city_id', $(this).data('id'));
                
                localStorage.setItem('city_name', $(this).data('city-name'));
                localStorage.setItem('city_phone', $(this).find('.phone-container').html());
                $(this).closest('#colorbox').find('#cboxClose').click();
                setPhoneToHtml();
                //deferReload();
                
                $.ajax({
                      url: '/assets/snippets/setSession.php',
                      data: 'sesstionCity='+$(this).attr('data-session'),
                      method: 'GET',
                      success : function(data){
                         if(data) {
                             //console.log(data);
                         }
                      }
                   });
                
                
                
                window.location.reload();
            });


            $('#colorbox').find('#cboxClose').appendTo('#views-exposed-form-cities-block .views-exposed-widgets');

            $('#modalContent').find('.popups-close').appendTo('.webform-client-form .form-actions');


            $('.view-faqs  a[href*=\\#]:not([href=\\#])').click(function () {
                if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
                    var target = $(this.hash);
                    target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
                    if (target.length) {
                        $('html,body').animate({
                            scrollTop: target.offset().top - 70
                        }, 1000);
                        return false;
                    }
                }
            });
            $('.view-faqs  .admin-menu').find('.view-faqs  a[href*=#]:not([href=#])').click(function () {
                if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
                    var target = $(this.hash);
                    target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
                    if (target.length) {
                        $('html,body').animate({
                            scrollTop: target.offset().top - 100
                        }, 1000);
                        return false;
                    }
                }
            });

           /* $('.view-main-banner .view-content').fotorama({
                width: '100%',
                maxheight: '450',
                minheight: '300',
                ratio: '1300/300',
                fit: 'cover',
                transition: 'crossfade',
                transitionduration: '500',
                autoplay: '3000',
                stopautoplayontouch: true,
                loop: true,
                arrows: false,
                click: false
            });*/

            /*$(window).resize(function () {
                $('.teaser3 ').selectorsEqualizer();
            });*/

            $('.ctools-auto-submit-full-form').find('.bef-checkboxes, .bef-select-as-radios').find('.form-item:has(input:checked)').addClass('checked');
            $('.ctools-auto-submit-full-form').find('.bef-select-as-radios:checked').click(function (e) {
                $(this).closest('.form-radios').find('input[value="All"]').click();
            });

            $('.zakaz').click(function () {
                var title = $(this).attr('data-title');
                var price = $(this).attr('data-price-packing');
                var link = $(this).attr('data-link');

                $('#webform-client-form-9').find('.webform-component--variant-tovara input').val(title);
                $('#webform-client-form-9').find('.webform-component--cena-za-up input').val(price);
                $('#webform-client-form-9').find('.webform-component--ssylka-na-tovar input').val(link);


                $('#webform-client-form-9').find('.webform-component--variant-tovara input').attr('value', title);
                $('#webform-client-form-9').find('.webform-component--cena-za-up input').attr('value', price);
                $('#webform-client-form-9').find('.webform-component--ssylka-na-tovar input').attr('value', link);
                var text = 'за уп.';

                if ($(this).is('.ready-solution-zakaz')) {
                    text = 'за м<sup>2</sup>.';
                }

                //--form--
                var src = $('.fotorama__img:first').attr('src');
                $('#webform-client-form-9').find('.colorbox-title').empty();
                $('#webform-client-form-9').prepend('<h3 class="colorbox-title"><img src="' + src + '" /><span class="title-t">' + title + '</span>  <span class="price-t">' + price + ' </span><span class="cena">' + text + '</span></h3>');

            });

            $('#colorbox').find('#cboxClose').appendTo('#cboxContent .webform-client-form .form-actions');
            $('#colorbox').find('#cboxClose').appendTo('#cboxContent .node-form  .form-actions');
            $(document).ajaxComplete(function () {
                $('#edit-field-tip-metki-tid-wrapper .form-type-bef-checkbox').click(function () {
                    $('#edit-field-tip-metki-tid-wrapper .form-type-bef-checkbox').removeClass('active active-trail');
                    $(this).addClass('active active-trail');
                });
                $('#colorbox').find('#cboxClose').appendTo('#otzuv-node-form #edit-actions--2');
                $('.ctools-auto-submit-full-form').find('.bef-checkboxes .form-item:has(input:checked)').addClass('checked');


                $('.zakaz').click(function () {
                    var title = $(this).attr('data-title');
                    var price = $(this).attr('data-price-packing');
                    var link = $(this).attr('data-link');

                    $('#webform-client-form-9').find('.webform-component--variant-tovara input').val(title);
                    $('#webform-client-form-9').find('.webform-component--cena-za-up input').val(price);
                    $('#webform-client-form-9').find('.webform-component--ssylka-na-tovar input').val(link);


                    $('#webform-client-form-9').find('.webform-component--variant-tovara input').attr('value', title);
                    $('#webform-client-form-9').find('.webform-component--cena-za-up input').attr('value', price);
                    $('#webform-client-form-9').find('.webform-component--ssylka-na-tovar input').attr('value', link);

                    if ($(this).is('.ready-solution-zakaz')) {
                        text = 'за м<sup>2</sup>.';
                    }
                    //--form--
                    var src = $('.fotorama__img:first').attr('src');
                    $('#webform-client-form-9').find('.colorbox-title').empty();
                    $('#webform-client-form-9').prepend('<h3 class="colorbox-title"><img src="' + src + '" /><span class="title-t">' + title + '</span>  <span class="price-t">' + price + ' </span><span class="cena">' + text + '</span></h3>');

                });

            });

            $(window).bind('scroll', function () {
                if ($(this).scrollTop() > 100) {

                    $('.header-sticky').removeClass('hidden');
                    $('body').addClass('with-sticky-header');
                } else {
                    $('.header-sticky').addClass('hidden');
                    $('body').removeClass('with-sticky-header');
                }
            });
            $('.to-top').click(function () {
                $('html,body').animate({
                    scrollTop: 0
                }, 500);
                return false;
            });

            $(document).on('click', '.fotorama__wrap-link .colorbox-trigger', function (e) {
                e.preventDefault();
                var i = $(this).data('item');
                $('.colorbox-gal-item a[data-item="' + i + '"]').click();
            });
            if ($('.variants-container table').length) {
                var num_of_columns = $('.variants-container table').find('tbody>tr:first>td').length;
                if (num_of_columns < 7) {
                    $('.variants-container table').width((num_of_columns * (100 / 7)) + '%');
                }
            }

            //------------------------------------------------------------------------------------------------------------

            $('.my-tooltip-trigger').click(function () {
                var $trg = $('.mdl-tooltip--my[for="' + $(this).attr('id') + '"]');
                $trg.css({
                    top: $(this).position().top + 20,
                    left: $(this).position().left - $trg.outerWidth(true) / 2
                });
                $trg.toggleClass('mdl-tooltip--my--shown');
            });

            $(document).mouseup(function (e) {
                var container = $(".mdl-tooltip--my, .my-tooltip-trigger");
                if (!container.is(e.target) && container.has(e.target).length === 0) {
                    $('.mdl-tooltip--my--shown').removeClass('mdl-tooltip--my--shown');
                }
            });



    $(function () {
        MaterialSnackbar.prototype.displaySnackbar_ = function () {
            this.element_.setAttribute('aria-hidden', 'true');

            if (this.actionHandler_) {
                this.actionElement_.textContent = this.actionText_;
                this.actionElement_.addEventListener('click', this.actionHandler_);
                this.setActionHidden_(false);
            }

            this.textElement_.innerHTML = this.message_;
            this.element_.classList.add(this.cssClasses_.ACTIVE);
            this.element_.setAttribute('aria-hidden', 'false');
            setTimeout(this.cleanup_.bind(this), this.timeout_);
        };
    });    
	
}(jQuery));


If any information is missing, write in the comments I will add…
MODX Revo

I apologize for the mistakes in the description, I use a translator

I’ve never had good luck using nested tags with conditional logic, even if they’re called uncached. I’ve had many instances where nested tags like this will output unpredictably or not at all. It may not be the problem in this case, but I’d recommend moving your nested tag logic into your snippet just to be sure everything is processing correctly.

With the code you provide a lot remains unclear:

  • You set the cookie value ‘city_id’ ($.cookie('city_id', id);) and then reload the page, but where to do read this value from the cookie?
  • You read the placeholder ‘gl.real.region.id’ in the snippet ($modx->getPlaceholder('gl.real.region.id');) but where do you set this placeholder?
  • You read the value ‘select_city’ from the session in the snippet ($_SESSION['select_city']) but this value only gets set when $type =='check'. Where do you call the snippet with $type =='check'?

I don’t think you can use the else modifier after a select modifier:

[[!+gl.real.country.id:select=`122=Алматы&36=Минск`:else=`...`]]

But it should work with the default modifier:

[[!+gl.real.country.id:select=`122=Алматы&36=Минск`:default=`...`]]

I’m sorry, this is not my snippet and I have to deal with what is left of the previous developer, so I do not understand what you wrote…

I put in a complete JS file, is this information enough?
The default option does not work

I’m not very keen on reading 400+ lines of js-code (and without the corresponding html it would be hard to understand what the code does anyway).

  • The function setCity (that you published initially) doesn’t get called anywhere!
  • Which function should I focus on? $('.act-select-city').click(function (e) {..}?
  • What is “The default option”?

Bit late to the party but …
The following lines don’t look right, not enough closing square brackets.

if(!empty($_SESSION['select_city']) && !empty($arrSesCity[$_SESSION['select_city'[2])){
    echo ($arrSesCity[$_SESSION['select_city'[2]);

Also the use of “else if” is a concern, you might want to replace them with “elseif”.
I believe the code

    if($type == 'city') {
        echo $city;
    } else if($type == 'phone') {
        echo $phone;
    }
     else if($type == 'check2') {
        if (!($_SESSION['select_city_first_modal'])) {
            echo 1;
            $_SESSION['select_city_first_modal']=1;
        }
    }

is interpreted as …

    if ($type == 'city') {
        echo $city;
    } else {
        if ($type == 'phone') {
            echo $phone;
        } else {
            if ($type == 'check2') {
                if (!($_SESSION['select_city_first_modal'])) {
                    echo 1;
                    $_SESSION['select_city_first_modal']=1;
                }
            }

Which might not be what is intended.
The standards recommend elseif instead of else if.

    if ($type == 'city') {
        echo $city;
    } elseif ($type == 'phone') {
        echo $phone;
    }
     elseif ($type == 'check2') {
        if (!($_SESSION['select_city_first_modal'])) {
            echo 1;
            $_SESSION['select_city_first_modal']=1;
        }
    }
    elseif ($type =='check') { etc.

Perhaps the tests of $type would be clearer as switch ($type) …

switch ($type) {
    case 'city':
        echo $city;
        break;
    case 'phone':
        echo $phone;
        break;
    case 'check2':
        if (!($_SESSION['select_city_first_modal'])) {
            echo 1;
            $_SESSION['select_city_first_modal']=1;
        }
        break;
    case 'check':
etc.

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.