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}">
<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>
</div>
@ -240,9 +240,16 @@ $(document).ready(function() {
$.post('/users/doedit',
userData,
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() {

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

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

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

Loading…
Cancel
Save