' + posts[i].content + '
' + '' + ''; frag.appendChild(li.cloneNode(true)); recent_replies.appendChild(frag); } $('#category_recent_replies span.timeago').timeago(); }); function onTopicsLoaded(topics) { var html = templates.prepare(templates['category'].blocks['topics']).parse({ topics: topics }), container = $('#topics-container'); jQuery('#topics-container, .category-sidebar').removeClass('hidden'); jQuery('#category-no-topics').remove(); container.append(html); $('#topics-container span.timeago').timeago(); } function loadMoreTopics(cid) { loadingMoreTopics = true; socket.emit('api:category.loadMore', { cid: cid, after: $('#topics-container').children().length }, function (data) { if (data.topics.length) { onTopicsLoaded(data.topics); } loadingMoreTopics = false; }); } $(window).off('scroll').on('scroll', function (ev) { var bottom = ($(document).height() - $(window).height()) * 0.9; if ($(window).scrollTop() > bottom && !loadingMoreTopics) { loadMoreTopics(cid); } }); })();