diff --git a/public/routes/bookmark.js b/public/routes/bookmark.js
index 4da2502..c627af4 100644
--- a/public/routes/bookmark.js
+++ b/public/routes/bookmark.js
@@ -36,7 +36,21 @@ const BookmarkRouter = {
},
getMessages: function(){
- var _usrid = "5d360f06b8f3ce67d12ccc92";
+ var arr = auth.bookmarks;
+ console.log("arr: "+arr+" auth.bookmarks: "+auth.bookmarks);
+ _messagelist.splice(0, _messagelist.length);
+ _messagelist.push.apply(_messagelist, arr);
+ for (var e in arr) {
+ if (!_messages[arr[e]]) {
+ //arr[e] =arr[e].replace(/\[/g, '').replace(/\"/g, '').replace(/\]/g, '')
+ console.log("getinsertmessage: "+ arr[e]);
+ get_insert_message(arr[e]);
+ }
+ }
+
+
+
+ /*var _usrid = auth.user;
$.ajax({
url: "api/usr/id/" + _usrid,
method: "GET"
@@ -59,7 +73,7 @@ const BookmarkRouter = {
function have_error(err) {
console.log("error: " + err.responseText);
console.log(err);
- }
+ }*/
}
},
mounted: function (){
diff --git a/public/routes/home.js b/public/routes/home.js
index e8f3a67..7fc092c 100644
--- a/public/routes/home.js
+++ b/public/routes/home.js
@@ -8,6 +8,7 @@ const HomeRouter = {
v-for="id in messagelist.slice().reverse()"
:key="id"
:msg="messages[id] || {}"
+ :isBookmark="bookmarkArray[id]"
>
`,
@@ -16,7 +17,8 @@ const HomeRouter = {
messagelist: _messagelist,
messages: _messages,
isSearchActiv: _isSearchActiv,
- isSubscripeButtonActiv: _isSubscripeButtonActiv
+ isSubscripeButtonActiv: _isSubscripeButtonActiv,
+ bookmarkArray: auth.bookmarks,
};
},
methods: {
@@ -29,6 +31,7 @@ const HomeRouter = {
_isSearchActiv = false;
}
+
},
mounted: function () {
this.list_messages();
diff --git a/public/routes/msgCard.js b/public/routes/msgCard.js
index 1152e9d..e20fcbc 100644
--- a/public/routes/msgCard.js
+++ b/public/routes/msgCard.js
@@ -2,7 +2,7 @@ Vue.component('MsgCard', {
template: `
{{ msg.subject }}
-
{{msg._id}}
+ {{msg._id}}
{{ msg.message }}
@@ -12,25 +12,36 @@ Vue.component('MsgCard', {
`,
- props: ['msg'],
+ props: ['msg', 'isBookmark'],
data: function () {
return {
- isActive: false,
+ isActive: this.isBookmark,
+ isActive_: 0,
+ msgid: this.msg._id
};
},
methods: {
- myFilter: function(_messageid) {
+ myFilter: function (_messageid) {
//var _messageid = $("#msgid").text();
+ if (this.isActive == true) {
+ var index = auth.bookmarks.indexOf(_messageid);
- var _bookmark = auth.bookmarks;
- _bookmark.push(_messageid);
- console.log("msgid"+_bookmark);
- var _userid = "5d360f06b8f3ce67d12ccc92";
+ if (index > -1) {
+ auth.bookmarks.splice(index, 1);
+ }
+ this.isActive = false;
+ } else {
+ console.log("_messsageid: "+_messageid+" bookmarks: "+auth.bookmarks);
+ auth.bookmarks.push(_messageid);
+ this.isActive =true;
+ }
+ /*console.log("msgid"+_bookmark);
+ var _userid = auth.user;
this.isActive = !this.isActive;
if(this.isActive){
$.ajax({
@@ -50,11 +61,25 @@ Vue.component('MsgCard', {
console.log("error: " + err.responseText);
console.log(err);
}
- }
+ }*/
},
- filterForTag: function(tag) {
- console.log("link: " +tag);
+ filterForTag: function (tag) {
+ console.log("link: " + tag);
searching(tag);
},
+ isBookmarkActive: function (msgid) {
+ //console.log("isBookmarkActive(): " + msgid);
+ if (auth.bookmarks.indexOf(msgid) > -1) {
+ // $("#bockmark-not-active").css("visibility","hidden");
+ // $("#bockmark-active").css("visibility","visible");
+ this.isActive = true;
+ //console.log("isBookmarkActive(): " + this.isActive);
+ this.isActive_ = 1;
+
+ }
+ }
+ },
+ beforeMount: function () {
+ //this.isBookmarkActive();
}
});
diff --git a/public/style/style.css b/public/style/style.css
index f646ef7..0c1d9b6 100644
--- a/public/style/style.css
+++ b/public/style/style.css
@@ -241,7 +241,6 @@ button.clearButton {
float: right;
}
}
-
-.subscribe-btn{
- float:right;
+#bockmark-not-active {
+ visibility: visible;
}
diff --git a/public/style/style.less b/public/style/style.less
index 5420cff..eeb9cf7 100644
--- a/public/style/style.less
+++ b/public/style/style.less
@@ -284,3 +284,10 @@ button.clearButton{
float: right;
}
}
+
+#bockmark-not-active{
+ visibility: visible;
+}
+#bockmark-active{
+ //visibility: hidden;
+}