# HG changeset patch # User Raphael Velt # Date 1337595321 -7200 # Node ID f65c1c3f77ea1b5bdf522bc78e0687bf738e2831 # Parent 3d071f445560ae4dab15625d8dfff1becd1039bf corrected metadataplayer for mediafragment bug diff -r 3d071f445560 -r f65c1c3f77ea web/jenkins/config.php --- a/web/jenkins/config.php Wed May 16 12:40:35 2012 +0200 +++ b/web/jenkins/config.php Mon May 21 12:15:21 2012 +0200 @@ -6,7 +6,7 @@ 'place' => 'Centre Pompidou, Grande Salle', 'title' => "Henry Jenkins, Transmedia 2.0", - 'abstract' => "Parole à la crtique
Vendredi 25 mai 2012, 19H
Grande Salle, Centre Pompidou, Paris", + 'abstract' => "Parole à la critique
Vendredi 25 mai 2012, 19H
Grande Salle, Centre Pompidou, Paris", 'description'=> "

Pionnier des études sur les fans, théoricien célébré de la culture de la convergence, Henry Jenkins a repensé l’écosystème médiatique diff -r 3d071f445560 -r f65c1c3f77ea web/res/metadataplayer/Mediafragment.js --- a/web/res/metadataplayer/Mediafragment.js Wed May 16 12:40:35 2012 +0200 +++ b/web/res/metadataplayer/Mediafragment.js Mon May 21 12:15:21 2012 +0200 @@ -1,6 +1,7 @@ IriSP.Widgets.Mediafragment = function(player, config) { IriSP.Widgets.Widget.call(this, player, config); - this.last_hash = ""; + this.last_hash_key = ""; + this.last_hash_value = ""; window.onhashchange = this.functionWrapper("goToHash"); if (typeof window.addEventListener !== "undefined") { window.addEventListener('message', function(_msg) { @@ -21,34 +22,55 @@ this.goToHash(); } +IriSP.Widgets.Mediafragment.prototype.getLastHash = function() { + var _tab = document.location.hash.replace(/^#/,'').split('&'); + _tab = IriSP._(_tab).filter(function(_el) { + return _el && !/^(id|t)=/.test(_el); + }); + if (this.last_hash_key) { + _tab.push(this.last_hash_key + '=' + this.last_hash_value); + } + return '#' + _tab.join('&'); +} + IriSP.Widgets.Mediafragment.prototype.goToHash = function() { - if (document.location.hash !== this.last_hash) { - this.last_hash = document.location.hash; - var _tab = this.last_hash.split("="); - if (_tab[0] === '#id') { - var _annotation = this.source.getElement(_tab[1]); - if (typeof _annotation !== "undefined") { - this.player.popcorn.currentTime(_annotation.begin.getSeconds()); + if (document.location.hash !== this.getLastHash()) { + var _tab = document.location.hash.replace(/^#/,'').split('&'); + for (var _i = 0; _i < _tab.length; _i++) { + var _subtab = _tab[_i].split("="); + if (_subtab[0] == "id" || _subtab[0] == "t") { + this.last_hash_key = _subtab[0]; + this.last_hash_value = _subtab[1]; + if (this.last_hash_key == "id") { + var _annotation = this.source.getElement(this.last_hash_value); + if (typeof _annotation !== "undefined") { + this.player.popcorn.currentTime(_annotation.begin.getSeconds()); + } + } + if (this.last_hash_key == "t") { + this.player.popcorn.currentTime(this.last_hash_value); + } + break; } } - if (_tab[0] === '#t') { - this.player.popcorn.currentTime(_tab[1]); - } } } IriSP.Widgets.Mediafragment.prototype.setHashToAnnotation = function(_annotationId) { - this.setHash( '#id=' + this.source.unNamespace(_annotationId) ); + this.setHash( 'id', this.source.unNamespace(_annotationId) ); } IriSP.Widgets.Mediafragment.prototype.setHashToTime = function(_time) { - _time = (typeof _time !== "undefined" ? _time : this.player.popcorn.currentTime() ); - this.setHash( '#t=' + _time ); + if (_time !== NaN) { + this.setHash( 't', this.player.popcorn.currentTime() ); + } } -IriSP.Widgets.Mediafragment.prototype.setHash = function(_hash) { - if (!this.blocked && this.last_hash !== _hash) { - this.last_hash = _hash; +IriSP.Widgets.Mediafragment.prototype.setHash = function(_key, _value) { + if (!this.blocked && (this.last_hash_key !== _key || this.last_hash_value !== _value)) { + this.last_hash_key = _key; + this.last_hash_value = _value; + var _hash = this.getLastHash(); document.location.hash = _hash; if (window.parent !== window) { window.parent.postMessage({ diff -r 3d071f445560 -r f65c1c3f77ea web/res/metadataplayer/Segments.js --- a/web/res/metadataplayer/Segments.js Wed May 16 12:40:35 2012 +0200 +++ b/web/res/metadataplayer/Segments.js Mon May 21 12:15:21 2012 +0200 @@ -42,9 +42,10 @@ segments : _list.map(function(_annotation, _k) { var _left = _annotation.begin * _scale, _width = ( _annotation.end - _annotation.begin ) * _scale, - _center = _left + _width / 2; + _center = _left + _width / 2, + _fulltext = _annotation.title + ( _annotation.description ? ( '
' + _annotation.description ) : '' ); return { - text : _annotation.title + ( _annotation.description ? '
' + _annotation.description.replace(/(^.{120,140})[\s].+$/,'$1…') : ''), + text : _fulltext.replace(/(^.{120,140})[\s].+$/,'$1…'), color : ( typeof _annotation.color !== "undefined" && _annotation.color ? _annotation.color : _this.colors[_k % _this.colors.length] ), beginseconds : _annotation.begin.getSeconds() , left : Math.floor( _left ),