| author | hamidouk |
| Tue, 25 Oct 2011 14:31:10 +0200 | |
| branch | popcorn-port |
| changeset 137 | ef6c1252c459 |
| parent 128 | f3fec80dd31c |
| child 147 | 955119f901b4 |
| permissions | -rw-r--r-- |
|
108
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
1 |
|
|
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
2 |
IriSP.JSONSerializer = function(DataLoader, url) { |
|
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
3 |
IriSP.Serializer.call(this, DataLoader, url); |
|
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
4 |
}; |
|
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
5 |
|
| 128 | 6 |
IriSP.JSONSerializer.prototype = new IriSP.Serializer(); |
|
108
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
7 |
|
|
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
8 |
IriSP.JSONSerializer.prototype.serialize = function(data) { |
|
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
9 |
return JSON.stringify(data); |
|
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
10 |
}; |
|
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
11 |
|
|
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
12 |
IriSP.JSONSerializer.prototype.deserialize = function(data) { |
|
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
13 |
return JSON.parse(data); |
|
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
14 |
}; |
|
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
15 |
|
|
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
16 |
IriSP.JSONSerializer.prototype.sync = function(callback) { |
|
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
17 |
/* we don't have to do much because jQuery handles json for us */ |
| 128 | 18 |
|
| 137 | 19 |
var self = this; |
20 |
||
21 |
var fn = function(data) { |
|
22 |
self._data = data; |
|
23 |
// sort the data too |
|
24 |
self._data["annotations"].sort(function(a, b) |
|
|
108
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
25 |
{ var a_begin = +a.begin; |
|
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
26 |
var b_begin = +b.begin; |
|
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
27 |
return a_begin - b_begin; |
|
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
28 |
}); |
| 137 | 29 |
|
30 |
callback(data); |
|
|
108
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
31 |
}; |
|
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
32 |
|
| 137 | 33 |
this._DataLoader.get(this._url, fn); |
|
108
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
34 |
}; |
|
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
35 |
|
|
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
36 |
IriSP.JSONSerializer.prototype.currentMedia = function() { |
|
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
37 |
return this._data.medias[0]; /* FIXME: don't hardcode it */ |
|
62da43e72e30
broke the serializers across multiple files. added a newline to the end of
hamidouk
parents:
diff
changeset
|
38 |
}; |