preliminary chat support

This commit is contained in:
Stefan Breunig
2013-02-01 22:27:43 +01:00
parent e83a582f7c
commit 25d6b4cdc5
10 changed files with 4743 additions and 15 deletions

View File

@ -67,13 +67,22 @@ window.postAjax = function(action, data, success, error) {
// converts unix timestamps to HH:mm:ss format if it was today;
// otherwise it returns YYYY-MM-DD
window.unixTimeToString = function(time) {
window.unixTimeToString = function(time, full) {
if(!time) return null;
var d = new Date(typeof time === 'string' ? parseInt(time) : time);
var time = d.toLocaleTimeString();
var date = d.getFullYear()+'-'+(d.getMonth()+1)+'-'+d.getDate();
if(typeof full !== 'undefined' && full) return date + ' ' + time;
if(d.toDateString() == new Date().toDateString())
return d.toLocaleTimeString();
return time;
else
return d.getFullYear()+'-'+(d.getMonth()+1)+'-'+d.getDate();
return date;
}
window.unixTimeToHHmm = function(time) {
if(!time) return null;
var d = new Date(typeof time === 'string' ? parseInt(time) : time);
return d.toLocaleTimeString().slice(0, -3);
}