|
@@ -29,6 +29,20 @@ var ranToken = writeSearch.getRanToken(); |
|
@@ -29,6 +29,20 @@ var ranToken = writeSearch.getRanToken(); |
29
|
var chHammer, cHammer;
|
29
|
var chHammer, cHammer;
|
30
|
|
30
|
|
31
|
chHammer = new Hammer($clearHistory[0]);
|
31
|
chHammer = new Hammer($clearHistory[0]);
|
|
|
32
|
+
|
|
|
33
|
+function isLocalStorageSupported() {
|
|
|
34
|
+ var testKey = 'test',
|
|
|
35
|
+ storage = Window.prototype.localStorage;
|
|
|
36
|
+
|
|
|
37
|
+ try {
|
|
|
38
|
+ storage.setItem(testKey, 'testValue');
|
|
|
39
|
+ storage.removeItem(testKey);
|
|
|
40
|
+ return true;
|
|
|
41
|
+ } catch (error) {
|
|
|
42
|
+ return false;
|
|
|
43
|
+ }
|
|
|
44
|
+}
|
|
|
45
|
+
|
32
|
chHammer.on('tap', function() {
|
46
|
chHammer.on('tap', function() {
|
33
|
dialog.showDialog({
|
47
|
dialog.showDialog({
|
34
|
dialogText: '您确定要删除您的最近搜索吗?',
|
48
|
dialogText: '您确定要删除您的最近搜索吗?',
|
|
@@ -37,7 +51,9 @@ chHammer.on('tap', function() { |
|
@@ -37,7 +51,9 @@ chHammer.on('tap', function() { |
37
|
rightBtnText: '确定'
|
51
|
rightBtnText: '确定'
|
38
|
}
|
52
|
}
|
39
|
}, function() {
|
53
|
}, function() {
|
40
|
- localStorage.removeItem('historys');
|
54
|
+ if (isLocalStorageSupported()) {
|
|
|
55
|
+ localStorage.removeItem('historys');
|
|
|
56
|
+ }
|
41
|
|
57
|
|
42
|
$history.html('');
|
58
|
$history.html('');
|
43
|
$historySearch.hide();
|
59
|
$historySearch.hide();
|
|
@@ -126,19 +142,6 @@ $search.on('touchend', function() { |
|
@@ -126,19 +142,6 @@ $search.on('touchend', function() { |
126
|
return false;
|
142
|
return false;
|
127
|
});
|
143
|
});
|
128
|
|
144
|
|
129
|
-function isLocalStorageSupported() {
|
|
|
130
|
- var testKey = 'test',
|
|
|
131
|
- storage = Window.prototype.localStorage;
|
|
|
132
|
-
|
|
|
133
|
- try {
|
|
|
134
|
- storage.setItem(testKey, 'testValue');
|
|
|
135
|
- storage.removeItem(testKey);
|
|
|
136
|
- return true;
|
|
|
137
|
- } catch (error) {
|
|
|
138
|
- return false;
|
|
|
139
|
- }
|
|
|
140
|
-}
|
|
|
141
|
-
|
|
|
142
|
//初始化历史搜索的内容
|
145
|
//初始化历史搜索的内容
|
143
|
(function() {
|
146
|
(function() {
|
144
|
var html = '',
|
147
|
var html = '',
|
|
@@ -146,7 +149,9 @@ function isLocalStorageSupported() { |
|
@@ -146,7 +149,9 @@ function isLocalStorageSupported() { |
146
|
historys, i, num = 1;
|
149
|
historys, i, num = 1;
|
147
|
|
150
|
|
148
|
if (localStorage) {
|
151
|
if (localStorage) {
|
149
|
- historys = localStorage.getItem('historys');
|
152
|
+ if (isLocalStorageSupported()) {
|
|
|
153
|
+ historys = localStorage.getItem('historys');
|
|
|
154
|
+ }
|
150
|
|
155
|
|
151
|
if (historys && historys.length > 0) {
|
156
|
if (historys && historys.length > 0) {
|
152
|
historys = historys.split(ranToken);
|
157
|
historys = historys.split(ranToken);
|
|
@@ -174,6 +179,6 @@ function isLocalStorageSupported() { |
|
@@ -174,6 +179,6 @@ function isLocalStorageSupported() { |
174
|
}
|
179
|
}
|
175
|
}());
|
180
|
}());
|
176
|
|
181
|
|
177
|
-if (isLocalStorageSupported) {
|
182
|
+if (isLocalStorageSupported()) {
|
178
|
writeSearch.bindWirteLocal($form);
|
183
|
writeSearch.bindWirteLocal($form);
|
179
|
} |
184
|
} |