r80273 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80272‎ | r80273 | r80274 >
Date:15:40, 14 January 2011
Author:dale
Status:deferred
Tags:
Comment:
* fixes bug 26717 ( made event prorogation more consistent )
* improves detect type
* adds stubs for media fragments support
Modified paths:
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerNative.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/TimedText/mw.TimedText.js (modified) (history)
  • /branches/MwEmbedStandAlone/remotes/mediaWiki.js (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/modules/TimedText/mw.TimedText.js
@@ -47,7 +47,7 @@
4848 enabledSources: null,
4949
5050 /**
51 - * The current langauge key
 51+ * The current language key
5252 */
5353 currentLangKey : null,
5454
@@ -106,7 +106,6 @@
107107 */
108108 init: function( embedPlayer, options ) {
109109 var _this = this;
110 - mw.log("TimedText: init() ");
111110 this.embedPlayer = embedPlayer;
112111 this.options = options;
113112
@@ -297,7 +296,6 @@
298297 * @param {Function} callback Function to be called once text sources are setup.
299298 */
300299 setupTextSources: function( callback ) {
301 - mw.log( 'mw.TimedText::setupTextSources');
302300 var _this = this;
303301 if( this.textSourceSetupFlag ) {
304302 if( callback ) {
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js
@@ -782,19 +782,19 @@
783783 */
784784 detectType: function( uri ) {
785785 // NOTE: if media is on the same server as the javascript
786 - // we can issue a HEAD request and read the mime type of the media ...
787 - // ( this will detect media mime type independently of the url name)
 786+ // we can issue a HEAD request and read the mime type of the media...
 787+ // ( this will detect media mime type independently of the url name )
788788 // http://www.jibbering.com/2002/4/httprequest.html
789 - var end_inx = ( uri.indexOf( '?' ) != -1 ) ? uri.indexOf( '?' ) : uri.length;
790 - var no_param_uri = uri.substr( 0, end_inx );
791 - switch( no_param_uri.substr( no_param_uri.lastIndexOf( '.' )+1 ).toLowerCase() ) {
 789+ var urlParts = mw.parseUri( uri );
 790+ // Get the extension from the url or from the relative name:
 791+ var ext = ( urlParts.file )? /[^.]+$/.exec( urlParts.file ) : /[^.]+$/.exec( uri );
 792+ switch( ext.toString().toLowerCase() ) {
792793 case 'smil':
793794 case 'sml':
794 - return 'application/smil'
 795+ return 'application/smil';
795796 break;
796797 case 'm4v':
797798 case 'mp4':
798 - case 'mov':
799799 return 'video/h264';
800800 break;
801801 case 'webm':
@@ -829,6 +829,7 @@
830830 return 'video/mpeg';
831831 break;
832832 }
 833+ mw.log( "Error: could not detect type of media src: " + uri );
833834 }
834835 };
835836
@@ -2628,12 +2629,10 @@
26292630 if( this.paused === true ){
26302631 this.paused = false;
26312632 // Check if we should Trigger the play event
2632 - if( this.bubbleEventCheck() ) {
2633 - mw.log("EmbedPlayer:: trigger play even::" + !this.paused);
2634 - if( this._propagateEvents ){
2635 - $j( this ).trigger( 'play' );
2636 - _this.tempDisableEvents();
2637 - }
 2633+ mw.log("EmbedPlayer:: trigger play even::" + !this.paused);
 2634+ if( this._propagateEvents ){
 2635+ $j( this ).trigger( 'play' );
 2636+ _this.tempDisableEvents();
26382637 }
26392638 }
26402639
@@ -2659,18 +2658,6 @@
26602659 this.monitor();
26612660 },
26622661 /**
2663 - * Returns true if the event should be triggered or false if not
2664 - *
2665 - * @@FIXME:: firefox nightlies now Do NOT bubble events. Once release tag
2666 - * every version after that
2667 - */
2668 - bubbleEventCheck: function(){
2669 - if( $j.browser.webkit ){
2670 - return true;
2671 - }
2672 - return false;
2673 - },
2674 - /**
26752662 * Base embed pause Updates the play/pause button state.
26762663 *
26772664 * There is no general way to pause the video must be overwritten by embed
@@ -2682,14 +2669,10 @@
26832670 // controls:
26842671 if( this.paused === false ){
26852672 this.paused = true;
2686 - mw.log( "EmbedPlayer:: pause: " + this._propagateEvents );
2687 -
2688 - if( this.bubbleEventCheck() ){
2689 - mw.log('EmbedPlayer:trigger pause:' + this.paused);
2690 - if( this._propagateEvents ){
2691 - $j( this ).trigger( 'pause' );
2692 - _this.tempDisableEvents();
2693 - }
 2673+ mw.log('EmbedPlayer:trigger pause:' + this.paused);
 2674+ if( this._propagateEvents ){
 2675+ $j( this ).trigger( 'pause' );
 2676+ _this.tempDisableEvents();
26942677 }
26952678 }
26962679
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerNative.js
@@ -199,7 +199,7 @@
200200 _this['on' + eventName ].apply( _this, argArray);
201201 } else {
202202 // No local handler directly propagate the event to the abstract object:
203 - $j( _this ).trigger( eventName, argArray )
 203+ $j( _this ).trigger( eventName, argArray );
204204 }
205205 }
206206 })
Index: branches/MwEmbedStandAlone/remotes/mediaWiki.js
@@ -34,7 +34,7 @@
3535 mwReqParam['embedplayer'] = 'yes';
3636 }
3737
38 -//mwReqParam['debug'] = true;
 38+// mwReqParam['debug'] = true;
3939
4040 // Setup up some globals to wrap mwEmbed mw.ready and mw.setConfig functions
4141
@@ -447,6 +447,24 @@
448448 var re = new RegExp( /videoUrl(":?\s*)*([^&]*)/ );
449449 src = re.exec( rewriteHTML )[2];
450450
 451+ var timeHash = '';
 452+ // Check for temporal url in document hash
 453+ if( location.hash.indexOf('#t=') === 0 ){
 454+ timeHash = location.hash;
 455+ }
 456+ // Check for temporal url in template hack
 457+ var $startTime = $j( '#' + vidId ).parent().find('.starttime');
 458+ if( $startTime.length ){
 459+ timeHash= '#t=' + $startTime.text();
 460+ // if we have a start time also look for endtime
 461+ var $endTime = $j( '#' + vidId ).parent().find('.endtime');
 462+ if( $endTime.lenght ){
 463+ timeHash += $endTime.text();
 464+ }
 465+ }
 466+ // Update the video source with the temporal time hash:
 467+ src+=timeHash;
 468+
451469 var apiTitleKey = src.split( '/' );
452470 apiTitleKey = decodeURI( apiTitleKey[ apiTitleKey.length - 1 ] );
453471
@@ -472,7 +490,6 @@
473491
474492 if ( src ) {
475493 var html_out = '';
476 -
477494 var common_attr = ' id="mwe_' + vidId + '" ' +
478495 'apiTitleKey="' + apiTitleKey + '" ' +
479496 'src="' + src + '" ' +

Status & tagging log