summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorWu Cheng-Han2016-10-10 20:55:33 +0800
committerWu Cheng-Han2016-10-10 20:55:33 +0800
commit36a1900ce3496f2d71ae4c41609dc52d24636be2 (patch)
tree1c99b91af2cd54cafef4a3b01b0d2a8d7f551721 /public
parent1d2a9826af247883ff8e67b346263e5e2cd49791 (diff)
Update to make note history count in server-side when user logged
Diffstat (limited to '')
-rw-r--r--public/js/history.js28
1 files changed, 27 insertions, 1 deletions
diff --git a/public/js/history.js b/public/js/history.js
index f9ce2267..9be68104 100644
--- a/public/js/history.js
+++ b/public/js/history.js
@@ -139,7 +139,8 @@ function removeHistory(id, notehistory) {
function writeHistory(view) {
checkIfAuth(
function () {
- writeHistoryToServer(view);
+ // no need to do this anymore, this will count from server-side
+ // writeHistoryToServer(view);
},
function () {
writeHistoryToStorage(view);
@@ -365,4 +366,29 @@ function parseToHistory(list, notehistory, callback) {
}
}
callback(list, notehistory);
+}
+
+function postHistoryToServer(noteId, data, callback) {
+ $.post(serverurl + '/history/' + noteId, data)
+ .done(function (result) {
+ return callback(null, result);
+ })
+ .fail(function (xhr, status, error) {
+ console.error(xhr.responseText);
+ return callback(error, null);
+ });
+}
+
+function deleteServerHistory(noteId, callback) {
+ $.ajax({
+ url: serverurl + '/history' + (noteId ? '/' + noteId : ""),
+ type: 'DELETE'
+ })
+ .done(function (result) {
+ return callback(null, result);
+ })
+ .fail(function (xhr, status, error) {
+ console.error(xhr.responseText);
+ return callback(error, null);
+ });
} \ No newline at end of file