From c94da47ae8bafe3265b315546177dffdd1499876 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Tue, 14 Jan 2014 19:23:27 -0500 Subject: [PATCH] added profile func, shorter getRecentReplies --- public/src/forum/category.js | 35 +++++++++++++++-------------------- public/src/utils.js | 6 ++++++ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/public/src/forum/category.js b/public/src/forum/category.js index 3e2fe29b92..c76c6871dc 100644 --- a/public/src/forum/category.js +++ b/public/src/forum/category.js @@ -15,6 +15,8 @@ define(['composer'], function(composer) { app.enterRoom('category_' + cid); + + twitterEl.on('click', function () { window.open(twitterUrl, '_blank', 'width=550,height=420,scrollbars=no,status=no'); return false; @@ -143,29 +145,22 @@ define(['composer'], function(composer) { return; } - var recent_replies = document.getElementById('category_recent_replies'); + var recentReplies = $('#category_recent_replies'); + var reply; + for (var i = 0, numPosts = posts.length; i < numPosts; ++i) { - recent_replies.innerHTML = ''; + reply = $('
  • ' + + '' + + '' + + ''+ posts[i].username + '' + + '

    ' + posts[i].content + '

    ' + + '
    ' + + '' + + '
  • '); - var frag = document.createDocumentFragment(), - li = document.createElement('li'); - for (var i = 0, numPosts = posts.length; i < numPosts; i++) { - - li.setAttribute('data-pid', posts[i].pid); - - - li.innerHTML = '' + - '' + - ''+ posts[i].username + '' + - '

    ' + - posts[i].content + - '

    ' + - '
    ' + - ''; - - frag.appendChild(li.cloneNode(true)); - recent_replies.appendChild(frag); + recentReplies.append(reply); } + $('#category_recent_replies span.timeago').timeago(); app.createUserTooltips(); }; diff --git a/public/src/utils.js b/public/src/utils.js index 8f6e51d59d..b4da160888 100644 --- a/public/src/utils.js +++ b/public/src/utils.js @@ -6,6 +6,12 @@ if ('undefined' === typeof window) { fs = require('fs'); XRegExp = require('xregexp').XRegExp; + + process.profile = function(operation, start) { + var diff = process.hrtime(start); + console.log('%s took %d milliseconds', operation, diff[0] * 1e3 + diff[1] / 1e6); + } + } else { XRegExp = window.XRegExp; }