equal
deleted
inserted
replaced
14 }; |
14 }; |
15 |
15 |
16 IriSP.JSONSerializer.prototype.sync = function(callback) { |
16 IriSP.JSONSerializer.prototype.sync = function(callback) { |
17 /* we don't have to do much because jQuery handles json for us */ |
17 /* we don't have to do much because jQuery handles json for us */ |
18 |
18 |
19 /* a wrapper to get a closure because we lose this in callbacks */ |
19 var self = this; |
20 var wrapper = function(obj) { |
20 |
21 return function(data) { |
21 var fn = function(data) { |
22 obj._data = data; |
22 self._data = data; |
23 // sort the data too |
23 // sort the data too |
24 obj._data["annotations"].sort(function(a, b) |
24 self._data["annotations"].sort(function(a, b) |
25 { var a_begin = +a.begin; |
25 { var a_begin = +a.begin; |
26 var b_begin = +b.begin; |
26 var b_begin = +b.begin; |
27 return a_begin - b_begin; |
27 return a_begin - b_begin; |
28 }); |
28 }); |
29 callback(data); |
29 |
30 } |
30 callback(data); |
31 }; |
31 }; |
32 |
32 |
33 this._DataLoader.get(this._url, wrapper(this)); |
33 this._DataLoader.get(this._url, fn); |
34 }; |
34 }; |
35 |
35 |
36 IriSP.JSONSerializer.prototype.currentMedia = function() { |
36 IriSP.JSONSerializer.prototype.currentMedia = function() { |
37 return this._data.medias[0]; /* FIXME: don't hardcode it */ |
37 return this._data.medias[0]; /* FIXME: don't hardcode it */ |
38 }; |
38 }; |