summaryrefslogtreecommitdiff
path: root/public/assets/js/lib/views/index/lastlog.js
blob: 02b3cca49e1cca9c0b4d1d31e7d1f135f122bc91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
age_class
views_class
comments_class
size_class
files_class
*/

var LastLog = View.extend({
  el: ".lastlog",
  
  events: {
  },
  
  initialize: function(){
    this.__super__.initialize.call(this)
    this.template = this.$(".template").html()
  },
  
  load: function(lastlog){
    if (!lastlog || !lastlog.length) {
      this.$el.hide()
      return
    }
    var s = lastlog.map(this.parse.bind(this)).filter(s => s).join(', ')
    this.$el.html(s)
  },
  
  parse: function(user){
    if (Date.now()/1000 - user.lastseen > 86400 * 5 *10) return ''
    var t = this.template
                .replace(/{{username}}/g, user.username)
                .replace(/{{age}}/g, get_age(user.lastseen) )
                .replace(/{{age_class}}/g, carbon_date(user.lastseen) )
                .trim()
    return t
  },
  
})