Fixup js/stores.js
1. Replace == with === and != with !== 2. Fixed variable scrope issue 3. Added missing () to constructors on lines 165 and 186
This commit is contained in:
+13
-11
@@ -53,7 +53,7 @@ function searchLocations()
|
|||||||
var address = document.getElementById('addressInput').value;
|
var address = document.getElementById('addressInput').value;
|
||||||
var geocoder = new google.maps.Geocoder();
|
var geocoder = new google.maps.Geocoder();
|
||||||
geocoder.geocode({address: address}, function(results, status) {
|
geocoder.geocode({address: address}, function(results, status) {
|
||||||
if (status == google.maps.GeocoderStatus.OK)
|
if (status === google.maps.GeocoderStatus.OK)
|
||||||
searchLocationsNear(results[0].geometry.location);
|
searchLocationsNear(results[0].geometry.location);
|
||||||
else
|
else
|
||||||
alert(address+' '+translation_6);
|
alert(address+' '+translation_6);
|
||||||
@@ -76,7 +76,7 @@ function clearLocations(n)
|
|||||||
option.innerHTML = translation_1;
|
option.innerHTML = translation_1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (n == 1)
|
if (n === 1)
|
||||||
option.innerHTML = '1'+' '+translation_2;
|
option.innerHTML = '1'+' '+translation_2;
|
||||||
else
|
else
|
||||||
option.innerHTML = n+' '+translation_3;
|
option.innerHTML = n+' '+translation_3;
|
||||||
@@ -113,7 +113,7 @@ function searchLocationsNear(center)
|
|||||||
createMarker(latlng, name, address, other, id_store, has_store_picture);
|
createMarker(latlng, name, address, other, id_store, has_store_picture);
|
||||||
bounds.extend(latlng);
|
bounds.extend(latlng);
|
||||||
|
|
||||||
$('#stores-table tr:last').after('<tr class="node"><td class="num">'+parseInt(i + 1)+'</td><td><b>'+name+'</b>'+(has_store_picture == 1 ? '<br /><img src="'+img_store_dir+parseInt(id_store)+'-medium.jpg" alt="" />' : '')+'</td><td>'+address+(phone != '' ? '<br /><br />'+translation_4+' '+phone : '')+'</td><td class="distance">'+distance+' '+distance_unit+'</td></tr>');
|
$('#stores-table tr:last').after('<tr class="node"><td class="num">'+parseInt(i + 1)+'</td><td><b>'+name+'</b>'+(has_store_picture === 1 ? '<br /><img src="'+img_store_dir+parseInt(id_store)+'-medium.jpg" alt="" />' : '')+'</td><td>'+address+(phone !== '' ? '<br /><br />'+translation_4+' '+phone : '')+'</td><td class="distance">'+distance+' '+distance_unit+'</td></tr>');
|
||||||
$('#stores-table').show();
|
$('#stores-table').show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,12 +135,14 @@ function searchLocationsNear(center)
|
|||||||
|
|
||||||
function createMarker(latlng, name, address, other, id_store, has_store_picture)
|
function createMarker(latlng, name, address, other, id_store, has_store_picture)
|
||||||
{
|
{
|
||||||
var html = '<b>'+name+'</b><br/>'+address+(has_store_picture == 1 ? '<br /><br /><img src="'+img_store_dir+parseInt(id_store)+'-medium.jpg" alt="" />' : '')+other+'<br /><a href="http://maps.google.com/maps?saddr=&daddr='+latlng+'" target="_blank">'+translation_5+'<\/a>';
|
var html = '<b>'+name+'</b><br/>'+address+(has_store_picture === 1 ? '<br /><br /><img src="'+img_store_dir+parseInt(id_store)+'-medium.jpg" alt="" />' : '')+other+'<br /><a href="http://maps.google.com/maps?saddr=&daddr='+latlng+'" target="_blank">'+translation_5+'<\/a>';
|
||||||
var image = new google.maps.MarkerImage(img_ps_dir+logo_store);
|
var image = new google.maps.MarkerImage(img_ps_dir+logo_store);
|
||||||
|
var marker = '';
|
||||||
|
|
||||||
if (hasStoreIcon)
|
if (hasStoreIcon)
|
||||||
var marker = new google.maps.Marker({ map: map, icon: image, position: latlng });
|
marker = new google.maps.Marker({ map: map, icon: image, position: latlng });
|
||||||
else
|
else
|
||||||
var marker = new google.maps.Marker({ map: map, position: latlng });
|
marker = new google.maps.Marker({ map: map, position: latlng });
|
||||||
google.maps.event.addListener(marker, 'click', function() {
|
google.maps.event.addListener(marker, 'click', function() {
|
||||||
infoWindow.setContent(html);
|
infoWindow.setContent(html);
|
||||||
infoWindow.open(map, marker);
|
infoWindow.open(map, marker);
|
||||||
@@ -160,10 +162,10 @@ function downloadUrl(url, callback)
|
|||||||
{
|
{
|
||||||
var request = window.ActiveXObject ?
|
var request = window.ActiveXObject ?
|
||||||
new ActiveXObject('Microsoft.XMLHTTP') :
|
new ActiveXObject('Microsoft.XMLHTTP') :
|
||||||
new XMLHttpRequest;
|
new XMLHttpRequest();
|
||||||
|
|
||||||
request.onreadystatechange = function() {
|
request.onreadystatechange = function() {
|
||||||
if (request.readyState == 4) {
|
if (request.readyState === 4) {
|
||||||
request.onreadystatechange = doNothing;
|
request.onreadystatechange = doNothing;
|
||||||
callback(request.responseText, request.status);
|
callback(request.responseText, request.status);
|
||||||
}
|
}
|
||||||
@@ -181,7 +183,7 @@ function parseXml(str)
|
|||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
else if (window.DOMParser) {
|
else if (window.DOMParser) {
|
||||||
return (new DOMParser).parseFromString(str, 'text/xml');
|
return (new DOMParser()).parseFromString(str, 'text/xml');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,13 +202,13 @@ $(document).ready(function()
|
|||||||
locationSelect = document.getElementById('locationSelect');
|
locationSelect = document.getElementById('locationSelect');
|
||||||
locationSelect.onchange = function() {
|
locationSelect.onchange = function() {
|
||||||
var markerNum = locationSelect.options[locationSelect.selectedIndex].value;
|
var markerNum = locationSelect.options[locationSelect.selectedIndex].value;
|
||||||
if (markerNum != 'none')
|
if (markerNum !== 'none')
|
||||||
google.maps.event.trigger(markers[markerNum], 'click');
|
google.maps.event.trigger(markers[markerNum], 'click');
|
||||||
};
|
};
|
||||||
|
|
||||||
$('#addressInput').keypress(function(e) {
|
$('#addressInput').keypress(function(e) {
|
||||||
code = e.keyCode ? e.keyCode : e.which;
|
code = e.keyCode ? e.keyCode : e.which;
|
||||||
if(code.toString() == 13)
|
if(code.toString() === 13)
|
||||||
searchLocations();
|
searchLocations();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user