|
|
|
@ -37,16 +37,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
(function() {
|
|
|
|
|
var locked = '{locked}';
|
|
|
|
|
|
|
|
|
|
jQuery('document').ready(function() {
|
|
|
|
|
jQuery('document').ready(function() {
|
|
|
|
|
var room = 'topic_' + '{topic_id}';
|
|
|
|
|
|
|
|
|
|
app.enter_room(room);
|
|
|
|
|
set_up_posts();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (locked === '1') set_locked_state(true);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
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) {
|
|
|
|
|
var anonymous = users.anonymous,
|
|
|
|
|
usernames = users.usernames,
|
|
|
|
|
usercount = usernames.length;
|
|
|
|
@ -65,28 +70,28 @@ socket.on('api:get_users_in_room', function(users) {
|
|
|
|
|
+ (anonymous === 0 ? (usercount > 1 ? ' are' : ' is') : '') + ' browsing this thread';
|
|
|
|
|
|
|
|
|
|
document.getElementById('thread_active_users').innerHTML = active;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
socket.on('event:rep_up', function(data) {
|
|
|
|
|
socket.on('event:rep_up', function(data) {
|
|
|
|
|
adjust_rep(1, data.pid, data.uid);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
socket.on('event:rep_down', function(data) {
|
|
|
|
|
socket.on('event:rep_down', function(data) {
|
|
|
|
|
adjust_rep(-1, data.pid, data.uid);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
socket.on('event:new_post', function(data) {
|
|
|
|
|
socket.on('event:new_post', function(data) {
|
|
|
|
|
var html = templates.prepare(templates['topic'].blocks['posts']).parse(data),
|
|
|
|
|
uniqueid = new Date().getTime();
|
|
|
|
|
|
|
|
|
|
jQuery('<div id="' + uniqueid + '"></div>').appendTo("#post-container").hide().append(html).fadeIn('slow');
|
|
|
|
|
set_up_posts(uniqueid);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function adjust_rep(value, pid, uid) {
|
|
|
|
|
function adjust_rep(value, pid, uid) {
|
|
|
|
|
var post_rep = jQuery('.post_rep_' + pid),
|
|
|
|
|
user_rep = jQuery('.user_rep_' + uid);
|
|
|
|
|
|
|
|
|
@ -98,19 +103,19 @@ function adjust_rep(value, pid, uid) {
|
|
|
|
|
|
|
|
|
|
post_rep.html(ptotal);
|
|
|
|
|
user_rep.html(utotal);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function set_up_posts(div) {
|
|
|
|
|
function set_up_posts(div) {
|
|
|
|
|
if (div == null) div = '';
|
|
|
|
|
else div = '#' + div;
|
|
|
|
|
|
|
|
|
|
jQuery(div + ' .post_reply').click(function() {
|
|
|
|
|
app.open_post_window('reply', "{topic_id}", "{topic_name}");
|
|
|
|
|
if (locked !== '1') app.open_post_window('reply', "{topic_id}", "{topic_name}");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
jQuery(div + ' .quote').click(function() {
|
|
|
|
|
app.open_post_window('quote', "{topic_id}", "{topic_name}");
|
|
|
|
|
if (locked !== '1') app.open_post_window('quote', "{topic_id}", "{topic_name}");
|
|
|
|
|
|
|
|
|
|
// this needs to be looked at, obviously. only single line quotes work well I think maybe replace all \r\n with > ?
|
|
|
|
|
document.getElementById('post_content').innerHTML = '> ' + document.getElementById('content_' + this.id.replace('quote_', '')).innerHTML;
|
|
|
|
@ -138,5 +143,29 @@ function set_up_posts(div) {
|
|
|
|
|
socket.emit('api:posts.unfavourite', {pid: pid, room_id: app.current_room});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function set_locked_state(locked) {
|
|
|
|
|
var threadReplyBtn = document.getElementById('post_reply'),
|
|
|
|
|
postReplyBtns = document.querySelectorAll('#post-container .post_reply'),
|
|
|
|
|
quoteBtns = document.querySelectorAll('#post-container .quote'),
|
|
|
|
|
numReplyBtns = postReplyBtns.length,
|
|
|
|
|
x;
|
|
|
|
|
if (locked === true) {
|
|
|
|
|
threadReplyBtn.disabled = true;
|
|
|
|
|
threadReplyBtn.innerHTML = 'Locked';
|
|
|
|
|
for(x=0;x<numReplyBtns;x++) {
|
|
|
|
|
postReplyBtns[x].innerHTML = 'Locked <i class="icon-lock"></i>';
|
|
|
|
|
quoteBtns[x].style.display = 'none';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
threadReplyBtn.disabled = false;
|
|
|
|
|
threadReplyBtn.innerHTML = 'Reply';
|
|
|
|
|
for(x=0;x<numReplyBtns;x++) {
|
|
|
|
|
postReplyBtns[x].innerHTML = 'Reply <i class="icon-reply"></i>';
|
|
|
|
|
quoteBtns[x].style.display = 'inline-block';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})();
|
|
|
|
|
</script>
|