summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js/lib/blogs/BlogView.js
blob: 4f888e8da8331e1eef1795a34d69ec2fbcde4d6d (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 BlogView = View.extend({

  data: null,
  loaded: false,
  initialize: function(){
    this.loader = new Loader ()
    this.fetch()
  },
  
  fetch: function(){
    $.ajax({
      method: "GET",
      url: "http://stone.sup.land/db.json",
      success: this.success.bind(this),
      cache: true,
    })
  },
  
  success: function(data){
    this.loaded = true
    this.data = data
    this.loader.preloadImage(data.archive[0].images[0].uri, function(img){
      app.archive.populate(data.archive)
    })
    this.loader.preloadImage(data.hub[0].image[0].uri, function(img){
      app.hub.populate(data.hub)
    })
    this.loader.preloadImage(data.story[0].image.uri, function(img){
      app.story.populate(data.story)
    })
    data.page.forEach(function(page){
      app[page.tag].populate(page)
    })
    if (data.store[0].StoreIsOpen !== "true") {
      app.closed.populate(data.store[0].ClosedStoreImages)
    }
  },

})