summaryrefslogtreecommitdiff
path: root/public/assets/js/lib/views/admin/adminz.js
blob: cd0c93d187d2cd1989f32dddfc16d1f7969b38c6 (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
40
41
var AdminView = View.extend({
  events: {},

  action: "/api/admin",

  initialize: function (opt) {
    // this.hootbox = new HootBox ({ parent: this })
    this.password = new ChangePasswordForm({ parent: this });
    this.lastlog = new LastLog({ parent: this });
  },

  load: function () {
    $("body").addClass("index").addClass("admin");
    $.get(this.action, this.populate.bind(this));
  },

  populate: function (data) {
    $("body").removeClass("loading");
    console.log(data);
    this.password.load(data.usernames);
    this.lastlog.load(data.lastlog);
    if (data.mail.count) {
      $(".alert")
        .show()
        .html(
          "<a href='/mail'>" +
            "You have " +
            data.mail.count +
            " new message" +
            courtesy_s(data.mail.count) +
            "!</a>"
        );
      if (is_mobile) {
        $("#content").prepend($(".alert"));
      }
    }
    if (is_desktop) {
      $(".search_form input").focus();
    }
  },
});