(function() { var cid = templates.get('category_id'), room = 'category_' + cid; app.enter_room(room); var new_post = document.getElementById('new_post'); new_post.onclick = function() { require(['composer'], function(cmp) { cmp.push(0, cid); }); } ajaxify.register_events([ 'event:new_topic' ]); socket.on('event:new_topic', function(data) { var html = templates.prepare(templates['category'].blocks['topics']).parse({ topics: [data] }), topic = document.createElement('div'), container = document.getElementById('topics-container'), topics = document.querySelectorAll('#topics-container a'), numTopics = topics.length, x; jQuery('#topics-container, .category-sidebar').removeClass('hidden'); jQuery('#category-no-topics').remove(); topic.innerHTML = html; if (numTopics > 0) { for(x=0;x').appendTo("#topics-container").hide().append(html).fadeIn('slow'); // set_up_posts(uniqueid); }); socket.emit('api:categories.getRecentReplies', cid); socket.on('api:categories.getRecentReplies', function(replies) { if (replies === false) { return; } var users = replies.users, posts = replies.posts, recent_replies = document.getElementById('category_recent_replies'); recent_replies.innerHTML = ''; for (var i=0, ii=posts.pids.length; i' + '

' + username + ': ' + posts.content[i] + '

posted ' + utils.relativeTime(posts.timestamp[i]) + ' ago'; a.appendChild(ul); recent_replies.appendChild(a); } }); })();