2016-10-19 14:14:32 +00:00
|
|
|
require('./locale');
|
|
|
|
|
2016-11-02 03:26:25 +00:00
|
|
|
require('../css/cover.css');
|
|
|
|
require('../css/site.css');
|
|
|
|
|
2017-01-05 10:10:55 +00:00
|
|
|
import {
|
|
|
|
checkIfAuth,
|
|
|
|
clearLoginState,
|
|
|
|
getLoginState,
|
|
|
|
resetCheckAuth,
|
|
|
|
setloginStateChangeEvent
|
|
|
|
} from './common';
|
|
|
|
|
2017-01-05 12:56:16 +00:00
|
|
|
import {
|
|
|
|
clearDuplicatedHistory,
|
|
|
|
deleteServerHistory,
|
|
|
|
getHistory,
|
|
|
|
getStorageHistory,
|
|
|
|
parseHistory,
|
|
|
|
parseServerToHistory,
|
|
|
|
parseStorageToHistory,
|
|
|
|
postHistoryToServer,
|
|
|
|
removeHistory,
|
|
|
|
saveHistory,
|
|
|
|
saveStorageHistoryToServer
|
|
|
|
} from './history';
|
2017-01-05 10:10:55 +00:00
|
|
|
|
2017-01-05 12:56:16 +00:00
|
|
|
import { saveAs } from 'file-saver';
|
2017-01-05 10:10:55 +00:00
|
|
|
import List from 'list.js';
|
|
|
|
import S from 'string';
|
2016-10-11 06:52:45 +00:00
|
|
|
|
2016-12-24 03:50:57 +00:00
|
|
|
import Cover from './views/Cover';
|
2016-12-24 03:10:18 +00:00
|
|
|
import Vue from 'vue';
|
|
|
|
|
2016-12-24 03:50:57 +00:00
|
|
|
new Vue({
|
|
|
|
el: '#cover-app',
|
|
|
|
render: (h) => h(Cover)
|
|
|
|
})
|
|
|
|
|
2017-01-05 10:10:55 +00:00
|
|
|
const options = {
|
2015-10-22 09:09:55 +00:00
|
|
|
valueNames: ['id', 'text', 'timestamp', 'fromNow', 'time', 'tags', 'pinned'],
|
2015-05-15 04:58:13 +00:00
|
|
|
item: '<li class="col-xs-12 col-sm-6 col-md-6 col-lg-4">\
|
|
|
|
<span class="id" style="display:none;"></span>\
|
|
|
|
<a href="#">\
|
|
|
|
<div class="item">\
|
2017-01-05 10:10:55 +00:00
|
|
|
<div class="ui-history-pin fa fa-thumb-tack fa-fw"></div>\
|
2015-07-01 16:10:20 +00:00
|
|
|
<div class="ui-history-close fa fa-close fa-fw" data-toggle="modal" data-target=".delete-modal"></div>\
|
|
|
|
<div class="content">\
|
|
|
|
<h4 class="text"></h4>\
|
|
|
|
<p>\
|
2015-09-24 03:55:56 +00:00
|
|
|
<i><i class="fa fa-clock-o"></i> visited </i><i class="fromNow"></i>\
|
2015-07-01 16:10:20 +00:00
|
|
|
<br>\
|
|
|
|
<i class="timestamp" style="display:none;"></i>\
|
|
|
|
<i class="time"></i>\
|
|
|
|
</p>\
|
|
|
|
<p class="tags"></p>\
|
|
|
|
</div>\
|
2015-05-15 04:58:13 +00:00
|
|
|
</div>\
|
|
|
|
</a>\
|
2016-10-11 08:48:42 +00:00
|
|
|
</li>',
|
|
|
|
page: 18,
|
|
|
|
plugins: [
|
2016-10-12 05:08:53 +00:00
|
|
|
ListPagination({
|
|
|
|
outerWindow: 1
|
|
|
|
})
|
2016-10-11 08:48:42 +00:00
|
|
|
]
|
2015-05-15 04:58:13 +00:00
|
|
|
};
|
2017-01-05 10:10:55 +00:00
|
|
|
const historyList = new List('history', options);
|
2015-05-15 04:58:13 +00:00
|
|
|
|
|
|
|
migrateHistoryFromTempCallback = pageInit;
|
2017-01-05 10:10:55 +00:00
|
|
|
setloginStateChangeEvent(pageInit);
|
|
|
|
|
2015-05-15 04:58:13 +00:00
|
|
|
pageInit();
|
|
|
|
|
|
|
|
function pageInit() {
|
|
|
|
checkIfAuth(
|
2017-01-05 10:10:55 +00:00
|
|
|
data => {
|
2015-05-15 04:58:13 +00:00
|
|
|
$('.ui-signin').hide();
|
|
|
|
$('.ui-or').hide();
|
|
|
|
$('.ui-welcome').show();
|
2016-05-16 05:47:35 +00:00
|
|
|
if (data.photo) $('.ui-avatar').prop('src', data.photo).show();
|
|
|
|
else $('.ui-avatar').prop('src', '').hide();
|
2015-05-15 04:58:13 +00:00
|
|
|
$('.ui-name').html(data.name);
|
|
|
|
$('.ui-signout').show();
|
|
|
|
$(".ui-history").click();
|
|
|
|
parseServerToHistory(historyList, parseHistoryCallback);
|
|
|
|
},
|
2017-01-05 10:10:55 +00:00
|
|
|
() => {
|
2016-08-15 02:56:14 +00:00
|
|
|
$('.ui-signin').show();
|
|
|
|
$('.ui-or').show();
|
2015-05-15 04:58:13 +00:00
|
|
|
$('.ui-welcome').hide();
|
2016-05-16 05:47:35 +00:00
|
|
|
$('.ui-avatar').prop('src', '').hide();
|
2015-05-15 04:58:13 +00:00
|
|
|
$('.ui-name').html('');
|
|
|
|
$('.ui-signout').hide();
|
|
|
|
parseStorageToHistory(historyList, parseHistoryCallback);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-05-04 07:53:29 +00:00
|
|
|
$(".masthead-nav li").click(function () {
|
|
|
|
$(this).siblings().removeClass("active");
|
|
|
|
$(this).addClass("active");
|
|
|
|
});
|
|
|
|
|
2017-01-05 10:10:55 +00:00
|
|
|
$(".ui-home").click(() => {
|
2016-08-15 02:56:14 +00:00
|
|
|
if (!$("#home").is(':visible')) {
|
|
|
|
$(".section:visible").hide();
|
|
|
|
$("#home").fadeIn();
|
|
|
|
}
|
2015-05-04 07:53:29 +00:00
|
|
|
});
|
|
|
|
|
2017-01-05 10:10:55 +00:00
|
|
|
$(".ui-history").click(() => {
|
2016-08-15 02:56:14 +00:00
|
|
|
if (!$("#history").is(':visible')) {
|
|
|
|
$(".section:visible").hide();
|
|
|
|
$("#history").fadeIn();
|
|
|
|
}
|
2015-05-04 07:53:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
function checkHistoryList() {
|
2015-05-15 04:58:13 +00:00
|
|
|
if ($("#history-list").children().length > 0) {
|
2017-01-12 09:14:32 +00:00
|
|
|
$('.pagination').show();
|
2015-05-04 07:53:29 +00:00
|
|
|
$(".ui-nohistory").hide();
|
2015-05-15 04:58:13 +00:00
|
|
|
$(".ui-import-from-browser").hide();
|
|
|
|
} else if ($("#history-list").children().length == 0) {
|
2017-01-12 09:14:32 +00:00
|
|
|
$('.pagination').hide();
|
2015-05-04 07:53:29 +00:00
|
|
|
$(".ui-nohistory").slideDown();
|
2017-01-05 10:10:55 +00:00
|
|
|
getStorageHistory(data => {
|
2015-05-15 04:58:13 +00:00
|
|
|
if (data && data.length > 0 && getLoginState() && historyList.items.length == 0) {
|
|
|
|
$(".ui-import-from-browser").slideDown();
|
|
|
|
}
|
|
|
|
});
|
2015-05-04 07:53:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-15 04:58:13 +00:00
|
|
|
function parseHistoryCallback(list, notehistory) {
|
2015-05-04 07:53:29 +00:00
|
|
|
checkHistoryList();
|
2017-01-05 10:10:55 +00:00
|
|
|
//sort by pinned then timestamp
|
|
|
|
list.sort('', {
|
|
|
|
sortFunction(a, b) {
|
|
|
|
const notea = a.values();
|
|
|
|
const noteb = b.values();
|
|
|
|
if (notea.pinned && !noteb.pinned) {
|
2015-10-22 09:09:55 +00:00
|
|
|
return -1;
|
|
|
|
} else if (!notea.pinned && noteb.pinned) {
|
|
|
|
return 1;
|
|
|
|
} else {
|
2017-01-05 10:10:55 +00:00
|
|
|
if (notea.timestamp > noteb.timestamp) {
|
|
|
|
return -1;
|
|
|
|
} else if (notea.timestamp < noteb.timestamp) {
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2016-10-12 05:14:46 +00:00
|
|
|
// parse filter tags
|
2017-01-05 10:10:55 +00:00
|
|
|
const filtertags = [];
|
|
|
|
for (let i = 0, l = list.items.length; i < l; i++) {
|
|
|
|
const tags = list.items[i]._values.tags;
|
2016-10-12 05:14:46 +00:00
|
|
|
if (tags && tags.length > 0) {
|
2017-01-05 10:10:55 +00:00
|
|
|
for (let j = 0; j < tags.length; j++) {
|
2016-10-12 05:14:46 +00:00
|
|
|
//push info filtertags if not found
|
2017-01-05 10:10:55 +00:00
|
|
|
let found = false;
|
|
|
|
if (filtertags.includes(tags[j]))
|
2016-10-12 05:14:46 +00:00
|
|
|
found = true;
|
|
|
|
if (!found)
|
|
|
|
filtertags.push(tags[j]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
buildTagsFilter(filtertags);
|
|
|
|
}
|
|
|
|
|
|
|
|
// update items whenever list updated
|
2017-01-05 10:10:55 +00:00
|
|
|
historyList.on('updated', e => {
|
|
|
|
for (let i = 0, l = e.items.length; i < l; i++) {
|
|
|
|
const item = e.items[i];
|
2016-10-12 05:14:46 +00:00
|
|
|
if (item.visible()) {
|
2017-01-05 10:10:55 +00:00
|
|
|
const itemEl = $(item.elm);
|
|
|
|
const values = item._values;
|
|
|
|
const a = itemEl.find("a");
|
|
|
|
const pin = itemEl.find(".ui-history-pin");
|
|
|
|
const tagsEl = itemEl.find(".tags");
|
2015-05-15 04:58:13 +00:00
|
|
|
//parse link to element a
|
2017-01-05 10:10:55 +00:00
|
|
|
a.attr('href', `${serverurl}/${values.id}`);
|
2016-10-12 05:14:46 +00:00
|
|
|
//parse pinned
|
|
|
|
if (values.pinned) {
|
|
|
|
pin.addClass('active');
|
|
|
|
} else {
|
|
|
|
pin.removeClass('active');
|
|
|
|
}
|
2015-05-15 04:58:13 +00:00
|
|
|
//parse tags
|
2017-01-05 10:10:55 +00:00
|
|
|
const tags = values.tags;
|
2016-10-12 05:14:46 +00:00
|
|
|
if (tags && tags.length > 0 && tagsEl.children().length <= 0) {
|
2017-01-05 10:10:55 +00:00
|
|
|
const labels = [];
|
|
|
|
for (let j = 0; j < tags.length; j++) {
|
2016-10-12 05:14:46 +00:00
|
|
|
//push into the item label
|
2017-01-05 10:10:55 +00:00
|
|
|
labels.push(`<span class='label label-default'>${tags[j]}</span>`);
|
2015-05-15 04:58:13 +00:00
|
|
|
}
|
2016-10-12 05:14:46 +00:00
|
|
|
tagsEl.html(labels.join(' '));
|
2015-05-15 04:58:13 +00:00
|
|
|
}
|
|
|
|
}
|
2016-10-12 05:14:46 +00:00
|
|
|
}
|
|
|
|
$(".ui-history-close").off('click');
|
|
|
|
$(".ui-history-close").on('click', historyCloseClick);
|
|
|
|
$(".ui-history-pin").off('click');
|
|
|
|
$(".ui-history-pin").on('click', historyPinClick);
|
|
|
|
});
|
|
|
|
|
|
|
|
function historyCloseClick(e) {
|
|
|
|
e.preventDefault();
|
2017-01-05 10:10:55 +00:00
|
|
|
const id = $(this).closest("a").siblings("span").html();
|
|
|
|
const value = historyList.get('id', id)[0]._values;
|
2016-10-12 05:14:46 +00:00
|
|
|
$('.ui-delete-modal-msg').text('Do you really want to delete below history?');
|
2017-01-05 10:10:55 +00:00
|
|
|
$('.ui-delete-modal-item').html(`<i class="fa fa-file-text"></i> ${value.text}<br><i class="fa fa-clock-o"></i> ${value.time}`);
|
2016-10-12 05:14:46 +00:00
|
|
|
clearHistory = false;
|
|
|
|
deleteId = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
function historyPinClick(e) {
|
|
|
|
e.preventDefault();
|
2017-01-05 10:10:55 +00:00
|
|
|
const $this = $(this);
|
|
|
|
const id = $this.closest("a").siblings("span").html();
|
|
|
|
const item = historyList.get('id', id)[0];
|
|
|
|
const values = item._values;
|
|
|
|
let pinned = values.pinned;
|
2016-10-12 05:14:46 +00:00
|
|
|
if (!values.pinned) {
|
|
|
|
pinned = true;
|
|
|
|
item._values.pinned = true;
|
|
|
|
} else {
|
|
|
|
pinned = false;
|
|
|
|
item._values.pinned = false;
|
|
|
|
}
|
2017-01-05 10:10:55 +00:00
|
|
|
checkIfAuth(() => {
|
2016-10-12 05:14:46 +00:00
|
|
|
postHistoryToServer(id, {
|
2017-01-05 10:10:55 +00:00
|
|
|
pinned
|
|
|
|
}, (err, result) => {
|
2016-10-12 05:14:46 +00:00
|
|
|
if (!err) {
|
2016-10-10 13:00:07 +00:00
|
|
|
if (pinned)
|
|
|
|
$this.addClass('active');
|
|
|
|
else
|
|
|
|
$this.removeClass('active');
|
2016-10-12 09:39:38 +00:00
|
|
|
}
|
2016-10-12 05:14:46 +00:00
|
|
|
});
|
2017-01-05 10:10:55 +00:00
|
|
|
}, () => {
|
|
|
|
getHistory(notehistory => {
|
|
|
|
for(let i = 0; i < notehistory.length; i++) {
|
2016-10-12 05:14:46 +00:00
|
|
|
if (notehistory[i].id == id) {
|
|
|
|
notehistory[i].pinned = pinned;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
saveHistory(notehistory);
|
|
|
|
if (pinned)
|
|
|
|
$this.addClass('active');
|
|
|
|
else
|
|
|
|
$this.removeClass('active');
|
|
|
|
});
|
2015-07-01 16:10:20 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
//auto update item fromNow every minutes
|
|
|
|
setInterval(updateItemFromNow, 60000);
|
|
|
|
|
|
|
|
function updateItemFromNow() {
|
2017-01-05 10:10:55 +00:00
|
|
|
const items = $('.item').toArray();
|
|
|
|
for (let i = 0; i < items.length; i++) {
|
|
|
|
const item = $(items[i]);
|
|
|
|
const timestamp = parseInt(item.find('.timestamp').text());
|
2015-07-01 16:10:20 +00:00
|
|
|
item.find('.fromNow').text(moment(timestamp).fromNow());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var clearHistory = false;
|
|
|
|
var deleteId = null;
|
|
|
|
|
|
|
|
function deleteHistory() {
|
2017-01-05 10:10:55 +00:00
|
|
|
checkIfAuth(() => {
|
|
|
|
deleteServerHistory(deleteId, (err, result) => {
|
2016-10-10 13:00:07 +00:00
|
|
|
if (!err) {
|
|
|
|
if (clearHistory) {
|
|
|
|
historyList.clear();
|
|
|
|
checkHistoryList();
|
|
|
|
} else {
|
|
|
|
historyList.remove('id', deleteId);
|
|
|
|
checkHistoryList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$('.delete-modal').modal('hide');
|
2015-09-24 03:55:56 +00:00
|
|
|
deleteId = null;
|
2016-10-10 13:00:07 +00:00
|
|
|
clearHistory = false;
|
2015-05-04 07:53:29 +00:00
|
|
|
});
|
2017-01-05 10:10:55 +00:00
|
|
|
}, () => {
|
2016-10-10 13:00:07 +00:00
|
|
|
if (clearHistory) {
|
|
|
|
saveHistory([]);
|
|
|
|
historyList.clear();
|
|
|
|
checkHistoryList();
|
|
|
|
deleteId = null;
|
|
|
|
} else {
|
|
|
|
if (!deleteId) return;
|
2017-01-05 10:10:55 +00:00
|
|
|
getHistory(notehistory => {
|
|
|
|
const newnotehistory = removeHistory(deleteId, notehistory);
|
2016-10-10 13:00:07 +00:00
|
|
|
saveHistory(newnotehistory);
|
|
|
|
historyList.remove('id', deleteId);
|
|
|
|
checkHistoryList();
|
|
|
|
deleteId = null;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
$('.delete-modal').modal('hide');
|
|
|
|
clearHistory = false;
|
|
|
|
});
|
2015-05-04 07:53:29 +00:00
|
|
|
}
|
|
|
|
|
2017-01-05 10:10:55 +00:00
|
|
|
$(".ui-delete-modal-confirm").click(() => {
|
2015-07-01 16:10:20 +00:00
|
|
|
deleteHistory();
|
|
|
|
});
|
|
|
|
|
2017-01-05 10:10:55 +00:00
|
|
|
$(".ui-import-from-browser").click(() => {
|
|
|
|
saveStorageHistoryToServer(() => {
|
2015-05-15 04:58:13 +00:00
|
|
|
parseStorageToHistory(historyList, parseHistoryCallback);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-01-05 10:10:55 +00:00
|
|
|
$(".ui-save-history").click(() => {
|
|
|
|
getHistory(data => {
|
|
|
|
const history = JSON.stringify(data);
|
|
|
|
const blob = new Blob([history], {
|
2015-05-15 04:58:13 +00:00
|
|
|
type: "application/json;charset=utf-8"
|
|
|
|
});
|
2017-01-05 10:10:55 +00:00
|
|
|
saveAs(blob, `hackmd_history_${moment().format('YYYYMMDDHHmmss')}`);
|
2015-05-15 04:58:13 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-01-05 10:10:55 +00:00
|
|
|
$(".ui-open-history").bind("change", e => {
|
|
|
|
const files = e.target.files || e.dataTransfer.files;
|
|
|
|
const file = files[0];
|
|
|
|
const reader = new FileReader();
|
|
|
|
reader.onload = () => {
|
|
|
|
const notehistory = JSON.parse(reader.result);
|
2015-05-15 04:58:13 +00:00
|
|
|
//console.log(notehistory);
|
|
|
|
if (!reader.result) return;
|
2017-01-05 10:10:55 +00:00
|
|
|
getHistory(data => {
|
|
|
|
let mergedata = data.concat(notehistory);
|
2015-05-15 04:58:13 +00:00
|
|
|
mergedata = clearDuplicatedHistory(mergedata);
|
|
|
|
saveHistory(mergedata);
|
|
|
|
parseHistory(historyList, parseHistoryCallback);
|
|
|
|
});
|
|
|
|
$(".ui-open-history").replaceWith($(".ui-open-history").val('').clone(true));
|
|
|
|
};
|
|
|
|
reader.readAsText(file);
|
|
|
|
});
|
|
|
|
|
2017-01-05 10:10:55 +00:00
|
|
|
$(".ui-clear-history").click(() => {
|
2015-07-01 16:10:20 +00:00
|
|
|
$('.ui-delete-modal-msg').text('Do you really want to clear all history?');
|
|
|
|
$('.ui-delete-modal-item').html('There is no turning back.');
|
|
|
|
clearHistory = true;
|
|
|
|
deleteId = null;
|
2015-05-15 04:58:13 +00:00
|
|
|
});
|
|
|
|
|
2017-01-05 10:10:55 +00:00
|
|
|
$(".ui-refresh-history").click(() => {
|
|
|
|
const lastTags = $(".ui-use-tags").select2('val');
|
2016-06-26 15:38:28 +00:00
|
|
|
$(".ui-use-tags").select2('val', '');
|
|
|
|
historyList.filter();
|
2017-01-05 10:10:55 +00:00
|
|
|
const lastKeyword = $('.search').val();
|
2016-06-26 15:38:28 +00:00
|
|
|
$('.search').val('');
|
|
|
|
historyList.search();
|
2016-10-12 05:08:53 +00:00
|
|
|
$('#history-list').slideUp('fast');
|
|
|
|
$('.pagination').slideUp('fast');
|
2016-10-10 02:14:17 +00:00
|
|
|
|
2015-05-15 04:58:13 +00:00
|
|
|
resetCheckAuth();
|
|
|
|
historyList.clear();
|
2017-01-05 10:10:55 +00:00
|
|
|
parseHistory(historyList, (list, notehistory) => {
|
2016-06-26 15:38:28 +00:00
|
|
|
parseHistoryCallback(list, notehistory);
|
|
|
|
$(".ui-use-tags").select2('val', lastTags);
|
|
|
|
$(".ui-use-tags").trigger('change');
|
|
|
|
historyList.search(lastKeyword);
|
|
|
|
$('.search').val(lastKeyword);
|
|
|
|
checkHistoryList();
|
2016-10-12 05:08:53 +00:00
|
|
|
$('#history-list').slideDown('fast');
|
|
|
|
$('.pagination').slideDown('fast');
|
2016-06-26 15:38:28 +00:00
|
|
|
});
|
2015-05-15 04:58:13 +00:00
|
|
|
});
|
|
|
|
|
2017-01-05 10:10:55 +00:00
|
|
|
$(".ui-logout").click(() => {
|
2015-05-15 04:58:13 +00:00
|
|
|
clearLoginState();
|
2017-01-05 10:10:55 +00:00
|
|
|
location.href = `${serverurl}/logout`;
|
2015-05-15 04:58:13 +00:00
|
|
|
});
|
|
|
|
|
2017-01-05 10:10:55 +00:00
|
|
|
let filtertags = [];
|
2015-05-15 04:58:13 +00:00
|
|
|
$(".ui-use-tags").select2({
|
2016-08-19 03:49:24 +00:00
|
|
|
placeholder: $(".ui-use-tags").attr('placeholder'),
|
2015-05-15 04:58:13 +00:00
|
|
|
multiple: true,
|
2017-01-05 10:10:55 +00:00
|
|
|
data() {
|
2015-05-15 04:58:13 +00:00
|
|
|
return {
|
|
|
|
results: filtertags
|
|
|
|
};
|
2015-05-04 07:53:29 +00:00
|
|
|
}
|
2015-05-15 04:58:13 +00:00
|
|
|
});
|
|
|
|
$('.select2-input').css('width', 'inherit');
|
|
|
|
buildTagsFilter([]);
|
2015-05-04 07:53:29 +00:00
|
|
|
|
2015-05-15 04:58:13 +00:00
|
|
|
function buildTagsFilter(tags) {
|
2017-01-05 10:10:55 +00:00
|
|
|
for (let i = 0; i < tags.length; i++)
|
2015-05-15 04:58:13 +00:00
|
|
|
tags[i] = {
|
|
|
|
id: i,
|
2016-11-29 13:33:29 +00:00
|
|
|
text: S(tags[i]).unescapeHTML().s
|
2015-05-15 04:58:13 +00:00
|
|
|
};
|
|
|
|
filtertags = tags;
|
|
|
|
}
|
|
|
|
$(".ui-use-tags").on('change', function () {
|
2017-01-05 10:10:55 +00:00
|
|
|
const tags = [];
|
|
|
|
const data = $(this).select2('data');
|
|
|
|
for (let i = 0; i < data.length; i++)
|
2015-05-15 04:58:13 +00:00
|
|
|
tags.push(data[i].text);
|
|
|
|
if (tags.length > 0) {
|
2017-01-05 10:10:55 +00:00
|
|
|
historyList.filter(item => {
|
|
|
|
const values = item.values();
|
2015-05-15 04:58:13 +00:00
|
|
|
if (!values.tags) return false;
|
2017-01-05 10:10:55 +00:00
|
|
|
let found = false;
|
|
|
|
for (let i = 0; i < tags.length; i++) {
|
|
|
|
if (values.tags.includes(tags[i])) {
|
2015-05-15 04:58:13 +00:00
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return found;
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
historyList.filter();
|
|
|
|
}
|
|
|
|
checkHistoryList();
|
|
|
|
});
|
2015-05-04 07:53:29 +00:00
|
|
|
|
2017-01-05 10:10:55 +00:00
|
|
|
$('.search').keyup(() => {
|
2015-05-15 04:58:13 +00:00
|
|
|
checkHistoryList();
|
2016-10-10 02:14:17 +00:00
|
|
|
});
|