{ "CityId": 781, "Name": "Санкт-Петербург", "RegionId": 58 },
function getCookie(name) {
function escape(s) { return s.replace(/([.*+?\^${}()|\[\]\/\\])/g, '\\$1'); };
var match = document.cookie.match(RegExp('(?:^|;\\s*)' + escape(name) + '=([^;]*)'));
return match ? match[1] : null;
};
var cities = [{ "CityId": 781, "Name": "Санкт-Петербург", "RegionId": 58 }],
currentCity = cities.filter(function(data) {
var currentCityId = getCookie('CityId');
return data.CityId == currentCityId;
});
console.log(currentCity);
function getCookie(name) {
var matches = document.cookie.match(new RegExp(
"(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
));
return matches ? decodeURIComponent(matches[1]) : undefined;
}
if (getCookie('CityId') == 781) {
// do stuff
}