diff options
author | Yukai Huang | 2016-10-11 18:39:15 +0800 |
---|---|---|
committer | Yukai Huang | 2016-10-11 18:40:23 +0800 |
commit | 6e651c8108783d224c5f40d1bb8047a9ebbeff00 (patch) | |
tree | c7d501cc6ebb46399c397768b3f58ef05034c522 /public/js/cover.js | |
parent | 21028c57735028574c769fb6650322eb3f0cb924 (diff) | |
parent | cd9f8fe36b707ff5a9f8f7be4d55145ddee97f3a (diff) |
Merge branch 'master' into webpack-frontend
Diffstat (limited to 'public/js/cover.js')
-rw-r--r-- | public/js/cover.js | 92 |
1 files changed, 63 insertions, 29 deletions
diff --git a/public/js/cover.js b/public/js/cover.js index 6346f144..7156bf27 100644 --- a/public/js/cover.js +++ b/public/js/cover.js @@ -35,7 +35,11 @@ var options = { </div>\ </div>\ </a>\ - </li>' + </li>', + page: 18, + plugins: [ + ListPagination({}) + ] }; var historyList = new List('history', options); @@ -183,19 +187,32 @@ function parseHistoryCallback(list, notehistory) { pinned = false; item._values.pinned = false; } - getHistory(function (notehistory) { - for(var i = 0; i < notehistory.length; i++) { - if (notehistory[i].id == id) { - notehistory[i].pinned = pinned; - break; - } - } - saveHistory(notehistory); - if (pinned) - $this.addClass('active'); - else - $this.removeClass('active'); - }); + checkIfAuth(function () { + postHistoryToServer(id, { + pinned: pinned + }, function (err, result) { + if (!err) { + if (pinned) + $this.addClass('active'); + else + $this.removeClass('active'); + } + }); + }, function () { + getHistory(function (notehistory) { + for(var i = 0; i < notehistory.length; i++) { + if (notehistory[i].id == id) { + notehistory[i].pinned = pinned; + break; + } + } + saveHistory(notehistory); + if (pinned) + $this.addClass('active'); + else + $this.removeClass('active'); + }); + }) }); buildTagsFilter(filtertags); } @@ -216,23 +233,40 @@ var clearHistory = false; var deleteId = null; function deleteHistory() { - if (clearHistory) { - saveHistory([]); - historyList.clear(); - checkHistoryList(); - deleteId = null; - } else { - if (!deleteId) return; - getHistory(function (notehistory) { - var newnotehistory = removeHistory(deleteId, notehistory); - saveHistory(newnotehistory); - historyList.remove('id', deleteId); - checkHistoryList(); + checkIfAuth(function () { + deleteServerHistory(deleteId, function (err, result) { + if (!err) { + if (clearHistory) { + historyList.clear(); + checkHistoryList(); + } else { + historyList.remove('id', deleteId); + checkHistoryList(); + } + } + $('.delete-modal').modal('hide'); deleteId = null; + clearHistory = false; }); - } - $('.delete-modal').modal('hide'); - clearHistory = false; + }, function () { + if (clearHistory) { + saveHistory([]); + historyList.clear(); + checkHistoryList(); + deleteId = null; + } else { + if (!deleteId) return; + getHistory(function (notehistory) { + var newnotehistory = removeHistory(deleteId, notehistory); + saveHistory(newnotehistory); + historyList.remove('id', deleteId); + checkHistoryList(); + deleteId = null; + }); + } + $('.delete-modal').modal('hide'); + clearHistory = false; + }); } $(".ui-delete-modal-confirm").click(function () { |