Skip to content

Commit 6840ec3

Browse files
committed
Processing will no longer continue if the input is blank
1 parent 817622d commit 6840ec3

File tree

3 files changed

+26
-19
lines changed

3 files changed

+26
-19
lines changed

js/jquery.storelocator.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* storeLocator v1.1.1 - jQuery store locator plugin
2+
* storeLocator v1.1.2 - jQuery store locator plugin
33
* (c) Copyright 2012, Bjorn Holine (http://www.bjornblog.com)
44
* Released under the MIT license
55
* Distance calculation function by Chris Pietschmann: http://pietschsoft.com/post/2008/02/01/Calculate-Distance-Between-Geocodes-in-C-and-JavaScript.aspx
@@ -87,24 +87,27 @@ $.fn.storeLocator = function(options) {
8787
userinput = userinput.replace("address=","");
8888
if (userinput == "")
8989
{
90+
//Show alert and stop processing
9091
alert("The input box was blank.");
9192
}
92-
93-
var g = new GoogleGeocode();
94-
var address = userinput;
95-
g.geocode(address, function(data) {
96-
if(data != null) {
97-
olat = data.latitude;
98-
olng = data.longitude;
99-
mapping(olat, olng);
100-
} else {
101-
//Unable to geocode
102-
alert('ERROR! Unable to geocode address');
103-
}
104-
});
93+
else
94+
{
95+
var g = new GoogleGeocode();
96+
var address = userinput;
97+
g.geocode(address, function(data) {
98+
if(data != null) {
99+
olat = data.latitude;
100+
olng = data.longitude;
101+
mapping(olat, olng);
102+
} else {
103+
//Unable to geocode
104+
alert('ERROR! Unable to geocode address');
105+
}
106+
});
105107

106-
//Replace spaces in user input
107-
userinput = userinput.replace(" ","+");
108+
//Replace spaces in user input
109+
userinput = userinput.replace(" ","+");
110+
}
108111

109112
});
110113
});

js/jquery.storelocator.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

readme.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ A note on the distance calculation: this plugin currently uses a distance functi
88

99
## Changelog
1010

11+
### Version 1.1.2
12+
13+
Changed it so that the processing stops if the user input is blank.
14+
1115
### Version 1.1.1
1216

1317
Added a modal window option. Set slideMap to false and modalWindow to true to use it. Also started using the new [jQuery .on() event api](http://blog.jquery.com/2011/11/03/jquery-1-7-released/) - make sure you're using jQuery v1.7+ or this won't work.

0 commit comments

Comments
 (0)