Support pinning note in history

This commit is contained in:
Wu Cheng-Han 2015-10-22 17:09:55 +08:00
parent 5ed395122d
commit 2cfcae6db2
3 changed files with 85 additions and 7 deletions

View file

@ -111,12 +111,13 @@ function clearDuplicatedHistory(notehistory) {
return newnotehistory;
}
function addHistory(id, text, time, tags, notehistory) {
function addHistory(id, text, time, tags, pinned, notehistory) {
notehistory.push({
id: id,
text: text,
time: time,
tags: tags
tags: tags,
pinned: pinned
});
return notehistory;
}
@ -232,8 +233,16 @@ function renderHistory(view) {
function generateHistory(view, notehistory) {
var info = renderHistory(view);
//keep any pinned data
var pinned = false;
for (var i = 0; i < notehistory.length; i++) {
if (notehistory[i].id == info.id && notehistory[i].pinned) {
pinned = true;
break;
}
}
notehistory = removeHistory(info.id, notehistory);
notehistory = addHistory(info.id, info.text, info.time, info.tags, notehistory);
notehistory = addHistory(info.id, info.text, info.time, info.tags, pinned, notehistory);
notehistory = clearDuplicatedHistory(notehistory);
return notehistory;
}