完成备忘录的添加
This commit is contained in:
parent
1d3b72ed2f
commit
8f8643deec
|
|
@ -12,6 +12,7 @@
|
|||
"dependencies": {
|
||||
"cheerio": "^1.0.0-rc.3",
|
||||
"fs-extra": "^9.0.0",
|
||||
"node-readability": "^3.0.0",
|
||||
"think-cache": "^1.0.0",
|
||||
"think-cache-file": "^1.0.8",
|
||||
"think-logger3": "^1.0.0",
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ exports.cache = {
|
|||
exports.model = {
|
||||
type: 'mysql',
|
||||
common: {
|
||||
logConnect: isDev,
|
||||
logConnect: false,
|
||||
logSql: isDev,
|
||||
logger: msg => think.logger.info(msg)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
const Base = require('./base.js');
|
||||
const crypto = require('crypto');
|
||||
const fs = require('fs-extra');
|
||||
const read = require('node-readability');
|
||||
|
||||
function md5(str) {
|
||||
return crypto.createHash('md5').update(str).digest('hex');
|
||||
|
|
@ -84,8 +85,8 @@ module.exports = class extends Base {
|
|||
if (param.bookmarkCount) {
|
||||
tag.bookmarkCount = await this.model('bookmarks').where({ tagId: tag.id }).count();
|
||||
}
|
||||
if (param.notes) {
|
||||
tag.bookmarkCount = await this.model('notes').where({ tagId: tag.id }).count();
|
||||
if (param.noteCount) {
|
||||
tag.noteCount = await this.model('notes').where({ tagId: tag.id }).count();
|
||||
}
|
||||
}
|
||||
this.json({ code: 0, data: tags, msg: '' });
|
||||
|
|
@ -104,6 +105,19 @@ module.exports = class extends Base {
|
|||
}
|
||||
}
|
||||
|
||||
// 获取书签
|
||||
// @todo 如果是自己的任意获取,如果是别人的必须公开才能获取
|
||||
async bookmarkAction() {
|
||||
let id = this.get("id");
|
||||
try {
|
||||
let data = await this.model('bookmarks').where({ id }).find();
|
||||
this.json({ code: 0, data });
|
||||
} catch (error) {
|
||||
this.json({ code: 1, msg: error.toString() });
|
||||
}
|
||||
}
|
||||
|
||||
// 添加书签
|
||||
async addBookmarkAction() {
|
||||
let bookmark = this.post();
|
||||
bookmark.userId = this.ctx.state.user.id;
|
||||
|
|
@ -140,6 +154,69 @@ module.exports = class extends Base {
|
|||
}
|
||||
}
|
||||
|
||||
// 点击书签
|
||||
async clickBookmarkAction() {
|
||||
let id = this.post("id");
|
||||
try {
|
||||
let data = await this.model('bookmarks').where({
|
||||
userId: this.ctx.state.user.id,
|
||||
id
|
||||
}).update({
|
||||
clickCount: ['exp', 'clickCount+1'],
|
||||
lastClick: ['exp', 'NOW()']
|
||||
});
|
||||
this.json({ code: 0, data });
|
||||
} catch (error) {
|
||||
this.json({ code: 1, msg: error.toString() });
|
||||
}
|
||||
}
|
||||
|
||||
// 更新书签
|
||||
async updateBookmarkAction() {
|
||||
let bookmark = this.post();
|
||||
try {
|
||||
let data = await this.model('bookmarks').where({
|
||||
userId: this.ctx.state.user.id,
|
||||
id: bookmark.id
|
||||
}).update(bookmark);
|
||||
this.json({ code: 0, data });
|
||||
} catch (error) {
|
||||
this.json({ code: 1, msg: error.toString() });
|
||||
}
|
||||
}
|
||||
// 获取文章
|
||||
async getArticleAction() {
|
||||
let url = this.get("url");
|
||||
async function readArticle(url) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
read(url, (err, article, meta) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
} else {
|
||||
resolve({
|
||||
title: article.title
|
||||
});
|
||||
article.close();
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
try {
|
||||
let article = await readArticle(url);
|
||||
this.json({
|
||||
code: 0,
|
||||
data: {
|
||||
title: article.title
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
this.json({
|
||||
code: 1,
|
||||
msg: error.toString()
|
||||
});
|
||||
}
|
||||
}
|
||||
// 新增留言
|
||||
async addAdviceAction() {
|
||||
let advice = this.post();
|
||||
|
|
@ -161,4 +238,53 @@ module.exports = class extends Base {
|
|||
this.json({ code: 1, data: '', msg: error.toString() });
|
||||
}
|
||||
}
|
||||
|
||||
// 新增
|
||||
async addNoteAction() {
|
||||
let note = this.post();
|
||||
note.userId = this.ctx.state.user.id;
|
||||
try {
|
||||
let data = await this.model("notes").add(note);
|
||||
this.json({ code: 0, data, msg: `备忘添加成功` });
|
||||
} catch (error) {
|
||||
this.json({ code: 1, msg: error.toString() });
|
||||
}
|
||||
}
|
||||
|
||||
// 更新备忘
|
||||
async updateNoteAction() {
|
||||
let note = this.post();
|
||||
note.userId = this.ctx.state.user.id;
|
||||
try {
|
||||
let data = await this.model('bookmarks').where({
|
||||
userId: this.ctx.state.user.id,
|
||||
id: note.id
|
||||
}).update(note);
|
||||
this.json({ code: 0, data, msg: `备忘更新成功` });
|
||||
} catch (error) {
|
||||
this.json({ code: 1, msg: error.toString() });
|
||||
}
|
||||
}
|
||||
|
||||
// 更新
|
||||
async delNoteAction() {
|
||||
let note = this.post();
|
||||
note.userId = this.ctx.state.user.id;
|
||||
try {
|
||||
let data = await this.model("notes").where(note).delete();
|
||||
this.json({ code: 0, data, msg: `备忘删除成功` });
|
||||
} catch (error) {
|
||||
this.json({ code: 1, msg: error.toString() });
|
||||
}
|
||||
}
|
||||
|
||||
async notesAction() {
|
||||
let where = {};
|
||||
try {
|
||||
let data = await this.model('notes').where(where).order("createdAt DESC").page(this.get('page'), this.get('pageSize')).countSelect();
|
||||
this.json({ code: 0, data });
|
||||
} catch (error) {
|
||||
this.json({ code: 1, msg: error.toString() });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,72 +1,63 @@
|
|||
app.controller('bookmarkInfoCtr', ['$scope', '$state', '$timeout', '$sce', '$window', '$filter', '$document', '$timeout', 'bookmarkService', 'pubSubService', 'dataService', function ($scope, $state, $timeout, $sce, $window, $filter, $document, $timeout, bookmarkService, pubSubService, dataService) {
|
||||
console.log("Hello bookmarkInfoCtr");
|
||||
$scope.bookmark = {}
|
||||
$scope.content = '';
|
||||
$scope.loading = false;
|
||||
|
||||
pubSubService.subscribe('TagCtr.showBookmarkInfo', $scope, function (event, bookmark) {
|
||||
console.log('subscribe TagCtr.showBookmarkInfo', bookmark);
|
||||
$('.ui.modal.js-bookmark-info').modal({
|
||||
closable: false,
|
||||
}).modal('setting', 'transition', dataService.animation()).modal('show');
|
||||
bookmark.favicon_url = 'http://favicon.luchenqun.com/?url=' + bookmark.url;
|
||||
bookmark.snap_url = bookmark.snap_url || ('./images/snap/' + bookmark.id + '.png');
|
||||
$scope.bookmark = bookmark;
|
||||
$scope.bookmark.description = $sce.trustAsHtml(bookmark.description);
|
||||
$scope.content = $sce.trustAsHtml(bookmark.content) || '';
|
||||
var params = {
|
||||
url: bookmark.url,
|
||||
requestId: 1
|
||||
}
|
||||
if (!$scope.content) {
|
||||
$timeout(function () {
|
||||
$('.ui.modal.js-bookmark-info').modal("refresh");
|
||||
$("p").css("word-wrap", "break-word");
|
||||
}, 500);
|
||||
$scope.loading = true
|
||||
bookmarkService.getArticle(params)
|
||||
.then((data) => {
|
||||
$scope.content = data.content ? $sce.trustAsHtml(data.content) : $sce.trustAsHtml('<p>数据获取失败,可能是服务器不允许获取,或者是https网站!</p>');
|
||||
setTimeout(function () {
|
||||
$('.ui.modal.js-bookmark-info').modal && $('.ui.modal.js-bookmark-info').modal("refresh");
|
||||
}, 100);
|
||||
$scope.loading = false;
|
||||
})
|
||||
.catch((err) => {
|
||||
$scope.content = $sce.trustAsHtml('<p>数据获取失败:' + JSON.stringify(err) + '</p>');
|
||||
$scope.loading = false;
|
||||
})
|
||||
} else {
|
||||
setTimeout(function () {
|
||||
$('.ui.modal.js-bookmark-info').modal && $('.ui.modal.js-bookmark-info').modal("refresh");
|
||||
}, 10);
|
||||
setTimeout(function () {
|
||||
$('.modals').animate({ scrollTop: 0 }, 100);
|
||||
}, 500);
|
||||
}
|
||||
});
|
||||
|
||||
$scope.jumpToUrl = function (url, id) {
|
||||
$window.open(url, '_blank');
|
||||
if ($scope.bookmark.own) {
|
||||
bookmarkService.clickBookmark({
|
||||
id: id
|
||||
});
|
||||
$scope.bookmark.click_count += 1;
|
||||
$scope.bookmark.last_click = $filter("date")(new Date(), "yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
}
|
||||
|
||||
$scope.copy = function (url) {
|
||||
dataService.clipboard(url);
|
||||
}
|
||||
|
||||
$document.bind("keydown", function (event) {
|
||||
$scope.$apply(function () {
|
||||
// Esc按键,退出
|
||||
if (event.keyCode == 27) {
|
||||
$('.ui.modal.js-bookmark-info').modal("hide");
|
||||
}
|
||||
})
|
||||
});
|
||||
}]);
|
||||
app.controller('bookmarkInfoCtr', ['$scope', '$state', '$timeout', '$sce', '$window', '$filter', '$document', '$timeout', 'bookmarkService', 'pubSubService', 'dataService', function ($scope, $state, $timeout, $sce, $window, $filter, $document, $timeout, bookmarkService, pubSubService, dataService) {
|
||||
console.log("Hello bookmarkInfoCtr");
|
||||
$scope.bookmark = {}
|
||||
$scope.content = '';
|
||||
$scope.loading = false;
|
||||
|
||||
pubSubService.subscribe('TagCtr.showBookmarkInfo', $scope, async function (event, bookmark) {
|
||||
console.log('subscribe TagCtr.showBookmarkInfo', bookmark);
|
||||
$('.ui.modal.js-bookmark-info').modal({
|
||||
closable: false,
|
||||
}).modal('setting', 'transition', dataService.animation()).modal('show');
|
||||
bookmark.favicon_url = 'http://favicon.luchenqun.com/?url=' + bookmark.url;
|
||||
$scope.bookmark = bookmark;
|
||||
$scope.bookmark.description = $sce.trustAsHtml(bookmark.description);
|
||||
$scope.content = $sce.trustAsHtml(bookmark.content) || '';
|
||||
if (!$scope.content) {
|
||||
$timeout(function () {
|
||||
$('.ui.modal.js-bookmark-info').modal("refresh");
|
||||
$("p").css("word-wrap", "break-word");
|
||||
}, 500);
|
||||
$scope.loading = true;
|
||||
try {
|
||||
let data = get("getArticle", { url: bookmark.url });
|
||||
$scope.content = data.content ? $sce.trustAsHtml(data.content) : $sce.trustAsHtml('<p>数据获取失败,可能是服务器不允许获取,或者是https网站!</p>');
|
||||
setTimeout(function () {
|
||||
$('.ui.modal.js-bookmark-info').modal && $('.ui.modal.js-bookmark-info').modal("refresh");
|
||||
}, 100);
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
$scope.loading = false;
|
||||
} else {
|
||||
setTimeout(function () {
|
||||
$('.ui.modal.js-bookmark-info').modal && $('.ui.modal.js-bookmark-info').modal("refresh");
|
||||
}, 10);
|
||||
setTimeout(function () {
|
||||
$('.modals').animate({ scrollTop: 0 }, 100);
|
||||
}, 500);
|
||||
}
|
||||
});
|
||||
|
||||
$scope.jumpToUrl = async function (url, id) {
|
||||
$window.open(url, '_blank');
|
||||
if ($scope.bookmark.own) {
|
||||
await post('clickBookmark', { id });
|
||||
$scope.bookmark.clickCount += 1;
|
||||
$scope.bookmark.lastClick = $filter("date")(new Date(), "yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
}
|
||||
|
||||
$scope.copy = function (url) {
|
||||
dataService.clipboard(url);
|
||||
}
|
||||
|
||||
$document.bind("keydown", function (event) {
|
||||
$scope.$apply(function () {
|
||||
// Esc按键,退出
|
||||
if (event.keyCode == 27) {
|
||||
$('.ui.modal.js-bookmark-info').modal("hide");
|
||||
}
|
||||
})
|
||||
});
|
||||
}]);
|
||||
|
|
|
|||
|
|
@ -1,414 +1,409 @@
|
|||
app.controller('bookmarksCtr', ['$scope', '$state', '$stateParams', '$filter', '$window', '$timeout', '$document', 'ngDialog', 'bookmarkService', 'pubSubService', 'dataService', function ($scope, $state, $stateParams, $filter, $window, $timeout, $document, ngDialog, bookmarkService, pubSubService, dataService) {
|
||||
console.log("Hello bookmarksCtr...", $stateParams);
|
||||
if (dataService.smallDevice()) {
|
||||
$window.location = "http://m.mybookmark.cn/#/tags";
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.bookmarks = []; // 书签数据
|
||||
$scope.showSearch = false; // 搜索对话框
|
||||
$scope.bookmarkNormalHover = false;
|
||||
$scope.bookmarkEditHover = false;
|
||||
$scope.hoverBookmark = null;
|
||||
var menusScope = $('div[ng-controller="menuCtr"]').scope();
|
||||
$scope.showStyle = ($stateParams && $stateParams.showStyle) || (menusScope && menusScope.showStyle); // 显示风格'navigate', 'costomTag', 'card', 'table'
|
||||
const perPageItems = 20;
|
||||
var dialog = null;
|
||||
$scope.totalPages = 0;
|
||||
$scope.currentPage = 1;
|
||||
$scope.inputPage = '';
|
||||
$scope.loadBusy = false;
|
||||
$scope.waitDelBookmark = {};
|
||||
$scope.order = [false, false, false];
|
||||
$scope.order[($stateParams && $stateParams.orderIndex) || 0] = true;
|
||||
$scope.bookmarkData = {};
|
||||
$scope.costomTags = [{
|
||||
index: 0,
|
||||
clicked: true,
|
||||
name: '最近使用'
|
||||
}, {
|
||||
index: 1,
|
||||
clicked: false,
|
||||
name: '最近添加'
|
||||
}, {
|
||||
index: 2,
|
||||
clicked: false,
|
||||
name: '最多使用'
|
||||
}]
|
||||
var timeagoInstance = timeago();
|
||||
|
||||
updateShowStyle();
|
||||
getBookmarks();
|
||||
|
||||
$scope.changeCurrentPage = function (currentPage) {
|
||||
currentPage = parseInt(currentPage) || 0;
|
||||
console.log('currentPage = ', currentPage);
|
||||
if (currentPage <= $scope.totalPages && currentPage >= 1) {
|
||||
$scope.currentPage = currentPage;
|
||||
$scope.inputPage = '';
|
||||
getBookmarks();
|
||||
} else {
|
||||
$scope.currentPage = $scope.totalPages
|
||||
}
|
||||
}
|
||||
|
||||
$scope.jumpToUrl = function (url, id) {
|
||||
$window.open(url, '_blank');
|
||||
bookmarkService.clickBookmark({
|
||||
id: id
|
||||
});
|
||||
|
||||
if ($scope.showStyle != 'navigate') {
|
||||
var bookmarks = $scope.showStyle == 'table' ? $scope.bookmarkData.bookmarks : $scope.bookmarkData;
|
||||
bookmarks.forEach(function (bookmark) {
|
||||
if (bookmark.id == id) {
|
||||
bookmark.click_count += 1;
|
||||
bookmark.last_click = $filter("date")(new Date(), "yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
})
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
$timeout(function () {
|
||||
timeagoInstance.cancel();
|
||||
timeagoInstance.render(document.querySelectorAll('.need_to_be_rendered'), 'zh_CN');
|
||||
}, 100)
|
||||
}
|
||||
|
||||
$scope.delBookmark = function (bookmark) {
|
||||
console.log('delBookmark..........')
|
||||
$scope.waitDelBookmark = $.extend(true, {}, bookmark); // 利用jQuery执行深度拷贝
|
||||
dialog = ngDialog.open({
|
||||
template: './views/dialog-del-bookmark.html',
|
||||
className: 'ngdialog-theme-default',
|
||||
scope: $scope
|
||||
});
|
||||
}
|
||||
|
||||
$scope.confirmDelBookmark = function (bookmarkId) {
|
||||
var params = {
|
||||
id: bookmarkId
|
||||
}
|
||||
ngDialog.close(dialog);
|
||||
bookmarkService.delBookmark(params)
|
||||
.then((data) => {
|
||||
$("#" + bookmarkId).transition({
|
||||
animation: dataService.animation(),
|
||||
duration: 500,
|
||||
onComplete: function () {
|
||||
$("#" + bookmarkId).remove();
|
||||
}
|
||||
});
|
||||
toastr.success($scope.waitDelBookmark.title + ' 书签删除成功!', "提示");
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error($scope.waitDelBookmark.title + ' 书签删除失败!错误提示:' + JSON.stringify(err), "提示");
|
||||
});
|
||||
}
|
||||
|
||||
$scope.editBookmark = function (bookmarkId) {
|
||||
pubSubService.publish('bookmarksCtr.editBookmark', {
|
||||
'bookmarkId': bookmarkId
|
||||
});
|
||||
}
|
||||
|
||||
$scope.detailBookmark = function (b) {
|
||||
var bookmark = $.extend(true, {}, b); // 利用jQuery执行深度拷贝
|
||||
bookmark.own = true;
|
||||
if ($scope.showStyle == 'navigate') {
|
||||
bookmark.tags = [{
|
||||
id: bookmark.tag_id,
|
||||
name: bookmark.tag_name
|
||||
}];
|
||||
}
|
||||
pubSubService.publish('TagCtr.showBookmarkInfo', bookmark);
|
||||
bookmarkService.clickBookmark({
|
||||
id: bookmark.id
|
||||
});
|
||||
}
|
||||
|
||||
$scope.copy = function (url) {
|
||||
dataService.clipboard(url);
|
||||
}
|
||||
|
||||
$scope.jumpToTags = function (tagId) {
|
||||
$state.go('tags', {
|
||||
tagId: tagId,
|
||||
})
|
||||
}
|
||||
|
||||
$scope.addBookmarkbyFile = function () {
|
||||
console.log("addBookmarkbyFile");
|
||||
$state.go('settings', {
|
||||
formIndex: 2,
|
||||
});
|
||||
pubSubService.publish('Common.menuActive', {
|
||||
login: true,
|
||||
index: dataService.LoginIndexSettings
|
||||
});
|
||||
}
|
||||
|
||||
$scope.closeMsg = function () {
|
||||
$('.js-msg').transition({
|
||||
animation: dataService.animation(),
|
||||
duration: '500ms',
|
||||
onComplete: function () {
|
||||
$(".js-msg").remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$scope.loadCardData = function () {
|
||||
console.log('loadCardData.........')
|
||||
if (!$scope.loadBusy) {
|
||||
$scope.changeCurrentPage($scope.currentPage += 1)
|
||||
}
|
||||
}
|
||||
|
||||
$scope.changeOrder = function (index) {
|
||||
if (index < 0 || index >= $scope.order.length) {
|
||||
return;
|
||||
}
|
||||
$scope.order = $scope.order.map(() => false);
|
||||
$scope.order[index] = true;
|
||||
$scope.bookmarks = [];
|
||||
if ($scope.order[0]) {
|
||||
$scope.bookmarkData.bookmarks.sort(clickCmp)
|
||||
$scope.bookmarkData.bookmarks.forEach((bookmark) => {
|
||||
if (bookmark.type == 1) {
|
||||
$scope.bookmarks.push(bookmark);
|
||||
}
|
||||
})
|
||||
} else if ($scope.order[1]) {
|
||||
$scope.bookmarkData.bookmarks.sort((a, b) => a.created_at >= b.created_at ? -1 : 1);
|
||||
$scope.bookmarkData.bookmarks.forEach((bookmark) => {
|
||||
if (bookmark.type == 2) {
|
||||
$scope.bookmarks.push(bookmark);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
$scope.bookmarkData.bookmarks.sort((a, b) => a.last_click >= b.last_click ? -1 : 1);
|
||||
$scope.bookmarkData.bookmarks.forEach((bookmark) => {
|
||||
if (bookmark.type == 3) {
|
||||
$scope.bookmarks.push(bookmark);
|
||||
}
|
||||
})
|
||||
}
|
||||
$timeout(function () {
|
||||
timeagoInstance.cancel();
|
||||
timeagoInstance.render(document.querySelectorAll('.need_to_be_rendered'), 'zh_CN');
|
||||
}, 100)
|
||||
}
|
||||
|
||||
$scope.updateCostomTagBookmarks = function (index) {
|
||||
console.log('updateCostomTagBookmarks index = ' + index);
|
||||
$scope.costomTags.forEach((tag, i) => {
|
||||
$scope.costomTags[i].clicked = false;
|
||||
})
|
||||
$scope.costomTags[index].clicked = true;
|
||||
|
||||
if (index == 0) {
|
||||
$scope.bookmarkData.sort((a, b) => a.last_click >= b.last_click ? -1 : 1);
|
||||
} else if (index == 1) {
|
||||
$scope.bookmarkData.sort((a, b) => a.created_at >= b.created_at ? -1 : 1);
|
||||
} else {
|
||||
$scope.bookmarkData.sort(clickCmp)
|
||||
}
|
||||
$scope.bookmarks = $scope.bookmarkData.slice(0, 79);
|
||||
}
|
||||
|
||||
pubSubService.subscribe('EditCtr.inserBookmarsSuccess', $scope, function (event, data) {
|
||||
console.log('subscribe EditCtr.inserBookmarsSuccess', JSON.stringify(data));
|
||||
|
||||
var menusScope = $('div[ng-controller="menuCtr"]').scope();
|
||||
if (menusScope.login && menusScope.selectLoginIndex == 0) {
|
||||
$scope.forbidTransition = true;
|
||||
if ($scope.showStyle == 'card') {
|
||||
var find = false;
|
||||
$scope.bookmarks.forEach((bookmark) => {
|
||||
if (bookmark.id == data.id) {
|
||||
bookmark.title = data.title;
|
||||
bookmark.url = data.url;
|
||||
bookmark.tags = data.tags;
|
||||
bookmark.description = data.description;
|
||||
find = true;
|
||||
}
|
||||
})
|
||||
if (!find) {
|
||||
$scope.bookmarks.unshift(data);
|
||||
$timeout(function () {
|
||||
timeagoInstance.cancel();
|
||||
timeagoInstance.render(document.querySelectorAll('.need_to_be_rendered'), 'zh_CN');
|
||||
}, 100)
|
||||
}
|
||||
} else {
|
||||
$scope.forbidTransition = true;
|
||||
getBookmarks();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$scope.setHoverBookmark = function (bookmark) {
|
||||
$scope.hoverBookmark = bookmark;
|
||||
}
|
||||
|
||||
// 在输入文字的时候也会触发,所以不要用Ctrl,Shift之类的按键
|
||||
$document.bind("keydown", function (event) {
|
||||
$scope.$apply(function () {
|
||||
var key = event.key.toUpperCase();
|
||||
console.log(key);
|
||||
if ($scope.hoverBookmark && dataService.keyShortcuts()) {
|
||||
if (key == 'E') {
|
||||
$scope.editBookmark($scope.hoverBookmark.id)
|
||||
} else if (key == 'I') {
|
||||
$scope.detailBookmark($scope.hoverBookmark)
|
||||
} else if (key == 'D') {
|
||||
$scope.delBookmark($scope.hoverBookmark)
|
||||
} else if (key == 'C') {
|
||||
$scope.copy($scope.hoverBookmark.url)
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
async function getBookmarks() {
|
||||
var params = {}
|
||||
params.showStyle = $scope.showStyle
|
||||
params.currentPage = $scope.currentPage;
|
||||
params.perPageItems = perPageItems;
|
||||
|
||||
if (!params.showStyle) {
|
||||
bookmarkService.userInfo({})
|
||||
.then((user) => {
|
||||
$scope.showStyle = (user && user.show_style) || 'navigate';
|
||||
updateShowStyle();
|
||||
getBookmarks(); // 拿到默认显示风格了,继续取获取书签
|
||||
})
|
||||
.catch((err) => dataService.netErrorHandle(err, $state));
|
||||
} else {
|
||||
$scope.loadBusy = true;
|
||||
if (params.showStyle == 'table' && (!$scope.forbidTransition)) {
|
||||
$('.js-table-bookmarks').transition('hide');
|
||||
}
|
||||
bookmarkService.getBookmarks(params)
|
||||
.then((data) => {
|
||||
if (params.showStyle != 'navigate') {
|
||||
$scope.bookmarkData = data;
|
||||
$scope.totalPages = Math.ceil(data.totalItems / perPageItems);
|
||||
if (data.totalItems == 0) {
|
||||
toastr.info('您还没有书签,请点击菜单栏的添加按钮进行添加', "提示");
|
||||
}
|
||||
if (params.showStyle == 'card') {
|
||||
$scope.bookmarkData.bookmarks.sort((a, b) => a.created_at >= b.created_at ? -1 : 1);
|
||||
$scope.bookmarkData.bookmarks.forEach(bookmark => {
|
||||
if (bookmark.type == 2) {
|
||||
bookmark.edit = false;
|
||||
$scope.bookmarks.push(bookmark);
|
||||
}
|
||||
})
|
||||
$timeout(function () {
|
||||
timeagoInstance.cancel();
|
||||
timeagoInstance.render(document.querySelectorAll('.need_to_be_rendered'), 'zh_CN');
|
||||
}, 100)
|
||||
} else if (params.showStyle == 'costomTag') {
|
||||
$scope.costomTags.forEach((tag) => {
|
||||
if (tag.clicked) {
|
||||
$scope.updateCostomTagBookmarks(tag.index)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
$scope.changeOrder($scope.order.indexOf(true));
|
||||
}
|
||||
} else {
|
||||
$scope.bookmarks = data;
|
||||
if ($scope.bookmarks.length <= 2) {
|
||||
$(".js-msg").removeClass("hidden");
|
||||
}
|
||||
if ($scope.bookmarks.length == 0) {
|
||||
toastr.info('您还没有书签,请点击菜单栏的添加按钮进行添加', "提示");
|
||||
}
|
||||
}
|
||||
|
||||
pubSubService.publish('Common.menuActive', {
|
||||
login: true,
|
||||
index: dataService.LoginIndexBookmarks
|
||||
});
|
||||
if (!$scope.forbidTransition) {
|
||||
transition();
|
||||
}
|
||||
$scope.forbidTransition = false;
|
||||
$scope.loadBusy = false;
|
||||
})
|
||||
.catch((err) => {
|
||||
dataService.netErrorHandle(err, $state);
|
||||
$scope.loadBusy = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function updateShowStyle() {
|
||||
$timeout(function () {
|
||||
if ($scope.showStyle) {
|
||||
$('.js-bookmark-dropdown' + ' .radio.checkbox').checkbox('set unchecked');
|
||||
$('.js-radio-' + $scope.showStyle).checkbox('set checked');
|
||||
$('.js-bookmark-dropdown' + ' .field.item').removeClass('active selected');
|
||||
$('.js-field-' + $scope.showStyle).addClass('active selected');
|
||||
}
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
function transition() {
|
||||
if ($scope.showStyle == 'card' && $scope.currentPage > 1) {
|
||||
return;
|
||||
}
|
||||
var className = 'js-segment-navigate';
|
||||
if ($scope.showStyle == 'card') {
|
||||
className = 'js-segment-card'
|
||||
} else if ($scope.showStyle == 'table') {
|
||||
className = 'js-table-bookmarks'
|
||||
} else if ($scope.showStyle == 'costomTag') {
|
||||
className = 'js-segment-costomTag'
|
||||
}
|
||||
$('.' + className).transition('hide');
|
||||
$('.' + className).transition({
|
||||
animation: dataService.animation(),
|
||||
duration: 500,
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: 我要将编辑按钮固定在容器的右上角
|
||||
$(window).resize(updateEditPos);
|
||||
updateEditPos();
|
||||
|
||||
function updateEditPos() {
|
||||
if ($scope.showStyle == 'navigate') {
|
||||
for (var i = 1; i <= 100; i += 10) {
|
||||
setTimeout(function () {
|
||||
var offset = $('.js-segment-navigate').offset();
|
||||
if (offset) {
|
||||
var t = offset.top;
|
||||
var l = offset.left;
|
||||
var w = $('.js-segment-navigate').width();
|
||||
$('.js-bookmark-edit').offset({
|
||||
top: t + 10,
|
||||
left: l + w - 10,
|
||||
})
|
||||
}
|
||||
}, 100 * i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function clickCmp(a, b) {
|
||||
var click1 = parseInt(a.click_count);
|
||||
var click2 = parseInt(b.click_count);
|
||||
if (click1 > click2) {
|
||||
return -1;
|
||||
} else if (click1 == click2) {
|
||||
return a.created_at >= b.created_at ? -1 : 1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}]);
|
||||
app.controller('bookmarksCtr', ['$scope', '$state', '$stateParams', '$filter', '$window', '$timeout', '$document', 'ngDialog', 'bookmarkService', 'pubSubService', 'dataService', function ($scope, $state, $stateParams, $filter, $window, $timeout, $document, ngDialog, bookmarkService, pubSubService, dataService) {
|
||||
console.log("Hello bookmarksCtr...", $stateParams);
|
||||
if (dataService.smallDevice()) {
|
||||
$window.location = "http://m.mybookmark.cn/#/tags";
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.bookmarks = []; // 书签数据
|
||||
$scope.showSearch = false; // 搜索对话框
|
||||
$scope.bookmarkNormalHover = false;
|
||||
$scope.bookmarkEditHover = false;
|
||||
$scope.hoverBookmark = null;
|
||||
var menusScope = $('div[ng-controller="menuCtr"]').scope();
|
||||
$scope.showStyle = ($stateParams && $stateParams.showStyle) || (menusScope && menusScope.showStyle); // 显示风格'navigate', 'costomTag', 'card', 'table'
|
||||
const perPageItems = 20;
|
||||
var dialog = null;
|
||||
$scope.totalPages = 0;
|
||||
$scope.currentPage = 1;
|
||||
$scope.inputPage = '';
|
||||
$scope.loadBusy = false;
|
||||
$scope.waitDelBookmark = {};
|
||||
$scope.order = [false, false, false];
|
||||
$scope.order[($stateParams && $stateParams.orderIndex) || 0] = true;
|
||||
$scope.bookmarkData = {};
|
||||
$scope.costomTags = [{
|
||||
index: 0,
|
||||
clicked: true,
|
||||
name: '最近使用'
|
||||
}, {
|
||||
index: 1,
|
||||
clicked: false,
|
||||
name: '最近添加'
|
||||
}, {
|
||||
index: 2,
|
||||
clicked: false,
|
||||
name: '最多使用'
|
||||
}]
|
||||
var timeagoInstance = timeago();
|
||||
|
||||
updateShowStyle();
|
||||
getBookmarks();
|
||||
|
||||
$scope.changeCurrentPage = function (currentPage) {
|
||||
currentPage = parseInt(currentPage) || 0;
|
||||
console.log('currentPage = ', currentPage);
|
||||
if (currentPage <= $scope.totalPages && currentPage >= 1) {
|
||||
$scope.currentPage = currentPage;
|
||||
$scope.inputPage = '';
|
||||
getBookmarks();
|
||||
} else {
|
||||
$scope.currentPage = $scope.totalPages
|
||||
}
|
||||
}
|
||||
|
||||
$scope.jumpToUrl = async function (url, id) {
|
||||
$window.open(url, '_blank');
|
||||
await post("clickBookmark", { id });
|
||||
|
||||
|
||||
if ($scope.showStyle != 'navigate') {
|
||||
var bookmarks = $scope.showStyle == 'table' ? $scope.bookmarkData.bookmarks : $scope.bookmarkData;
|
||||
bookmarks.forEach(function (bookmark) {
|
||||
if (bookmark.id == id) {
|
||||
bookmark.click_count += 1;
|
||||
bookmark.last_click = $filter("date")(new Date(), "yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
})
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
$timeout(function () {
|
||||
timeagoInstance.cancel();
|
||||
timeagoInstance.render(document.querySelectorAll('.need_to_be_rendered'), 'zh_CN');
|
||||
}, 100)
|
||||
}
|
||||
|
||||
$scope.delBookmark = function (bookmark) {
|
||||
console.log('delBookmark..........')
|
||||
$scope.waitDelBookmark = $.extend(true, {}, bookmark); // 利用jQuery执行深度拷贝
|
||||
dialog = ngDialog.open({
|
||||
template: './views/dialog-del-bookmark.html',
|
||||
className: 'ngdialog-theme-default',
|
||||
scope: $scope
|
||||
});
|
||||
}
|
||||
|
||||
$scope.confirmDelBookmark = function (bookmarkId) {
|
||||
var params = {
|
||||
id: bookmarkId
|
||||
}
|
||||
ngDialog.close(dialog);
|
||||
bookmarkService.delBookmark(params)
|
||||
.then((data) => {
|
||||
$("#" + bookmarkId).transition({
|
||||
animation: dataService.animation(),
|
||||
duration: 500,
|
||||
onComplete: function () {
|
||||
$("#" + bookmarkId).remove();
|
||||
}
|
||||
});
|
||||
toastr.success($scope.waitDelBookmark.title + ' 书签删除成功!', "提示");
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error($scope.waitDelBookmark.title + ' 书签删除失败!错误提示:' + JSON.stringify(err), "提示");
|
||||
});
|
||||
}
|
||||
|
||||
$scope.editBookmark = function (id) {
|
||||
pubSubService.publish('bookmarksCtr.editBookmark', { id });
|
||||
}
|
||||
|
||||
$scope.detailBookmark = async function (b) {
|
||||
var bookmark = $.extend(true, {}, b); // 利用jQuery执行深度拷贝
|
||||
bookmark.own = true;
|
||||
if ($scope.showStyle == 'navigate') {
|
||||
bookmark.tags = [{
|
||||
id: bookmark.tag_id,
|
||||
name: bookmark.tag_name
|
||||
}];
|
||||
}
|
||||
pubSubService.publish('TagCtr.showBookmarkInfo', bookmark);
|
||||
await post("clickBookmark", { id: bookmark.id });
|
||||
}
|
||||
|
||||
$scope.copy = function (url) {
|
||||
dataService.clipboard(url);
|
||||
}
|
||||
|
||||
$scope.jumpToTags = function (tagId) {
|
||||
$state.go('tags', {
|
||||
tagId: tagId,
|
||||
})
|
||||
}
|
||||
|
||||
$scope.addBookmarkbyFile = function () {
|
||||
console.log("addBookmarkbyFile");
|
||||
$state.go('settings', {
|
||||
formIndex: 2,
|
||||
});
|
||||
pubSubService.publish('Common.menuActive', {
|
||||
login: true,
|
||||
index: dataService.LoginIndexSettings
|
||||
});
|
||||
}
|
||||
|
||||
$scope.closeMsg = function () {
|
||||
$('.js-msg').transition({
|
||||
animation: dataService.animation(),
|
||||
duration: '500ms',
|
||||
onComplete: function () {
|
||||
$(".js-msg").remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$scope.loadCardData = function () {
|
||||
console.log('loadCardData.........')
|
||||
if (!$scope.loadBusy) {
|
||||
$scope.changeCurrentPage($scope.currentPage += 1)
|
||||
}
|
||||
}
|
||||
|
||||
$scope.changeOrder = function (index) {
|
||||
if (index < 0 || index >= $scope.order.length) {
|
||||
return;
|
||||
}
|
||||
$scope.order = $scope.order.map(() => false);
|
||||
$scope.order[index] = true;
|
||||
$scope.bookmarks = [];
|
||||
if ($scope.order[0]) {
|
||||
$scope.bookmarkData.bookmarks.sort(clickCmp)
|
||||
$scope.bookmarkData.bookmarks.forEach((bookmark) => {
|
||||
if (bookmark.type == 1) {
|
||||
$scope.bookmarks.push(bookmark);
|
||||
}
|
||||
})
|
||||
} else if ($scope.order[1]) {
|
||||
$scope.bookmarkData.bookmarks.sort((a, b) => a.created_at >= b.created_at ? -1 : 1);
|
||||
$scope.bookmarkData.bookmarks.forEach((bookmark) => {
|
||||
if (bookmark.type == 2) {
|
||||
$scope.bookmarks.push(bookmark);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
$scope.bookmarkData.bookmarks.sort((a, b) => a.last_click >= b.last_click ? -1 : 1);
|
||||
$scope.bookmarkData.bookmarks.forEach((bookmark) => {
|
||||
if (bookmark.type == 3) {
|
||||
$scope.bookmarks.push(bookmark);
|
||||
}
|
||||
})
|
||||
}
|
||||
$timeout(function () {
|
||||
timeagoInstance.cancel();
|
||||
timeagoInstance.render(document.querySelectorAll('.need_to_be_rendered'), 'zh_CN');
|
||||
}, 100)
|
||||
}
|
||||
|
||||
$scope.updateCostomTagBookmarks = function (index) {
|
||||
console.log('updateCostomTagBookmarks index = ' + index);
|
||||
$scope.costomTags.forEach((tag, i) => {
|
||||
$scope.costomTags[i].clicked = false;
|
||||
})
|
||||
$scope.costomTags[index].clicked = true;
|
||||
|
||||
if (index == 0) {
|
||||
$scope.bookmarkData.sort((a, b) => a.last_click >= b.last_click ? -1 : 1);
|
||||
} else if (index == 1) {
|
||||
$scope.bookmarkData.sort((a, b) => a.created_at >= b.created_at ? -1 : 1);
|
||||
} else {
|
||||
$scope.bookmarkData.sort(clickCmp)
|
||||
}
|
||||
$scope.bookmarks = $scope.bookmarkData.slice(0, 79);
|
||||
}
|
||||
|
||||
pubSubService.subscribe('EditCtr.inserBookmarsSuccess', $scope, function (event, data) {
|
||||
console.log('subscribe EditCtr.inserBookmarsSuccess', JSON.stringify(data));
|
||||
|
||||
var menusScope = $('div[ng-controller="menuCtr"]').scope();
|
||||
if (menusScope.login && menusScope.selectLoginIndex == 0) {
|
||||
$scope.forbidTransition = true;
|
||||
if ($scope.showStyle == 'card') {
|
||||
var find = false;
|
||||
$scope.bookmarks.forEach((bookmark) => {
|
||||
if (bookmark.id == data.id) {
|
||||
bookmark.title = data.title;
|
||||
bookmark.url = data.url;
|
||||
bookmark.tags = data.tags;
|
||||
bookmark.description = data.description;
|
||||
find = true;
|
||||
}
|
||||
})
|
||||
if (!find) {
|
||||
$scope.bookmarks.unshift(data);
|
||||
$timeout(function () {
|
||||
timeagoInstance.cancel();
|
||||
timeagoInstance.render(document.querySelectorAll('.need_to_be_rendered'), 'zh_CN');
|
||||
}, 100)
|
||||
}
|
||||
} else {
|
||||
$scope.forbidTransition = true;
|
||||
getBookmarks();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$scope.setHoverBookmark = function (bookmark) {
|
||||
$scope.hoverBookmark = bookmark;
|
||||
}
|
||||
|
||||
// 在输入文字的时候也会触发,所以不要用Ctrl,Shift之类的按键
|
||||
$document.bind("keydown", function (event) {
|
||||
$scope.$apply(function () {
|
||||
var key = event.key.toUpperCase();
|
||||
console.log(key);
|
||||
if ($scope.hoverBookmark && dataService.keyShortcuts()) {
|
||||
if (key == 'E') {
|
||||
$scope.editBookmark($scope.hoverBookmark.id)
|
||||
} else if (key == 'I') {
|
||||
$scope.detailBookmark($scope.hoverBookmark)
|
||||
} else if (key == 'D') {
|
||||
$scope.delBookmark($scope.hoverBookmark)
|
||||
} else if (key == 'C') {
|
||||
$scope.copy($scope.hoverBookmark.url)
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
async function getBookmarks() {
|
||||
var params = {}
|
||||
params.showStyle = $scope.showStyle
|
||||
params.currentPage = $scope.currentPage;
|
||||
params.perPageItems = perPageItems;
|
||||
|
||||
if (!params.showStyle) {
|
||||
bookmarkService.userInfo({})
|
||||
.then((user) => {
|
||||
$scope.showStyle = (user && user.show_style) || 'navigate';
|
||||
updateShowStyle();
|
||||
getBookmarks(); // 拿到默认显示风格了,继续取获取书签
|
||||
})
|
||||
.catch((err) => dataService.netErrorHandle(err, $state));
|
||||
} else {
|
||||
$scope.loadBusy = true;
|
||||
if (params.showStyle == 'table' && (!$scope.forbidTransition)) {
|
||||
$('.js-table-bookmarks').transition('hide');
|
||||
}
|
||||
bookmarkService.getBookmarks(params)
|
||||
.then((data) => {
|
||||
if (params.showStyle != 'navigate') {
|
||||
$scope.bookmarkData = data;
|
||||
$scope.totalPages = Math.ceil(data.totalItems / perPageItems);
|
||||
if (data.totalItems == 0) {
|
||||
toastr.info('您还没有书签,请点击菜单栏的添加按钮进行添加', "提示");
|
||||
}
|
||||
if (params.showStyle == 'card') {
|
||||
$scope.bookmarkData.bookmarks.sort((a, b) => a.created_at >= b.created_at ? -1 : 1);
|
||||
$scope.bookmarkData.bookmarks.forEach(bookmark => {
|
||||
if (bookmark.type == 2) {
|
||||
bookmark.edit = false;
|
||||
$scope.bookmarks.push(bookmark);
|
||||
}
|
||||
})
|
||||
$timeout(function () {
|
||||
timeagoInstance.cancel();
|
||||
timeagoInstance.render(document.querySelectorAll('.need_to_be_rendered'), 'zh_CN');
|
||||
}, 100)
|
||||
} else if (params.showStyle == 'costomTag') {
|
||||
$scope.costomTags.forEach((tag) => {
|
||||
if (tag.clicked) {
|
||||
$scope.updateCostomTagBookmarks(tag.index)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
$scope.changeOrder($scope.order.indexOf(true));
|
||||
}
|
||||
} else {
|
||||
$scope.bookmarks = data;
|
||||
if ($scope.bookmarks.length <= 2) {
|
||||
$(".js-msg").removeClass("hidden");
|
||||
}
|
||||
if ($scope.bookmarks.length == 0) {
|
||||
toastr.info('您还没有书签,请点击菜单栏的添加按钮进行添加', "提示");
|
||||
}
|
||||
}
|
||||
|
||||
pubSubService.publish('Common.menuActive', {
|
||||
login: true,
|
||||
index: dataService.LoginIndexBookmarks
|
||||
});
|
||||
if (!$scope.forbidTransition) {
|
||||
transition();
|
||||
}
|
||||
$scope.forbidTransition = false;
|
||||
$scope.loadBusy = false;
|
||||
})
|
||||
.catch((err) => {
|
||||
dataService.netErrorHandle(err, $state);
|
||||
$scope.loadBusy = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function updateShowStyle() {
|
||||
$timeout(function () {
|
||||
if ($scope.showStyle) {
|
||||
$('.js-bookmark-dropdown' + ' .radio.checkbox').checkbox('set unchecked');
|
||||
$('.js-radio-' + $scope.showStyle).checkbox('set checked');
|
||||
$('.js-bookmark-dropdown' + ' .field.item').removeClass('active selected');
|
||||
$('.js-field-' + $scope.showStyle).addClass('active selected');
|
||||
}
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
function transition() {
|
||||
if ($scope.showStyle == 'card' && $scope.currentPage > 1) {
|
||||
return;
|
||||
}
|
||||
var className = 'js-segment-navigate';
|
||||
if ($scope.showStyle == 'card') {
|
||||
className = 'js-segment-card'
|
||||
} else if ($scope.showStyle == 'table') {
|
||||
className = 'js-table-bookmarks'
|
||||
} else if ($scope.showStyle == 'costomTag') {
|
||||
className = 'js-segment-costomTag'
|
||||
}
|
||||
$('.' + className).transition('hide');
|
||||
$('.' + className).transition({
|
||||
animation: dataService.animation(),
|
||||
duration: 500,
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: 我要将编辑按钮固定在容器的右上角
|
||||
$(window).resize(updateEditPos);
|
||||
updateEditPos();
|
||||
|
||||
function updateEditPos() {
|
||||
if ($scope.showStyle == 'navigate') {
|
||||
for (var i = 1; i <= 100; i += 10) {
|
||||
setTimeout(function () {
|
||||
var offset = $('.js-segment-navigate').offset();
|
||||
if (offset) {
|
||||
var t = offset.top;
|
||||
var l = offset.left;
|
||||
var w = $('.js-segment-navigate').width();
|
||||
$('.js-bookmark-edit').offset({
|
||||
top: t + 10,
|
||||
left: l + w - 10,
|
||||
})
|
||||
}
|
||||
}, 100 * i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function clickCmp(a, b) {
|
||||
var click1 = parseInt(a.click_count);
|
||||
var click2 = parseInt(b.click_count);
|
||||
if (click1 > click2) {
|
||||
return -1;
|
||||
} else if (click1 == click2) {
|
||||
return a.created_at >= b.created_at ? -1 : 1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}]);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ app.controller('editCtr', ['$scope', '$state', '$timeout', '$document', 'ngDialo
|
|||
var cancelDefault = false;
|
||||
init();
|
||||
|
||||
$scope.$watch('url', function (newUrl, oldUrl, scope) {
|
||||
$scope.$watch('url', async function (newUrl, oldUrl, scope) {
|
||||
$timeout(function () {
|
||||
$scope.urlError = $scope.url == '' && $('.ui.modal.js-add-bookmark').modal('is active');
|
||||
});
|
||||
|
|
@ -17,23 +17,21 @@ app.controller('editCtr', ['$scope', '$state', '$timeout', '$document', 'ngDialo
|
|||
requestId: 0,
|
||||
}
|
||||
$scope.loadTitle = true;
|
||||
bookmarkService.getArticle(params)
|
||||
.then((data) => {
|
||||
$scope.loadTitle = false;
|
||||
$scope.originTitle = data.title;
|
||||
$scope.title = data.title;
|
||||
try {
|
||||
let data = await get('getArticle', { url: newUrl });
|
||||
$scope.loadTitle = false;
|
||||
$scope.originTitle = data.title;
|
||||
$scope.title = data.title;
|
||||
|
||||
if (!$scope.title) {
|
||||
toastr.error('获取书签标题失败,请手动填入', "提示");
|
||||
} else {
|
||||
$scope.title = data.title.split('-')[0].trim();
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('getTitle err', err);
|
||||
toastr.error('获取书签标题失败:' + JSON.stringify(err) + ',请手动填入', "提示");
|
||||
$scope.loadTitle = false;
|
||||
})
|
||||
if (!$scope.title) {
|
||||
toastr.error('获取书签标题失败,请手动填入', "提示");
|
||||
} else {
|
||||
$scope.title = data.title.split('-')[0].trim();
|
||||
}
|
||||
} catch (error) {
|
||||
toastr.error('获取书签标题失败:' + JSON.stringify(err) + ',请手动填入', "提示");
|
||||
$scope.loadTitle = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -84,7 +82,7 @@ app.controller('editCtr', ['$scope', '$state', '$timeout', '$document', 'ngDialo
|
|||
return;
|
||||
}
|
||||
if ($scope.tagsError) {
|
||||
toastr.error('您至少要选择一个分类!最多选择三个分类!如果暂时没想到放到哪个分类,可以先选择未分类', "错误");
|
||||
toastr.error('您至少要选择一个分类!如果暂时没想到放到哪个分类,可以先选择未分类', "错误");
|
||||
return;
|
||||
}
|
||||
if ($scope.titleError) {
|
||||
|
|
@ -98,16 +96,10 @@ app.controller('editCtr', ['$scope', '$state', '$timeout', '$document', 'ngDialo
|
|||
$('.ui.modal.js-add-bookmark').modal('hide');
|
||||
pubSubService.publish('EditCtr.inserBookmarsSuccess', params);
|
||||
} else {
|
||||
bookmarkService.updateBookmark(params)
|
||||
.then((data) => {
|
||||
$('.ui.modal.js-add-bookmark').modal('hide');
|
||||
pubSubService.publish('EditCtr.inserBookmarsSuccess', data);
|
||||
toastr.success('[ ' + params.title + ' ] 更新成功,将自动重新更新书签!', "提示");
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('updateBookmark err', err);
|
||||
toastr.error('[ ' + params.title + ' ] 更新失败' + JSON.stringify(err), "提示");
|
||||
});
|
||||
await post('updateBookmark', params);
|
||||
$('.ui.modal.js-add-bookmark').modal('hide');
|
||||
pubSubService.publish('EditCtr.inserBookmarsSuccess', data);
|
||||
toastr.success('[ ' + params.title + ' ] 更新成功,将自动重新更新书签!', "提示");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -168,7 +160,7 @@ app.controller('editCtr', ['$scope', '$state', '$timeout', '$document', 'ngDialo
|
|||
getTags();
|
||||
});
|
||||
|
||||
pubSubService.subscribe('bookmarksCtr.editBookmark', $scope, function (event, params) {
|
||||
pubSubService.subscribe('bookmarksCtr.editBookmark', $scope, async function (event, params) {
|
||||
console.log('subscribe bookmarksCtr.editBookmark', params);
|
||||
$('.ui.modal.js-add-bookmark').modal({
|
||||
closable: false,
|
||||
|
|
@ -178,36 +170,24 @@ app.controller('editCtr', ['$scope', '$state', '$timeout', '$document', 'ngDialo
|
|||
}, 500);
|
||||
$scope.add = false;
|
||||
$scope.loadTags = true;
|
||||
$scope.autoGettitle = false;
|
||||
|
||||
cancelDefault = false;
|
||||
bookmarkService.getBookmark(params)
|
||||
.then((data) => {
|
||||
console.log('getBookmark ', data);
|
||||
|
||||
var bookmark = data.bookmark;
|
||||
$scope.autoGettitle = false;
|
||||
$scope.id = (bookmark && bookmark.id) || '';
|
||||
$scope.url = (bookmark && bookmark.url) || '';
|
||||
$scope.title = (bookmark && bookmark.title) || '';
|
||||
$scope.description = (bookmark && bookmark.description) || '';
|
||||
$scope.tags = data.tags.map((tag) => {
|
||||
tag.clicked = false;
|
||||
return tag;
|
||||
});
|
||||
$scope.public = (bookmark && bookmark.id) || '1';
|
||||
$('.ui.checkbox.js-public').checkbox((bookmark && bookmark.public && bookmark.public == '1') ? 'set checked' : 'set unchecked')
|
||||
let bookmark = await get("bookmark", params);
|
||||
let tags = await get("tags");
|
||||
|
||||
$timeout(function () {
|
||||
data.bookmarkTags.forEach((tagId) => {
|
||||
$scope.tags.forEach((tag) => {
|
||||
if (tag.id == tagId) {
|
||||
tag.clicked = true;
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
$scope.loadTags = false;
|
||||
})
|
||||
.catch((err) => console.log('updateBookmark err', err));
|
||||
$scope.id = (bookmark && bookmark.id) || '';
|
||||
$scope.url = (bookmark && bookmark.url) || '';
|
||||
$scope.title = (bookmark && bookmark.title) || '';
|
||||
$scope.description = (bookmark && bookmark.description) || '';
|
||||
$scope.tags = tags.map((tag) => {
|
||||
tag.clicked = bookmark.tagId == tag.id;
|
||||
return tag;
|
||||
});
|
||||
$scope.public = (bookmark && bookmark.id) || '1';
|
||||
$('.ui.checkbox.js-public').checkbox((bookmark && bookmark.public && bookmark.public == '1') ? 'set checked' : 'set unchecked')
|
||||
$scope.loadTags = false;
|
||||
});
|
||||
|
||||
pubSubService.subscribe('TagCtr.storeBookmark', $scope, function (event, bookmark) {
|
||||
|
|
|
|||
|
|
@ -26,12 +26,12 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
|
|||
$scope.loginMenus = dataService.loginMenus; // 登陆之后显示的菜单数据。uiSerf:内部跳转链接。
|
||||
$scope.notLoginMenus = dataService.notLoginMenus; // 未登陆显示的菜单数据
|
||||
|
||||
(async () => {
|
||||
$scope.user = await get('own');
|
||||
if (data.username === 'lcq') {
|
||||
get('own').then(user => {
|
||||
$scope.user = user;
|
||||
if ($scope.user.username === 'lcq') {
|
||||
$scope.loginMenus[dataService.LoginIndexHot].show = false;
|
||||
}
|
||||
})();
|
||||
});
|
||||
|
||||
$scope.toggleReady = function (ready) {
|
||||
if (ready) {
|
||||
|
|
|
|||
|
|
@ -1,441 +1,387 @@
|
|||
app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$window', '$timeout', '$document', 'ngDialog', 'bookmarkService', 'pubSubService', 'dataService', function ($scope, $state, $stateParams, $filter, $window, $timeout, $document, ngDialog, bookmarkService, pubSubService, dataService) {
|
||||
console.log("Hello noteCtr...", $stateParams);
|
||||
if (dataService.smallDevice()) {
|
||||
$window.location = "http://m.mybookmark.cn/#/tags";
|
||||
return;
|
||||
}
|
||||
|
||||
const perPageItems = 35;
|
||||
var dialog = null;
|
||||
$scope.hoverNote = null;
|
||||
$scope.loadBusy = false;
|
||||
$scope.add = false;
|
||||
$scope.edit = false;
|
||||
$scope.preContent = '';
|
||||
$scope.content = '';
|
||||
$scope.currentTagId = null;
|
||||
$scope.currentNoteId = null;
|
||||
$scope.tags = []; // 书签数据
|
||||
$scope.notes = [];
|
||||
$scope.totalPages = 0;
|
||||
$scope.currentPage = 1;
|
||||
$scope.inputPage = '';
|
||||
$scope.searchWord = $stateParams.searchWord
|
||||
$scope.key = $stateParams.key
|
||||
$scope.totalItems = 0;
|
||||
|
||||
var timeagoInstance = timeago();
|
||||
|
||||
bookmarkService.autoLogin()
|
||||
.then((data) => {
|
||||
var login = data.logined;
|
||||
var index = login ? dataService.LoginIndexNote : dataService.NotLoginIndexLogin;
|
||||
pubSubService.publish('Common.menuActive', {
|
||||
login: login,
|
||||
index: index
|
||||
});
|
||||
getTags();
|
||||
getNotes();
|
||||
})
|
||||
.catch((err) => {
|
||||
dataService.netErrorHandle(err, $state)
|
||||
});
|
||||
|
||||
$scope.changeCurrentPage = function (currentPage) {
|
||||
currentPage = parseInt(currentPage) || 0;
|
||||
if (currentPage <= $scope.totalPages && currentPage >= 1) {
|
||||
$scope.currentPage = currentPage;
|
||||
$scope.inputPage = '';
|
||||
getNotes();
|
||||
} else {
|
||||
$scope.currentPage = $scope.totalPages
|
||||
}
|
||||
}
|
||||
|
||||
// 快捷键a增加书签
|
||||
$document.bind("keydown", function (event) {
|
||||
$scope.$apply(function () {
|
||||
// a按键,显示
|
||||
var key = event.key.toUpperCase();
|
||||
if (key == 'A' && dataService.keyShortcuts() && (!$scope.add)) {
|
||||
$scope.showAddNote();
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
$scope.showAddNote = function () {
|
||||
$scope.add = (!$scope.add);
|
||||
$scope.edit = false;
|
||||
$scope.content = '';
|
||||
if ($scope.add) {
|
||||
$timeout(function () {
|
||||
$("#noteedit")[0].focus();
|
||||
});
|
||||
}
|
||||
console.log('$scope.showAddNote');
|
||||
// 没有选中分类,默认一个分类
|
||||
if (!$scope.currentTagId) {
|
||||
$scope.tags.forEach((tag) => {
|
||||
tag.clicked = false;
|
||||
if (tag.name == '未分类') {
|
||||
$scope.currentTagId = tag.id;
|
||||
tag.clicked = true;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
$scope.addNote = function (close) {
|
||||
if ($scope.content == '') {
|
||||
toastr.error('不允许备忘录内容为空!', "提示");
|
||||
return;
|
||||
}
|
||||
if ($scope.preContent == $scope.content) {
|
||||
toastr.error('您刚刚添加了这条内容!', "提示");
|
||||
return;
|
||||
}
|
||||
$scope.add = close;
|
||||
var tagName = '';
|
||||
|
||||
$scope.tags.forEach((tag) => {
|
||||
if ($scope.currentTagId === tag.id) {
|
||||
tagName = tag.name;
|
||||
tag.ncnt += 1;
|
||||
}
|
||||
if (!$scope.currentTagId) {
|
||||
if (tag.name == '未分类') {
|
||||
$scope.currentTagId = tag.id;
|
||||
tagName = tag.name
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
var note = {
|
||||
tag_id: $scope.currentTagId,
|
||||
content: $scope.content,
|
||||
}
|
||||
|
||||
bookmarkService.addNote(note)
|
||||
.then((data) => {
|
||||
// 增加成功,重新获取一次备忘录
|
||||
$scope.tags.forEach((tag) => {
|
||||
tag.clicked = false;
|
||||
})
|
||||
$scope.preContent = $scope.content;
|
||||
$scope.content = '';
|
||||
$scope.currentTagId = null;
|
||||
$scope.currentPage = 1;
|
||||
$scope.searchWord = '';
|
||||
getNotes();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('addNote err', err);
|
||||
$scope.currentTagId = null;
|
||||
});
|
||||
}
|
||||
|
||||
$scope.copy = function (content, $event) {
|
||||
dataService.clipboard(content);
|
||||
$event && $event.stopPropagation();
|
||||
}
|
||||
|
||||
$scope.delNote = function (id, content) {
|
||||
$scope.currentNoteId = id;
|
||||
$scope.content = content;
|
||||
var width = content.length >= 500 ? "50%" : "30%";
|
||||
dialog = ngDialog.open({
|
||||
template: './views/dialog-del-note.html',
|
||||
className: 'ngdialog-theme-default',
|
||||
width: width,
|
||||
scope: $scope
|
||||
});
|
||||
}
|
||||
|
||||
$scope.confirmDelNote = function () {
|
||||
if ($scope.currentNoteId) {
|
||||
var params = {
|
||||
id: $scope.currentNoteId
|
||||
}
|
||||
ngDialog.close(dialog);
|
||||
bookmarkService.delNote(params)
|
||||
.then((data) => {
|
||||
if (data.result == 1) {
|
||||
$("#" + $scope.currentNoteId).transition({
|
||||
animation: dataService.animation(),
|
||||
duration: 500,
|
||||
onComplete: function () {
|
||||
$("#" + $scope.currentNoteId).remove();
|
||||
}
|
||||
});
|
||||
toastr.success('备忘删除成功!', "提示");
|
||||
$scope.totalItems -= 1;
|
||||
} else {
|
||||
toastr.error('没有找到对应的备忘录,删除失败!请刷新页面再尝试', "提示");
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error('备忘删除失败!错误提示:' + JSON.stringify(err), "提示");
|
||||
});
|
||||
} else {
|
||||
toastr.error('删除失败!请刷新页面再尝试', "提示");
|
||||
}
|
||||
}
|
||||
|
||||
$scope.editNote = function (id, content, tagId) {
|
||||
$scope.add = true;
|
||||
$scope.edit = true;
|
||||
$scope.content = content;
|
||||
$scope.currentNoteId = id;
|
||||
$scope.currentTagId = tagId;
|
||||
updateSelectTag(tagId);
|
||||
}
|
||||
|
||||
$scope.updateNote = function () {
|
||||
if (!$scope.content) {
|
||||
toastr.error('更新失败,更新内容不能为空', "提示");
|
||||
return;
|
||||
}
|
||||
var tagName = '';
|
||||
$scope.tags.forEach((tag) => {
|
||||
if ($scope.currentTagId === tag.id) {
|
||||
tagName = tag.name;
|
||||
}
|
||||
if (!$scope.currentTagId) {
|
||||
if (tag.name == '未分类') {
|
||||
$scope.currentTagId = tag.id;
|
||||
tagName = tag.name
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
var params = {
|
||||
id: $scope.currentNoteId,
|
||||
content: $scope.content,
|
||||
tag_id: $scope.currentTagId,
|
||||
}
|
||||
|
||||
bookmarkService.updateNote(params)
|
||||
.then((data) => {
|
||||
if (data.result == 1) {
|
||||
toastr.success('备忘更新成功!', "提示");
|
||||
$scope.notes.forEach((note) => {
|
||||
if (note.id == $scope.currentNoteId) {
|
||||
note.content = $scope.content;
|
||||
note.tagName = tagName;
|
||||
note.tag_id = $scope.currentTagId;
|
||||
toPos(note.id);
|
||||
}
|
||||
})
|
||||
$scope.add = false;
|
||||
$scope.edit = false;
|
||||
} else {
|
||||
toastr.error('备忘更新失败!请刷新页面再尝试', "提示");
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error('备忘更新失败!错误提示:' + JSON.stringify(err), "提示");
|
||||
});
|
||||
}
|
||||
|
||||
$scope.detailNote = function (content) {
|
||||
$scope.content = content;
|
||||
var width = content.length >= 500 ? "50%" : "30%";
|
||||
dialog = ngDialog.open({
|
||||
template: './views/dialog-detail-note.html',
|
||||
className: 'ngdialog-theme-default',
|
||||
width: width,
|
||||
scope: $scope
|
||||
});
|
||||
}
|
||||
|
||||
$scope.closeNote = function () {
|
||||
$('.js-note').transition({
|
||||
animation: dataService.animation(),
|
||||
duration: '500ms',
|
||||
onComplete: function () {
|
||||
$(".js-note").remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$scope.setHoverNote = function (note) {
|
||||
$scope.hoverNote = note;
|
||||
}
|
||||
|
||||
$scope.clickTag = function (id) {
|
||||
$scope.currentTagId = id;
|
||||
$scope.totalItems = 0;
|
||||
updateSelectTag(id);
|
||||
|
||||
if ($scope.add || $scope.edit) {
|
||||
|
||||
} else {
|
||||
$scope.currentPage = 1;
|
||||
getNotes($scope.currentTagId);
|
||||
}
|
||||
}
|
||||
|
||||
$scope.noteClick = function (note, flag, $event) {
|
||||
if (!note.detail || flag) {
|
||||
var detail = note.detail;
|
||||
$scope.notes.forEach((note) => {
|
||||
note.detail = false;
|
||||
$("#" + note.id).removeClass("secondary");
|
||||
})
|
||||
note.detail = !detail;
|
||||
note.detail && $("#" + note.id).addClass("secondary") && toPos(note.id);
|
||||
}
|
||||
if (flag) {
|
||||
$event && $event.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
$scope.share = function (note) {
|
||||
var time = 100;
|
||||
if (note.public == '0') {
|
||||
toastr.info('由于打算分享备忘,系统会自动将备忘的私密状态转为公开状态');
|
||||
$scope.updatePublic(note, '1');
|
||||
time = 1000;
|
||||
}
|
||||
setTimeout(() => {
|
||||
dataService.clipboard(`https://mybookmark.cn/api/notes/?shareNote=${note.id}`);
|
||||
toastr.info(`将地址 https://mybookmark.cn/api/notes/?shareNote=${note.id} 发给别人粘贴到浏览器地址栏就可以访问到你分享的备忘啦!`, "提示");
|
||||
}, time)
|
||||
|
||||
}
|
||||
|
||||
$scope.updatePublic = function (note, public) {
|
||||
var params = {
|
||||
id: note.id,
|
||||
public: public,
|
||||
}
|
||||
|
||||
bookmarkService.updateNotePublic(params)
|
||||
.then((data) => {
|
||||
if (data.result == 1) {
|
||||
public == 1 && toastr.success('备忘已由私密状态转为公开状态', "提示");
|
||||
public == 0 && toastr.success('备忘已由公开状态转为私密状态', "提示");
|
||||
note.public = public;
|
||||
} else {
|
||||
toastr.error('备忘状态更新失败', "提示");
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error('备忘更新失败!错误提示:' + JSON.stringify(err), "提示");
|
||||
});
|
||||
}
|
||||
|
||||
function updateSelectTag(tagId) {
|
||||
$scope.tags.forEach((tag) => {
|
||||
tag.clicked = false;
|
||||
if (tag.id == tagId) {
|
||||
tag.clicked = true;
|
||||
t = tag;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 在输入文字的时候也会触发,所以不要用Ctrl,Shift之类的按键
|
||||
$document.bind("keydown", function (event) {
|
||||
$scope.$apply(function () {
|
||||
var key = event.key.toUpperCase();
|
||||
if ($scope.hoverNote && dataService.keyShortcuts()) {
|
||||
if (key == 'E') {
|
||||
$scope.editNote($scope.hoverNote.id, $scope.hoverNote.content, $scope.hoverNote.tag_id)
|
||||
} else if (key == 'I') {
|
||||
$scope.detailNote($scope.hoverNote.content)
|
||||
} else if (key == 'D') {
|
||||
$scope.delNote($scope.hoverNote.id, $scope.hoverNote.content)
|
||||
} else if (key == 'C') {
|
||||
$scope.copy($scope.hoverNote.content)
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
function getNotes(tagId) {
|
||||
$scope.notes = [];
|
||||
$scope.loadBusy = true;
|
||||
var params = {
|
||||
currentPage: $scope.currentPage,
|
||||
perPageItems: perPageItems,
|
||||
searchWord: $scope.searchWord,
|
||||
};
|
||||
if (tagId || $scope.currentTagId) {
|
||||
params.tagId = tagId || $scope.currentTagId;
|
||||
}
|
||||
bookmarkService.getNotes(params)
|
||||
.then((data) => {
|
||||
$scope.notes = data.notes;
|
||||
$scope.notes.forEach((note) => {
|
||||
note.brief = note.content || "";
|
||||
while (note.brief.indexOf("\n") > 0) {
|
||||
note.brief = note.brief.replace(/\n/g, "");
|
||||
}
|
||||
note.brief = " " + note.brief.substring(0, 200) + (note.content.length > 200 ? " ......" : "");
|
||||
})
|
||||
$scope.totalPages = Math.ceil(data.totalItems / perPageItems);
|
||||
$scope.totalItems = data.totalItems;
|
||||
$timeout(function () {
|
||||
timeagoInstance.cancel();
|
||||
timeagoInstance.render(document.querySelectorAll('.need_to_be_rendered'), 'zh_CN');
|
||||
// 如果需要增加书签
|
||||
if ($scope.key == 'A') {
|
||||
$scope.key = null;
|
||||
$scope.showAddNote();
|
||||
}
|
||||
}, 100)
|
||||
$scope.loadBusy = false;
|
||||
if ($scope.totalItems == 0) {
|
||||
$(".js-note").removeClass("hidden");
|
||||
}
|
||||
transition();
|
||||
})
|
||||
.catch((err) => {
|
||||
$scope.notes = [];
|
||||
$scope.loadBusy = false;
|
||||
});
|
||||
}
|
||||
|
||||
function getTags(params) {
|
||||
$scope.loadBusy = true;
|
||||
bookmarkService.getTags(params)
|
||||
.then((data) => {
|
||||
$scope.tags = []
|
||||
var find = false;
|
||||
data.forEach((tag) => {
|
||||
$scope.tags.push(tag);
|
||||
if (tag.id == $scope.currentTagId) {
|
||||
find = true; // 如果是删了分类返回来,那么要重新默认选中第一个分类
|
||||
}
|
||||
})
|
||||
if (!find) $scope.currentTagId = null;
|
||||
|
||||
if ($scope.currentTagId) {
|
||||
getTags($scope.currentTagId);
|
||||
}
|
||||
$scope.loadBusy = false;
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('getTags err', err);
|
||||
$scope.loadBusy = false;
|
||||
});
|
||||
}
|
||||
|
||||
$('.js-note-card').transition('hide');
|
||||
|
||||
function transition() {
|
||||
var className = 'js-note-card';
|
||||
$('.' + className).transition('hide');
|
||||
$('.' + className).transition({
|
||||
animation: dataService.animation(),
|
||||
duration: 500,
|
||||
});
|
||||
}
|
||||
|
||||
function toPos(id) {
|
||||
setTimeout(function () {
|
||||
$('html,body').animate({ scrollTop: $('#' + id).offset().top - 20 }, 100);
|
||||
}, 36);
|
||||
}
|
||||
}]);
|
||||
app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$window', '$timeout', '$document', 'ngDialog', 'bookmarkService', 'pubSubService', 'dataService', function ($scope, $state, $stateParams, $filter, $window, $timeout, $document, ngDialog, bookmarkService, pubSubService, dataService) {
|
||||
console.log("Hello noteCtr...", $stateParams);
|
||||
if (dataService.smallDevice()) {
|
||||
$window.location = "http://m.mybookmark.cn/#/tags";
|
||||
return;
|
||||
}
|
||||
|
||||
const perPageItems = 35;
|
||||
var dialog = null;
|
||||
$scope.hoverNote = null;
|
||||
$scope.loadBusy = false;
|
||||
$scope.add = false;
|
||||
$scope.edit = false;
|
||||
$scope.preContent = '';
|
||||
$scope.content = '';
|
||||
$scope.currentTagId = null;
|
||||
$scope.currentNoteId = null;
|
||||
$scope.tags = []; // 书签数据
|
||||
$scope.notes = [];
|
||||
$scope.totalPages = 0;
|
||||
$scope.currentPage = 1;
|
||||
$scope.inputPage = '';
|
||||
$scope.searchWord = $stateParams.searchWord
|
||||
$scope.key = $stateParams.key
|
||||
$scope.totalItems = 0;
|
||||
|
||||
var timeagoInstance = timeago();
|
||||
|
||||
get('own').then(user => {
|
||||
pubSubService.publish('Common.menuActive', {
|
||||
login: true,
|
||||
index: dataService.LoginIndexNote
|
||||
});
|
||||
getTags();
|
||||
getNotes();
|
||||
});
|
||||
|
||||
$scope.changeCurrentPage = function (currentPage) {
|
||||
currentPage = parseInt(currentPage) || 0;
|
||||
if (currentPage <= $scope.totalPages && currentPage >= 1) {
|
||||
$scope.currentPage = currentPage;
|
||||
$scope.inputPage = '';
|
||||
getNotes();
|
||||
} else {
|
||||
$scope.currentPage = $scope.totalPages
|
||||
}
|
||||
}
|
||||
|
||||
// 快捷键a增加书签
|
||||
$document.bind("keydown", function (event) {
|
||||
$scope.$apply(function () {
|
||||
// a按键,显示
|
||||
var key = event.key.toUpperCase();
|
||||
if (key == 'A' && dataService.keyShortcuts() && (!$scope.add)) {
|
||||
$scope.showAddNote();
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
$scope.showAddNote = function () {
|
||||
$scope.add = (!$scope.add);
|
||||
$scope.edit = false;
|
||||
$scope.content = '';
|
||||
if ($scope.add) {
|
||||
$timeout(function () {
|
||||
$("#noteedit")[0].focus();
|
||||
});
|
||||
}
|
||||
console.log('$scope.showAddNote');
|
||||
// 没有选中分类,默认一个分类
|
||||
if (!$scope.currentTagId) {
|
||||
$scope.tags.forEach((tag) => {
|
||||
tag.clicked = false;
|
||||
if (tag.name == '未分类') {
|
||||
$scope.currentTagId = tag.id;
|
||||
tag.clicked = true;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
$scope.addNote = async function (close) {
|
||||
if ($scope.content == '') {
|
||||
toastr.error('不允许备忘录内容为空!', "提示");
|
||||
return;
|
||||
}
|
||||
if ($scope.preContent == $scope.content) {
|
||||
toastr.error('您刚刚添加了这条内容!', "提示");
|
||||
return;
|
||||
}
|
||||
$scope.add = close;
|
||||
var tagName = '';
|
||||
|
||||
$scope.tags.forEach((tag) => {
|
||||
if ($scope.currentTagId === tag.id) {
|
||||
tagName = tag.name;
|
||||
tag.noteCount += 1;
|
||||
}
|
||||
if (!$scope.currentTagId) {
|
||||
if (tag.name == '未分类') {
|
||||
$scope.currentTagId = tag.id;
|
||||
tagName = tag.name
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
var note = {
|
||||
tagId: $scope.currentTagId,
|
||||
content: $scope.content,
|
||||
}
|
||||
|
||||
await post("addNote", note);
|
||||
|
||||
// 增加成功,重新获取一次备忘录
|
||||
$scope.tags.forEach((tag) => {
|
||||
tag.clicked = false;
|
||||
})
|
||||
$scope.preContent = $scope.content;
|
||||
$scope.content = '';
|
||||
$scope.currentTagId = null;
|
||||
$scope.currentPage = 1;
|
||||
$scope.searchWord = '';
|
||||
getNotes();
|
||||
}
|
||||
|
||||
$scope.copy = function (content, $event) {
|
||||
dataService.clipboard(content);
|
||||
$event && $event.stopPropagation();
|
||||
}
|
||||
|
||||
$scope.delNote = function (id, content) {
|
||||
$scope.currentNoteId = id;
|
||||
$scope.content = content;
|
||||
var width = content.length >= 500 ? "50%" : "30%";
|
||||
dialog = ngDialog.open({
|
||||
template: './views/dialog-del-note.html',
|
||||
className: 'ngdialog-theme-default',
|
||||
width: width,
|
||||
scope: $scope
|
||||
});
|
||||
}
|
||||
|
||||
$scope.confirmDelNote = async function () {
|
||||
if ($scope.currentNoteId) {
|
||||
var params = {
|
||||
id: $scope.currentNoteId
|
||||
}
|
||||
ngDialog.close(dialog);
|
||||
await post('delNote', params)
|
||||
$("#" + $scope.currentNoteId).transition({
|
||||
animation: dataService.animation(),
|
||||
duration: 500,
|
||||
onComplete: function () {
|
||||
$("#" + $scope.currentNoteId).remove();
|
||||
}
|
||||
});
|
||||
$scope.totalItems -= 1;
|
||||
} else {
|
||||
toastr.error('删除失败!请刷新页面再尝试', "提示");
|
||||
}
|
||||
}
|
||||
|
||||
$scope.editNote = function (id, content, tagId) {
|
||||
$scope.add = true;
|
||||
$scope.edit = true;
|
||||
$scope.content = content;
|
||||
$scope.currentNoteId = id;
|
||||
$scope.currentTagId = tagId;
|
||||
updateSelectTag(tagId);
|
||||
}
|
||||
|
||||
$scope.updateNote = async function () {
|
||||
if (!$scope.content) {
|
||||
toastr.error('更新失败,更新内容不能为空', "提示");
|
||||
return;
|
||||
}
|
||||
var tagName = '';
|
||||
$scope.tags.forEach((tag) => {
|
||||
if ($scope.currentTagId === tag.id) {
|
||||
tagName = tag.name;
|
||||
}
|
||||
if (!$scope.currentTagId) {
|
||||
if (tag.name == '未分类') {
|
||||
$scope.currentTagId = tag.id;
|
||||
tagName = tag.name
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
var params = {
|
||||
id: $scope.currentNoteId,
|
||||
content: $scope.content,
|
||||
tagId: $scope.currentTagId,
|
||||
}
|
||||
|
||||
await post("updateNote", params);
|
||||
$scope.notes.forEach((note) => {
|
||||
if (note.id == $scope.currentNoteId) {
|
||||
note.content = $scope.content;
|
||||
note.tagName = tagName;
|
||||
note.tag_id = $scope.currentTagId;
|
||||
toPos(note.id);
|
||||
}
|
||||
})
|
||||
$scope.add = false;
|
||||
$scope.edit = false;
|
||||
}
|
||||
|
||||
$scope.detailNote = function (content) {
|
||||
$scope.content = content;
|
||||
var width = content.length >= 500 ? "50%" : "30%";
|
||||
dialog = ngDialog.open({
|
||||
template: './views/dialog-detail-note.html',
|
||||
className: 'ngdialog-theme-default',
|
||||
width: width,
|
||||
scope: $scope
|
||||
});
|
||||
}
|
||||
|
||||
$scope.closeNote = function () {
|
||||
$('.js-note').transition({
|
||||
animation: dataService.animation(),
|
||||
duration: '500ms',
|
||||
onComplete: function () {
|
||||
$(".js-note").remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$scope.setHoverNote = function (note) {
|
||||
$scope.hoverNote = note;
|
||||
}
|
||||
|
||||
$scope.clickTag = function (id) {
|
||||
$scope.currentTagId = id;
|
||||
$scope.totalItems = 0;
|
||||
updateSelectTag(id);
|
||||
|
||||
if ($scope.add || $scope.edit) {
|
||||
|
||||
} else {
|
||||
$scope.currentPage = 1;
|
||||
getNotes($scope.currentTagId);
|
||||
}
|
||||
}
|
||||
|
||||
$scope.noteClick = function (note, flag, $event) {
|
||||
if (!note.detail || flag) {
|
||||
var detail = note.detail;
|
||||
$scope.notes.forEach((note) => {
|
||||
note.detail = false;
|
||||
$("#" + note.id).removeClass("secondary");
|
||||
})
|
||||
note.detail = !detail;
|
||||
note.detail && $("#" + note.id).addClass("secondary") && toPos(note.id);
|
||||
}
|
||||
if (flag) {
|
||||
$event && $event.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
$scope.share = function (note) {
|
||||
var time = 100;
|
||||
if (note.public == '0') {
|
||||
toastr.info('由于打算分享备忘,系统会自动将备忘的私密状态转为公开状态');
|
||||
$scope.updatePublic(note, '1');
|
||||
time = 1000;
|
||||
}
|
||||
setTimeout(() => {
|
||||
dataService.clipboard(`https://mybookmark.cn/api/notes/?shareNote=${note.id}`);
|
||||
toastr.info(`将地址 https://mybookmark.cn/api/notes/?shareNote=${note.id} 发给别人粘贴到浏览器地址栏就可以访问到你分享的备忘啦!`, "提示");
|
||||
}, time)
|
||||
}
|
||||
|
||||
$scope.updatePublic = async function (note, public) {
|
||||
var params = {
|
||||
id: note.id,
|
||||
public: public,
|
||||
}
|
||||
|
||||
await post("updateNode", params);
|
||||
note.public = public;
|
||||
}
|
||||
|
||||
function updateSelectTag(tagId) {
|
||||
$scope.tags.forEach((tag) => {
|
||||
tag.clicked = false;
|
||||
if (tag.id == tagId) {
|
||||
tag.clicked = true;
|
||||
t = tag;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 在输入文字的时候也会触发,所以不要用Ctrl,Shift之类的按键
|
||||
$document.bind("keydown", function (event) {
|
||||
$scope.$apply(function () {
|
||||
var key = event.key.toUpperCase();
|
||||
if ($scope.hoverNote && dataService.keyShortcuts()) {
|
||||
if (key == 'E') {
|
||||
$scope.editNote($scope.hoverNote.id, $scope.hoverNote.content, $scope.hoverNote.tag_id)
|
||||
} else if (key == 'I') {
|
||||
$scope.detailNote($scope.hoverNote.content)
|
||||
} else if (key == 'D') {
|
||||
$scope.delNote($scope.hoverNote.id, $scope.hoverNote.content)
|
||||
} else if (key == 'C') {
|
||||
$scope.copy($scope.hoverNote.content)
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
async function getNotes(tagId) {
|
||||
$scope.notes = [];
|
||||
$scope.loadBusy = true;
|
||||
var params = {
|
||||
page: $scope.currentPage,
|
||||
pageSize: perPageItems,
|
||||
searchWord: $scope.searchWord,
|
||||
tagId: tagId || $scope.currentTagId
|
||||
};
|
||||
|
||||
try {
|
||||
let reply = await get("notes", params);
|
||||
$scope.notes = reply.data;
|
||||
$scope.notes.forEach((note) => {
|
||||
note.brief = note.content || "";
|
||||
while (note.brief.indexOf("\n") > 0) {
|
||||
note.brief = note.brief.replace(/\n/g, "");
|
||||
}
|
||||
note.brief = " " + note.brief.substring(0, 200) + (note.content.length > 200 ? " ......" : "");
|
||||
})
|
||||
$scope.totalPages = reply.totalPages;
|
||||
$scope.totalItems = reply.count;
|
||||
$timeout(function () {
|
||||
timeagoInstance.cancel();
|
||||
timeagoInstance.render(document.querySelectorAll('.need_to_be_rendered'), 'zh_CN');
|
||||
// 如果需要增加书签
|
||||
if ($scope.key == 'A') {
|
||||
$scope.key = null;
|
||||
$scope.showAddNote();
|
||||
}
|
||||
}, 100)
|
||||
$scope.loadBusy = false;
|
||||
if ($scope.totalItems == 0) {
|
||||
$(".js-note").removeClass("hidden");
|
||||
}
|
||||
transition();
|
||||
} catch (error) {
|
||||
$scope.notes = [];
|
||||
$scope.loadBusy = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function getTags() {
|
||||
$scope.loadBusy = true;
|
||||
$scope.tags = []
|
||||
|
||||
let tags = await get('tags', { noteCount: true });
|
||||
let find = false;
|
||||
tags.forEach((tag) => {
|
||||
$scope.tags.push(tag);
|
||||
if (tag.id == $scope.currentTagId) {
|
||||
find = true; // 如果是删了分类返回来,那么要重新默认选中第一个分类
|
||||
}
|
||||
})
|
||||
if (!find) $scope.currentTagId = null;
|
||||
$scope.loadBusy = false;
|
||||
}
|
||||
|
||||
$('.js-note-card').transition('hide');
|
||||
|
||||
function transition() {
|
||||
var className = 'js-note-card';
|
||||
$('.' + className).transition('hide');
|
||||
$('.' + className).transition({
|
||||
animation: dataService.animation(),
|
||||
duration: 500,
|
||||
});
|
||||
}
|
||||
|
||||
function toPos(id) {
|
||||
setTimeout(function () {
|
||||
$('html,body').animate({ scrollTop: $('#' + id).offset().top - 20 }, 100);
|
||||
}, 36);
|
||||
}
|
||||
}]);
|
||||
|
|
@ -1,312 +1,309 @@
|
|||
app.controller('searchCtr', ['$scope', '$state', '$stateParams', '$filter', '$window', '$timeout', '$document', 'ngDialog', 'bookmarkService', 'pubSubService', 'dataService', function ($scope, $state, $stateParams, $filter, $window, $timeout, $document, ngDialog, bookmarkService, pubSubService, dataService) {
|
||||
console.log("Hello searchCtr...", $stateParams);
|
||||
if (dataService.smallDevice()) {
|
||||
$window.location = "http://m.mybookmark.cn/#/tags";
|
||||
return;
|
||||
}
|
||||
|
||||
const perPageItems = 20;
|
||||
var dialog = null;
|
||||
$scope.hoverBookmark = null;
|
||||
$scope.searchBookmarks = []; // 书签数据
|
||||
$scope.showSearch = false; //
|
||||
$scope.showTags = false; //
|
||||
$scope.searchWord = ($stateParams && $stateParams.searchWord) || ''
|
||||
$scope.dateCreateBegin = '';
|
||||
$scope.dateCreateEnd = '';
|
||||
$scope.dateClickBegin = '';
|
||||
$scope.dateClickEnd = '';
|
||||
$scope.clickCount = '';
|
||||
$scope.username = '';
|
||||
$scope.userRange = '';
|
||||
$scope.bookmarkCount = 0;
|
||||
$scope.tags = []
|
||||
$scope.totalPages = 0;
|
||||
$scope.currentPage = 1;
|
||||
$scope.inputPage = '';
|
||||
$scope.loading = false;
|
||||
$scope.waitDelBookmark = {};
|
||||
$scope.searchHotBookmarks = false;
|
||||
var timeagoInstance = timeago();
|
||||
|
||||
$scope.changeCurrentPage = function (currentPage) {
|
||||
currentPage = parseInt(currentPage) || 0;
|
||||
console.log(currentPage);
|
||||
if (currentPage <= $scope.totalPages && currentPage >= 1) {
|
||||
$scope.currentPage = currentPage;
|
||||
$scope.inputPage = '';
|
||||
$scope.search();
|
||||
}
|
||||
}
|
||||
|
||||
bookmarkService.getTags({})
|
||||
.then((data) => {
|
||||
$scope.tags = data;
|
||||
})
|
||||
.catch((err) => console.log('getTags err', err));
|
||||
// 默认登陆
|
||||
pubSubService.publish('Common.menuActive', {
|
||||
login: true,
|
||||
index: dataService.LoginIndexBookmarks
|
||||
});
|
||||
|
||||
var searchParams = {
|
||||
searchWord: $scope.searchWord,
|
||||
currentPage: 1,
|
||||
perPageItems: perPageItems,
|
||||
userRange: '1', // 默认搜索自己的书签
|
||||
}
|
||||
if ($scope.searchWord) {
|
||||
searchBookmarks(searchParams);
|
||||
} else {
|
||||
toastr.warning("请输入搜索关键字再进行查询!", "提示");
|
||||
}
|
||||
|
||||
$scope.jumpToUrl = function (url, id) {
|
||||
if (!$scope.edit) {
|
||||
$window.open(url);
|
||||
bookmarkService.clickBookmark({
|
||||
id: id
|
||||
});
|
||||
$scope.searchBookmarks.forEach(function (bookmark) {
|
||||
if (bookmark.id == id && bookmark.own) {
|
||||
bookmark.click_count += 1;
|
||||
bookmark.last_click = $filter("date")(new Date(), "yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
})
|
||||
$timeout(function () {
|
||||
timeagoInstance.cancel();
|
||||
timeagoInstance.render(document.querySelectorAll('.need_to_be_rendered'), 'zh_CN');
|
||||
}, 100)
|
||||
}
|
||||
}
|
||||
|
||||
$scope.delBookmark = function (bookmark) {
|
||||
$scope.waitDelBookmark = $.extend(true, {}, bookmark); // 利用jQuery执行深度拷贝
|
||||
dialog = ngDialog.open({
|
||||
template: './views/dialog-del-bookmark.html',
|
||||
className: 'ngdialog-theme-default',
|
||||
scope: $scope
|
||||
});
|
||||
}
|
||||
|
||||
$scope.confirmDelBookmark = function (bookmarkId) {
|
||||
var params = {
|
||||
id: bookmarkId
|
||||
}
|
||||
ngDialog.close(dialog);
|
||||
bookmarkService.delBookmark(params)
|
||||
.then((data) => {
|
||||
$("#" + bookmarkId).transition({
|
||||
animation: dataService.animation(),
|
||||
duration: 500,
|
||||
onComplete: function () {
|
||||
$("#" + bookmarkId).remove();
|
||||
}
|
||||
});
|
||||
toastr.success($scope.waitDelBookmark.title + ' 书签删除成功!', "提示");
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error($scope.waitDelBookmark.title + ' 书签删除失败!错误提示:' + JSON.stringify(err), "提示");
|
||||
});
|
||||
}
|
||||
|
||||
$scope.editBookmark = function (bookmarkId) {
|
||||
pubSubService.publish('bookmarksCtr.editBookmark', {
|
||||
'bookmarkId': bookmarkId
|
||||
});
|
||||
}
|
||||
|
||||
$scope.detailBookmark = function (bookmark) {
|
||||
pubSubService.publish('TagCtr.showBookmarkInfo', bookmark);
|
||||
}
|
||||
|
||||
$scope.storeBookmark = function (bookmark) {
|
||||
var b = $.extend(true, {}, bookmark); // 利用jQuery执行深度拷贝
|
||||
pubSubService.publish('TagCtr.storeBookmark', b);
|
||||
}
|
||||
|
||||
$scope.favoriteBookmark = function (b) {
|
||||
var bookmark = {}
|
||||
bookmark.description = '';
|
||||
bookmark.title = b.title;
|
||||
bookmark.url = b.url;
|
||||
bookmark.public = 1;
|
||||
bookmark.click_count = 1;
|
||||
|
||||
bookmarkService.favoriteBookmark(bookmark)
|
||||
.then((data) => {
|
||||
pubSubService.publish('EditCtr.inserBookmarsSuccess', data);
|
||||
if (data.title) {
|
||||
toastr.success('[ ' + data.title + ' ] 收藏成功!', "提示");
|
||||
} else {
|
||||
toastr.error('[ ' + bookmark.title + ' ] 收藏失败!', "提示");
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error('[ ' + bookmark.title + ' ] 收藏失败,' + JSON.stringify(err), "提示");
|
||||
});
|
||||
}
|
||||
|
||||
$scope.copy = function (url) {
|
||||
dataService.clipboard(url);
|
||||
}
|
||||
|
||||
$scope.search = function (page) {
|
||||
var params = {}
|
||||
params.userRange = $('.js-user-range').dropdown('get value');
|
||||
if (params.userRange == '1') {
|
||||
var tags = $('.js-search-tags').dropdown('get value')
|
||||
if (tags) {
|
||||
params.tags = tags;
|
||||
}
|
||||
} else if ($scope.username) {
|
||||
params.username = $scope.username
|
||||
}
|
||||
if ($scope.searchWord) {
|
||||
params.searchWord = $scope.searchWord;
|
||||
}
|
||||
|
||||
var dateCreate = $('.js-create-date').dropdown('get value') || undefined;
|
||||
console.log('dateCreate = ', dateCreate)
|
||||
if (dateCreate) {
|
||||
if (dateCreate != -1) {
|
||||
params.dateCreate = dateCreate;
|
||||
}
|
||||
} else {
|
||||
params.dateCreateBegin = $scope.dateCreateBegin;
|
||||
params.dateCreateEnd = $scope.dateCreateEnd;
|
||||
}
|
||||
|
||||
var dateClick = $('.js-click-date').dropdown('get value') || undefined;
|
||||
console.log('dateClick = ', dateClick)
|
||||
if (dateClick) {
|
||||
if (dateClick != -1) {
|
||||
params.dateClick = dateClick
|
||||
}
|
||||
} else {
|
||||
params.dateClickBegin = $scope.dateClickBegin;
|
||||
params.dateClickEnd = $scope.dateClickEnd;
|
||||
}
|
||||
params.currentPage = page ? page : $scope.currentPage;
|
||||
params.perPageItems = perPageItems;
|
||||
|
||||
$scope.currentPage = params.currentPage;
|
||||
searchBookmarks(params)
|
||||
console.log('search..', page, 'params = ', params)
|
||||
}
|
||||
$scope.updateCreateDate = function () {
|
||||
console.log($scope.dateCreateBegin, $scope.dateCreateEnd);
|
||||
if ($scope.dateCreateBegin && $scope.dateCreateEnd) {
|
||||
$('.js-create-date').dropdown('hide');
|
||||
$('.js-create-date').dropdown('clear');
|
||||
$('.js-create-date .text').text($scope.dateCreateBegin + " 至 " + $scope.dateCreateEnd).removeClass('default');
|
||||
}
|
||||
}
|
||||
|
||||
$scope.updateClickDate = function () {
|
||||
console.log($scope.dateClickBegin, $scope.dateClickEnd);
|
||||
if ($scope.dateClickBegin && $scope.dateClickEnd) {
|
||||
$('.js-click-date').dropdown('hide');
|
||||
$('.js-click-date').dropdown('clear');
|
||||
$('.js-click-date .text').text($scope.dateClickBegin + " 至 " + $scope.dateClickEnd).removeClass('default');
|
||||
}
|
||||
}
|
||||
|
||||
$scope.updateTagsSelect = function () {
|
||||
$('.ui.dropdown.js-search-tags .text').removeClass('default');
|
||||
var text = $('.ui.dropdown.js-search-tags .text').text().replace('selected', '个已选');
|
||||
$('.ui.dropdown.js-search-tags .text').text(text);
|
||||
}
|
||||
|
||||
$scope.setHoverBookmark = function (bookmark) {
|
||||
$scope.hoverBookmark = bookmark;
|
||||
}
|
||||
|
||||
// 在输入文字的时候也会触发,所以不要用Ctrl,Shift之类的按键
|
||||
$document.bind("keydown", function (event) {
|
||||
$scope.$apply(function () {
|
||||
var key = event.key.toUpperCase();
|
||||
console.log($scope.hoverBookmark);
|
||||
if ($scope.hoverBookmark && dataService.keyShortcuts()) {
|
||||
if (key == 'E' && $scope.hoverBookmark.own) {
|
||||
$scope.editBookmark($scope.hoverBookmark.id)
|
||||
} else if (key == 'I') {
|
||||
$scope.detailBookmark($scope.hoverBookmark)
|
||||
} else if (key == 'D' && $scope.hoverBookmark.own) {
|
||||
$scope.delBookmark($scope.hoverBookmark)
|
||||
} else if (key == 'C') {
|
||||
$scope.copy($scope.hoverBookmark.url)
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
pubSubService.subscribe('EditCtr.inserBookmarsSuccess', $scope, function (event, data) {
|
||||
console.log('subscribe EditCtr.inserBookmarsSuccess', JSON.stringify(data));
|
||||
$scope.searchBookmarks.forEach((bookmark) => {
|
||||
if (bookmark.id == data.id) {
|
||||
bookmark.title = data.title;
|
||||
bookmark.url = data.url;
|
||||
bookmark.description = data.description;
|
||||
bookmark.tags = data.tags;
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
function searchBookmarks(params) {
|
||||
$scope.loading = true;
|
||||
$('.js-table-search').transition('hide');
|
||||
if ($scope.searchHotBookmarks) {
|
||||
console.log(params);
|
||||
bookmarkService.searchHotBookmarks(params)
|
||||
.then((data) => {
|
||||
$scope.searchBookmarks = [];
|
||||
data.bookmarks.forEach((bookmark) => {
|
||||
bookmark.tags = [{
|
||||
id: -1,
|
||||
name: bookmark.created_by, // 给转存用
|
||||
}]
|
||||
bookmark.created_at = $filter('date')(new Date(bookmark.created_at), "yyyy-MM-dd HH:mm:ss");
|
||||
bookmark.last_click = $filter('date')(new Date(bookmark.last_click), "yyyy-MM-dd HH:mm:ss");
|
||||
$scope.searchBookmarks.push(bookmark);
|
||||
})
|
||||
$scope.bookmarkCount = data.totalItems;
|
||||
$scope.totalPages = Math.ceil($scope.bookmarkCount / perPageItems);
|
||||
$scope.loading = false;
|
||||
transition();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('searchHotBookmarks err', err);
|
||||
$scope.loading = false;
|
||||
});
|
||||
} else {
|
||||
bookmarkService.searchBookmarks(params)
|
||||
.then((data) => {
|
||||
$scope.searchBookmarks = data.bookmarks;
|
||||
$scope.bookmarkCount = data.totalItems;
|
||||
$scope.totalPages = Math.ceil($scope.bookmarkCount / perPageItems);
|
||||
$scope.loading = false;
|
||||
transition();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('getBookmarks err', err);
|
||||
$scope.loading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function transition() {
|
||||
$timeout(function () {
|
||||
timeagoInstance.cancel();
|
||||
timeagoInstance.render(document.querySelectorAll('.need_to_be_rendered'), 'zh_CN');
|
||||
}, 100)
|
||||
var className = 'js-table-search';
|
||||
$('.' + className).transition('hide');
|
||||
$('.' + className).transition({
|
||||
animation: dataService.animation(),
|
||||
duration: 500,
|
||||
});
|
||||
}
|
||||
|
||||
}]);
|
||||
app.controller('searchCtr', ['$scope', '$state', '$stateParams', '$filter', '$window', '$timeout', '$document', 'ngDialog', 'bookmarkService', 'pubSubService', 'dataService', function ($scope, $state, $stateParams, $filter, $window, $timeout, $document, ngDialog, bookmarkService, pubSubService, dataService) {
|
||||
console.log("Hello searchCtr...", $stateParams);
|
||||
if (dataService.smallDevice()) {
|
||||
$window.location = "http://m.mybookmark.cn/#/tags";
|
||||
return;
|
||||
}
|
||||
|
||||
const perPageItems = 20;
|
||||
var dialog = null;
|
||||
$scope.hoverBookmark = null;
|
||||
$scope.searchBookmarks = []; // 书签数据
|
||||
$scope.showSearch = false; //
|
||||
$scope.showTags = false; //
|
||||
$scope.searchWord = ($stateParams && $stateParams.searchWord) || ''
|
||||
$scope.dateCreateBegin = '';
|
||||
$scope.dateCreateEnd = '';
|
||||
$scope.dateClickBegin = '';
|
||||
$scope.dateClickEnd = '';
|
||||
$scope.clickCount = '';
|
||||
$scope.username = '';
|
||||
$scope.userRange = '';
|
||||
$scope.bookmarkCount = 0;
|
||||
$scope.tags = []
|
||||
$scope.totalPages = 0;
|
||||
$scope.currentPage = 1;
|
||||
$scope.inputPage = '';
|
||||
$scope.loading = false;
|
||||
$scope.waitDelBookmark = {};
|
||||
$scope.searchHotBookmarks = false;
|
||||
var timeagoInstance = timeago();
|
||||
|
||||
$scope.changeCurrentPage = function (currentPage) {
|
||||
currentPage = parseInt(currentPage) || 0;
|
||||
console.log(currentPage);
|
||||
if (currentPage <= $scope.totalPages && currentPage >= 1) {
|
||||
$scope.currentPage = currentPage;
|
||||
$scope.inputPage = '';
|
||||
$scope.search();
|
||||
}
|
||||
}
|
||||
|
||||
bookmarkService.getTags({})
|
||||
.then((data) => {
|
||||
$scope.tags = data;
|
||||
})
|
||||
.catch((err) => console.log('getTags err', err));
|
||||
// 默认登陆
|
||||
pubSubService.publish('Common.menuActive', {
|
||||
login: true,
|
||||
index: dataService.LoginIndexBookmarks
|
||||
});
|
||||
|
||||
var searchParams = {
|
||||
searchWord: $scope.searchWord,
|
||||
currentPage: 1,
|
||||
perPageItems: perPageItems,
|
||||
userRange: '1', // 默认搜索自己的书签
|
||||
}
|
||||
if ($scope.searchWord) {
|
||||
searchBookmarks(searchParams);
|
||||
} else {
|
||||
toastr.warning("请输入搜索关键字再进行查询!", "提示");
|
||||
}
|
||||
|
||||
$scope.jumpToUrl = async function (url, id) {
|
||||
if (!$scope.edit) {
|
||||
$window.open(url);
|
||||
await post("clickBookmark", { id });
|
||||
|
||||
$scope.searchBookmarks.forEach(function (bookmark) {
|
||||
if (bookmark.id == id && bookmark.own) {
|
||||
bookmark.click_count += 1;
|
||||
bookmark.last_click = $filter("date")(new Date(), "yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
})
|
||||
$timeout(function () {
|
||||
timeagoInstance.cancel();
|
||||
timeagoInstance.render(document.querySelectorAll('.need_to_be_rendered'), 'zh_CN');
|
||||
}, 100)
|
||||
}
|
||||
}
|
||||
|
||||
$scope.delBookmark = function (bookmark) {
|
||||
$scope.waitDelBookmark = $.extend(true, {}, bookmark); // 利用jQuery执行深度拷贝
|
||||
dialog = ngDialog.open({
|
||||
template: './views/dialog-del-bookmark.html',
|
||||
className: 'ngdialog-theme-default',
|
||||
scope: $scope
|
||||
});
|
||||
}
|
||||
|
||||
$scope.confirmDelBookmark = function (bookmarkId) {
|
||||
var params = {
|
||||
id: bookmarkId
|
||||
}
|
||||
ngDialog.close(dialog);
|
||||
bookmarkService.delBookmark(params)
|
||||
.then((data) => {
|
||||
$("#" + bookmarkId).transition({
|
||||
animation: dataService.animation(),
|
||||
duration: 500,
|
||||
onComplete: function () {
|
||||
$("#" + bookmarkId).remove();
|
||||
}
|
||||
});
|
||||
toastr.success($scope.waitDelBookmark.title + ' 书签删除成功!', "提示");
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error($scope.waitDelBookmark.title + ' 书签删除失败!错误提示:' + JSON.stringify(err), "提示");
|
||||
});
|
||||
}
|
||||
|
||||
$scope.editBookmark = function (id) {
|
||||
pubSubService.publish('bookmarksCtr.editBookmark', { id });
|
||||
}
|
||||
|
||||
$scope.detailBookmark = function (bookmark) {
|
||||
pubSubService.publish('TagCtr.showBookmarkInfo', bookmark);
|
||||
}
|
||||
|
||||
$scope.storeBookmark = function (bookmark) {
|
||||
var b = $.extend(true, {}, bookmark); // 利用jQuery执行深度拷贝
|
||||
pubSubService.publish('TagCtr.storeBookmark', b);
|
||||
}
|
||||
|
||||
$scope.favoriteBookmark = function (b) {
|
||||
var bookmark = {}
|
||||
bookmark.description = '';
|
||||
bookmark.title = b.title;
|
||||
bookmark.url = b.url;
|
||||
bookmark.public = 1;
|
||||
bookmark.click_count = 1;
|
||||
|
||||
bookmarkService.favoriteBookmark(bookmark)
|
||||
.then((data) => {
|
||||
pubSubService.publish('EditCtr.inserBookmarsSuccess', data);
|
||||
if (data.title) {
|
||||
toastr.success('[ ' + data.title + ' ] 收藏成功!', "提示");
|
||||
} else {
|
||||
toastr.error('[ ' + bookmark.title + ' ] 收藏失败!', "提示");
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error('[ ' + bookmark.title + ' ] 收藏失败,' + JSON.stringify(err), "提示");
|
||||
});
|
||||
}
|
||||
|
||||
$scope.copy = function (url) {
|
||||
dataService.clipboard(url);
|
||||
}
|
||||
|
||||
$scope.search = function (page) {
|
||||
var params = {}
|
||||
params.userRange = $('.js-user-range').dropdown('get value');
|
||||
if (params.userRange == '1') {
|
||||
var tags = $('.js-search-tags').dropdown('get value')
|
||||
if (tags) {
|
||||
params.tags = tags;
|
||||
}
|
||||
} else if ($scope.username) {
|
||||
params.username = $scope.username
|
||||
}
|
||||
if ($scope.searchWord) {
|
||||
params.searchWord = $scope.searchWord;
|
||||
}
|
||||
|
||||
var dateCreate = $('.js-create-date').dropdown('get value') || undefined;
|
||||
console.log('dateCreate = ', dateCreate)
|
||||
if (dateCreate) {
|
||||
if (dateCreate != -1) {
|
||||
params.dateCreate = dateCreate;
|
||||
}
|
||||
} else {
|
||||
params.dateCreateBegin = $scope.dateCreateBegin;
|
||||
params.dateCreateEnd = $scope.dateCreateEnd;
|
||||
}
|
||||
|
||||
var dateClick = $('.js-click-date').dropdown('get value') || undefined;
|
||||
console.log('dateClick = ', dateClick)
|
||||
if (dateClick) {
|
||||
if (dateClick != -1) {
|
||||
params.dateClick = dateClick
|
||||
}
|
||||
} else {
|
||||
params.dateClickBegin = $scope.dateClickBegin;
|
||||
params.dateClickEnd = $scope.dateClickEnd;
|
||||
}
|
||||
params.currentPage = page ? page : $scope.currentPage;
|
||||
params.perPageItems = perPageItems;
|
||||
|
||||
$scope.currentPage = params.currentPage;
|
||||
searchBookmarks(params)
|
||||
console.log('search..', page, 'params = ', params)
|
||||
}
|
||||
$scope.updateCreateDate = function () {
|
||||
console.log($scope.dateCreateBegin, $scope.dateCreateEnd);
|
||||
if ($scope.dateCreateBegin && $scope.dateCreateEnd) {
|
||||
$('.js-create-date').dropdown('hide');
|
||||
$('.js-create-date').dropdown('clear');
|
||||
$('.js-create-date .text').text($scope.dateCreateBegin + " 至 " + $scope.dateCreateEnd).removeClass('default');
|
||||
}
|
||||
}
|
||||
|
||||
$scope.updateClickDate = function () {
|
||||
console.log($scope.dateClickBegin, $scope.dateClickEnd);
|
||||
if ($scope.dateClickBegin && $scope.dateClickEnd) {
|
||||
$('.js-click-date').dropdown('hide');
|
||||
$('.js-click-date').dropdown('clear');
|
||||
$('.js-click-date .text').text($scope.dateClickBegin + " 至 " + $scope.dateClickEnd).removeClass('default');
|
||||
}
|
||||
}
|
||||
|
||||
$scope.updateTagsSelect = function () {
|
||||
$('.ui.dropdown.js-search-tags .text').removeClass('default');
|
||||
var text = $('.ui.dropdown.js-search-tags .text').text().replace('selected', '个已选');
|
||||
$('.ui.dropdown.js-search-tags .text').text(text);
|
||||
}
|
||||
|
||||
$scope.setHoverBookmark = function (bookmark) {
|
||||
$scope.hoverBookmark = bookmark;
|
||||
}
|
||||
|
||||
// 在输入文字的时候也会触发,所以不要用Ctrl,Shift之类的按键
|
||||
$document.bind("keydown", function (event) {
|
||||
$scope.$apply(function () {
|
||||
var key = event.key.toUpperCase();
|
||||
console.log($scope.hoverBookmark);
|
||||
if ($scope.hoverBookmark && dataService.keyShortcuts()) {
|
||||
if (key == 'E' && $scope.hoverBookmark.own) {
|
||||
$scope.editBookmark($scope.hoverBookmark.id)
|
||||
} else if (key == 'I') {
|
||||
$scope.detailBookmark($scope.hoverBookmark)
|
||||
} else if (key == 'D' && $scope.hoverBookmark.own) {
|
||||
$scope.delBookmark($scope.hoverBookmark)
|
||||
} else if (key == 'C') {
|
||||
$scope.copy($scope.hoverBookmark.url)
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
pubSubService.subscribe('EditCtr.inserBookmarsSuccess', $scope, function (event, data) {
|
||||
console.log('subscribe EditCtr.inserBookmarsSuccess', JSON.stringify(data));
|
||||
$scope.searchBookmarks.forEach((bookmark) => {
|
||||
if (bookmark.id == data.id) {
|
||||
bookmark.title = data.title;
|
||||
bookmark.url = data.url;
|
||||
bookmark.description = data.description;
|
||||
bookmark.tags = data.tags;
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
function searchBookmarks(params) {
|
||||
$scope.loading = true;
|
||||
$('.js-table-search').transition('hide');
|
||||
if ($scope.searchHotBookmarks) {
|
||||
console.log(params);
|
||||
bookmarkService.searchHotBookmarks(params)
|
||||
.then((data) => {
|
||||
$scope.searchBookmarks = [];
|
||||
data.bookmarks.forEach((bookmark) => {
|
||||
bookmark.tags = [{
|
||||
id: -1,
|
||||
name: bookmark.created_by, // 给转存用
|
||||
}]
|
||||
bookmark.created_at = $filter('date')(new Date(bookmark.created_at), "yyyy-MM-dd HH:mm:ss");
|
||||
bookmark.last_click = $filter('date')(new Date(bookmark.last_click), "yyyy-MM-dd HH:mm:ss");
|
||||
$scope.searchBookmarks.push(bookmark);
|
||||
})
|
||||
$scope.bookmarkCount = data.totalItems;
|
||||
$scope.totalPages = Math.ceil($scope.bookmarkCount / perPageItems);
|
||||
$scope.loading = false;
|
||||
transition();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('searchHotBookmarks err', err);
|
||||
$scope.loading = false;
|
||||
});
|
||||
} else {
|
||||
bookmarkService.searchBookmarks(params)
|
||||
.then((data) => {
|
||||
$scope.searchBookmarks = data.bookmarks;
|
||||
$scope.bookmarkCount = data.totalItems;
|
||||
$scope.totalPages = Math.ceil($scope.bookmarkCount / perPageItems);
|
||||
$scope.loading = false;
|
||||
transition();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('getBookmarks err', err);
|
||||
$scope.loading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function transition() {
|
||||
$timeout(function () {
|
||||
timeagoInstance.cancel();
|
||||
timeagoInstance.render(document.querySelectorAll('.need_to_be_rendered'), 'zh_CN');
|
||||
}, 100)
|
||||
var className = 'js-table-search';
|
||||
$('.' + className).transition('hide');
|
||||
$('.' + className).transition({
|
||||
animation: dataService.animation(),
|
||||
duration: 500,
|
||||
});
|
||||
}
|
||||
|
||||
}]);
|
||||
|
|
|
|||
|
|
@ -91,12 +91,11 @@ app.controller('tagsCtr', ['$scope', '$filter', '$state', '$window', '$statePara
|
|||
}
|
||||
}
|
||||
|
||||
$scope.jumpToUrl = function (url, id) {
|
||||
$scope.jumpToUrl = async function (url, id) {
|
||||
if (!$scope.editMode) {
|
||||
$window.open(url, '_blank');
|
||||
bookmarkService.clickBookmark({
|
||||
id: id
|
||||
});
|
||||
await post("clickBookmark", { id });
|
||||
|
||||
$scope.bookmarks.forEach(function (bookmark, index) {
|
||||
if (bookmark.id == id) {
|
||||
bookmark.click_count += 1;
|
||||
|
|
@ -149,18 +148,15 @@ app.controller('tagsCtr', ['$scope', '$filter', '$state', '$window', '$statePara
|
|||
});
|
||||
}
|
||||
|
||||
$scope.editBookmark = function (bookmarkId) {
|
||||
pubSubService.publish('bookmarksCtr.editBookmark', {
|
||||
'bookmarkId': bookmarkId
|
||||
});
|
||||
$scope.editBookmark = function (id) {
|
||||
console.log('publish bookmarksCtr.editBookmark', { id });
|
||||
pubSubService.publish('bookmarksCtr.editBookmark', { id });
|
||||
}
|
||||
|
||||
$scope.detailBookmark = function (bookmark) {
|
||||
$scope.detailBookmark = async function (bookmark) {
|
||||
bookmark.own = true;
|
||||
pubSubService.publish('TagCtr.showBookmarkInfo', bookmark);
|
||||
bookmarkService.clickBookmark({
|
||||
id: bookmark.id
|
||||
});
|
||||
await post("clickBookmark", { id: bookmark.id });
|
||||
}
|
||||
|
||||
$scope.copy = function (url) {
|
||||
|
|
|
|||
|
|
@ -1,60 +1,60 @@
|
|||
<div class="ui long modal js-bookmark-info" ng-controller="bookmarkInfoCtr" ng-keydown="close()">
|
||||
<i class="close icon"></i>
|
||||
<div class="header">
|
||||
{{bookmark.title}}
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="ui grid">
|
||||
<div class="sixteen wide column">
|
||||
<div class="ui vertically divided grid">
|
||||
<div class="one column row">
|
||||
<div class="column">
|
||||
<img class="ui middle aligned mini image" ng-src="{{bookmark.favicon_url}}" style="width:16px;height:16px;padding:0;cursor:pointer;" ng-click="jumpToUrl(bookmark.url, bookmark.id)" title="点击跳转到原页面">
|
||||
<span ng-click="jumpToUrl(bookmark.url, bookmark.id)" style="cursor:pointer;" title="点击跳转到原页面">网页地址</span>:
|
||||
<span title="点击复制链接" ng-click="copy(bookmark.url)" class="urlSpan">{{bookmark.url}}
|
||||
<span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="two column row">
|
||||
<div class="column">
|
||||
<i class="add to calendar icon"></i>创建日期:
|
||||
<span>{{bookmark.created_at}}</span>
|
||||
</div>
|
||||
<div class="column">
|
||||
<i class="calendar icon"></i>最后点击:
|
||||
<span>{{bookmark.last_click}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="two column row">
|
||||
<div class="column" ng-if="bookmark.click_count">
|
||||
<i class="hand pointer icon"></i>点击次数:{{bookmark.click_count}}
|
||||
</div>
|
||||
<div class="column" ng-if="bookmark.fav_count">
|
||||
<i class="heart icon"></i>收藏人数:{{bookmark.fav_count}}
|
||||
</div>
|
||||
<div class="column" ng-if="!bookmark.created_by">
|
||||
<i class="tags icon"></i>书签分类:
|
||||
<div class="ui label" ng-repeat="tag in bookmark.tags">
|
||||
{{ tag.name }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="column" ng-if="bookmark.created_by">
|
||||
<i class="info circle icon"></i>来源信息:{{bookmark.created_by}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui divider"></div>
|
||||
<div class="content" style="padding:0 20px">
|
||||
<div class="description js-content">
|
||||
<p ng-bind-html="content"></p>
|
||||
<img class="ui centered medium image" src="/images/loading.gif" ng-show="loading">
|
||||
</div>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<div class="ui right button" ng-click="jumpToUrl(bookmark.url, bookmark.id)">跳转到原页面</div>
|
||||
<button class="positive ui right button">关闭页面</button>
|
||||
</div>
|
||||
<div class="ui long modal js-bookmark-info" ng-controller="bookmarkInfoCtr" ng-keydown="close()">
|
||||
<i class="close icon"></i>
|
||||
<div class="header">
|
||||
{{bookmark.title}}
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="ui grid">
|
||||
<div class="sixteen wide column">
|
||||
<div class="ui vertically divided grid">
|
||||
<div class="one column row">
|
||||
<div class="column">
|
||||
<img class="ui middle aligned mini image" ng-src="{{bookmark.favicon_url}}" style="width:16px;height:16px;padding:0;cursor:pointer;" ng-click="jumpToUrl(bookmark.url, bookmark.id)" title="点击跳转到原页面">
|
||||
<span ng-click="jumpToUrl(bookmark.url, bookmark.id)" style="cursor:pointer;" title="点击跳转到原页面">网页地址</span>:
|
||||
<span title="点击复制链接" ng-click="copy(bookmark.url)" class="urlSpan">{{bookmark.url}}
|
||||
<span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="two column row">
|
||||
<div class="column">
|
||||
<i class="add to calendar icon"></i>创建日期:
|
||||
<span>{{bookmark.created_at}}</span>
|
||||
</div>
|
||||
<div class="column">
|
||||
<i class="calendar icon"></i>最后点击:
|
||||
<span>{{bookmark.lastClick}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="two column row">
|
||||
<div class="column" ng-if="bookmark.clickCount">
|
||||
<i class="hand pointer icon"></i>点击次数:{{bookmark.clickCount}}
|
||||
</div>
|
||||
<div class="column" ng-if="bookmark.fav_count">
|
||||
<i class="heart icon"></i>收藏人数:{{bookmark.fav_count}}
|
||||
</div>
|
||||
<div class="column" ng-if="!bookmark.created_by">
|
||||
<i class="tags icon"></i>书签分类:
|
||||
<div class="ui label" ng-repeat="tag in bookmark.tags">
|
||||
{{ tag.name }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="column" ng-if="bookmark.created_by">
|
||||
<i class="info circle icon"></i>来源信息:{{bookmark.created_by}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui divider"></div>
|
||||
<div class="content" style="padding:0 20px">
|
||||
<div class="description js-content">
|
||||
<p ng-bind-html="content"></p>
|
||||
<img class="ui centered medium image" src="/images/loading.gif" ng-show="loading">
|
||||
</div>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<div class="ui right button" ng-click="jumpToUrl(bookmark.url, bookmark.id)">跳转到原页面</div>
|
||||
<button class="positive ui right button">关闭页面</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,135 +1,135 @@
|
|||
<div class="ui hidden info message js-msg" ng-if="showStyle === 'navigate' && bookmarks.length <= 2">
|
||||
<i class="close icon" ng-click="closeMsg()"></i>
|
||||
<div class="content">
|
||||
<div class="header">系统检测到您好像还没添加过书签哦!</div>
|
||||
<ul class="list">
|
||||
<li>您可以将您的IE浏览器或者谷歌浏览器上面的书签导入系统!<a style="cursor:pointer;" ng-click="addBookmarkbyFile()">现在就去</a></li>
|
||||
<li>您也可以点击菜单栏上面的<i class="add square icon"></i>图标进行添加。也可以使用快捷键:Insert键打开添加页面,再次按Insert键保存书签,Esc取消添加。</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui segment js-segment-navigate" ng-if="showStyle === 'navigate'" ng-show="!loadBusy">
|
||||
<div class="ui container" ng-repeat="tag in bookmarks" ng-init="tagIndex=$index">
|
||||
<div class="ui grid">
|
||||
<div class="row">
|
||||
<div class="wrap" style="width:88px;color:#0aa770;text-align:left;margin-left:20px;">
|
||||
<span title="{{ tag.name }} - 点击查看该分类所有书签" ng-click="jumpToTags(tag.id)" style="cursor:pointer;">{{ tag.name }}</span>
|
||||
</div>
|
||||
<div class="fourteen wide column" ng-if="tag.bookmarks.length">
|
||||
<div class="ui grid container">
|
||||
<div class="four wide column js-navigate-bookmark" ng-class="{bookmarkNormalHover:bookmarkNormalHover, bookmarkEditHover:bookmarkEditHover, bookmark:(!bookmarkNormalHover && !bookmarkEditHover)}" ng-mouseover="bookmarkNormalHover=true; setHoverBookmark(bookmark)" ng-mouseleave="bookmarkNormalHover=false; setHoverBookmark(null)" ng-repeat="bookmark in tag.bookmarks" ng-click="jumpToUrl(bookmark.url, bookmark.id)" title="{{ bookmark.title }}" id="{{bookmark.id}}">
|
||||
<img class="ui ui middle aligned tiny image bookmarkInfo" ng-src="http://favicon.luchenqun.com/?url={{bookmark.url}}" err-src="./images/default.ico" style="width:16px;height:16px;" ng-click="detailBookmark(bookmark);$event.stopPropagation()" />
|
||||
<span>{{ bookmark.title}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui divider"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui segment js-segment-costomTag" ng-if="showStyle === 'costomTag'" ng-show="!loadBusy">
|
||||
<div class="ui container">
|
||||
<div class="ui grid">
|
||||
<div class="two wide column js-costomTag-label" ng-repeat="tag in costomTags">
|
||||
<div class="ui small label" ng-class="{green:tag.clicked}" ng-click="updateCostomTagBookmarks(tag.index)">
|
||||
{{ tag.name }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui divider"></div>
|
||||
<div class="ui five column grid">
|
||||
<div class="column js-costomTag-item" ng-class="{bookmarkNormalHover:bookmarkNormalHover, bookmark:(!bookmarkNormalHover)}" ng-mouseover="bookmarkNormalHover=true; setHoverBookmark(bookmark)" ng-mouseleave="bookmarkNormalHover=false; setHoverBookmark(null)" ng-repeat="bookmark in bookmarks" ng-click="jumpToUrl(bookmark.url, bookmark.id)" title="{{ bookmark.title }}" id="{{bookmark.id}}">
|
||||
<img class="ui ui middle aligned tiny image bookmarkInfo" ng-src="http://favicon.luchenqun.com/?url={{bookmark.url}}" err-src="./images/default.ico" style="width:16px;height:16px;" ng-click="detailBookmark(bookmark);$event.stopPropagation()" />
|
||||
<span>{{ bookmark.title}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<table class="ui selectable sortable celled table js-table-bookmarks" ng-if="showStyle === 'table'" ng-show="!loadBusy">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="forbid_sorted">标题</th>
|
||||
<th class="forbid_sorted">链接</th>
|
||||
<th style="width:90px;" ng-class="{descending: order[0], sorted:order[0]}" ng-click="changeOrder(0)" title="点击可对表格进行排序">点击次数</th>
|
||||
<th style="width:100px;" ng-class="{descending: order[1], sorted:order[1]}" ng-click="changeOrder(1)" title="点击可对表格进行排序">创建日期</th>
|
||||
<th style="width:100px;" ng-class="{descending: order[2], sorted:order[2]}" ng-click="changeOrder(2)" title="点击可对表格进行排序">最后点击</th>
|
||||
<th style="width:150px;" class="forbid_sorted">分类</th>
|
||||
<th style="width:88px;" class="forbid_sorted">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="bookmark in bookmarks" id="{{ bookmark.id }}" ng-mouseover="setHoverBookmark(bookmark)" ng-mouseleave="setHoverBookmark(null)">
|
||||
<td>
|
||||
<img class="ui ui middle aligned tiny image" ng-src="http://favicon.luchenqun.com/?url={{bookmark.url}}" err-src="./images/default.ico" style="width:16px;height:16px;cursor:pointer;" ng-click="jumpToUrl(bookmark.url, bookmark.id)" />
|
||||
<span ng-click="jumpToUrl(bookmark.url, bookmark.id)" title="{{bookmark.title}}" style="cursor:pointer;">
|
||||
{{ bookmark.title }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span title="{{bookmark.url}} 点击复制链接" ng-click="copy(bookmark.url)" style="cursor:default;">{{ bookmark.url }}</span>
|
||||
</td>
|
||||
<td>{{ bookmark.click_count }}</td>
|
||||
<td>
|
||||
<span title="{{bookmark.created_at}}" class="need_to_be_rendered" data-timeago="{{bookmark.created_at}}"></span>
|
||||
</td>
|
||||
<td>
|
||||
<span id="time{{bookmark.id}}" title="{{bookmark.last_click}}" class="need_to_be_rendered" data-timeago="{{bookmark.last_click}}"></span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="ui label" ng-repeat="tag in bookmark.tags" tag-id="{{ tag.id }}" ng-click="jumpToTags(tag.id)">
|
||||
{{ tag.name }}
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<img class="ui mini spaced image" style="width:16px;height:16px;margin:0 1px" ng-src="./images/delete.png" ng-click="delBookmark(bookmark)" title="删除书签" />
|
||||
<img class="ui mini spaced image" style="width:16px;height:16px;margin:0 1px" ng-src="./images/edit-bookmark.png" ng-click="editBookmark(bookmark.id)" title="编辑书签" />
|
||||
<img class="ui mini spaced image" style="width:16px;height:16px;margin:0 1px" ng-src="./images/detail.png" ng-click="detailBookmark(bookmark)" title="书签详情" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="7">
|
||||
<pagination></pagination>
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<div class="ui segment js-segment-card" ng-if="showStyle === 'card'" ng-show="!loadBusy || currentPage>1">
|
||||
<div class="ui five stackable cards" infinite-scroll="loadCardData()" infinite-scroll-immediate-check="false">
|
||||
<div class="card" ng-repeat="bookmark in bookmarks" id="{{bookmark.id}}" ng-mouseover="setHoverBookmark(bookmark)" ng-mouseleave="setHoverBookmark(null)">
|
||||
<div class="content" ng-click="jumpToUrl(bookmark.url, bookmark.id)" style="max-height:70px;cursor:pointer">
|
||||
<div class="description bookmarkTitle">
|
||||
{{bookmark.title}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="image" href="{{ bookmark.url }}" ng-click="jumpToUrl(bookmark.url, bookmark.id)" style="cursor:pointer">
|
||||
<img ng-src="./images/snap/{{bookmark.id}}.png" err-src="./images/default.jpg" />
|
||||
</div>
|
||||
<div class="extra content tags" style="height:50px;">
|
||||
<div class="ui label" ng-repeat="tag in bookmark.tags" tag-id="{{ tag.id }}" ng-click="jumpToTags(tag.id)">
|
||||
{{ tag.name }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="extra content" ng-show="!bookmark.edit" style="height:50px;padding-right:2px;padding-left:8px;">
|
||||
<span class="left floated like" style="margin-top:6px;">
|
||||
<img class="ui ui middle aligned tiny image" ng-src="http://favicon.luchenqun.com/?url={{bookmark.url}}" err-src="./images/default.ico" style="width:16px;height:16px;cursor:pointer;" ng-click="jumpToUrl(bookmark.url, bookmark.id)" />
|
||||
创建于:
|
||||
<span title="{{bookmark.created_at}}" class="need_to_be_rendered" data-timeago="{{bookmark.created_at}}"></span>
|
||||
<!-- {{ bookmark.created_at }} -->
|
||||
</span>
|
||||
<i class="ellipsis horizontal icon right floated" style="margin-top:8px;" ng-mouseover="bookmark.edit=true;"></i>
|
||||
</div>
|
||||
<div class="extra content" ng-show="bookmark.edit" ng-mouseleave="bookmark.edit=false;" style="height:50px;">
|
||||
<img class="ui mini spaced image" style="width:16px;height:16px;margin:0 8px;margin-top:8px;" ng-src="./images/delete.png" ng-click="delBookmark(bookmark)" title="删除书签" />
|
||||
<img class="ui mini spaced image" style="width:16px;height:16px;margin:0 8px;margin-top:8px;" ng-src="./images/edit-bookmark.png" ng-click="editBookmark(bookmark.id)" title="编辑书签" />
|
||||
<img class="ui mini spaced image" style="width:16px;height:16px;margin:0 8px;margin-top:8px;" ng-src="./images/copy.png" ng-click="copy(bookmark.url)" title="复制链接" />
|
||||
<img class="ui mini spaced image" style="width:16px;height:16px;margin:0 8px;margin-top:8px;" ng-src="./images/detail.png" ng-click="detailBookmark(bookmark)" title="书签详情" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui massive text centered inline loader" ng-class="{active:loadBusy, disabled:!loadBusy}">
|
||||
正在加载中...
|
||||
</div>
|
||||
<div class="ui hidden info message js-msg" ng-if="showStyle === 'navigate' && bookmarks.length <= 2">
|
||||
<i class="close icon" ng-click="closeMsg()"></i>
|
||||
<div class="content">
|
||||
<div class="header">系统检测到您好像还没添加过书签哦!</div>
|
||||
<ul class="list">
|
||||
<li>您可以将您的IE浏览器或者谷歌浏览器上面的书签导入系统!<a style="cursor:pointer;" ng-click="addBookmarkbyFile()">现在就去</a></li>
|
||||
<li>您也可以点击菜单栏上面的<i class="add square icon"></i>图标进行添加。也可以使用快捷键:Insert键打开添加页面,再次按Insert键保存书签,Esc取消添加。</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui segment js-segment-navigate" ng-if="showStyle === 'navigate'" ng-show="!loadBusy">
|
||||
<div class="ui container" ng-repeat="tag in bookmarks" ng-init="tagIndex=$index">
|
||||
<div class="ui grid">
|
||||
<div class="row">
|
||||
<div class="wrap" style="width:88px;color:#0aa770;text-align:left;margin-left:20px;">
|
||||
<span title="{{ tag.name }} - 点击查看该分类所有书签" ng-click="jumpToTags(tag.id)" style="cursor:pointer;">{{ tag.name }}</span>
|
||||
</div>
|
||||
<div class="fourteen wide column" ng-if="tag.bookmarks.length">
|
||||
<div class="ui grid container">
|
||||
<div class="four wide column js-navigate-bookmark" ng-class="{bookmarkNormalHover:bookmarkNormalHover, bookmarkEditHover:bookmarkEditHover, bookmark:(!bookmarkNormalHover && !bookmarkEditHover)}" ng-mouseover="bookmarkNormalHover=true; setHoverBookmark(bookmark)" ng-mouseleave="bookmarkNormalHover=false; setHoverBookmark(null)" ng-repeat="bookmark in tag.bookmarks" ng-click="jumpToUrl(bookmark.url, bookmark.id)" title="{{ bookmark.title }}" id="{{bookmark.id}}">
|
||||
<img class="ui ui middle aligned tiny image bookmarkInfo" ng-src="http://favicon.luchenqun.com/?url={{bookmark.url}}" err-src="./images/default.ico" style="width:16px;height:16px;" ng-click="detailBookmark(bookmark);$event.stopPropagation()" />
|
||||
<span>{{ bookmark.title}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui divider"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui segment js-segment-costomTag" ng-if="showStyle === 'costomTag'" ng-show="!loadBusy">
|
||||
<div class="ui container">
|
||||
<div class="ui grid">
|
||||
<div class="two wide column js-costomTag-label" ng-repeat="tag in costomTags">
|
||||
<div class="ui small label" ng-class="{green:tag.clicked}" ng-click="updateCostomTagBookmarks(tag.index)">
|
||||
{{ tag.name }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui divider"></div>
|
||||
<div class="ui five column grid">
|
||||
<div class="column js-costomTag-item" ng-class="{bookmarkNormalHover:bookmarkNormalHover, bookmark:(!bookmarkNormalHover)}" ng-mouseover="bookmarkNormalHover=true; setHoverBookmark(bookmark)" ng-mouseleave="bookmarkNormalHover=false; setHoverBookmark(null)" ng-repeat="bookmark in bookmarks" ng-click="jumpToUrl(bookmark.url, bookmark.id)" title="{{ bookmark.title }}" id="{{bookmark.id}}">
|
||||
<img class="ui ui middle aligned tiny image bookmarkInfo" ng-src="http://favicon.luchenqun.com/?url={{bookmark.url}}" err-src="./images/default.ico" style="width:16px;height:16px;" ng-click="detailBookmark(bookmark);$event.stopPropagation()" />
|
||||
<span>{{ bookmark.title}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<table class="ui selectable sortable celled table js-table-bookmarks" ng-if="showStyle === 'table'" ng-show="!loadBusy">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="forbid_sorted">标题</th>
|
||||
<th class="forbid_sorted">链接</th>
|
||||
<th style="width:90px;" ng-class="{descending: order[0], sorted:order[0]}" ng-click="changeOrder(0)" title="点击可对表格进行排序">点击次数</th>
|
||||
<th style="width:100px;" ng-class="{descending: order[1], sorted:order[1]}" ng-click="changeOrder(1)" title="点击可对表格进行排序">创建日期</th>
|
||||
<th style="width:100px;" ng-class="{descending: order[2], sorted:order[2]}" ng-click="changeOrder(2)" title="点击可对表格进行排序">最后点击</th>
|
||||
<th style="width:150px;" class="forbid_sorted">分类</th>
|
||||
<th style="width:88px;" class="forbid_sorted">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="bookmark in bookmarks" id="{{ bookmark.id }}" ng-mouseover="setHoverBookmark(bookmark)" ng-mouseleave="setHoverBookmark(null)">
|
||||
<td>
|
||||
<img class="ui ui middle aligned tiny image" ng-src="http://favicon.luchenqun.com/?url={{bookmark.url}}" err-src="./images/default.ico" style="width:16px;height:16px;cursor:pointer;" ng-click="jumpToUrl(bookmark.url, bookmark.id)" />
|
||||
<span ng-click="jumpToUrl(bookmark.url, bookmark.id)" title="{{bookmark.title}}" style="cursor:pointer;">
|
||||
{{ bookmark.title }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span title="{{bookmark.url}} 点击复制链接" ng-click="copy(bookmark.url)" style="cursor:default;">{{ bookmark.url }}</span>
|
||||
</td>
|
||||
<td>{{ bookmark.click_count }}</td>
|
||||
<td>
|
||||
<span title="{{bookmark.created_at}}" class="need_to_be_rendered" data-timeago="{{bookmark.created_at}}"></span>
|
||||
</td>
|
||||
<td>
|
||||
<span id="time{{bookmark.id}}" title="{{bookmark.last_click}}" class="need_to_be_rendered" data-timeago="{{bookmark.last_click}}"></span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="ui label" ng-repeat="tag in bookmark.tags" tag-id="{{ tag.id }}" ng-click="jumpToTags(tag.id)">
|
||||
{{ tag.name }}
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<img class="ui mini spaced image" style="width:16px;height:16px;margin:0 1px" ng-src="./images/delete.png" ng-click="delBookmark(bookmark)" title="删除书签" />
|
||||
<img class="ui mini spaced image" style="width:16px;height:16px;margin:0 1px" ng-src="./images/edit-bookmark.png" ng-click="editBookmark(bookmark.id)" title="编辑书签" />
|
||||
<img class="ui mini spaced image" style="width:16px;height:16px;margin:0 1px" ng-src="./images/detail.png" ng-click="detailBookmark(bookmark)" title="书签详情" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="7">
|
||||
<pagination></pagination>
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<div class="ui segment js-segment-card" ng-if="showStyle === 'card'" ng-show="!loadBusy || currentPage>1">
|
||||
<div class="ui five stackable cards" infinite-scroll="loadCardData()" infinite-scroll-immediate-check="false">
|
||||
<div class="card" ng-repeat="bookmark in bookmarks" id="{{bookmark.id}}" ng-mouseover="setHoverBookmark(bookmark)" ng-mouseleave="setHoverBookmark(null)">
|
||||
<div class="content" ng-click="jumpToUrl(bookmark.url, bookmark.id)" style="max-height:70px;cursor:pointer">
|
||||
<div class="description bookmarkTitle">
|
||||
{{bookmark.title}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="image" href="{{ bookmark.url }}" ng-click="jumpToUrl(bookmark.url, bookmark.id)" style="cursor:pointer">
|
||||
<img ng-src="./images/snap/{{bookmark.id}}.png" err-src="./images/default.jpg" />
|
||||
</div>
|
||||
<div class="extra content tags" style="height:50px;">
|
||||
<div class="ui label" ng-repeat="tag in bookmark.tags" tag-id="{{ tag.id }}" ng-click="jumpToTags(tag.id)">
|
||||
{{ tag.name }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="extra content" ng-show="!bookmark.edit" style="height:50px;padding-right:2px;padding-left:8px;">
|
||||
<span class="left floated like" style="margin-top:6px;">
|
||||
<img class="ui ui middle aligned tiny image" ng-src="http://favicon.luchenqun.com/?url={{bookmark.url}}" err-src="./images/default.ico" style="width:16px;height:16px;cursor:pointer;" ng-click="jumpToUrl(bookmark.url, bookmark.id)" />
|
||||
创建于:
|
||||
<span title="{{bookmark.created_at}}" class="need_to_be_rendered" data-timeago="{{bookmark.created_at}}"></span>
|
||||
<!-- {{ bookmark.created_at }} -->
|
||||
</span>
|
||||
<i class="ellipsis horizontal icon right floated" style="margin-top:8px;" ng-mouseover="bookmark.edit=true;"></i>
|
||||
</div>
|
||||
<div class="extra content" ng-show="bookmark.edit" ng-mouseleave="bookmark.edit=false;" style="height:50px;">
|
||||
<img class="ui mini spaced image" style="width:16px;height:16px;margin:0 8px;margin-top:8px;" ng-src="./images/delete.png" ng-click="delBookmark(bookmark)" title="删除书签" />
|
||||
<img class="ui mini spaced image" style="width:16px;height:16px;margin:0 8px;margin-top:8px;" ng-src="./images/edit-bookmark.png" ng-click="editBookmark(bookmark.id)" title="编辑书签" />
|
||||
<img class="ui mini spaced image" style="width:16px;height:16px;margin:0 8px;margin-top:8px;" ng-src="./images/copy.png" ng-click="copy(bookmark.url)" title="复制链接" />
|
||||
<img class="ui mini spaced image" style="width:16px;height:16px;margin:0 8px;margin-top:8px;" ng-src="./images/detail.png" ng-click="detailBookmark(bookmark)" title="书签详情" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui massive text centered inline loader" ng-class="{active:loadBusy, disabled:!loadBusy}">
|
||||
正在加载中...
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,68 +1,68 @@
|
|||
<div class="ui segment js-note-card" style="padding:14px 0px 0px 0px;">
|
||||
<div class="ui container" style="padding-left:14px">
|
||||
<div class="ui label" style="margin:3px 15px 8px 0px;cursor:default;" ng-class="{green:tag.clicked}" ng-repeat="tag in tags" ng-click="clickTag(tag.id)" ng-show="tag.ncnt || add">{{ tag.name }} ({{ tag.ncnt || 0 }})</div>
|
||||
<div class="ui label" style="margin:3px 15px 8px 0px;cursor:default;" ng-click="showAddNote()" data-tooltip="点击添加备忘。你也可以在任意界面按快捷键A(不区分大小写)增加备忘录。">
|
||||
<i class="plus icon" style="margin-right:0px;"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui container" style="padding-left:14px;padding-bottom:14px">
|
||||
<div class="ui form" ng-show="add">
|
||||
<div class="required field">
|
||||
<label>内容</label>
|
||||
<textarea rows="12" placeholder="" ng-model="content" id="noteedit"></textarea>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="actions">
|
||||
<div class="ui cancel button" ng-click="add=false;">取消</div>
|
||||
<div class="ui green button" ng-click="addNote(false)" ng-show="!edit">提交关闭</div>
|
||||
<div class="ui green button" ng-click="addNote(true)" ng-show="!edit">提交继续</div>
|
||||
<div class="ui green button" ng-click="updateNote()" ng-show="edit">更新</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui divider" ng-show="notes.length > 0" style="margin:0px;"></div>
|
||||
<div class="ui hidden info message js-note" ng-if="(!add) && notes.length == 0" style="margin-left:14px;margin-right:14px">
|
||||
<i class="close icon" ng-click="closeNote()"></i>
|
||||
<div class="content">
|
||||
<div class="header">系统提示!</div>
|
||||
<ul class="list">
|
||||
<li>您可以在任意界面按快捷键A(不区分大小写)增加备忘录。双击备忘录可查看详情!</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui vertical segment" ng-repeat="note in notes" ng-click="noteClick(note)" ng-mouseover="setHoverNote(note)" ng-mouseleave="setHoverNote(null)" id="{{note.id}}" style="margin:0px;padding-top:10px;padding-bottom: 10px;">
|
||||
<pre class="note-content" title="单击查看详情,C复制,D删除,E编辑" style="margin:0px;padding-left:14px;padding-right:14px" ng-if="!note.detail">{{ note.brief }}</pre>
|
||||
<pre class="note-content" title="双击复制" ng-dblclick="copy(note.content)" style="margin:0px; font-size:16px;padding:60px 14px;" ng-if="note.detail">{{ note.content }}</pre>
|
||||
<div class="ui right aligned grid" ng-show="note.detail">
|
||||
<div class="sixteen wide column" style="margin:0px 20px 0px 0px;padding:20px 0px 0px 0px;">
|
||||
<div class="extra content" ng-show="true" ng-mouseleave="note.edit=false;" style="height:50px;">
|
||||
<div class="ui mini label" ng-click="clickTag(note.tag_id)" style="margin:3px 0px 0px 10px;cursor:default;">{{ note.tagName || "未分类" }}</div>
|
||||
<span style="margin:0 8px;">
|
||||
<span title="添加于{{note.created_at}}" class="need_to_be_rendered" data-timeago="{{ note.created_at }}"></span>
|
||||
<span style="margin-left:-3px;">添加</span>
|
||||
</span>
|
||||
<i ng-if="note.public == 0" class="black lock icon" title="点击公开备忘" ng-click="updatePublic(note, 1)"></i>
|
||||
<i ng-if="note.public == 1" class="black open lock icon" title="点击不公开备忘" ng-click="updatePublic(note, 0)"></i>
|
||||
<img class="ui mini spaced image" style="width:16px;height:16px;margin:0 8px;" ng-src="./images/delete.png" ng-click="delNote(note.id, note.content)" title="删除备忘" />
|
||||
<label for="noteedit">
|
||||
<img class="ui mini spaced image" style="width:16px;height:16px;margin:0 8px;" ng-src="./images/edit-bookmark.png" ng-click="editNote(note.id, note.content, note.tag_id)" title="编辑备忘" />
|
||||
</label>
|
||||
<img class="ui mini spaced image" id="noteid{{note.id}}" style="width:16px;height:16px;margin:0 8px;" ng-src="./images/copy.png" id="url{{bookmark.id}}" ng-click="copy(note.content)" title="复制备忘" />
|
||||
<i class="black share alternate icon" title="复制分享地址" ng-click="share(note)"></i>
|
||||
<i class="black chevron up icon" title="收起详情" ng-click="noteClick(note, true, $event)"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="height:20px;" ng-show="notes.length === 0"></div>
|
||||
<div class="ui grid" ng-show="totalItems>0" style="margin:0px;padding:0px 14px">
|
||||
<div class="eight wide column" style="padding-top:26px;"><span ng-show="searchWord">通过搜索关键字"{{searchWord}}"(点击菜单"备忘录"重新查看所有),</span>共找到备忘一共约{{totalItems}}个</div>
|
||||
<div class="eight wide column">
|
||||
<pagination></pagination>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui massive text centered inline loader js-hot-loader" ng-class="{active:loadBusy, disabled:!loadBusy}">
|
||||
正在加载中...
|
||||
</div>
|
||||
<div class="ui segment js-note-card" style="padding:14px 0px 0px 0px;">
|
||||
<div class="ui container" style="padding-left:14px">
|
||||
<div class="ui label" style="margin:3px 15px 8px 0px;cursor:default;" ng-class="{green:tag.clicked}" ng-repeat="tag in tags" ng-click="clickTag(tag.id)" ng-show="tag.noteCount || add">{{ tag.name }} ({{ tag.noteCount || 0 }})</div>
|
||||
<div class="ui label" style="margin:3px 15px 8px 0px;cursor:default;" ng-click="showAddNote()" data-tooltip="点击添加备忘。你也可以在任意界面按快捷键A(不区分大小写)增加备忘录。">
|
||||
<i class="plus icon" style="margin-right:0px;"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui container" style="padding-left:14px;padding-bottom:14px">
|
||||
<div class="ui form" ng-show="add">
|
||||
<div class="required field">
|
||||
<label>内容</label>
|
||||
<textarea rows="12" placeholder="" ng-model="content" id="noteedit"></textarea>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="actions">
|
||||
<div class="ui cancel button" ng-click="add=false;">取消</div>
|
||||
<div class="ui green button" ng-click="addNote(false)" ng-show="!edit">提交关闭</div>
|
||||
<div class="ui green button" ng-click="addNote(true)" ng-show="!edit">提交继续</div>
|
||||
<div class="ui green button" ng-click="updateNote()" ng-show="edit">更新</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui divider" ng-show="notes.length > 0" style="margin:0px;"></div>
|
||||
<div class="ui hidden info message js-note" ng-if="(!add) && notes.length == 0" style="margin-left:14px;margin-right:14px">
|
||||
<i class="close icon" ng-click="closeNote()"></i>
|
||||
<div class="content">
|
||||
<div class="header">系统提示!</div>
|
||||
<ul class="list">
|
||||
<li>您可以在任意界面按快捷键A(不区分大小写)增加备忘录。双击备忘录可查看详情!</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui vertical segment" ng-repeat="note in notes" ng-click="noteClick(note)" ng-mouseover="setHoverNote(note)" ng-mouseleave="setHoverNote(null)" id="{{note.id}}" style="margin:0px;padding-top:10px;padding-bottom: 10px;">
|
||||
<pre class="note-content" title="单击查看详情,C复制,D删除,E编辑" style="margin:0px;padding-left:14px;padding-right:14px" ng-if="!note.detail">{{ note.brief }}</pre>
|
||||
<pre class="note-content" title="双击复制" ng-dblclick="copy(note.content)" style="margin:0px; font-size:16px;padding:60px 14px;" ng-if="note.detail">{{ note.content }}</pre>
|
||||
<div class="ui right aligned grid" ng-show="note.detail">
|
||||
<div class="sixteen wide column" style="margin:0px 20px 0px 0px;padding:20px 0px 0px 0px;">
|
||||
<div class="extra content" ng-show="true" ng-mouseleave="note.edit=false;" style="height:50px;">
|
||||
<div class="ui mini label" ng-click="clickTag(note.tag_id)" style="margin:3px 0px 0px 10px;cursor:default;">{{ note.tagName || "未分类" }}</div>
|
||||
<span style="margin:0 8px;">
|
||||
<span title="添加于{{note.created_at}}" class="need_to_be_rendered" data-timeago="{{ note.created_at }}"></span>
|
||||
<span style="margin-left:-3px;">添加</span>
|
||||
</span>
|
||||
<i ng-if="note.public == 0" class="black lock icon" title="点击公开备忘" ng-click="updatePublic(note, 1)"></i>
|
||||
<i ng-if="note.public == 1" class="black open lock icon" title="点击不公开备忘" ng-click="updatePublic(note, 0)"></i>
|
||||
<img class="ui mini spaced image" style="width:16px;height:16px;margin:0 8px;" ng-src="./images/delete.png" ng-click="delNote(note.id, note.content)" title="删除备忘" />
|
||||
<label for="noteedit">
|
||||
<img class="ui mini spaced image" style="width:16px;height:16px;margin:0 8px;" ng-src="./images/edit-bookmark.png" ng-click="editNote(note.id, note.content, note.tag_id)" title="编辑备忘" />
|
||||
</label>
|
||||
<img class="ui mini spaced image" id="noteid{{note.id}}" style="width:16px;height:16px;margin:0 8px;" ng-src="./images/copy.png" id="url{{bookmark.id}}" ng-click="copy(note.content)" title="复制备忘" />
|
||||
<i class="black share alternate icon" title="复制分享地址" ng-click="share(note)"></i>
|
||||
<i class="black chevron up icon" title="收起详情" ng-click="noteClick(note, true, $event)"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="height:20px;" ng-show="notes.length === 0"></div>
|
||||
<div class="ui grid" ng-show="totalItems>0" style="margin:0px;padding:0px 14px">
|
||||
<div class="eight wide column" style="padding-top:26px;"><span ng-show="searchWord">通过搜索关键字"{{searchWord}}"(点击菜单"备忘录"重新查看所有),</span>共找到备忘一共约{{totalItems}}个</div>
|
||||
<div class="eight wide column">
|
||||
<pagination></pagination>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui massive text centered inline loader js-hot-loader" ng-class="{active:loadBusy, disabled:!loadBusy}">
|
||||
正在加载中...
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue