From f7f8c901f4bc39c3ed0a2bdfe1cbaa1ee6957999 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Mon, 1 Jun 2015 18:04:25 +0800 Subject: Marked as 0.2.9 --- public/js/history.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'public/js/history.js') diff --git a/public/js/history.js b/public/js/history.js index 717a7ca4..c5db94c5 100644 --- a/public/js/history.js +++ b/public/js/history.js @@ -47,7 +47,7 @@ function saveHistoryToStorage(notehistory) { if (store.enabled) store.set('notehistory', JSON.stringify(notehistory)); else - saveHistoryToCookie(notehistory); + saveHistoryToStorage(notehistory); } function saveHistoryToCookie(notehistory) { @@ -146,11 +146,14 @@ function writeHistoryToServer(view) { } catch (err) { var notehistory = []; } + if(!notehistory) + notehistory = []; + var newnotehistory = generateHistory(view, notehistory); saveHistoryToServer(newnotehistory); }) .fail(function () { - writeHistoryToCookie(view); + writeHistoryToStorage(view); }); } @@ -160,7 +163,9 @@ function writeHistoryToCookie(view) { } catch (err) { var notehistory = []; } - + if(!notehistory) + notehistory = []; + var newnotehistory = generateHistory(view, notehistory); saveHistoryToCookie(newnotehistory); } @@ -174,6 +179,9 @@ function writeHistoryToStorage(view) { var notehistory = data; } else var notehistory = []; + if(!notehistory) + notehistory = []; + var newnotehistory = generateHistory(view, notehistory); saveHistoryToStorage(newnotehistory); } else { @@ -241,7 +249,7 @@ function getServerHistory(callback) { } }) .fail(function () { - getCookieHistory(callback); + getStorageHistory(callback); }); } @@ -282,7 +290,7 @@ function parseServerToHistory(list, callback) { } }) .fail(function () { - parseCookieToHistory(list, callback); + parseStorageToHistory(list, callback); }); } -- cgit v1.2.3