|
904
|
1 |
/* Used when Putting annotations on the platform */ |
|
|
2 |
|
|
|
3 |
if (typeof IriSP.serializers === "undefined") { |
|
|
4 |
IriSP.serializers = {} |
|
|
5 |
} |
|
|
6 |
|
|
|
7 |
IriSP.serializers.ldt_annotate = { |
|
|
8 |
types : { |
|
|
9 |
annotation : { |
|
|
10 |
serialized_name : "annotations", |
|
|
11 |
serializer : function(_data, _source) { |
|
|
12 |
return { |
|
|
13 |
begin: _data.begin.milliseconds, |
|
|
14 |
end: _data.end.milliseconds, |
|
|
15 |
content: { |
|
|
16 |
data: _data.description |
|
|
17 |
}, |
|
|
18 |
tags: _data.getTagTexts(), |
|
|
19 |
media: _source.unNamespace(_data.getMedia().id), |
|
|
20 |
title: _data.title, |
|
|
21 |
type_title: _data.getAnnotationType().title, |
|
|
22 |
type: _source.unNamespace(_data.getAnnotationType().id) |
|
|
23 |
} |
|
|
24 |
} |
|
|
25 |
} |
|
|
26 |
}, |
|
|
27 |
serialize : function(_source) { |
|
|
28 |
var _res = {}, |
|
|
29 |
_this = this; |
|
|
30 |
_source.forEach(function(_list, _typename) { |
|
|
31 |
if (typeof _this.types[_typename] !== "undefined") { |
|
|
32 |
_res[_this.types[_typename].serialized_name] = _list.map(function(_el) { |
|
|
33 |
return _this.types[_typename].serializer(_el, _source); |
|
|
34 |
}); |
|
|
35 |
} |
|
|
36 |
}); |
|
|
37 |
_res.meta = { |
|
|
38 |
creator: _source.creator, |
|
|
39 |
created: _source.created |
|
|
40 |
} |
|
|
41 |
return JSON.stringify(_res); |
|
|
42 |
} |
|
|
43 |
} |