relative time fix

v1.18.x
Baris Usakli 12 years ago
parent 91b4ec2547
commit 9cd189e273

@ -120,7 +120,7 @@
<input type="hidden" id="inputUID" value="{uid}"> <input type="hidden" id="inputUID" value="{uid}">
<div class="form-actions"> <div class="form-actions">
<a id="submitBtn" href="" class="btn btn-primary">Save changes</a> <a id="submitBtn" href="#" class="btn btn-primary">Save changes</a>
<a href="/users/{username}" class="btn">Cancel</a> <a href="/users/{username}" class="btn">Cancel</a>
</div> </div>
@ -240,9 +240,16 @@ $(document).ready(function() {
$.post('/users/doedit', $.post('/users/doedit',
userData, userData,
function(data) { function(data) {
app.alert({
} 'alert_id': 'user_profile_updated',
type: 'success',
title: 'Profile Updated',
message: 'Your profile has been updated successfully',
timeout: 2000
});
}
); );
return false;
}); });
function updateImages() { function updateImages() {

@ -78,12 +78,13 @@ var user = require('./../user.js'),
if(!req.user) if(!req.user)
return res.redirect('/403'); return res.redirect('/403');
if(req.user.uid != req.body.uid) if(req.user.uid != req.body.uid) {
return res.redirect('/'); return res.redirect('/');
}
user.updateProfile(req.user.uid, req.body); user.updateProfile(req.user.uid, req.body);
res.redirect('/'); res.send({});
}); });
app.post('/users/uploadpicture', function(req, res) { app.post('/users/uploadpicture', function(req, res) {
@ -283,8 +284,9 @@ var user = require('./../user.js'),
user.getUserData(uid, function(data) { user.getUserData(uid, function(data) {
if(data) { if(data) {
console.log(data.joindate);
data.joindate = utils.relativeTime(data.joindate); data.joindate = utils.relativeTime(data.joindate);
console.log(data.joindate);
if(!data.birthday) if(!data.birthday)
data.age = ''; data.age = '';
else else

@ -80,7 +80,7 @@ var config = require('../config.js'),
for(var i=0,ii=fields.length; i<ii; ++i) { for(var i=0,ii=fields.length; i<ii; ++i) {
key = fields[i]; key = fields[i];
if(data[key] !== undefined) { if(data[key] !== undefined) {
console.log(data[key]);
User.setUserField(uid, key, data[key]); User.setUserField(uid, key, data[key]);
if(key === 'email') { if(key === 'email') {
@ -91,7 +91,7 @@ var config = require('../config.js'),
} }
User.setUserField = function(uid, field, value) { User.setUserField = function(uid, field, value) {
RDB.hset('user:'+uid, field, value); RDB.hset('user:'+uid, field, value);
} }
User.incrementUserFieldBy = function(uid, field, value) { User.incrementUserFieldBy = function(uid, field, value) {

@ -11,6 +11,7 @@ var utils = {
difference = now - Math.floor(parseFloat(timestamp)); difference = now - Math.floor(parseFloat(timestamp));
difference = Math.floor(difference / 1000); difference = Math.floor(difference / 1000);
console.log(difference);
if (difference < 60) return difference + ' second' + (difference !== 1 ? 's' : ''); if (difference < 60) return difference + ' second' + (difference !== 1 ? 's' : '');
difference = Math.floor(difference / 60); difference = Math.floor(difference / 60);
@ -20,16 +21,13 @@ var utils = {
if (difference < 24) return difference + ' hour' + (difference !== 1 ? 's' : ''); if (difference < 24) return difference + ' hour' + (difference !== 1 ? 's' : '');
difference = Math.floor(difference / 24); difference = Math.floor(difference / 24);
if (difference < 3) return difference + ' day' + (difference !== 1 ? 's' : ''); if (difference < 30) return difference + ' day' + (difference !== 1 ? 's' : '');
// Lastly, just return a formatted date difference = Math.floor(difference / 30);
var date = new Date(timestamp); if (difference < 12) return difference + ' month' + (difference !== 1 ? 's' : '');
// hour = date.getHours(),
// minute = date.getMinutes(), difference = Math.floor(difference / 12);
// day = date.getDate(), return difference + ' year' + (difference !== 1 ? 's' : '');
// month = date.getMonth(),
// months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
return date.toDateString();
}, },
//http://dense13.com/blog/2009/05/03/converting-string-to-slug-javascript/ //http://dense13.com/blog/2009/05/03/converting-string-to-slug-javascript/

Loading…
Cancel
Save