Skip to content

Node.js based forum software built for the modern web

decimal places for rep and post count

Baris Usaklid308242d2d5d
diff --git a/public/templates/account.tpl b/public/templates/account.tpl
index e371c02d3a..1fad9dd15a 100644
--- a/public/templates/account.tpl
+++ b/public/templates/account.tpl
@@ -28,11 +28,11 @@
<br/>
<span class="account-bio-label">reputation</span>
- <span>{user.reputation}</span>
+ <span id='reputation'>{user.reputation}</span>
<br/>
<span class="account-bio-label">posts</span>
- <span>{user.postcount}</span>
+ <span id='postcount'>{user.postcount}</span>
</div>
@@ -47,6 +47,20 @@
</div>
<script type="text/javascript">
(function() {
- // ...
+
+ function addCommas(text) {
+ return text.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
+ }
+
+ $(document).ready(function() {
+ var rep = $('#reputation');
+ rep.html(addCommas(rep.html()));
+
+ var postcount = $('#postcount');
+ postcount.html(addCommas(postcount.html()));
+
+ });
+
+
}());
</script>
\ No newline at end of file
diff --git a/public/templates/users.tpl b/public/templates/users.tpl
index e782b5a8d9..826c1be78e 100644
--- a/public/templates/users.tpl
+++ b/public/templates/users.tpl
@@ -11,15 +11,35 @@
<a href="/users/{users.username}">{users.username}</a>
<br/>
<div title="reputation">
- <span>{users.reputation}</span>
+ <span id='reputation'>{users.reputation}</span>
<i class='icon-star'></i>
</div>
<div title="post count">
- <span>{users.postcount}</span>
+ <span id='postcount'>{users.postcount}</span>
<i class='icon-pencil'></i>
</div>
</div>
<!-- END users -->
-</div>
\ No newline at end of file
+</div>
+
+<script>
+(function() {
+
+ function addCommas(text) {
+ return text.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
+ }
+
+ $(document).ready(function() {
+ var rep = $('#reputation');
+ rep.html(addCommas(rep.html()));
+
+ var postcount = $('#postcount');
+ postcount.html(addCommas(postcount.html()));
+
+ });
+
+
+}());
+</script>
\ No newline at end of file
diff --git a/src/webserver.js b/src/webserver.js
index 23e0ec343e..a006e2ffd3 100644
--- a/src/webserver.js
+++ b/src/webserver.js
@@ -436,7 +436,8 @@ passport.deserializeUser(function(uid, done) {
user.getUserData(uid, function(data) {
if(data) {
- res.send(templates['header'] + '<script>templates.ready(function(){ajaxify.go("users/'+data.username + '");});</script>' + templates['footer']);
+ //res.send(templates['header'] + '<script>templates.ready(function(){ajaxify.go("users/'+data.username + '");});</script>' + templates['footer']);
+ res.send(templates['header'] + create_route('users/'+data.username,'users') + templates['footer']);
}
else {
res.send("User doesn't exist! /users/"+req.params.username);