var HOST_CORE = "http://core.pogoda360.ru" var STATIC_HOST_MAPIMAGES = "http://map-icons.pogoda360.ru"; try { document.domain = 'pogoda360.ru'; } catch (e){} if (typeof String.prototype.startsWith != 'function') { String.prototype.startsWith = function (str){ return this.indexOf(str) == 0; }; }; pageInit = function() {}; var ajx = { request: function(params) { jQuery.ajax({ data: params.data, error: function(data, status, request) { if (params.error!=undefined) { params.error(data, status, request); } else { ajx.defaultError(data, status, request); } }, success: function(data, status, request) { if (data.length>=4 && data.substring(0,4)=='err:') { ajx.displayErrorMessage(data.substring(4)); } else { params.success(data, status, request); } }, type: 'POST', url: params.url }); }, defaultError: function(data, status, request) { }, displayErrorMessage: function(msg) { } }; $(document).ready(function() { $('.tabs .tab').click(tabs.setTab); $('.subTabs .subTab').click(tabs.setSubTab); $('#searchCity').width($('#searchMain').width()-70); $('#searchCity').keypress(function(e) { if(e.which == 10 || e.which == 13) { $('#searchForm').submit(); } }).focus(function() { if ($(this).val()=='Поиск по сайту...') $(this).val(''); }).focusout(function() { if ($(this).val()=='') $(this).val('Поиск по сайту...'); });; pageInit(); }); var divClick = function(e) { var a = $(this).find('a'); if (e.ctrlKey) { window.open(a.attr('href'), a.attr('href')+Math.random()); } else { if (a.attr('target')!=undefined) { window.open(a.attr('href'), a.attr('href')+Math.random()); } else { window.location=a.attr('href'); } } e.preventDefault(); }; var divClickOut = function(e) { var href = $(this).find('a').attr('href'); if (!href.startsWith('javascript')) { window.open(href, href); e.preventDefault(); } }; var map = { domain: 'pogoda360.ru', type: 'weather', subtype: '', cityId: 0, markers: [], map: {}, initializeFrameMap: function(w, h, x, y, z, type, subtype, cityId) { map.cityId = cityId; if (type!=undefined) map.type=type; if (subtype!=undefined) map.subtype=subtype; $('#frameMapCanvas').width(w).height(h); map.init(); map.map.setView([y, x], z); }, initializeFrameMapByBorders: function(w, h, x1, y1, x2, y2, type, subtype, cityId) { map.cityId = cityId; if (type!=undefined) map.type=type; if (subtype!=undefined) map.subtype=subtype; $('#frameMapCanvas').width(w).height(h); map.init(); map.map.fitBounds(L.latLngBounds(L.latLng(y2, x1), L.latLng(y1, x2))); }, init: function() { map.map = L.map('frameMapCanvas', {scrollWheelZoom: false}); L.tileLayer('https://tiles.turtella.ru/v1/{z}/{y}/{x}', { attribution: 'Tiles © Esri — Sources: GEBCO, NOAA, CHS, OSU, UNH, CSUMB, National Geographic, DeLorme, NAVTEQ, and Esri', minZoom: 2, maxZoom: 10 }).addTo(map.map); map.map.on('moveend', map.drawIcons); }, drawIcons: function() { var markers = []; var bounds = map.map.getBounds(); jQuery.ajax({ data: {x1: bounds.getWest(), x2: bounds.getEast(), y1: bounds.getSouth(), y2: bounds.getNorth(), width: map.map.getSize().x, height: map.map.getSize().y, cityId: map.cityId}, success: function(data, status, request) { var json = jQuery.parseJSON(data); var newMarkers = []; $.each(map.markers, function(index, m) { m.remove(); }); $.each(json, function(index, resort) { map.markers.push(L.marker([ resort.y, resort.x], {icon: L.icon({iconUrl: map.getIconUrl(resort), iconAnchor: [30, 15]}), data: map.getMainLnk(resort)}).addTo(map.map).on('click', map.markerClick)); }); }, type: 'POST', url: '/ajax/getBoundsResorts/' }); if (map.postProcessor!=undefined) map.postProcessor(); }, markerClick: function(evt) { top.location = evt.target.options.data; }, getIconUrl: function(r) { if (map.type=='weather') { return STATIC_HOST_MAPIMAGES+'/w/'+encodeURIComponent(r.name)+'/'+r.temp+'/'+r.code+'/'; } else if (map.type=='avg') { return STATIC_HOST_MAPIMAGES+'/a/'+encodeURIComponent(r.name)+'/'+eval('r.avg.'+map.subtype)+'/'; } else { if (!r.isMarine) return CORE_HOST+'/img/s.gif'; if (map.subtype=='') { return STATIC_HOST_MAPIMAGES+'/s/'+encodeURIComponent(r.name)+'/'+r.seaTemp+'/'; } else { return STATIC_HOST_MAPIMAGES+'/s/'+encodeURIComponent(r.name)+'/'+eval('r.msst.'+map.subtype)+'/'; } } }, switchMapType: function(type, subtype) { map.type=type; map.subtype=subtype; map.drawIcons(); }, getMainLnk: function(r) { return 'http://'+DOMAINS[r.domain]+'.'+map.domain+'/'+r.id+'/'; } }; var tabs = new Object(); tabs.tab = 'weather'; tabs.subTab = ''; tabs.setTab = function(el) { tabs.tab = $(this).attr('val'); var subType = ''; if (tabs.tab=='avg' || tabs.tab=='sstavg') { subType = 'm1'; } tabs.switchMapType(tabs.tab,subType); }; tabs.setSubTab = function(el) { tabs.switchMapType(tabs.tab, $(this).attr('val')); }; tabs.switchMapType = function(type, subtype) { // redraw tabs $('.tabs .tab').removeClass('tab-sel'); $('.tabs .tab[val="'+type+'"]').addClass('tab-sel'); if (subtype=='') { $('.subTabs').hide(); } else { $('.subTabs').show(); $('.subTabs .subTab').removeClass('subTab-sel'); $('.subTabs .subTab[val="'+subtype+'"]').addClass('subTab-sel'); } if (type=='sstavg') type='sst'; document.getElementById('weatherMapPanel').contentWindow.map.switchMapType(type, subtype); };