]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - js/geometa.js
Needed to add notice_id to selected fields ... :-(
[quix0rs-gnu-social.git] / js / geometa.js
index ced5be06081bd7a8b43b1ee0e0c575976718bcb9..bba59b4486d616b32e754b7912f8142af5b76313 100644 (file)
@@ -1,5 +1,5 @@
 // A shim to implement the W3C Geolocation API Specification using Gears or the Ajax API
-if ( typeof navigator.geolocation == "undefined" || navigator.geolocation.shim ) (function(){
+if (typeof navigator.geolocation == "undefined" || navigator.geolocation.shim ) { (function(){
 
 // -- BEGIN GEARS_INIT
 (function() {
@@ -23,8 +23,7 @@ if ( typeof navigator.geolocation == "undefined" || navigator.geolocation.shim )
       }
     } catch (e) {
       // Safari
-      if ((typeof navigator.mimeTypes != 'undefined')
-           && navigator.mimeTypes["application/x-googlegears"]) {
+      if ((typeof navigator.mimeTypes != 'undefined') && navigator.mimeTypes["application/x-googlegears"]) {
         factory = document.createElement("object");
         factory.style.display = "none";
         factory.width = 0;
@@ -64,8 +63,8 @@ var GearsGeoLocation = (function() {
         return function(position) {
             callback(position);
             self.lastPosition = position;
-        }
-    }
+        };
+    };
     
     // -- PUBLIC
     return {
@@ -94,7 +93,7 @@ var GearsGeoLocation = (function() {
         }
 
     };
-})();
+});
 
 var AjaxGeoLocation = (function() {
     // -- PRIVATE
@@ -103,7 +102,7 @@ var AjaxGeoLocation = (function() {
         if (!hasGoogleLoader() && !loading) {
             loading = true;
             var s = document.createElement('script');
-            s.src = 'http://www.google.com/jsapi?callback=_google_loader_apiLoaded';
+            s.src = (document.location.protocol == "https:"?"https://":"http://") + 'www.google.com/jsapi?callback=_google_loader_apiLoaded';
             s.type = "text/javascript";
             document.getElementsByTagName('body')[0].appendChild(s);
         }
@@ -112,7 +111,7 @@ var AjaxGeoLocation = (function() {
     var queue = [];
     var addLocationQueue = function(callback) {
         queue.push(callback);
-    }
+    };
     
     var runLocationQueue = function() {
         if (hasGoogleLoader()) {
@@ -121,18 +120,18 @@ var AjaxGeoLocation = (function() {
                 call();
             }
         }
-    }
+    };
     
     window['_google_loader_apiLoaded'] = function() {
         runLocationQueue();
-    }
+    };
     
     var hasGoogleLoader = function() {
         return (window['google'] && google['loader']);
-    }
+    };
     
     var checkGoogleLoader = function(callback) {
-        if (hasGoogleLoader()) return true;
+        if (hasGoogleLoader()) { return true; }
 
         addLocationQueue(callback);
                 
@@ -155,28 +154,29 @@ var AjaxGeoLocation = (function() {
             var self = this;
             if (!checkGoogleLoader(function() {
                 self.getCurrentPosition(successCallback, errorCallback, options);
-            })) return;
+            })) { return; }
             
             if (google.loader.ClientLocation) {
                 var cl = google.loader.ClientLocation;
                 
                 var position = {
-                    latitude: cl.latitude,
-                    longitude: cl.longitude,
-                    altitude: null,
-                    accuracy: 43000, // same as Gears accuracy over wifi?
-                    altitudeAccuracy: null,
-                    heading: null,
-                    velocity: null,
-                    timestamp: new Date(),
-                    
+                    coords: {
+                        latitude: cl.latitude,
+                        longitude: cl.longitude,
+                        altitude: null,
+                        accuracy: 43000, // same as Gears accuracy over wifi?
+                        altitudeAccuracy: null,
+                        heading: null,
+                        speed: null
+                    },
                     // extra info that is outside of the bounds of the core API
                     address: {
                         city: cl.address.city,
                         country: cl.address.country,
                         country_code: cl.address.country_code,
                         region: cl.address.region
-                    }
+                    },
+                    timestamp: new Date()
                 };
 
                 successCallback(position);
@@ -208,9 +208,10 @@ var AjaxGeoLocation = (function() {
         }
 
     };
-})();
+});
 
 // If you have Gears installed use that, else use Ajax ClientLocation
-navigator.geolocation = (window.google && google.gears) ? GearsGeoLocation : AjaxGeoLocation;
+navigator.geolocation = (window.google && google.gears) ? GearsGeoLocation() : AjaxGeoLocation();
 
 })();
+}