diff options
| author | czaks <marcin@6irc.net> | 2014-10-08 23:23:59 +0200 |
|---|---|---|
| committer | czaks <marcin@6irc.net> | 2014-10-08 23:23:59 +0200 |
| commit | 9b3fa77719642acd13a2ae6f29087dffcb261f4d (patch) | |
| tree | 6ea26048a0f540c29d28041e1191920d5485f346 /templates/main.js | |
| parent | 906764a62f6fbc263d8b1d21957531edb6481e59 (diff) | |
new banlist implementation; also includes a public banlist
Diffstat (limited to 'templates/main.js')
| -rw-r--r-- | templates/main.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/templates/main.js b/templates/main.js index 52f38e69..ed25f7d9 100644 --- a/templates/main.js +++ b/templates/main.js @@ -22,6 +22,53 @@ function fmt(s,a) { return s.replace(/\{([0-9]+)\}/g, function(x) { return a[x[1]]; }); } +function until($timestamp) { + var $difference = $timestamp - Date.now()/1000|0, $num; + switch(true){ + case ($difference < 60): + return "" + $difference + ' ' + _('second(s)'); + case ($difference < 3600): //60*60 = 3600 + return "" + ($num = Math.round($difference/(60))) + ' ' + _('minute(s)'); + case ($difference < 86400): //60*60*24 = 86400 + return "" + ($num = Math.round($difference/(3600))) + ' ' + _('hour(s)'); + case ($difference < 604800): //60*60*24*7 = 604800 + return "" + ($num = Math.round($difference/(86400))) + ' ' + _('day(s)'); + case ($difference < 31536000): //60*60*24*365 = 31536000 + return "" + ($num = Math.round($difference/(604800))) + ' ' + _('week(s)'); + default: + return "" + ($num = Math.round($difference/(31536000))) + ' ' + _('year(s)'); + } +} + +function ago($timestamp) { + var $difference = (Date.now()/1000|0) - $timestamp, $num; + switch(true){ + case ($difference < 60) : + return "" + $difference + ' ' + _('second(s)'); + case ($difference < 3600): //60*60 = 3600 + return "" + ($num = Math.round($difference/(60))) + ' ' + _('minute(s)'); + case ($difference < 86400): //60*60*24 = 86400 + return "" + ($num = Math.round($difference/(3600))) + ' ' + _('hour(s)'); + case ($difference < 604800): //60*60*24*7 = 604800 + return "" + ($num = Math.round($difference/(86400))) + ' ' + _('day(s)'); + case ($difference < 31536000): //60*60*24*365 = 31536000 + return "" + ($num = Math.round($difference/(604800))) + ' ' + _('week(s)'); + default: + return "" + ($num = Math.round($difference/(31536000))) + ' ' + _('year(s)'); + } +} + +var datelocale = + { days: [_('Sunday'), _('Monday'), _('Tuesday'), _('Wednesday'), _('Thursday'), _('Friday'), _('Saturday')] + , shortDays: [_("Sun"), _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat")] + , months: [_('January'), _('February'), _('March'), _('April'), _('May'), _('June'), _('July'), _('August'), _('September'), _('October'), _('November'), _('December')] + , shortMonths: [_('Jan'), _('Feb'), _('Mar'), _('Apr'), _('May'), _('Jun'), _('Jul'), _('Aug'), _('Sep'), _('Oct'), _('Nov'), _('Dec')] + , AM: _('AM') + , PM: _('PM') + , am: _('am') + , pm: _('pm') + }; + var saved = {}; |
