From c73d1237d21e89db66b8926e07b298126d326363 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Fri, 3 May 2013 17:52:20 +0000 Subject: [PATCH] started favourites/rep --- public/css/style.less | 4 ++++ public/templates/topic.tpl | 19 ++++++++++++++++--- src/websockets.js | 4 ++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/public/css/style.less b/public/css/style.less index f29dce41e5..81c55db407 100644 --- a/public/css/style.less +++ b/public/css/style.less @@ -193,6 +193,10 @@ footer.footer { padding-right: 5px; } } + + .icon-star { + //theme this to make it yellow eventually + } } background: #fff; } diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl index e9402b7f82..5f91ff0917 100644 --- a/public/templates/topic.tpl +++ b/public/templates/topic.tpl @@ -21,7 +21,7 @@ posted by {posts.userName} {posts.relativeTime}
-
+
0
Reply
@@ -47,7 +47,20 @@ jQuery('.quote').click(function() { }); jQuery('.favourite').click(function() { - if (this.children[0].className == 'icon-star-empty') this.children[0].className = 'icon-star'; - else this.children[0].className = 'icon-star-empty'; + var pid = this.id.replace('favs_', ''), + favs_counter = document.getElementById('favs_counter_' + pid); + + var total = parseInt(favs_counter.innerHTML, 10); + + if (this.children[1].className == 'icon-star-empty') { + this.children[1].className = 'icon-star'; + total++; + favs_counter.innerHTML = total; + } + else { + this.children[1].className = 'icon-star-empty'; + total--; + favs_counter.innerHTML = total; + } }) \ No newline at end of file diff --git a/src/websockets.js b/src/websockets.js index 17018a4f70..33ac1ea8ab 100644 --- a/src/websockets.js +++ b/src/websockets.js @@ -124,6 +124,10 @@ var SocketIO = require('socket.io').listen(global.server,{log:false}), modules.user.active.get(); }); + socket.on('api:posts.favourite', function(data) { + modules.posts.favourite(socket, data.pid); + }) + socket.on('api:user.active.get_record', function() { modules.user.active.get_record(socket); });