You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
3.0 KiB
109 lines
3.0 KiB
GetNoun = function(number, one, two, five) {
|
|
number = Math.abs(number);
|
|
number %= 100;
|
|
if (number >= 5 && number <= 20) {
|
|
return five;
|
|
}
|
|
number %= 10;
|
|
if (number == 1) {
|
|
return one;
|
|
}
|
|
if (number >= 2 && number <= 4) {
|
|
return two;
|
|
}
|
|
return five;
|
|
};
|
|
|
|
GetAdj = function(number, one, two) {
|
|
number %= 100;
|
|
if (number == 11) return two;
|
|
number %= 10;
|
|
if (number == 1) return one;
|
|
return two;
|
|
};
|
|
|
|
setCookie = function(key, value) {
|
|
var expires = new Date();
|
|
expires.setTime(expires.getTime() + (1 * 24 * 60 * 60 * 1000));
|
|
document.cookie = key + '=' + value + ';expires=' + expires.toUTCString() + ';path=/';
|
|
};
|
|
|
|
getCookie = function(name) {
|
|
var matches = document.cookie.match(new RegExp(
|
|
"(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
|
|
));
|
|
|
|
return matches ? decodeURIComponent(matches[1]) : undefined;
|
|
}
|
|
|
|
detectRegion = function() {
|
|
function renderRegionData(current_region) {
|
|
var regions = {
|
|
'Moscow': {
|
|
'city': 'В Москве',
|
|
'phone': '+7 495 775-16-37'
|
|
},
|
|
'St.-Petersburg': {
|
|
'city': 'В Санкт Петербурге',
|
|
'phone': '+7 800 700-16-37'
|
|
},
|
|
'Rostov': {
|
|
'city': 'В Ростове-на-Дону',
|
|
'phone': '+7 863 209-85-65'
|
|
},
|
|
'Krasnodarskiy Kray': {
|
|
'city': 'В Ростове-на-Дону',
|
|
'phone': '+7 863 209-85-65'
|
|
},
|
|
'Stavropol\'skiy Kray': {
|
|
'city': 'В Ростове-на-Дону',
|
|
'phone': '+7 863 209-85-65'
|
|
},
|
|
'Voronezhskaya Oblast': {
|
|
'city': 'В Воронеже',
|
|
'phone': '+7 800 700-16-37'
|
|
},
|
|
'Volgogradskaya Oblast': {
|
|
'city': 'В Волгограде',
|
|
'phone': '+7 800 700-16-37'
|
|
}
|
|
};
|
|
|
|
console.log(current_region);
|
|
|
|
if(typeof current_region !== "undefined") {
|
|
$('.city').text(regions[current_region]['city']);
|
|
$('.header-contacts .consultation h3').text(regions[current_region]['phone']);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
if(typeof getCookie('region') === "undefined" || getCookie('region') == "") {
|
|
var request = $.get('http://ip-api.com/json')
|
|
|
|
request.done(function(data) {
|
|
setCookie('region', data.regionName);
|
|
|
|
renderRegionData(data.regionName);
|
|
});
|
|
} else {
|
|
renderRegionData(getCookie('region'));
|
|
}
|
|
|
|
};
|
|
|
|
$(function() {
|
|
$( "[href^=mailto]" ).click(function() {
|
|
yaCounter950321.reachGoal('EmailClick');
|
|
ga('send', 'event', 'Communication', 'email');
|
|
});
|
|
|
|
$( "[href^='#service-form-submit']" ).click(function(e) {
|
|
e.preventDefault();
|
|
$('.service-calculator form').submit();
|
|
});
|
|
|
|
detectRegion();
|
|
|
|
});
|
|
|