Fixed index clear history list not working, history list will now be id-unique, fixed typo and styles
This commit is contained in:
parent
6bdc63ca60
commit
c06fb7a526
4 changed files with 22 additions and 13 deletions
|
@ -207,7 +207,7 @@ input {
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
}
|
}
|
||||||
.list li * {
|
.list li * {
|
||||||
word-break: break-all;
|
word-break: break-word;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
}
|
}
|
||||||
.list li a {
|
.list li a {
|
||||||
|
|
|
@ -232,6 +232,7 @@
|
||||||
<script src="/vendor/list.min.js" defer></script>
|
<script src="/vendor/list.min.js" defer></script>
|
||||||
<script src="/vendor/FileSaver.min.js" defer></script>
|
<script src="/vendor/FileSaver.min.js" defer></script>
|
||||||
<script src="/vendor/store.min.js" defer></script>
|
<script src="/vendor/store.min.js" defer></script>
|
||||||
|
<script src="/vendor/lz-string.min.js" defer></script>
|
||||||
<script src="/js/common.js" defer></script>
|
<script src="/js/common.js" defer></script>
|
||||||
<script src="/js/history.js" defer></script>
|
<script src="/js/history.js" defer></script>
|
||||||
<script src="/js/cover.js" defer></script>
|
<script src="/js/cover.js" defer></script>
|
||||||
|
|
|
@ -8,7 +8,7 @@ var options = {
|
||||||
<div class="content">\
|
<div class="content">\
|
||||||
<h4 class="text"></h4>\
|
<h4 class="text"></h4>\
|
||||||
<p>\
|
<p>\
|
||||||
<i><i class="fa fa-clock-o"></i> visit </i><i class="fromNow"></i>\
|
<i><i class="fa fa-clock-o"></i> visited </i><i class="fromNow"></i>\
|
||||||
<br>\
|
<br>\
|
||||||
<i class="timestamp" style="display:none;"></i>\
|
<i class="timestamp" style="display:none;"></i>\
|
||||||
<i class="time"></i>\
|
<i class="time"></i>\
|
||||||
|
@ -148,18 +148,19 @@ function deleteHistory() {
|
||||||
saveHistory([]);
|
saveHistory([]);
|
||||||
historyList.clear();
|
historyList.clear();
|
||||||
checkHistoryList();
|
checkHistoryList();
|
||||||
|
deleteId = null;
|
||||||
} else {
|
} else {
|
||||||
if (!deleteId) return;
|
if (!deleteId) return;
|
||||||
getHistory(function (notehistory) {
|
getHistory(function (notehistory) {
|
||||||
var newnotehistory = removeHistory(deleteId, notehistory);
|
var newnotehistory = removeHistory(deleteId, notehistory);
|
||||||
saveHistory(newnotehistory);
|
saveHistory(newnotehistory);
|
||||||
|
historyList.remove('id', deleteId);
|
||||||
|
checkHistoryList();
|
||||||
|
deleteId = null;
|
||||||
});
|
});
|
||||||
historyList.remove('id', deleteId);
|
|
||||||
checkHistoryList();
|
|
||||||
}
|
}
|
||||||
$('.delete-modal').modal('hide');
|
$('.delete-modal').modal('hide');
|
||||||
clearHistory = false;
|
clearHistory = false;
|
||||||
deleteId = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$(".ui-delete-modal-confirm").click(function () {
|
$(".ui-delete-modal-confirm").click(function () {
|
||||||
|
|
|
@ -93,7 +93,14 @@ function clearDuplicatedHistory(notehistory) {
|
||||||
for (var i = 0; i < notehistory.length; i++) {
|
for (var i = 0; i < notehistory.length; i++) {
|
||||||
var found = false;
|
var found = false;
|
||||||
for (var j = 0; j < newnotehistory.length; j++) {
|
for (var j = 0; j < newnotehistory.length; j++) {
|
||||||
if (notehistory[i].id == newnotehistory[j].id) {
|
var id = LZString.decompressFromBase64(notehistory[i].id);
|
||||||
|
var newId = LZString.decompressFromBase64(newnotehistory[j].id);
|
||||||
|
if (id == newId || notehistory[i].id == newnotehistory[j].id || !notehistory[i].id || !newnotehistory[j].id) {
|
||||||
|
var time = moment(notehistory[i].time, 'MMMM Do YYYY, h:mm:ss a');
|
||||||
|
var newTime = moment(newnotehistory[j].time, 'MMMM Do YYYY, h:mm:ss a');
|
||||||
|
if(time >= newTime) {
|
||||||
|
newnotehistory[j] = notehistory[i];
|
||||||
|
}
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -146,9 +153,9 @@ function writeHistoryToServer(view) {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
var notehistory = [];
|
var notehistory = [];
|
||||||
}
|
}
|
||||||
if(!notehistory)
|
if (!notehistory)
|
||||||
notehistory = [];
|
notehistory = [];
|
||||||
|
|
||||||
var newnotehistory = generateHistory(view, notehistory);
|
var newnotehistory = generateHistory(view, notehistory);
|
||||||
saveHistoryToServer(newnotehistory);
|
saveHistoryToServer(newnotehistory);
|
||||||
})
|
})
|
||||||
|
@ -163,9 +170,9 @@ function writeHistoryToCookie(view) {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
var notehistory = [];
|
var notehistory = [];
|
||||||
}
|
}
|
||||||
if(!notehistory)
|
if (!notehistory)
|
||||||
notehistory = [];
|
notehistory = [];
|
||||||
|
|
||||||
var newnotehistory = generateHistory(view, notehistory);
|
var newnotehistory = generateHistory(view, notehistory);
|
||||||
saveHistoryToCookie(newnotehistory);
|
saveHistoryToCookie(newnotehistory);
|
||||||
}
|
}
|
||||||
|
@ -179,9 +186,9 @@ function writeHistoryToStorage(view) {
|
||||||
var notehistory = data;
|
var notehistory = data;
|
||||||
} else
|
} else
|
||||||
var notehistory = [];
|
var notehistory = [];
|
||||||
if(!notehistory)
|
if (!notehistory)
|
||||||
notehistory = [];
|
notehistory = [];
|
||||||
|
|
||||||
var newnotehistory = generateHistory(view, notehistory);
|
var newnotehistory = generateHistory(view, notehistory);
|
||||||
saveHistoryToStorage(newnotehistory);
|
saveHistoryToStorage(newnotehistory);
|
||||||
} else {
|
} else {
|
||||||
|
@ -223,9 +230,9 @@ function renderHistory(view) {
|
||||||
|
|
||||||
function generateHistory(view, notehistory) {
|
function generateHistory(view, notehistory) {
|
||||||
var info = renderHistory(view);
|
var info = renderHistory(view);
|
||||||
notehistory = clearDuplicatedHistory(notehistory);
|
|
||||||
notehistory = removeHistory(info.id, notehistory);
|
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, notehistory);
|
||||||
|
notehistory = clearDuplicatedHistory(notehistory);
|
||||||
return notehistory;
|
return notehistory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue