equal
deleted
inserted
replaced
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 }; |
|
39 |
|
40 /* this function searches for an annotation which matches title, description and keyword |
|
41 "" matches any field. |
|
42 */ |
|
43 IriSP.JSONSerializer.prototype.searchAnnotations = function(title, description, keyword) { |
|
44 var rTitle; |
|
45 var rDescription; |
|
46 var rKeyword; |
|
47 |
|
48 /* match anything if given the empty string */ |
|
49 if (title == "") |
|
50 title = ".*"; |
|
51 if (description == "") |
|
52 description = ".*"; |
|
53 if (keyword == "") |
|
54 keyword = ".*"; |
|
55 |
|
56 rTitle = new RegExp(title, "i"); |
|
57 rDescription = new RegExp(description, "i"); |
|
58 rKeyword = new RegExp(keyword, "i"); |
|
59 |
|
60 var ret_array = []; |
|
61 |
|
62 var i; |
|
63 for (i in this._data.annotations) { |
|
64 var annotation = this._data.annotations[i]; |
|
65 |
|
66 if (rTitle.test(annotation.content.title) && |
|
67 rDescription.test(annotation.content.description)) { |
|
68 /* FIXME : implement keyword support */ |
|
69 ret_array.push(annotation); |
|
70 } |
|
71 } |
|
72 |
|
73 return ret_array; |
|
74 } |