Отформатировал JS с пробелов на табы
This commit is contained in:
parent
4b4514d559
commit
202a2ffb47
|
|
@ -12,9 +12,7 @@ var route = false;
|
||||||
// -------------------------------- Libs ---------------------------------------
|
// -------------------------------- Libs ---------------------------------------
|
||||||
|
|
||||||
function getURLParameter(name) {
|
function getURLParameter(name) {
|
||||||
return decodeURI(
|
return decodeURI((RegExp(name + '=' + '(.+?)(&|$)').exec(location.search) || [, null])[1]);
|
||||||
(RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -34,9 +32,9 @@ function init() {
|
||||||
initCategories()
|
initCategories()
|
||||||
getPoints();
|
getPoints();
|
||||||
|
|
||||||
myMap.events.add('click', function (e) {
|
myMap.events.add('click', function(e) {
|
||||||
if (!myMap.balloon.isOpen()) {
|
if (!myMap.balloon.isOpen()) {
|
||||||
if ( $('#addPointButton').hasClass('btn-success') )
|
if ($('#addPointButton').hasClass('btn-success'))
|
||||||
{
|
{
|
||||||
coords = e.get('coordPosition');
|
coords = e.get('coordPosition');
|
||||||
$('#addPointLat').val(coords[0].toPrecision(11));
|
$('#addPointLat').val(coords[0].toPrecision(11));
|
||||||
|
|
@ -49,9 +47,9 @@ function init() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
myMap.events.add('boundschange', function(e){
|
myMap.events.add('boundschange', function(e) {
|
||||||
if (!myMap.balloon.isOpen()) {
|
if (!myMap.balloon.isOpen()) {
|
||||||
history.pushState({}, document.title, "/?lat="+e.get('newCenter')[0]+"&lng="+e.get('newCenter')[1]+"&zoom="+e.get('newZoom'));
|
history.pushState({}, document.title, "/?lat=" + e.get('newCenter')[0] + "&lng=" + e.get('newCenter')[1] + "&zoom=" + e.get('newZoom'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -93,7 +91,7 @@ function constructPoint(data)
|
||||||
balloonCloseButton: true
|
balloonCloseButton: true
|
||||||
});
|
});
|
||||||
|
|
||||||
points[id].events.add('click', function (e) {
|
points[id].events.add('click', function(e) {
|
||||||
showInfo(e.get('target').properties.get('id'));
|
showInfo(e.get('target').properties.get('id'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -104,15 +102,15 @@ function getPoints()
|
||||||
{
|
{
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/json/points/",
|
url: "/json/points/",
|
||||||
success: function(data){
|
success: function(data) {
|
||||||
for(var k in data) {
|
for (var k in data) {
|
||||||
myMap.geoObjects.add(constructPoint(data[k]));
|
myMap.geoObjects.add(constructPoint(data[k]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getURLParameter('point') != 'null')
|
if (getURLParameter('point') != 'null')
|
||||||
{
|
{
|
||||||
showInfo(getURLParameter('point'));
|
showInfo(getURLParameter('point'));
|
||||||
} else if ( (getURLParameter('lat') != 'null')&&(getURLParameter('lng') != 'null')&&(getURLParameter('zoom') != 'null') )
|
} else if ((getURLParameter('lat') != 'null') && (getURLParameter('lng') != 'null') && (getURLParameter('zoom') != 'null'))
|
||||||
{
|
{
|
||||||
myMap.setCenter([getURLParameter('lat'), getURLParameter('lng')], getURLParameter('zoom'));
|
myMap.setCenter([getURLParameter('lat'), getURLParameter('lng')], getURLParameter('zoom'));
|
||||||
}
|
}
|
||||||
|
|
@ -131,7 +129,7 @@ function showInfo(id)
|
||||||
url: "/json/point/id/" + id,
|
url: "/json/point/id/" + id,
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
description = '<div class="infoCard">' +
|
description = '<div class="infoCard">' +
|
||||||
'<a href="/?point='+id+'">' +
|
'<a href="/?point=' + id + '">' +
|
||||||
'<h3>' + data.name + '</h3>' +
|
'<h3>' + data.name + '</h3>' +
|
||||||
'</a>' +
|
'</a>' +
|
||||||
'<img src="' + data.img + '" />' +
|
'<img src="' + data.img + '" />' +
|
||||||
|
|
@ -151,7 +149,7 @@ function showInfo(id)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
history.pushState({}, document.title, "/?point="+id);
|
history.pushState({}, document.title, "/?point=" + id);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -159,7 +157,7 @@ function initCategories()
|
||||||
{
|
{
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/json/categories/",
|
url: "/json/categories/",
|
||||||
success: function(data){
|
success: function(data) {
|
||||||
categories = data;
|
categories = data;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -171,12 +169,13 @@ function searchAdderess()
|
||||||
{
|
{
|
||||||
var myGeocoder = ymaps.geocode($('#addressField').val());
|
var myGeocoder = ymaps.geocode($('#addressField').val());
|
||||||
myGeocoder.then(
|
myGeocoder.then(
|
||||||
function (res) {
|
function(res) {
|
||||||
search = new ymaps.Placemark(res.geoObjects.get(0).geometry.getCoordinates());
|
search = new ymaps.Placemark(res.geoObjects.get(0).geometry.getCoordinates());
|
||||||
myMap.geoObjects.add(search);
|
myMap.geoObjects.add(search);
|
||||||
myMap.setCenter(res.geoObjects.get(0).geometry.getCoordinates(), 10);
|
myMap.setCenter(res.geoObjects.get(0).geometry.getCoordinates(), 10);
|
||||||
},
|
},
|
||||||
function (err) {}
|
function(err) {
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -193,7 +192,7 @@ function showMeOnTheMap()
|
||||||
function activateAddPoint()
|
function activateAddPoint()
|
||||||
{
|
{
|
||||||
$('#addPointButton').toggleClass('btn-success').toggleClass('btn-default');
|
$('#addPointButton').toggleClass('btn-success').toggleClass('btn-default');
|
||||||
if ( $('#addPointButton').hasClass('btn-success') )
|
if ($('#addPointButton').hasClass('btn-success'))
|
||||||
myMap.cursors.push('crosshair');
|
myMap.cursors.push('crosshair');
|
||||||
else
|
else
|
||||||
myMap.cursors.push('arrow');
|
myMap.cursors.push('arrow');
|
||||||
|
|
@ -227,7 +226,7 @@ function addPoint()
|
||||||
obj.lng = $('#addPointLng').val();
|
obj.lng = $('#addPointLng').val();
|
||||||
obj.categoryIcon = categories[$('#addPointCategoryId').val()].icon;
|
obj.categoryIcon = categories[$('#addPointCategoryId').val()].icon;
|
||||||
|
|
||||||
setTimeout(function(){
|
setTimeout(function() {
|
||||||
myMap.geoObjects.add(constructPoint(obj));
|
myMap.geoObjects.add(constructPoint(obj));
|
||||||
}, 3000);
|
}, 3000);
|
||||||
|
|
||||||
|
|
@ -294,7 +293,7 @@ function buildRoute()
|
||||||
|
|
||||||
function addToRoute(id)
|
function addToRoute(id)
|
||||||
{
|
{
|
||||||
$('#wayPoints').append('<div pointid="'+id+'" class="wayPoint"><span onclick="$(this).parent().remove()">×</span> ' + points[id].properties.get('hintContent') + '</div>');
|
$('#wayPoints').append('<div pointid="' + id + '" class="wayPoint"><span onclick="$(this).parent().remove()">×</span> ' + points[id].properties.get('hintContent') + '</div>');
|
||||||
myMap.balloon.close();
|
myMap.balloon.close();
|
||||||
$('#routeWindow').show(200);
|
$('#routeWindow').show(200);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue