|
|
|
@ -4,7 +4,7 @@
|
|
|
|
|
<li class="active">{topic_name}</li>
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
<small>psychobunny, null, and 2 guests are browsing this thread</small><br />
|
|
|
|
|
<div id="thread_active_users"></div><br />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<ul id="post-container" class="post-container container">
|
|
|
|
@ -38,15 +38,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
|
|
jQuery('document').ready(function() {
|
|
|
|
|
// join room for this thread - DRY failure, see ajaxify and app.js
|
|
|
|
|
socket.emit('event:enter_room', 'topic_' + '{topic_id}');
|
|
|
|
|
current_room = 'topic_' + '{topic_id}';
|
|
|
|
|
var room = 'topic_' + '{topic_id}';
|
|
|
|
|
app.enter_room(room);
|
|
|
|
|
set_up_posts();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ajaxify.register_events(['event:rep_up', 'event:rep_down', 'event:new_post']);
|
|
|
|
|
ajaxify.register_events(['event:rep_up', 'event:rep_down', 'event:new_post', 'api:get_users_in_room']);
|
|
|
|
|
socket.on('api:get_users_in_room', function(users) {
|
|
|
|
|
document.getElementById('thread_active_users').innerHTML = (users.uids.join(', ')) + ' are browsing this thread';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
socket.on('event:rep_up', function(data) {
|
|
|
|
|
adjust_rep(1, data.pid, data.uid);
|
|
|
|
@ -56,6 +59,7 @@ socket.on('event:rep_down', function(data) {
|
|
|
|
|
adjust_rep(-1, data.pid, data.uid);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
socket.on('event:new_post', function(data) {
|
|
|
|
|
var html = templates.prepare(templates['topic'].blocks['posts']).parse(data),
|
|
|
|
|
uniqueid = new Date().getTime();
|
|
|
|
@ -64,6 +68,8 @@ socket.on('event:new_post', function(data) {
|
|
|
|
|
set_up_posts(uniqueid);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function adjust_rep(value, pid, uid) {
|
|
|
|
|
var post_rep = jQuery('.post_rep_' + pid),
|
|
|
|
|
user_rep = jQuery('.user_rep_' + uid);
|
|
|
|
@ -109,11 +115,11 @@ function set_up_posts(div) {
|
|
|
|
|
|
|
|
|
|
if (this.children[1].className == 'icon-star-empty') {
|
|
|
|
|
this.children[1].className = 'icon-star';
|
|
|
|
|
socket.emit('api:posts.favourite', {pid: pid, room_id: current_room});
|
|
|
|
|
socket.emit('api:posts.favourite', {pid: pid, room_id: app.current_room});
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this.children[1].className = 'icon-star-empty';
|
|
|
|
|
socket.emit('api:posts.unfavourite', {pid: pid, room_id: current_room});
|
|
|
|
|
socket.emit('api:posts.unfavourite', {pid: pid, room_id: app.current_room});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|