Node.js based forum software built for the modern web
moved format number functions to utils
barisusaklib1a6d394e301
diff --git a/public/src/app.js b/public/src/app.jsindex 3d2b78c6bd..a2219dfe24 100644--- a/public/src/app.js+++ b/public/src/app.js@@ -166,11 +166,6 @@ var socket,});};- // 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@@ -362,12 +357,6 @@ var socket,});};- app.makeNumbersHumanReadable = function(elements) {- elements.each(function() {- $(this).html(utils.makeNumberHumanReadable($(this).attr('title')));- });- };-app.processPage = function () {app.populateOnlineUsers();@@ -376,7 +365,7 @@ var socket,$('span.timeago').timeago();$('.post-content img').addClass('img-responsive');- app.makeNumbersHumanReadable($('.human-readable-number'));+ utils.makeNumbersHumanReadable($('.human-readable-number'));app.createUserTooltips();@@ -407,12 +396,6 @@ var socket,}};- app.addCommasToNumbers = function () {- $('.formatted-number').each(function (index, element) {- $(element).html(app.addCommas($(element).html()));- });- };-app.openChat = function (username, touid) {if (username === app.username) {app.alert({diff --git a/public/src/forum/account.js b/public/src/forum/account.jsindex 9fbccf2bf7..ba5338448a 100644--- a/public/src/forum/account.js+++ b/public/src/forum/account.js@@ -12,8 +12,8 @@ define(['forum/accountheader'], function(header) {var username = $('.account-username').html();app.enterRoom('user/' + theirid);- app.addCommasToNumbers();- app.makeNumbersHumanReadable($('.account .human-readable-number'));+ utils.addCommasToNumbers($('.account .formatted-number'));+ utils.makeNumbersHumanReadable($('.account .human-readable-number'));$('.user-recent-posts img').addClass('img-responsive');var followBtn = $('#follow-btn');diff --git a/public/src/forum/accountposts.js b/public/src/forum/accountposts.jsindex 1609886fa1..1403b606fe 100644--- a/public/src/forum/accountposts.js+++ b/public/src/forum/accountposts.js@@ -49,7 +49,7 @@ define(['forum/accountheader'], function(header) {$('.user-favourite-posts').append(html);$('span.timeago').timeago();app.createUserTooltips();- app.makeNumbersHumanReadable(html.find('.human-readable-number'));+ utils.makeNumbersHumanReadable(html.find('.human-readable-number'));});});}diff --git a/public/src/forum/category.js b/public/src/forum/category.jsindex f493df08ed..eef2a04207 100644--- a/public/src/forum/category.js+++ b/public/src/forum/category.js@@ -284,7 +284,7 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {html.find('span.timeago').timeago();app.createUserTooltips();- app.makeNumbersHumanReadable(html.find('.human-readable-number'));+ utils.makeNumbersHumanReadable(html.find('.human-readable-number'));if (typeof callback === 'function') {callback(topics);diff --git a/public/src/forum/favourites.js b/public/src/forum/favourites.jsindex 6b992c89de..f9944e5e29 100644--- a/public/src/forum/favourites.js+++ b/public/src/forum/favourites.js@@ -42,9 +42,9 @@ define(['forum/accountheader'], function(header) {html = $(translatedHTML);html.find('img').addClass('img-responsive');$('.user-favourite-posts').append(html);- $('span.timeago').timeago();+ html.find('span.timeago').timeago();app.createUserTooltips();- app.makeNumbersHumanReadable(html.find('.human-readable-number'));+ utils.makeNumbersHumanReadable(html.find('.human-readable-number'));});});}diff --git a/public/src/forum/followers.js b/public/src/forum/followers.jsindex 7916a67214..15263c142e 100644--- a/public/src/forum/followers.js+++ b/public/src/forum/followers.js@@ -9,11 +9,11 @@ define(['forum/accountheader'], function(header) {followersCount = ajaxify.variables.get('followersCount');- if (parseInt(followersCount, 10) === 0) {- $('#no-followers-notice').removeClass('hide');- }+ if (parseInt(followersCount, 10) === 0) {+ $('#no-followers-notice').removeClass('hide');+ }- app.addCommasToNumbers();+ utils.addCommasToNumbers($('.account .formatted-number'));};return Followers;diff --git a/public/src/forum/following.js b/public/src/forum/following.jsindex 4bc23d1a5a..80571cd19d 100644--- a/public/src/forum/following.js+++ b/public/src/forum/following.js@@ -10,7 +10,7 @@ define(['forum/accountheader'], function(header) {$('#no-following-notice').removeClass('hide');}- app.addCommasToNumbers();+ utils.addCommasToNumbers($('.account .formatted-number'));};return Following;diff --git a/public/src/forum/recent.js b/public/src/forum/recent.jsindex 81f69f098b..17d5abedc8 100644--- a/public/src/forum/recent.js+++ b/public/src/forum/recent.js@@ -124,9 +124,9 @@ define(function() {html = $(translatedHTML);$('#topics-container').append(html);- $('span.timeago').timeago();+ html.find('span.timeago').timeago();app.createUserTooltips();- app.makeNumbersHumanReadable(html.find('.human-readable-number'));+ utils.makeNumbersHumanReadable(html.find('.human-readable-number'));});});}diff --git a/public/src/forum/topic.js b/public/src/forum/topic.jsindex 387c147b52..ba4e4ae41f 100644--- a/public/src/forum/topic.js+++ b/public/src/forum/topic.js@@ -44,7 +44,7 @@ define(['forum/pagination', 'forum/topic/threadTools', 'forum/topic/postTools'],}$(function() {- app.addCommasToNumbers();+ utils.addCommasToNumbers($('.topic .formatted-number'));app.enterRoom('topic_' + tid);@@ -761,8 +761,8 @@ define(['forum/pagination', 'forum/topic/threadTools', 'forum/topic/postTools'],app.populateOnlineUsers();app.createUserTooltips();- app.addCommasToNumbers();- app.makeNumbersHumanReadable($('.human-readable-number'));+ utils.addCommasToNumbers(html.find('.formatted-number'));+ utils.makeNumbersHumanReadable(html.find('.human-readable-number'));html.find('span.timeago').timeago();html.find('.post-content img').addClass('img-responsive');updatePostCount();diff --git a/public/src/forum/users.js b/public/src/forum/users.jsindex 4a74dacb7f..180bcd36fe 100644--- a/public/src/forum/users.js+++ b/public/src/forum/users.js@@ -16,7 +16,7 @@ define(function() {var lastSearch = null;- app.addCommasToNumbers();+ utils.addCommasToNumbers($('.users .formatted-number'));$('.nav-pills li').removeClass('active');$('.nav-pills li a').each(function() {diff --git a/public/src/utils.js b/public/src/utils.jsindex b62a8bce21..a66681c559 100644--- a/public/src/utils.js+++ b/public/src/utils.js@@ -198,6 +198,12 @@return (firstChar === '.' || firstChar === '/');},+ makeNumbersHumanReadable: function(elements) {+ elements.each(function() {+ $(this).html(utils.makeNumberHumanReadable($(this).attr('title')));+ });+ },+makeNumberHumanReadable: function(num) {var n = parseInt(num, 10);if(!n) {@@ -212,6 +218,17 @@return n;},+ addCommasToNumbers: function (elements) {+ elements.each(function (index, element) {+ $(element).html(utils.addCommas($(element).html()));+ });+ },++ // takes a string like 1000 and returns 1,000+ addCommas: function (text) {+ return text.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");+ },+toISOString: function(timestamp) {if(!timestamp) {return '';