Skip to content

Commit 398f772

Browse files
committed
Fixed ie7
1 parent 96507ad commit 398f772

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

lib/utils/local_storage.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
toURL: function(value) {
2727
return "data:text/plain;base64," + Global.Utils.encodeBase64(value || "");
2828
}
29-
}
29+
};
3030

3131
function LocalStorage() {
3232
this.storage = window.localStorage;
@@ -41,10 +41,14 @@
4141
},
4242

4343
saveFileSystem: function() {
44+
if (!this.storage)
45+
return;
4446
this.storage.setItem(this.descriptor, JSON.stringify(this.files));
4547
},
4648

4749
readFileSystem: function() {
50+
if (!this.storage)
51+
return null;
4852
var fileSystem = this.storage.getItem(this.descriptor);
4953
if (!fileSystem)
5054
return {
@@ -55,6 +59,8 @@
5559
},
5660

5761
getDirectoryEntry: function(path, create) {
62+
if (!this.files)
63+
return;
5864
var entry = this.files.root;
5965
for (var i = 0; i < path.length; ++i) {
6066
var folderName = path[i];
@@ -74,6 +80,8 @@
7480
},
7581

7682
saveFileEntry: function(entry, value) {
83+
if (!this.storage)
84+
return;
7785
var filePath = entry.path,
7886
fileName = entry.name,
7987
dirEntry = this.getDirectoryEntry(filePath, true);
@@ -90,6 +98,8 @@
9098
},
9199

92100
removeFileEntry: function(entry, value) {
101+
if (!this.storage)
102+
return;
93103
var filePath = entry.path,
94104
fileName = entry.name,
95105
dirEntry = this.getDirectoryEntry(filePath, true);
@@ -102,6 +112,8 @@
102112
},
103113

104114
loadFileEntry: function(entry) {
115+
if (!this.storage)
116+
return null;
105117
var filePath = entry.path,
106118
fileName = entry.name,
107119
dirEntry = this.getDirectoryEntry(filePath, false);
@@ -115,7 +127,7 @@
115127

116128
get: function(path, callback) {
117129
var self = this;
118-
this.getEntry(path,
130+
this.getEntry(path,
119131
function(err, entry) {
120132
if (err) {
121133
callback(err);
@@ -149,6 +161,8 @@
149161
dirEntry = this.getDirectoryEntry(filePath, true),
150162
list = [],
151163
self = this;
164+
if (!dirEntry)
165+
return callback(null, []);
152166
$.each(dirEntry, function(i, entry) {
153167
list.push(new FileEntry(self, filePath, entry.name));
154168
});

lib/utils/utils.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@
4747
return -1;
4848
};
4949
}
50+
51+
if (!window.console) {
52+
window.console = {
53+
error: function() { },
54+
log: function() { }
55+
};
56+
}
5057

5158
/*
5259
* Helper function to extend the prototype of a class from another base class
@@ -67,7 +74,7 @@
6774
identity: function(a) { return a; },
6875

6976
clone: function(a) {
70-
return JSON.parse(JSON.stringify(a));
77+
return $.extend(true, {}, a);
7178
},
7279

7380
upperCaseFirstLetter: function(str) {

0 commit comments

Comments
 (0)