You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ripple.apache.org by br...@apache.org on 2014/04/25 00:29:28 UTC
[09/10] git commit: Addresses #45 - Firefox support related
Addresses #45 - Firefox support related
Project: http://git-wip-us.apache.org/repos/asf/incubator-ripple/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ripple/commit/21641ae5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ripple/tree/21641ae5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ripple/diff/21641ae5
Branch: refs/heads/master
Commit: 21641ae5fefd78d7db0305c412e31fc47fe2280c
Parents: 0ac75c5
Author: Raymond Camden <ra...@gmail.com>
Authored: Tue Apr 15 10:57:12 2014 -0500
Committer: Brent Lintner <br...@gmail.com>
Committed: Thu Apr 24 18:20:54 2014 -0400
----------------------------------------------------------------------
lib/client/db.js | 8 ++++----
lib/client/utils.js | 35 ++++++++++++++++++++---------------
2 files changed, 24 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/21641ae5/lib/client/db.js
----------------------------------------------------------------------
diff --git a/lib/client/db.js b/lib/client/db.js
index a863e66..ecc2fb8 100644
--- a/lib/client/db.js
+++ b/lib/client/db.js
@@ -57,7 +57,7 @@ function save(key, value, prefix, callback) {
var item = createItem(key, value, prefix);
cache[item.id] = item;
- if (!openDatabase) {
+ if (!window.openDatabase) {
saveToStorage();
if (callback) { callback(); }
} else {
@@ -93,7 +93,7 @@ function remove(key, prefix, callback) {
delete cache[id];
- if (!openDatabase) {
+ if (!window.openDatabase) {
saveToStorage();
if (callback) { callback(); }
} else {
@@ -108,7 +108,7 @@ function remove(key, prefix, callback) {
function removeAll(callback) {
cache = {};
- if (!openDatabase) {
+ if (!window.openDatabase) {
delete localStorage[DB_NAME];
saveToStorage();
} else {
@@ -155,7 +155,7 @@ self = {
},
initialize: function (previous, baton) {
- if (!openDatabase) {
+ if (!window.openDatabase) {
var store = localStorage[DB_NAME];
cache = store ? JSON.parse(store) : {};
saveToStorage();
http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/21641ae5/lib/client/utils.js
----------------------------------------------------------------------
diff --git a/lib/client/utils.js b/lib/client/utils.js
index 6d5ecbd..668bb41 100644
--- a/lib/client/utils.js
+++ b/lib/client/utils.js
@@ -262,6 +262,8 @@ self = module.exports = {
initial = init === undefined ? 0 : init,
result = initial;
+ //MozHack for NamedNodeMap
+ if(window.MozNamedAttrMap) NamedNodeMap = window.MozNamedAttrMap;
if (obj instanceof Array) {
return obj.reduce(func, initial);
@@ -288,6 +290,9 @@ self = module.exports = {
returnVal = null,
result = [];
+ //MozHack for NamedNodeMap
+ if(window.MozNamedAttrMap) NamedNodeMap = window.MozNamedAttrMap;
+
if (obj instanceof Array) {
return obj.map(func, scope);
}
@@ -444,26 +449,26 @@ self = module.exports = {
},
navHelper: function () {
- return {
- getHeading: function (lat1, lon1, lat2, lon2) {
+ return {
+ getHeading: function (lat1, lon1, lat2, lon2) {
var dLon = this.rad(lon2 - lon1),
llat1 = this.rad(lat1),
llat2 = this.rad(lat2),
y = Math.sin(dLon) * Math.cos(llat2),
x = Math.cos(llat1) * Math.sin(llat2) - Math.sin(llat1) * Math.cos(llat2) * Math.cos(dLon);
- return (this.deg(Math.atan2(y, x)) + 360) % 360;
+ return (this.deg(Math.atan2(y, x)) + 360) % 360;
},
- getDistance: function (lat1, lon1, lat2, lon2) {
+ getDistance: function (lat1, lon1, lat2, lon2) {
var dLat = this.rad(lat2 - lat1),
dLon = this.rad(lon2 - lon1),
a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(this.rad(lat1)) * Math.cos(this.rad(lat2)) * Math.sin(dLon / 2) * Math.sin(dLon / 2),
c = 2 * Math.asin(Math.sqrt(a)),
d = 6378100 * c;
- return d;
+ return d;
},
- simulateTravel: function (lat, lon, hdg, dist) {
+ simulateTravel: function (lat, lon, hdg, dist) {
var lat1 = this.rad(lat),
lon1 = this.rad(lon),
brng = this.rad(hdg),
@@ -472,19 +477,19 @@ self = module.exports = {
lon2 = lon1 + Math.atan2(Math.sin(brng) * Math.sin(angularDistance) * Math.cos(lat1), Math.cos(angularDistance) - Math.sin(lat1) * Math.sin(lat2));
lon2 = (lon2 + 3 * Math.PI) % (2 * Math.PI) - Math.PI; // Normalize to -180..+180
- return {
- latitude: this.deg(lat2),
- longitude: this.deg(lon2)
- };
+ return {
+ latitude: this.deg(lat2),
+ longitude: this.deg(lon2)
+ };
},
- deg: function (num) {
- return num * 180 / Math.PI;
+ deg: function (num) {
+ return num * 180 / Math.PI;
},
- rad: function (num) {
- return num * Math.PI / 180;
- }
+ rad: function (num) {
+ return num * Math.PI / 180;
+ }
};
},