diff -r b5ada3bb8e53 -r 2fad193bae98 client/js/ldtjson-bin.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/js/ldtjson-bin.js Wed Aug 22 16:50:42 2012 +0200 @@ -0,0 +1,70 @@ +Rkns.Bins.LdtJson = Rkns.Utils.inherit(Rkns.Bins._Base); + +Rkns.Bins.LdtJson.prototype.tagTemplate = Rkns._.template( + '
  • ' + + '

    <%-title%>

  • ' +); + +Rkns.Bins.LdtJson.prototype.annotationTemplate = Rkns._.template( + '
  • ' + + '

    <%-title%>

    <%-description%>

    Start: <%=start%>, End: <%=end%>, Duration: <%=duration%>

  • ' +); + +Rkns.Bins.LdtJson.prototype._init = function(_renkan, _opts) { + this.proj_id = _opts.project_id; + this.title_$.html(_opts.title); + var _this = this; + function convertTC(_ms) { + function pad(_n) { + var _res = _n.toString(); + while (_res.length < 2) { + _res = '0' + _res; + } + return _res; + } + var _totalSeconds = Math.abs(Math.floor(_ms/1000)), + _hours = Math.floor(_totalSeconds / 3600), + _minutes = (Math.floor(_totalSeconds / 60) % 60), + _seconds = _totalSeconds % 60, + _res = ''; + if (_hours) { + _res += pad(_hours) + ':' + } + _res += pad(_minutes) + ':' + pad(_seconds); + return _res; + } + Rkns.$.getJSON( + 'http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/cljson/id/' + this.proj_id + '?callback=?', + function(_data) { + var _html = '
  • Tags

  • ', + _projtitle = _data.meta["dc:title"]; + _this.title_$.html('LDT Project: "' + _projtitle + '"'); + _html += Rkns._(_data.tags).map(function(_tag) { + var _title = _tag.meta["dc:title"] + return _this.tagTemplate({ + title: _title, + encodedtitle : encodeURIComponent(_title) + }) + }).join(""); + _html += '
  • Annotations

  • '; + _html += Rkns._(_data.annotations).map(function(_annotation) { + var _description = _annotation.content.description, + _title = _annotation.content.title.replace(_description,""), + _duration = _annotation.end - _annotation.begin; + return _this.annotationTemplate({ + title: _title, + description: _description, + start: convertTC(_annotation.begin), + end: convertTC(_annotation.end), + duration: convertTC(_duration), + mediaid: _annotation.media, + annotationid: _annotation.id, + type: _duration ? "Segment" : "Point" + }); + }).join(""); + + _this.main_$.html(_html); + _renkan.resizeBins(); + } + ); +} \ No newline at end of file