diff --git a/database/db.js b/database/db.js
index c6a4a9a..b3cca0a 100644
--- a/database/db.js
+++ b/database/db.js
@@ -153,6 +153,58 @@ db.delBookmarkTags = function(bookmard_id) {
});
}
+db.getBookmarkIdsByTagId = function(tagId) {
+ var sql = "SELECT bookmark_id FROM `tags_bookmarks` WHERE `tag_id` = '" + tagId + "'";
+ return new Promise(function(resolve, reject) {
+ client.query(sql, (err, result) => {
+ if (err) {
+ reject(err);
+ } else {
+ resolve(result);
+ }
+ });
+ });
+}
+
+db.delTag = function(tagId) {
+ var sql = "DELETE FROM `tags` WHERE (`id`='" + tagId + "')";
+ return new Promise(function(resolve, reject) {
+ client.query(sql, (err, result) => {
+ if (err) {
+ reject(err);
+ } else {
+ resolve(result.affectedRows);
+ }
+ });
+ });
+}
+
+db.delTagBookmarks = function(tagId) {
+ var sql = "DELETE FROM `tags_bookmarks` WHERE (`tag_id`='" + tagId + "')";
+ return new Promise(function(resolve, reject) {
+ client.query(sql, (err, result) => {
+ if (err) {
+ reject(err);
+ } else {
+ resolve(result.affectedRows);
+ }
+ });
+ });
+}
+
+db.delBookmarks = function(bookmarkIds) {
+ var sql = "DELETE FROM `bookmarks` WHERE id IN (" + (bookmarkIds.toString() || ("-1")) + ")";
+ return new Promise(function(resolve, reject) {
+ client.query(sql, (err, result) => {
+ if (err) {
+ reject(err);
+ } else {
+ resolve(result.affectedRows);
+ }
+ });
+ });
+}
+
db.addTagsBookmarks = function(tags, bookmard_id) {
sql = "INSERT INTO `tags_bookmarks` (`tag_id`, `bookmark_id`) VALUES";
for (var i = 0; i < tags.length; i++) {
@@ -312,8 +364,8 @@ db.getTags = function(user_id) {
});
};
-db.updateTag = function(tag) {
- console.log('updateTag');
+db.updateTagName = function(tag) {
+ console.log('updateTagName');
var sql = "UPDATE `tags` SET `name`='" + tag.name + "' WHERE (`id`='" + tag.id + "')";
console.log(sql);
return new Promise(function(resolve, reject) {
@@ -327,6 +379,27 @@ db.updateTag = function(tag) {
});
};
+db.updateTagsIndex = function(tagsIndex) {
+ console.log('updateTagsIndex');
+ var sql = "UPDATE tags SET sort = CASE id ";
+ tagsIndex.forEach((tagIndex) => {
+ sql += "WHEN " + tagIndex.id + " THEN " + tagIndex.index + " ";
+ })
+ var tagsId = tagsIndex.map((item) => item.id);
+ sql += "END WHERE id IN (" + tagsId.toString() + ")";
+
+ console.log(sql);
+ return new Promise(function(resolve, reject) {
+ client.query(sql, (err, result) => {
+ if (err) {
+ reject(err);
+ } else {
+ resolve(result.affectedRows);
+ }
+ });
+ });
+};
+
db.getTagsByIds = function(tagIds) {
var sql = "SELECT * FROM `tags` WHERE id in(" + (tagIds.toString() || ("-1")) + ") GROUP BY id"; // 如果是空的,那查一个不存在的就行了。
console.log('db getTagsByIds = ', sql);
@@ -417,7 +490,7 @@ db.getBookmarksNavigate = function(tags) {
if (index >= 1) {
sql += " UNION "
}
- sql += "(SELECT * FROM ((SELECT t.id AS tag_id, t.`name` as tag_name, b.* FROM `tags` as t, `bookmarks`as b, `tags_bookmarks` as tb WHERE t.id = tb.tag_id AND b.id = tb.bookmark_id AND t.id = " + tag.id + " ORDER BY b.click_count DESC LIMIT 0, 16) UNION (SELECT t.id AS tag_id, t.`name` as tag_name, b.* FROM `tags` as t, `bookmarks`as b, `tags_bookmarks` as tb WHERE t.id = tb.tag_id AND b.id = tb.bookmark_id AND t.id = " + tag.id + " ORDER BY b.created_at DESC LIMIT 0, 16)) as " + t + " ORDER BY " + t + ".click_count DESC, " + t + ".created_at DESC)";
+ sql += "(SELECT * FROM ((SELECT t.id AS tag_id, t.`name` as tag_name, t.sort, b.* FROM `tags` as t, `bookmarks`as b, `tags_bookmarks` as tb WHERE t.id = tb.tag_id AND b.id = tb.bookmark_id AND t.id = " + tag.id + " ORDER BY b.click_count DESC LIMIT 0, 16) UNION (SELECT t.id AS tag_id, t.`name` as tag_name, t.sort, b.* FROM `tags` as t, `bookmarks`as b, `tags_bookmarks` as tb WHERE t.id = tb.tag_id AND b.id = tb.bookmark_id AND t.id = " + tag.id + " ORDER BY b.created_at DESC LIMIT 0, 16)) as " + t + " ORDER BY " + t + ".click_count DESC, " + t + ".created_at DESC)";
})
console.log(sql);
diff --git a/public/css/externe/ngDialog-theme-default.css b/public/css/externe/ngDialog-theme-default.css
new file mode 100644
index 0000000..742c1bd
--- /dev/null
+++ b/public/css/externe/ngDialog-theme-default.css
@@ -0,0 +1,146 @@
+@keyframes ngdialog-flyin {
+ 0% {
+ opacity: 0;
+ transform: translateY(-40px);
+ }
+
+ 100% {
+ opacity: 1;
+ transform: translateY(0);
+ }
+}
+
+@keyframes ngdialog-flyout {
+ 0% {
+ opacity: 1;
+ transform: translateY(0);
+ }
+
+ 100% {
+ opacity: 0;
+ transform: translateY(-40px);
+ }
+}
+
+.ngdialog.ngdialog-theme-default {
+ padding-bottom: 160px;
+ padding-top: 160px;
+}
+
+.ngdialog.ngdialog-theme-default.ngdialog-closing .ngdialog-content {
+ animation: ngdialog-flyout .5s;
+}
+
+.ngdialog.ngdialog-theme-default .ngdialog-content {
+ animation: ngdialog-flyin .5s;
+ background: #f0f0f0;
+ border-radius: 5px;
+ color: #444;
+ font-family: 'Helvetica',sans-serif;
+ font-size: 1.1em;
+ line-height: 1.5em;
+ margin: 0 auto;
+ max-width: 100%;
+ padding: 1em;
+ position: relative;
+ width: 450px;
+}
+
+.ngdialog.ngdialog-theme-default .ngdialog-close {
+ border-radius: 5px;
+ cursor: pointer;
+ position: absolute;
+ right: 0;
+ top: 0;
+}
+
+.ngdialog.ngdialog-theme-default .ngdialog-close:before {
+ background: transparent;
+ border-radius: 3px;
+ color: #bbb;
+ content: '\00D7';
+ font-size: 26px;
+ font-weight: 400;
+ height: 30px;
+ line-height: 26px;
+ position: absolute;
+ right: 3px;
+ text-align: center;
+ top: 3px;
+ width: 30px;
+}
+
+.ngdialog.ngdialog-theme-default .ngdialog-close:hover:before,.ngdialog.ngdialog-theme-default .ngdialog-close:active:before {
+ color: #777;
+}
+
+.ngdialog.ngdialog-theme-default .ngdialog-message {
+ margin-bottom: .5em;
+}
+
+.ngdialog.ngdialog-theme-default .ngdialog-input {
+ margin-bottom: 1em;
+}
+
+.ngdialog.ngdialog-theme-default .ngdialog-input textarea,.ngdialog.ngdialog-theme-default .ngdialog-input input[type="text"],.ngdialog.ngdialog-theme-default .ngdialog-input input[type="password"],.ngdialog.ngdialog-theme-default .ngdialog-input input[type="email"],.ngdialog.ngdialog-theme-default .ngdialog-input input[type="url"] {
+ background: #fff;
+ border: 0;
+ border-radius: 3px;
+ font-family: inherit;
+ font-size: inherit;
+ font-weight: inherit;
+ margin: 0 0 .25em;
+ min-height: 2.5em;
+ padding: .25em .67em;
+ width: 100%;
+}
+
+.ngdialog.ngdialog-theme-default .ngdialog-input textarea:focus,.ngdialog.ngdialog-theme-default .ngdialog-input input[type="text"]:focus,.ngdialog.ngdialog-theme-default .ngdialog-input input[type="password"]:focus,.ngdialog.ngdialog-theme-default .ngdialog-input input[type="email"]:focus,.ngdialog.ngdialog-theme-default .ngdialog-input input[type="url"]:focus {
+ box-shadow: inset 0 0 0 2px #8dbdf1;
+ outline: none;
+}
+
+.ngdialog.ngdialog-theme-default .ngdialog-buttons {
+ *zoom: 1;
+}
+
+.ngdialog.ngdialog-theme-default .ngdialog-buttons:after {
+ content: '';
+ display: table;
+ clear: both;
+}
+
+.ngdialog.ngdialog-theme-default .ngdialog-button {
+ border: 0;
+ border-radius: 3px;
+ cursor: pointer;
+ float: right;
+ font-family: inherit;
+ font-size: .8em;
+ letter-spacing: .1em;
+ line-height: 1em;
+ margin: 0 0 0 .5em;
+ padding: .75em 2em;
+ text-transform: uppercase;
+}
+
+.ngdialog.ngdialog-theme-default .ngdialog-button:focus {
+ animation: ngdialog-pulse 1.1s infinite;
+ outline: none;
+}
+
+@media (max-width: 568px) {
+ .ngdialog.ngdialog-theme-default .ngdialog-button:focus {
+ animation: none;
+ }
+}
+
+.ngdialog.ngdialog-theme-default .ngdialog-button.ngdialog-button-primary {
+ background: #3288e6;
+ color: #fff;
+}
+
+.ngdialog.ngdialog-theme-default .ngdialog-button.ngdialog-button-secondary {
+ background: #e0e0e0;
+ color: #777;
+}
diff --git a/public/css/externe/ngDialog-theme-plain.css b/public/css/externe/ngDialog-theme-plain.css
new file mode 100644
index 0000000..2b101f4
--- /dev/null
+++ b/public/css/externe/ngDialog-theme-plain.css
@@ -0,0 +1,112 @@
+.ngdialog.ngdialog-theme-plain {
+ padding-bottom: 160px;
+ padding-top: 160px;
+}
+
+.ngdialog.ngdialog-theme-plain .ngdialog-content {
+ background: #fff;
+ color: #444;
+ font-family: 'Helvetica Neue',sans-serif;
+ font-size: 1.1em;
+ line-height: 1.5em;
+ margin: 0 auto;
+ max-width: 100%;
+ padding: 1em;
+ position: relative;
+ width: 450px;
+}
+
+.ngdialog.ngdialog-theme-plain .ngdialog-content h1,.ngdialog.ngdialog-theme-plain .ngdialog-content h2,.ngdialog.ngdialog-theme-plain .ngdialog-content h3,.ngdialog.ngdialog-theme-plain .ngdialog-content h4,.ngdialog.ngdialog-theme-plain .ngdialog-content h5,.ngdialog.ngdialog-theme-plain .ngdialog-content h6,.ngdialog.ngdialog-theme-plain .ngdialog-content p,.ngdialog.ngdialog-theme-plain .ngdialog-content ul,.ngdialog.ngdialog-theme-plain .ngdialog-content li {
+ color: inherit;
+}
+
+.ngdialog.ngdialog-theme-plain .ngdialog-close {
+ cursor: pointer;
+ position: absolute;
+ right: 0;
+ top: 0;
+}
+
+.ngdialog.ngdialog-theme-plain .ngdialog-close:before {
+ background: transparent;
+ color: #bbb;
+ content: "\00D7";
+ font-size: 26px;
+ font-weight: 400;
+ height: 30px;
+ line-height: 26px;
+ position: absolute;
+ right: 3px;
+ text-align: center;
+ top: 3px;
+ width: 30px;
+}
+
+.ngdialog.ngdialog-theme-plain .ngdialog-close:hover:before,.ngdialog.ngdialog-theme-plain .ngdialog-close:active:before {
+ color: #777;
+}
+
+.ngdialog.ngdialog-theme-plain .ngdialog-message {
+ margin-bottom: .5em;
+}
+
+.ngdialog.ngdialog-theme-plain .ngdialog-input {
+ margin-bottom: 1em;
+}
+
+.ngdialog.ngdialog-theme-plain .ngdialog-input textarea,.ngdialog.ngdialog-theme-plain .ngdialog-input input[type="text"],.ngdialog.ngdialog-theme-plain .ngdialog-input input[type="password"],.ngdialog.ngdialog-theme-plain .ngdialog-input input[type="email"],.ngdialog.ngdialog-theme-plain .ngdialog-input input[type="url"] {
+ background: #f0f0f0;
+ border: 0;
+ font-family: inherit;
+ font-size: inherit;
+ font-weight: inherit;
+ margin: 0 0 .25em;
+ min-height: 2.5em;
+ padding: .25em .67em;
+ width: 100%;
+}
+
+.ngdialog.ngdialog-theme-plain .ngdialog-input textarea:focus,.ngdialog.ngdialog-theme-plain .ngdialog-input input[type="text"]:focus,.ngdialog.ngdialog-theme-plain .ngdialog-input input[type="password"]:focus,.ngdialog.ngdialog-theme-plain .ngdialog-input input[type="email"]:focus,.ngdialog.ngdialog-theme-plain .ngdialog-input input[type="url"]:focus {
+ box-shadow: inset 0 0 0 2px rgba(0,0,0,0.2);
+ outline: none;
+}
+
+.ngdialog.ngdialog-theme-plain .ngdialog-buttons:after {
+ clear: both;
+ content: '';
+ display: table;
+}
+
+.ngdialog.ngdialog-theme-plain .ngdialog-button {
+ border: 0;
+ cursor: pointer;
+ float: right;
+ font-family: inherit;
+ font-size: .8em;
+ letter-spacing: .1em;
+ line-height: 1em;
+ margin: 0 0 0 .5em;
+ padding: .75em 2em;
+ text-transform: uppercase;
+}
+
+.ngdialog.ngdialog-theme-plain .ngdialog-button:focus {
+ animation: ngdialog-pulse 1.1s infinite;
+ outline: none;
+}
+
+@media (max-width: 568px) {
+ .ngdialog.ngdialog-theme-plain .ngdialog-button:focus {
+ animation: none;
+ }
+}
+
+.ngdialog.ngdialog-theme-plain .ngdialog-button.ngdialog-button-primary {
+ background: #3288e6;
+ color: #fff;
+}
+
+.ngdialog.ngdialog-theme-plain .ngdialog-button.ngdialog-button-secondary {
+ background: #e0e0e0;
+ color: #777;
+}
diff --git a/public/css/externe/ngDialog.css b/public/css/externe/ngDialog.css
new file mode 100644
index 0000000..5b3485c
--- /dev/null
+++ b/public/css/externe/ngDialog.css
@@ -0,0 +1,87 @@
+@keyframes ngdialog-fadeout {
+ 0% {
+ opacity: 1;
+ }
+ 100% {
+ opacity: 0;
+ }
+}
+
+@keyframes ngdialog-fadein {
+ 0% {
+ opacity: 0;
+ }
+ 100% {
+ opacity: 1;
+ }
+}
+
+.ngdialog {
+ box-sizing: border-box;
+}
+
+.ngdialog *,
+.ngdialog *:before,
+.ngdialog *:after {
+ box-sizing: inherit;
+}
+
+.ngdialog {
+ position: fixed;
+ overflow: auto;
+ -webkit-overflow-scrolling: touch;
+ z-index: 10000;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ left: 0;
+}
+
+.ngdialog.ngdialog-disabled-animation,
+.ngdialog.ngdialog-disabled-animation .ngdialog-overlay,
+.ngdialog.ngdialog-disabled-animation .ngdialog-content {
+ animation: none!important;
+}
+
+.ngdialog-overlay {
+ position: fixed;
+ background: rgba(0, 0, 0, 0.4);
+ top: 0;
+ right: 0;
+ bottom: 0;
+ left: 0;
+ -webkit-backface-visibility: hidden;
+ animation: ngdialog-fadein 0.5s;
+}
+
+.ngdialog-no-overlay {
+ pointer-events: none;
+}
+
+.ngdialog.ngdialog-closing .ngdialog-overlay {
+ -webkit-backface-visibility: hidden;
+ animation: ngdialog-fadeout 0.5s;
+}
+
+.ngdialog-content {
+ background: white;
+ -webkit-backface-visibility: hidden;
+ animation: ngdialog-fadein 0.5s;
+ pointer-events: all;
+}
+
+.ngdialog.ngdialog-closing .ngdialog-content {
+ -webkit-backface-visibility: hidden;
+ animation: ngdialog-fadeout 0.5s;
+}
+
+.ngdialog-close:before {
+ font-family: 'Helvetica', Arial, sans-serif;
+ content: '\00D7';
+ cursor: pointer;
+}
+
+html.ngdialog-open,
+body.ngdialog-open {
+ overflow: hidden;
+}
diff --git a/public/css/style.css b/public/css/style.css
index 28363e1..c504312 100644
--- a/public/css/style.css
+++ b/public/css/style.css
@@ -54,7 +54,7 @@ code {
-o-text-overflow: ellipsis;
overflow: hidden;
color: #212121;
- cursor: move;
+ cursor: default;
border: 1px dashed #3388FF;
}
.img-fixed-size {
diff --git a/public/index.html b/public/index.html
index 2caffa5..a612e24 100644
--- a/public/index.html
+++ b/public/index.html
@@ -11,6 +11,9 @@
+
+
+