More work on polls and themes
This commit is contained in:
@ -424,6 +424,11 @@ function newPosts() {
|
||||
};
|
||||
|
||||
window.setInterval(function() {
|
||||
var timestamp;
|
||||
$('.postAge').each(function(a){
|
||||
timestamp = $(this).attr('id');
|
||||
$(this).html(timeSince(timestamp)+' ago');
|
||||
});
|
||||
newPosts();
|
||||
}, 25000);
|
||||
|
||||
@ -477,3 +482,37 @@ function themecheck(name){
|
||||
$('#customtheme').css("display","none");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function timeSince(date) {
|
||||
/* https://stackoverflow.com/questions/3177836/how-to-format-time-since-xxx-e-g-4-minutes-ago-similar-to-stack-exchange-site */
|
||||
|
||||
var seconds = Math.floor((new Date() - (date*1000)) / 1000);
|
||||
|
||||
var interval = Math.floor(seconds / 31536000);
|
||||
|
||||
if (interval >= 1) {
|
||||
return interval + " years";
|
||||
}
|
||||
interval = Math.floor(seconds / 2592000);
|
||||
if (interval >= 1) {
|
||||
return interval + " months";
|
||||
}
|
||||
interval = Math.floor(seconds / 604800);
|
||||
if (interval >= 1) {
|
||||
return interval + " weeks";
|
||||
}
|
||||
interval = Math.floor(seconds / 86400);
|
||||
if (interval >= 1) {
|
||||
return interval + " days";
|
||||
}
|
||||
interval = Math.floor(seconds / 3600);
|
||||
if (interval >= 1) {
|
||||
return interval + " hours";
|
||||
}
|
||||
interval = Math.floor(seconds / 60);
|
||||
if (interval >= 1) {
|
||||
return interval + " minutes";
|
||||
}
|
||||
return Math.floor(seconds) + " seconds";
|
||||
}
|
Reference in New Issue
Block a user