...
|
...
|
@@ -29,6 +29,20 @@ var ranToken = writeSearch.getRanToken(); |
|
|
var chHammer, cHammer;
|
|
|
|
|
|
chHammer = new Hammer($clearHistory[0]);
|
|
|
|
|
|
function isLocalStorageSupported() {
|
|
|
var testKey = 'test',
|
|
|
storage = Window.prototype.localStorage;
|
|
|
|
|
|
try {
|
|
|
storage.setItem(testKey, 'testValue');
|
|
|
storage.removeItem(testKey);
|
|
|
return true;
|
|
|
} catch (error) {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
chHammer.on('tap', function() {
|
|
|
dialog.showDialog({
|
|
|
dialogText: '您确定要删除您的最近搜索吗?',
|
...
|
...
|
@@ -37,7 +51,9 @@ chHammer.on('tap', function() { |
|
|
rightBtnText: '确定'
|
|
|
}
|
|
|
}, function() {
|
|
|
localStorage.removeItem('historys');
|
|
|
if (isLocalStorageSupported()) {
|
|
|
localStorage.removeItem('historys');
|
|
|
}
|
|
|
|
|
|
$history.html('');
|
|
|
$historySearch.hide();
|
...
|
...
|
@@ -126,19 +142,6 @@ $search.on('touchend', function() { |
|
|
return false;
|
|
|
});
|
|
|
|
|
|
function isLocalStorageSupported() {
|
|
|
var testKey = 'test',
|
|
|
storage = Window.prototype.localStorage;
|
|
|
|
|
|
try {
|
|
|
storage.setItem(testKey, 'testValue');
|
|
|
storage.removeItem(testKey);
|
|
|
return true;
|
|
|
} catch (error) {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//初始化历史搜索的内容
|
|
|
(function() {
|
|
|
var html = '',
|
...
|
...
|
@@ -146,7 +149,9 @@ function isLocalStorageSupported() { |
|
|
historys, i, num = 1;
|
|
|
|
|
|
if (localStorage) {
|
|
|
historys = localStorage.getItem('historys');
|
|
|
if (isLocalStorageSupported()) {
|
|
|
historys = localStorage.getItem('historys');
|
|
|
}
|
|
|
|
|
|
if (historys && historys.length > 0) {
|
|
|
historys = historys.split(ranToken);
|
...
|
...
|
@@ -174,6 +179,6 @@ function isLocalStorageSupported() { |
|
|
}
|
|
|
}());
|
|
|
|
|
|
if (isLocalStorageSupported) {
|
|
|
if (isLocalStorageSupported()) {
|
|
|
writeSearch.bindWirteLocal($form);
|
|
|
} |
...
|
...
|
|