diff --git a/public/src/app.js b/public/src/app.js index 8139fbdad1..967e472ef7 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -44,6 +44,11 @@ var socket, async: false }); + // takes a string like 1000 and returns 1,000 + app.addCommas = function(text) { + return text.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,"); + } + // use unique alert_id to have multiple alerts visible at a time, use the same alert_id to fade out the current instance // type : error, success, info, warning/notify // title = bolded title text diff --git a/public/templates/account.tpl b/public/templates/account.tpl index 91c76d4ad9..af717beadd 100644 --- a/public/templates/account.tpl +++ b/public/templates/account.tpl @@ -74,17 +74,13 @@ var theirid = '{theirid}'; var isFriend = {isFriend}; - function addCommas(text) { - return text.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,"); - } - $(document).ready(function() { var rep = $('#reputation'); - rep.html(addCommas(rep.html())); + rep.html(app.addCommas(rep.html())); var postcount = $('#postcount'); - postcount.html(addCommas(postcount.html())); + postcount.html(app.addCommas(postcount.html())); var editLink = $('#editLink'); var addFriendBtn = $('#add-friend-btn'); diff --git a/public/templates/friends.tpl b/public/templates/friends.tpl index 57edeb8563..b7c634e2a5 100644 --- a/public/templates/friends.tpl +++ b/public/templates/friends.tpl @@ -49,10 +49,6 @@ var friendCount = '{friendCount}'; (function() { - function addCommas(text) { - return text.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,"); - } - $(document).ready(function() { if(parseInt(friendCount, 10) === 0) { @@ -80,12 +76,12 @@ var friendCount = '{friendCount}'; } $('.reputation').each(function(index, element) { - $(element).html(addCommas($(element).html())); - }) + $(element).html(app.addCommas($(element).html())); + }); $('.postcount').each(function(index, element) { - $(element).html(addCommas($(element).html())); - }) + $(element).html(app.addCommas($(element).html())); + }); }); diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl index cffea752ff..4148a7f933 100644 --- a/public/templates/topic.tpl +++ b/public/templates/topic.tpl @@ -58,7 +58,7 @@ - {posts.user_rep} + {posts.user_rep}
@@ -126,6 +126,11 @@ }; jQuery('document').ready(function() { + + $('.user_reputation_text').each(function(index, element) { + $(element).html(app.addCommas($(element).html())); + }); + var room = 'topic_' + '{topic_id}', adminTools = document.getElementById('thread-tools'); diff --git a/public/templates/users.tpl b/public/templates/users.tpl index f22d55675c..479cc06c56 100644 --- a/public/templates/users.tpl +++ b/public/templates/users.tpl @@ -27,19 +27,17 @@