equal
deleted
inserted
replaced
1 /* ldt_localstorage serializer: Used to store personal annotations in local storage */ |
1 /* ldt_localstorage serializer: Used to store personal annotations in local storage */ |
|
2 import _ from "lodash"; |
2 |
3 |
3 if (typeof IriSP.serializers === "undefined") { |
4 const ldt_localstorage = function(IriSP) { return { |
4 IriSP.serializers = {}; |
|
5 } |
|
6 |
|
7 IriSP.serializers.ldt_localstorage = { |
|
8 serializeAnnotation : function(_data, _source) { |
5 serializeAnnotation : function(_data, _source) { |
9 var _annType = _data.getAnnotationType(); |
6 var _annType = _data.getAnnotationType(); |
10 return { |
7 return { |
11 id: _data.id, |
8 id: _data.id, |
12 begin: _data.begin.milliseconds, |
9 begin: _data.begin.milliseconds, |
43 _anntype = new IriSP.Model.AnnotationType(_anndata.type, _source); |
40 _anntype = new IriSP.Model.AnnotationType(_anndata.type, _source); |
44 _anntype.title = _anndata.type_title; |
41 _anntype.title = _anndata.type_title; |
45 _source.getAnnotationTypes().push(_anntype); |
42 _source.getAnnotationTypes().push(_anntype); |
46 } |
43 } |
47 _ann.setAnnotationType(_anntype.id); |
44 _ann.setAnnotationType(_anntype.id); |
48 var _tagIds = IriSP._(_anndata.tags).map(function(_title) { |
45 var _tagIds = _(_anndata.tags).map(function(_title) { |
49 var _tags = _source.getTags(true).searchByTitle(_title, true); |
46 var _tags = _source.getTags(true).searchByTitle(_title, true); |
50 if (_tags.length) { |
47 if (_tags.length) { |
51 var _tag = _tags[0]; |
48 var _tag = _tags[0]; |
52 } |
49 } |
53 else { |
50 else { |
80 _source.addList('tag', new IriSP.Model.List(_source.directory)); |
77 _source.addList('tag', new IriSP.Model.List(_source.directory)); |
81 _source.addList('annotationType', new IriSP.Model.List(_source.directory)); |
78 _source.addList('annotationType', new IriSP.Model.List(_source.directory)); |
82 _source.addList('annotation', new IriSP.Model.List(_source.directory)); |
79 _source.addList('annotation', new IriSP.Model.List(_source.directory)); |
83 _data.map( function (a) { _this.deserializeAnnotation(a, _source); }); |
80 _data.map( function (a) { _this.deserializeAnnotation(a, _source); }); |
84 } |
81 } |
85 }; |
82 }}; |
|
83 |
|
84 export default ldt_localstorage; |
86 |
85 |
87 /* End ldt_localstorage serializer */ |
86 /* End ldt_localstorage serializer */ |