--- a/web/res/metadataplayer/LdtPlayer-core.js Thu Jul 11 15:30:43 2013 +0200
+++ b/web/res/metadataplayer/LdtPlayer-core.js Tue Jul 23 13:14:21 2013 +0200
@@ -31,7 +31,9 @@
/* Initialization of the namespace */
if (typeof window.IriSP === "undefined") {
- window.IriSP = {};
+ window.IriSP = {
+ VERSION: "0.3.1"
+ };
}
if (typeof IriSP.jQuery === "undefined" && typeof window.jQuery !== "undefined" && parseFloat(window.jQuery().jquery) >= 1.7) {
@@ -100,7 +102,7 @@
addToList(_regexp, '<span class="Ldt-Highlight">', '</span>');
}
- addToList(/(https?:\/\/)?\w+\.\w+\S+/gm, function(matches) {
+ addToList(/(https?:\/\/)?[\w\d\-]+\.[\w\d\-]+\S+/gm, function(matches) {
return '<a href="' + (matches[1] ? '' : 'http://') + matches[0] + '" target="_blank">'
}, '</a>');
addToList(/@([\d\w]{1,15})/gm, function(matches) {
@@ -166,6 +168,14 @@
});
};
+IriSP.FakeClass = function(properties) {
+ var _this = this,
+ noop = (function() {});
+ IriSP._(properties).each(function(p) {
+ _this[p] = noop
+ });
+}
+
/* js is where data is stored in a standard form, whatever the serializer */
//TODO: Separate Project-specific data from Source
@@ -1176,7 +1186,10 @@
return (_e.elementType === _listId);
});
} else {
- return this.contents[_listId] || new IriSP.List(this.directory);
+ if (typeof this.contents[_listId] === "undefined") {
+ this.contents[_listId] = new IriSP.List(this.directory);
+ }
+ return this.contents[_listId];
}
};
@@ -1378,7 +1391,9 @@
videoEl.attr({
width : opts.width || undefined,
- height : opts.height || undefined
+ height : opts.height || undefined,
+ controls : opts.controls || undefined,
+ autoplay : opts.autostart || opts.autoplay || undefined
});
if(typeof videoURL === "string"){
@@ -1396,10 +1411,6 @@
jqselector.html(videoEl);
- if (opts.autostart || opts.autoplay) {
- videoEl.attr("autoplay", true);
- }
-
var mediaEl = videoEl[0];
// Binding HTML video functions to media events
@@ -1544,7 +1555,22 @@
"id-ref": _data.id
},
items: _source.getAnnotationTypes().filter(function(_at) {
- return _at.media === _data;
+ switch (typeof _at.media) {
+ case "object":
+ return (_at.media === _data);
+ case "string":
+ return (_at.media === _data.id);
+ default:
+ var _ann = _at.getAnnotations();
+ if (_ann) {
+ for (var i = 0; i < _ann.length; i++) {
+ if (_ann[i].getMedia() === _data) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
}).map(function(_at) {
return {
"id-ref": _at.id
@@ -1557,13 +1583,15 @@
},
tag : {
serialized_name : "tags",
- model_name : "tag",
deserializer : function(_data, _source) {
var _res = new IriSP.Model.Tag(_data.id, _source);
_res.title = _data.meta["dc:title"];
return _res;
},
serializer : function(_data, _source, _dest) {
+ if (_source.regenerateTags && !_data.regenerated) {
+ return;
+ }
var _res = {
id : _data.id,
meta : {
@@ -1617,6 +1645,7 @@
}
_res.color = '#' + _c;
}
+ _res.content = _data.content;
_res.setMedia(_data.media);
_res.setAnnotationType(_data.meta["id-ref"]);
_res.setTags(IriSP._(_data.tags).pluck("id-ref"));
@@ -1639,14 +1668,22 @@
id : _data.id,
begin : _data.begin.milliseconds,
end : _data.end.milliseconds,
- content : {
- title : _data.title || "",
- description : _data.description || "",
+ content : IriSP._.defaults(
+ {},
+ {
+ title : _data.title,
+ description : _data.description,
audio : _data.audio,
img: {
src: _data.thumbnail
}
},
+ _data.content,
+ {
+ title: "",
+ description: ""
+ }
+ ),
color: _color,
media : _data.media.id,
meta : {
@@ -1656,13 +1693,22 @@
"dc:creator" : _data.creator || _source.creator,
"dc:contributor" : _data.contributor || _source.contributor || _data.creator || _source.creator,
// project : _source.projectId
- },
- tags : IriSP._(_data.tag.id).map(function(_id) {
+ }
+ }
+ if (_source.regenerateTags) {
+ _res.tags = IriSP._(_data.keywords).map(function(_kw) {
+ return {
+ "id-ref": _source.__keywords[_kw.toLowerCase()].id
+ }
+ });
+ } else {
+ _res.tags = IriSP._(_data.tag.id).map(function(_id) {
return {
"id-ref" : _id
}
- })
+ });
}
+ _res.content.title = _data.title || _res.content.title || "";
_dest.annotations.push(_res);
}
},
@@ -1724,6 +1770,24 @@
annotations: []
},
_this = this;
+ if (_source.regenerateTags) {
+ _source.__keywords = {};
+ _source.getAnnotations().forEach(function(a) {
+ IriSP._(a.keywords).each(function(kw) {
+ var lkw = kw.toLowerCase();
+ if (typeof _source.__keywords[lkw] === "undefined") {
+ _source.__keywords[lkw] = {
+ id: IriSP.Model.getUID(),
+ title: kw,
+ regenerated: true
+ }
+ }
+ });
+ });
+ IriSP._(_source.__keywords).each(function(kw) {
+ _this.types.tag.serializer(kw, _source, _res);
+ })
+ }
_source.forEach(function(_list, _typename) {
if (typeof _this.types[_typename] !== "undefined") {
_list.forEach(function(_el) {
@@ -1761,6 +1825,11 @@
if (typeof _data.meta !== "undefined") {
_source.projectId = _data.meta.id;
+ _source.title = _data.meta["dc:title"] || _data.meta.title || "";
+ _source.description = _data.meta["dc:description"] || _data.meta.description || "";
+ _source.creator = _data.meta["dc:creator"] || _data.meta.creator || "";
+ _source.contributor = _data.meta["dc:contributor"] || _data.meta.contributor || _source.creator;
+ _source.created = IriSP.Model.isoToDate(_data.meta["dc:created"] || _data.meta.created);
}
if (typeof _data.meta !== "undefined" && typeof _data.meta.main_media !== "undefined" && typeof _data.meta.main_media["id-ref"] !== "undefined") {
@@ -1953,7 +2022,8 @@
IriSP.guiDefaults = {
width : 640,
container : 'LdtPlayer',
- spacer_div_height : 0
+ spacer_div_height : 0,
+ widgets: []
};
/* End of defaults.js */
@@ -2200,8 +2270,8 @@
this.__subwidgets = [];
/* Setting all the configuration options */
- var _type = config.type,
- _config = IriSP._.defaults({}, config, player.config.default_options, this.defaults),
+ var _type = config.type || "(unknown)",
+ _config = IriSP._.defaults({}, config, (player && player.config ? player.config.default_options : {}), this.defaults),
_this = this;
IriSP._(_config).forEach(function(_value, _key) {
@@ -2223,7 +2293,7 @@
/* Setting this.player at the end in case it's been overriden
* by a configuration option of the same name :-(
*/
- this.player = player;
+ this.player = player || new IriSP.FakeClass(["on","trigger","off","loadWidget","loadMetadata"]);
/* Adding classes and html attributes */
this.$.addClass("Ldt-TraceMe Ldt-Widget").attr("widget-type", _type);
@@ -2239,27 +2309,31 @@
);
/* Loading Metadata if required */
+
+ function onsourceloaded() {
+ if (_this.media_id) {
+ _this.media = this.getElement(_this.media_id);
+ } else {
+ var _mediaopts = {
+ is_mashup: _this.is_mashup || false
+ }
+ _this.media = _this.source.getCurrentMedia(_mediaopts);
+ }
+
+ _this.draw();
+ _this.player.trigger("widget-loaded");
+ }
if (this.metadata) {
/* Getting metadata */
this.source = player.loadMetadata(this.metadata);
/* Call draw when loaded */
- this.source.onLoad(function() {
- if (_this.media_id) {
- _this.media = this.getElement(_this.media_id);
- } else {
- var _mediaopts = {
- is_mashup: _this.is_mashup || false
- }
- _this.media = this.getCurrentMedia(_mediaopts);
- }
-
- _this.draw();
- player.trigger("widget-loaded");
- });
+ this.source.onLoad(onsourceloaded);
} else {
- this.draw();
+ if (this.source) {
+ onsourceloaded();
+ }
}
@@ -2271,6 +2345,10 @@
IriSP.Widgets.Widget.prototype.messages = {"en":{}};
+IriSP.Widgets.Widget.prototype.toString = function() {
+ return "Widget " + this.type;
+};
+
IriSP.Widgets.Widget.prototype.templateToHtml = function(_template) {
return Mustache.to_html(_template, this);
};