summaryrefslogtreecommitdiff
path: root/public/assets/js/lib/views/index/index.js
blob: 5acfe8b325fcf8e5e185bb6831c4af1130d395ae (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
var IndexView = View.extend({

  events: {
  },
  
  action: "/api/index",
  keywordAction: "/api/keyword/",
  
  initialize: function(opt){
    // opt.parent = parent
    this.hootbox = new HootBox ({ parent: this })
    this.threadbox = new ThreadBox ({ parent: this, latest: true, welcome: true, })
    this.lastlog = new LastLog ({ parent: this })
  },
  
  load: function(keyword){
    if (keyword) {
      $(".subtitle").html('<a href="/">&lt; Home</a>')
      this.threadbox.options.welcome = false
      $.get(this.keywordAction + keyword, this.populate.bind(this))
    }
    else {
      $.get(this.action, this.populate.bind(this))
    }
  },
  
  populate: function(data){
    $("body").removeClass('loading')
    this.hootbox.load(data.hootbox)
    this.threadbox.load(data)
    this.lastlog.load(data.lastlog)
    $("#search_form input").focus()
  },
  
  success: function(){
    window.location.href = "/index"
  },

})