Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cleanup of Eric's changes

  • Loading branch information...
commit aae6b754653faf32f41192c7ea65ee6dd37dccd2 1 parent f105120
Nicholas authored
View
30 build/gallery-geo/gallery-geo-debug.js
@@ -22,8 +22,11 @@ YUI.add('gallery-geo', function(Y) {
* four properties: success (true/false), coords (an object),
* timestamp, and source ("native" or "geoplugin").
* @param scope {Object} (Optional) The this value for the callback function.
+ * @param opts {Object} (Optional) The PositionOptions object passed to
+ * the getCurrentPosition function and has three optional properties:
+ * enableHighAccuracy (true/false), timeout (number), maximumAge (number).
*/
-function getCurrentPositionByAPI(callback, scope){
+function getCurrentPositionByAPI(callback, scope, opts){
navigator.geolocation.getCurrentPosition(
function(data){
callback.call(scope, {
@@ -45,9 +48,10 @@ function getCurrentPositionByAPI(callback, scope){
if (error.code == 1) { //user denied permission, so don't do anything
callback.call(scope, { success: false, denied: true });
} else { //try Geo IP Lookup instead
- getCurrentPositionByGeoIp(callback,scope);
+ getCurrentPositionByGeoIP(callback,scope);
}
- }
+ },
+ opts
);
}
@@ -56,11 +60,19 @@ function getCurrentPositionByAPI(callback, scope){
* @param callback {Function} The callback function to call when the
* request is complete. The object passed into the request has
* four properties: success (true/false), coords (an object),
- * timestamp, and source ("native" or "geoplugin").
+ * timestamp, and source ("native" or "pidgets.geoip").
* @param scope {Object} (Optional) The this value for the callback function.
+ * @param opts {Object} (Optional) The PositionOptions object passed to
+ * the getCurrentPosition function and has three optional properties:
+ * enableHighAccuracy (true/false) which is ingored, timeout (number),
+ * maximumAge (number) passed to YQL request as maxAge URL-query param.
*/
-function getCurrentPositionByGeoIP(callback, scope){
+function getCurrentPositionByGeoIP(callback, scope, opts){
+ opts = opts || {};
+ var yqlParams = Y.Lang.isNumber(opts.maximumAge) ?
+ { _maxage: opts.maximumAge } : {};
+
Y.YQL("select * from pidgets.geoip", {
on: {
success: function(response){
@@ -84,9 +96,13 @@ function getCurrentPositionByGeoIP(callback, scope){
},
failure: function(){
callback.call(scope, { success: false });
+ },
+ timeout: function(){
+ callback.call(scope, { success: false });
}
- }
- });
+ },
+ timeout: opts.timeout
+ }, yqlParams);
}
View
2  build/gallery-geo/gallery-geo-min.js
@@ -1 +1 @@
-YUI.add("gallery-geo",function(C){function A(E,D){navigator.geolocation.getCurrentPosition(function(F){E.call(D,{success:true,coords:{latitude:F.coords.latitude,longitude:F.coords.longitude,accuracy:F.coords.accuracy,altitude:F.coords.altitude,altitudeAccuracy:F.coords.altitudeAccuracy,heading:F.coords.heading,speed:F.coords.speed},timestamp:F.timestamp,source:"native"});},function(F){if(F.code==1){E.call(D,{success:false,denied:true});}else{getCurrentPositionByGeoIp(E,D);}});}function B(E,D){C.YQL("select * from pidgets.geoip",{on:{success:function(F){var G;if(F.error){E.call(D,{success:false});}else{G=F.query.results.Result;E.call(D,{success:true,coords:{latitude:parseFloat(G.latitude),longitude:parseFloat(G.longitude),accuracy:Infinity},timestamp:+new Date(),source:"pidgets.geoip"});}},failure:function(){E.call(D,{success:false});}}});}C.Geo={getCurrentPosition:navigator.geolocation?A:B};},"@VERSION@",{requires:["yql"]});
+YUI.add("gallery-geo",function(C){function A(F,D,E){navigator.geolocation.getCurrentPosition(function(G){F.call(D,{success:true,coords:{latitude:G.coords.latitude,longitude:G.coords.longitude,accuracy:G.coords.accuracy,altitude:G.coords.altitude,altitudeAccuracy:G.coords.altitudeAccuracy,heading:G.coords.heading,speed:G.coords.speed},timestamp:G.timestamp,source:"native"});},function(G){if(G.code==1){F.call(D,{success:false,denied:true});}else{B(F,D);}},E);}function B(G,E,F){F=F||{};var D=C.Lang.isNumber(F.maximumAge)?{_maxage:F.maximumAge}:{};C.YQL("select * from pidgets.geoip",{on:{success:function(H){var I;if(H.error){G.call(E,{success:false});}else{I=H.query.results.Result;G.call(E,{success:true,coords:{latitude:parseFloat(I.latitude),longitude:parseFloat(I.longitude),accuracy:Infinity},timestamp:+new Date(),source:"pidgets.geoip"});}},failure:function(){G.call(E,{success:false});},timeout:function(){G.call(E,{success:false});}},timeout:F.timeout},D);}C.Geo={getCurrentPosition:navigator.geolocation?A:B};},"@VERSION@",{requires:["yql"]});
View
30 build/gallery-geo/gallery-geo.js
@@ -22,8 +22,11 @@ YUI.add('gallery-geo', function(Y) {
* four properties: success (true/false), coords (an object),
* timestamp, and source ("native" or "geoplugin").
* @param scope {Object} (Optional) The this value for the callback function.
+ * @param opts {Object} (Optional) The PositionOptions object passed to
+ * the getCurrentPosition function and has three optional properties:
+ * enableHighAccuracy (true/false), timeout (number), maximumAge (number).
*/
-function getCurrentPositionByAPI(callback, scope){
+function getCurrentPositionByAPI(callback, scope, opts){
navigator.geolocation.getCurrentPosition(
function(data){
callback.call(scope, {
@@ -45,9 +48,10 @@ function getCurrentPositionByAPI(callback, scope){
if (error.code == 1) { //user denied permission, so don't do anything
callback.call(scope, { success: false, denied: true });
} else { //try Geo IP Lookup instead
- getCurrentPositionByGeoIp(callback,scope);
+ getCurrentPositionByGeoIP(callback,scope);
}
- }
+ },
+ opts
);
}
@@ -56,11 +60,19 @@ function getCurrentPositionByAPI(callback, scope){
* @param callback {Function} The callback function to call when the
* request is complete. The object passed into the request has
* four properties: success (true/false), coords (an object),
- * timestamp, and source ("native" or "geoplugin").
+ * timestamp, and source ("native" or "pidgets.geoip").
* @param scope {Object} (Optional) The this value for the callback function.
+ * @param opts {Object} (Optional) The PositionOptions object passed to
+ * the getCurrentPosition function and has three optional properties:
+ * enableHighAccuracy (true/false) which is ingored, timeout (number),
+ * maximumAge (number) passed to YQL request as maxAge URL-query param.
*/
-function getCurrentPositionByGeoIP(callback, scope){
+function getCurrentPositionByGeoIP(callback, scope, opts){
+ opts = opts || {};
+ var yqlParams = Y.Lang.isNumber(opts.maximumAge) ?
+ { _maxage: opts.maximumAge } : {};
+
Y.YQL("select * from pidgets.geoip", {
on: {
success: function(response){
@@ -84,9 +96,13 @@ function getCurrentPositionByGeoIP(callback, scope){
},
failure: function(){
callback.call(scope, { success: false });
+ },
+ timeout: function(){
+ callback.call(scope, { success: false });
}
- }
- });
+ },
+ timeout: opts.timeout
+ }, yqlParams);
}
View
4 src/gallery-geo/js/geo.js
@@ -58,7 +58,7 @@ function getCurrentPositionByAPI(callback, scope, opts){
* @param callback {Function} The callback function to call when the
* request is complete. The object passed into the request has
* four properties: success (true/false), coords (an object),
- * timestamp, and source ("native" or "geoplugin").
+ * timestamp, and source ("native" or "pidgets.geoip").
* @param scope {Object} (Optional) The this value for the callback function.
* @param opts {Object} (Optional) The PositionOptions object passed to
* the getCurrentPosition function and has three optional properties:
@@ -67,7 +67,7 @@ function getCurrentPositionByAPI(callback, scope, opts){
*/
function getCurrentPositionByGeoIP(callback, scope, opts){
- opts || (opts = {});
+ opts = opts || {};
var yqlParams = Y.Lang.isNumber(opts.maximumAge) ?
{ _maxage: opts.maximumAge } : {};
Please sign in to comment.
Something went wrong with that request. Please try again.