From 748093d21097ecc50f02e5a06287bd61ca72b42e Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Sat, 14 Nov 2009 17:49:01 +0000 Subject: [PATCH] * fix incorrectly split negatives (f.e. "-1" -> "- 1") * update indentation and formatting --- js2/mwEmbed/jsScriptLoader.php | 8 +- .../searchLibs/baseRemoteSearch.js | 4 +- .../libAddMedia/searchLibs/flickrSearch.js | 30 +- .../libAddMedia/searchLibs/mediaWikiSearch.js | 6 +- js2/mwEmbed/libAddMedia/simpleUploadForm.js | 2 +- js2/mwEmbed/libClipEdit/mvClipEdit.js | 2 +- js2/mwEmbed/libEmbedVideo/embedVideo.js | 22 +- js2/mwEmbed/libEmbedVideo/flowplayerEmbed.js | 758 ++++++++---------- js2/mwEmbed/libEmbedVideo/genericEmbed.js | 6 +- js2/mwEmbed/libEmbedVideo/htmlEmbed.js | 90 +-- js2/mwEmbed/libEmbedVideo/javaEmbed.js | 14 +- js2/mwEmbed/libEmbedVideo/kplayerEmbed.js | 2 +- js2/mwEmbed/libEmbedVideo/nativeEmbed.js | 8 +- js2/mwEmbed/libEmbedVideo/vlcEmbed.js | 43 +- js2/mwEmbed/libSequencer/mvPlayList.js | 12 +- js2/mwEmbed/libSequencer/mvSequencer.js | 2 +- js2/mwEmbed/libTimedText/mvTextInterface.js | 2 +- js2/mwEmbed/mv_embed.js | 30 +- js2/uploadPage.js | 4 +- 19 files changed, 467 insertions(+), 578 deletions(-) diff --git a/js2/mwEmbed/jsScriptLoader.php b/js2/mwEmbed/jsScriptLoader.php index 580bf76a83..5dca6a7532 100644 --- a/js2/mwEmbed/jsScriptLoader.php +++ b/js2/mwEmbed/jsScriptLoader.php @@ -126,7 +126,7 @@ class jsScriptLoader { } } else { // Make sure the wiki title ends with .js - if ( substr( $title_block, - 3 ) != '.js' ) { + if ( substr( $title_block, -3 ) != '.js' ) { $this->error_msg .= 'WikiTitle includes should end with .js'; return false; } @@ -146,7 +146,7 @@ class jsScriptLoader { // Dealing with files // Check that the filename ends with .js and does not include ../ traversing - if ( substr( $file_name, - 3 ) != '.js' ) { + if ( substr( $file_name, -3 ) != '.js' ) { $this->error_msg .= "\nError file name must end with .js: " . htmlspecialchars( $file_name ) . " \n "; return false; } @@ -550,13 +550,13 @@ class simpleFileCache { } public function outputFromFileCache() { - if ( $this->clientAcceptsGzip() && substr( $this->filename, - 3 ) == '.gz' ) { + if ( $this->clientAcceptsGzip() && substr( $this->filename, -3 ) == '.gz' ) { header( 'Content-Encoding: gzip' ); readfile( $this->filename ); return true; } // Output without gzip: - if ( substr( $this->filename, - 3 ) == '.gz' ) { + if ( substr( $this->filename, -3 ) == '.gz' ) { readgzfile( $this->filename ); } else { readfile( $this->filename ); diff --git a/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js b/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js index 65e8255649..1c05cf8c60 100644 --- a/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js +++ b/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js @@ -115,7 +115,7 @@ baseRemoteSearch.prototype = { var attr_name = null; if ( typeof selector[1] != 'undefined' ) { attr_name = selector[1]; - if ( attr_name.indexOf( '|' ) != - 1 ) + if ( attr_name.indexOf( '|' ) != -1 ) attr_name = attr_name.split( '|' ); } @@ -159,7 +159,7 @@ baseRemoteSearch.prototype = { options.style_attr = 'style="width:' + outOpt.width + 'px;height:' + outOpt.height + 'px"'; options.id_attr = ( options['id'] ) ? ' id = "' + options['id'] + '" ': ''; - if ( rObj.mime.indexOf( 'image' ) != - 1 ) { + if ( rObj.mime.indexOf( 'image' ) != -1 ) { return this.getImageEmbedHTML( rObj, options ); } else { js_log( "ERROR:: no embed code for mime type: " + rObj.mime ); diff --git a/js2/mwEmbed/libAddMedia/searchLibs/flickrSearch.js b/js2/mwEmbed/libAddMedia/searchLibs/flickrSearch.js index a752ef5a33..3969e32b83 100644 --- a/js2/mwEmbed/libAddMedia/searchLibs/flickrSearch.js +++ b/js2/mwEmbed/libAddMedia/searchLibs/flickrSearch.js @@ -1,19 +1,19 @@ /* -* basic flickr search uses flickr jsonp api -* http://www.flickr.com/services/api/ -* -* uses the "example api_key" 519b66e3fd8d8080e27a64fe51101e2c -* should update with a different "public" key sometime soon -http://www.flickr.com/services/rest/?method=flickr.test.echo&format=json&api_key=519b66e3fd8d8080e27a64fe51101e2c -* -* we look for licenses from method=flickr.photos.licenses.getInfo -* per http://commons.wikimedia.org/wiki/Special:Upload?uselang=fromflickr -* we are interested in: - (4) Attribution License - (5) Attribution-ShareAlike License, - (7) No known copyright restrictions, - (8) United States Government Work -*/ + * basic flickr search uses flickr jsonp api + * http://www.flickr.com/services/api/ + * + * uses the "example api_key" 519b66e3fd8d8080e27a64fe51101e2c + * should update with a different "public" key sometime soon + * http://www.flickr.com/services/rest/?method=flickr.test.echo&format=json&api_key=519b66e3fd8d8080e27a64fe51101e2c + * + * we look for licenses from method=flickr.photos.licenses.getInfo + * per http://commons.wikimedia.org/wiki/Special:Upload?uselang=fromflickr + * we are interested in: + * (4) Attribution License + * (5) Attribution-ShareAlike License, + * (7) No known copyright restrictions, + * (8) United States Government Work + */ var flickrSearch = function ( iObj ) { return this.init( iObj ); diff --git a/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js b/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js index 9bddd4081b..7c2047c99c 100644 --- a/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js +++ b/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js @@ -312,7 +312,7 @@ mediaWikiSearch.prototype = { options = { }; this.parent_getEmbedHTML( rObj, options ); // check for image output: - if ( rObj.mime.indexOf( 'image' ) != - 1 ) { + if ( rObj.mime.indexOf( 'image' ) != -1 ) { return this.getImageEmbedHTML( rObj, options ); } // for video and audio output: @@ -322,11 +322,11 @@ mediaWikiSearch.prototype = { ' src="' + rObj.src + '" ' + options.style_attr + ' poster="' + rObj.poster + '" ' - if ( rObj.mime.indexOf( 'application/ogg' ) != - 1 ) { + if ( rObj.mime.indexOf( 'application/ogg' ) != -1 ) { return ''; } - if ( rObj.mime.indexOf( 'audio/ogg' ) != - 1 ) { + if ( rObj.mime.indexOf( 'audio/ogg' ) != -1 ) { return ''; } } diff --git a/js2/mwEmbed/libAddMedia/simpleUploadForm.js b/js2/mwEmbed/libAddMedia/simpleUploadForm.js index d3501eab03..e3013ad5b7 100644 --- a/js2/mwEmbed/libAddMedia/simpleUploadForm.js +++ b/js2/mwEmbed/libAddMedia/simpleUploadForm.js @@ -103,7 +103,7 @@ var default_form_options = { var slash = path.lastIndexOf( '/' ); var backslash = path.lastIndexOf( '\\' ); var fname; - if ( slash == - 1 && backslash == - 1 ) { + if ( slash == -1 && backslash == -1 ) { fname = path; } else if ( slash > backslash ) { fname = path.substring( slash + 1, 10000 ); diff --git a/js2/mwEmbed/libClipEdit/mvClipEdit.js b/js2/mwEmbed/libClipEdit/mvClipEdit.js index e81ae65139..9d00d08be2 100644 --- a/js2/mwEmbed/libClipEdit/mvClipEdit.js +++ b/js2/mwEmbed/libClipEdit/mvClipEdit.js @@ -602,7 +602,7 @@ mvClipEdit.prototype = { $tool_target.append( '

' + gM( 'mwe-edit-tools' ) + '

' ); for ( var i in _this.toolset ) { var toolid = _this.toolset[i]; - if ( $j.inArray( toolid, _this.enabled_tools ) != - 1 || _this.enabled_tools == 'all' ) + if ( $j.inArray( toolid, _this.enabled_tools ) != -1 || _this.enabled_tools == 'all' ) _this.appendTool( $tool_target, toolid ); } } diff --git a/js2/mwEmbed/libEmbedVideo/embedVideo.js b/js2/mwEmbed/libEmbedVideo/embedVideo.js index 9fd50ac6c6..22da50301f 100644 --- a/js2/mwEmbed/libEmbedVideo/embedVideo.js +++ b/js2/mwEmbed/libEmbedVideo/embedVideo.js @@ -472,7 +472,7 @@ mediaSource.prototype = { // we can issue a HEAD request and read the mime type of the media... // (this will detect media mime type independently of the url name) // http://www.jibbering.com/2002/4/httprequest.html (this should be done by extending jquery's ajax objects) - var end_inx = ( uri.indexOf( '?' ) != - 1 ) ? uri.indexOf( '?' ) : uri.length; + var end_inx = ( uri.indexOf( '?' ) != -1 ) ? uri.indexOf( '?' ) : uri.length; var no_param_uri = uri.substr( 0, end_inx ); switch( no_param_uri.substr( no_param_uri.lastIndexOf( '.' ), 4 ).toLowerCase() ) { case '.mp4': @@ -583,7 +583,7 @@ mediaElement.prototype = { // apply mime filter: var source_set = new Array(); for ( var i = 0; i < this.sources.length ; i++ ) { - if ( this.sources[i].mime_type.indexOf( mime_filter ) != - 1 ) + if ( this.sources[i].mime_type.indexOf( mime_filter ) != -1 ) source_set.push( this.sources[i] ); } return source_set; @@ -859,7 +859,7 @@ embedVideo.prototype = { var sn = element.getAttribute( 'class' ); if ( sn && sn != '' ) { for ( var n = 0; n < mw.valid_skins.length; n++ ) { - if ( sn.indexOf( mw.valid_skins[n] ) !== - 1 ) { + if ( sn.indexOf( mw.valid_skins[n] ) !== -1 ) { this.skin_name = mw.valid_skins[ n ]; } } @@ -1265,7 +1265,7 @@ embedVideo.prototype = { 'style="width:' + parseInt( parseInt( this.width ) / 2 ) + 'px;' + 'height:' + parseInt( parseInt( this.height ) ) + 'px;' + 'position:absolute;top:10px;overflow:auto' + - 'width: ' + parseInt( ( ( parseInt( this.width ) / 2 ) - 15 ) ) + 'px;' + + 'width: ' + parseInt( ( ( parseInt( this.width ) / 2 ) -15 ) ) + 'px;' + 'left:' + parseInt( ( ( parseInt( this.width ) / 2 ) + 15 ) ) + 'px;">' + '' ); @@ -1551,7 +1551,7 @@ embedVideo.prototype = { renderTimelineThumbnail:function( options ) { var my_thumb_src = this.media_element.getThumbnailURL(); // check if our thumbnail has a time attribute: - if ( my_thumb_src.indexOf( 't=' ) !== - 1 ) { + if ( my_thumb_src.indexOf( 't=' ) !== -1 ) { var time_ntp = seconds2npt ( options.time + parseInt( this.start_offset ) ); my_thumb_src = getURLParamReplace( my_thumb_src, { 't':time_ntp, @@ -1576,7 +1576,7 @@ embedVideo.prototype = { if ( typeof this.org_thum_src == 'undefined' ) { this.org_thum_src = this.media_element.getThumbnailURL(); } - if ( this.org_thum_src.indexOf( 't=' ) !== - 1 ) { + if ( this.org_thum_src.indexOf( 't=' ) !== -1 ) { this.last_thumb_url = getURLParamReplace( this.org_thum_src, { 't' : seconds2npt( float_sec + parseInt( this.start_offset ) ) @@ -1673,7 +1673,7 @@ embedVideo.prototype = { embed_thumb_url = eURL.protocol + '://' + eURL.host + thumbnail; // js_log('set from mv_embed_path:'+embed_thumb_html); } else { - embed_thumb_url = ( thumbnail.indexOf( 'http://' ) != - 1 ) ? thumbnail:mv_embed_path + thumbnail; + embed_thumb_url = ( thumbnail.indexOf( 'http://' ) != -1 ) ? thumbnail:mv_embed_path + thumbnail; } var embed_code_html = '<script type="text/javascript" ' + 'src="' + mv_embed_path + 'mv_embed.js"></script>' + @@ -1701,7 +1701,7 @@ embedVideo.prototype = { var sel_id = ( this.pc != null ) ? this.pc.pp.id:this.id; var pos = $j( '#' + sel_id + ' .options-btn' ).offset(); pos['top'] = pos['top'] + 24; - pos['left'] = pos['left'] - 124; + pos['left'] = pos['left'] -124; // js_log('pos of options button: t:'+pos['top']+' l:'+ pos['left']); $j( '#mv_vid_options_' + sel_id ).css( pos ).toggle(); return; @@ -1932,7 +1932,7 @@ embedVideo.prototype = { $j.each( _this.media_element.getSources(), function( index, source ) { var dl_line = '
  • ' + ' ' + source.getTitle() + ' ' + '
  • ' + "\n"; - if ( source.getURI().indexOf( '?t=' ) !== - 1 ) { + if ( source.getURI().indexOf( '?t=' ) !== -1 ) { out += dl_line; } else if ( this.getMIMEType() == "text/cmml" || this.getMIMEType() == "text/x-srt" ) { dl_txt_list += dl_line; @@ -2491,7 +2491,7 @@ mediaPlayers.prototype = for ( var i in this.preference ) cookieVal += i + '=' + this.preference[i] + '&'; - cookieVal = cookieVal.substr( 0, cookieVal.length - 1 ); + cookieVal = cookieVal.substr( 0, cookieVal.length -1 ); var week = 7 * 86400 * 1000; $j.cookie( 'ogg_player_exp', cookieVal, { 'expires':week } ); } @@ -2602,7 +2602,7 @@ var embedTypes = { for ( var i = 0; i < navigator.mimeTypes.length; i++ ) { var type = navigator.mimeTypes[i].type; var semicolonPos = type.indexOf( ';' ); - if ( semicolonPos > - 1 ) { + if ( semicolonPos > -1 ) { type = type.substr( 0, semicolonPos ); } // js_log('on type: '+type); diff --git a/js2/mwEmbed/libEmbedVideo/flowplayerEmbed.js b/js2/mwEmbed/libEmbedVideo/flowplayerEmbed.js index 580cf0bd5e..56f719aa01 100644 --- a/js2/mwEmbed/libEmbedVideo/flowplayerEmbed.js +++ b/js2/mwEmbed/libEmbedVideo/flowplayerEmbed.js @@ -1,11 +1,11 @@ /** - * metavid: mv_flashEmbed builds off of flowplayer api (included first in this file) + * metavid: mv_flashEmbed builds off of flowplayer api (included first in this file) * THIS WILL BE DEPRECIATED SOON */ - + /** * flowplayer.js 3.0.0-rc5. The Flowplayer API. - * + * * This file is part of Flowplayer, http://flowplayer.org * * Author: Tero Piirainen, @@ -13,22 +13,21 @@ * * Released under the MIT License: * http://www.opensource.org/licenses/mit-license.php - * + * * Version: 3.0.0-rc5 - Thu Nov 20 2008 22:09:49 GMT-0000 (GMT+00:00) */ ( function() { - -/* - FEATURES + +/* + FEATURES -------- - - handling multiple instances - - Flowplayer programming API - - Flowplayer event model + - handling multiple instances + - Flowplayer programming API + - Flowplayer event model - player loading / unloading - $f() function - jQuery support */ - /*jslint glovar: true, browser: true */ /*global flowplayer, $f */ @@ -36,18 +35,17 @@ // {{{ private utility methods function log( args ) { - + // write into opera console if ( typeof opera == 'object' ) { opera.postError( "$f.fireEvent: " + args.join( " | " ) ); - + } else if ( typeof console == 'object' ) { console.log( "$f.fireEvent", [].slice.call( args ) ); } } - // thanks: http://keithdevens.com/weblog/archive/2007/Jun/07/javascript.clone function clone ( obj ) { if ( !obj || typeof obj != 'object' ) { return obj; } @@ -60,36 +58,34 @@ return temp; } - // stripped from jQuery, thanks John Resig + // stripped from jQuery, thanks John Resig function each( obj, fn ) { if ( !obj ) { return; } - + var name, i = 0, length = obj.length; - + // object if ( length === undefined ) { for ( name in obj ) { if ( fn.call( obj[name], name, obj[name] ) === false ) { break; } } - + // array } else { for ( var value = obj[0]; i < length && fn.call( value, i, value ) !== false; value = obj[++i] ) { } } - + return obj; } - // convenience function el( id ) { return document.getElementById( id ); } - - // used extensively. a very simple implementation. + // used extensively. a very simple implementation. function extend( to, from, skipFuncs ) { if ( to && from ) { each( from, function( name, value ) { @@ -99,8 +95,8 @@ } ); } } - - // var arr = select("elem.className"); + + // var arr = select("elem.className"); function select( query ) { var index = query.indexOf( "." ); if ( index != - 1 ) { @@ -115,15 +111,15 @@ return els; } } - + // fix event inconsistencies across browsers function stopEvent( e ) { e = e || window.event; - + if ( e.preventDefault ) { e.stopPropagation(); e.preventDefault(); - + } else { e.returnValue = false; e.cancelBubble = true; @@ -136,56 +132,51 @@ to[evt] = to[evt] || []; to[evt].push( fn ); } - - - // generates an unique id - function makeId() { - return "_" + ( "" + Math.random() ).substring( 2, 10 ); - } - -// }}} -// {{{ Clip + // generates an unique id + function makeId() { + return "_" + ( "" + Math.random() ).substring( 2, 10 ); + } +// }}} +// {{{ Clip var Clip = function( json, index, player ) { - // private variables var self = this; var cuepoints = { }; var listeners = { }; this.index = index; - + // instance variables if ( typeof json == 'string' ) { json = { url:json }; } - + extend( this, json, true ); - - // event handling + + // event handling each( ( "Begin*,Start,Pause*,Resume*,Seek*,Stop*,Finish*,LastSecond,Update,BufferFull,BufferEmpty,BufferStop" ).split( "," ), function() { - + var evt = "on" + this; - + // before event if ( evt.indexOf( "*" ) != - 1 ) { evt = evt.substring( 0, evt.length - 1 ); var before = "onBefore" + evt.substring( 2 ); - + self[before] = function( fn ) { bind( listeners, before, fn ); return self; }; } - + self[evt] = function( fn ) { bind( listeners, evt, fn ); return self; }; - - + // set common clip event listeners to player level if ( index == - 1 ) { if ( self[before] ) { @@ -195,34 +186,30 @@ player[evt] = self[evt]; } } - } ); - + extend( this, { - - onCuepoint: function( points, fn ) { - + // embedded cuepoints if ( arguments.length == 1 ) { cuepoints.embedded = [null, points]; return self; } - + if ( typeof points == 'number' ) { points = [points]; } - + var fnId = makeId(); cuepoints[fnId] = [points, fn]; - + if ( player.isLoaded() ) { player._api().fp_addCuepoints( points, index, fnId ); } - + return self; }, - update: function( json ) { extend( self, json ); @@ -233,57 +220,53 @@ var clip = ( index == - 1 ) ? conf.clip : conf.playlist[index]; extend( clip, json, true ); }, - - // internal event for performing clip tasks. should be made private someday _fireEvent: function( evt, arg1, arg2, target ) { - + if ( evt == 'onLoad' ) { each( cuepoints, function( key, val ) { player._api().fp_addCuepoints( val[0], index, key ); } ); return false; } - + // target clip we are working against if ( index != - 1 ) { target = self; } - + if ( evt == 'onCuepoint' ) { var fn = cuepoints[arg1]; if ( fn ) { return fn[1].call( player, target, arg2 ); } } - + if ( evt == 'onStart' || evt == 'onUpdate' ) { - + extend( target, arg1 ); - + if ( !target.duration ) { target.duration = arg1.metaData.duration; } else { target.fullDuration = arg1.metaData.duration; } } - + var ret = true; each( listeners[evt], function() { ret = this.call( player, target, arg1 ); } ); return ret; } - } ); - - + // get cuepoints from config if ( json.onCuepoint ) { self.onCuepoint.apply( self, json.onCuepoint ); delete json.onCuepoint; } - + // get other events each( json, function( key, val ) { if ( typeof val == 'function' ) { @@ -292,29 +275,23 @@ } } ); - // setup common clip event callbacks for Player object too (shortcuts) if ( index == - 1 ) { player.onCuepoint = this.onCuepoint; } - }; // }}} - - // {{{ Plugin - var Plugin = function( name, json, player, fn ) { - var listeners = { }; var self = this; var hasMethods = false; - + if ( fn ) { extend( listeners, fn ); } - + // custom callback functions in configuration each( json, function( key, val ) { if ( typeof val == 'function' ) { @@ -322,37 +299,35 @@ delete json[key]; } } ); - - // core plugin methods + + // core plugin methods extend( this, { - animate: function( props, speed, fn ) { if ( !props ) { return self; } - + if ( typeof speed == 'function' ) { fn = speed; speed = 500; } - + if ( typeof props == 'string' ) { var key = props; props = { }; props[key] = speed; speed = 500; } - + if ( fn ) { var fnId = makeId(); listeners[fnId] = fn; } - + if ( speed === undefined ) { speed = 500; } json = player._api().fp_animate( name, props, speed, fnId ); return self; }, - css: function( props, val ) { if ( val !== undefined ) { var css = { }; @@ -367,31 +342,27 @@ js_log( 'flow player could not set css: ' + json ); } }, - show: function() { this.display = 'block'; player._api().fp_showPlugin( name ); return self; }, - hide: function() { this.display = 'none'; player._api().fp_hidePlugin( name ); return self; }, - toggle: function() { this.display = player._api().fp_togglePlugin( name ); return self; }, - fadeTo: function( o, speed, fn ) { - + if ( typeof speed == 'function' ) { fn = speed; speed = 500; } - + if ( fn ) { var fnId = makeId(); listeners[fnId] = fn; @@ -400,70 +371,58 @@ this.opacity = o; return self; }, - fadeIn: function( speed, fn ) { return self.fadeTo( 1, speed, fn ); }, - fadeOut: function( speed, fn ) { return self.fadeTo( 0, speed, fn ); }, - getName: function() { return name; }, - - // internal method not meant to be used by clients - _fireEvent: function( evt, arg ) { - - - // update plugins properties & methods - if ( evt == 'onUpdate' ) { - var json = arg || player._api().fp_getPlugin( name ); - if ( !json ) { return; } - - extend( self, json ); - delete self.methods; - - if ( !hasMethods ) { - each( json.methods, function() { - var method = "" + this; - - self[method] = function() { - var a = [].slice.call( arguments ); - var ret = player._api().fp_invoke( name, method, a ); - return ret == 'undefined' ? self : ret; - }; - } ); - hasMethods = true; - } - } - - // plugin callbacks - var fn = listeners[evt]; + _fireEvent: function( evt, arg ) { + // update plugins properties & methods + if ( evt == 'onUpdate' ) { + var json = arg || player._api().fp_getPlugin( name ); + if ( !json ) { return; } + + Extend( self, json ); + delete self.methods; + + if ( !hasMethods ) { + each( json.methods, function() { + var method = "" + this; + + self[method] = function() { + var a = [].slice.call( arguments ); + var ret = player._api().fp_invoke( name, method, a ); + return ret == 'undefined' ? self : ret; + }; + } ); + hasMethods = true; + } + } + + // plugin callbacks + var fn = listeners[evt]; if ( fn ) { - fn.call( self, arg ); - + // "one-shot" callback if ( evt.substring( 0, 1 ) == "_" ) { delete listeners[evt]; } + } } - } - + } ); }; - // }}} - - function Player( wrapper, params, conf ) { - // private variables (+ arguments) var self = this, @@ -479,133 +438,109 @@ function Player( wrapper, params, conf ) { swfHeight, wrapperHeight; - -// {{{ public methods - +// {{{ public methods extend( self, { - id: function() { return playerId; }, - isLoaded: function() { return ( api !== null ); }, - getParent: function() { return wrapper; }, - hide: function( all ) { if ( all ) { wrapper.style.height = "0px"; } if ( api ) { api.style.height = "0px"; } return self; }, - show: function() { wrapper.style.height = wrapperHeight + "px"; if ( api ) { api.style.height = swfHeight + "px"; } return self; }, - isHidden: function() { return api && parseInt( api.style.height, 10 ) === 0; }, - - load: function( fn ) { - + if ( !api && self._fireEvent( "onBeforeLoad" ) !== false ) { - + // unload all instances each( players, function() { this.unload(); } ); - + html = wrapper.innerHTML; flashembed( wrapper, params, { config: conf } ); - + // function argument if ( fn ) { fn.cached = true; bind( listeners, "onLoad", fn ); } } - + return self; }, - unload: function() { - - if ( api && html.replace( /\s/g, '' ) !== '' && !api.fp_isFullscreen() && - self._fireEvent( "onBeforeUnload" ) !== false ) { + if ( api && html.replace( /\s/g, '' ) !== '' && !api.fp_isFullscreen() && + self._fireEvent( "onBeforeUnload" ) !== false ) { api.fp_close(); wrapper.innerHTML = html; self._fireEvent( "onUnload" ); api = null; } - + return self; }, - getClip: function( index ) { if ( index === undefined ) { index = activeIndex; } return playlist[index]; }, - - getCommonClip: function() { return commonClip; }, - getPlaylist: function() { return playlist; }, - - getPlugin: function( name ) { - var plugin = plugins[name]; - + getPlugin: function( name ) { + var plugin = plugins[name]; // create plugin if nessessary - if ( !plugin && self.isLoaded() ) { + if ( !plugin && self.isLoaded() ) { var json = self._api().fp_getPlugin( name ); if ( json ) { plugin = new Plugin( name, json, self ); plugins[name] = plugin; } - } - return plugin; - }, - + } + return plugin; + }, getScreen: function() { return self.getPlugin( "screen" ); }, - getControls: function() { return self.getPlugin( "controls" ); }, - getConfig: function() { return clone ( conf ); }, - getFlashParams: function() { return params; }, - loadPlugin: function( name, url, props, fn ) { - - // properties not supplied + // properties not supplied if ( typeof props == 'function' ) { fn = props; props = { }; } - + // if fn not given, make a fake id so that plugin's onUpdate get's fired var fnId = fn ? makeId() : "_"; self._api().fp_loadPlugin( name, url, props, fnId ); - + // create new plugin var arg = { }; arg[fnId] = fn; @@ -613,15 +548,11 @@ function Player( wrapper, params, conf ) { plugins[name] = p; return p; }, - - getState: function() { return api ? api.fp_getState() : - 1; }, - // "lazy" play play: function( clip ) { - function play() { if ( clip !== undefined ) { self._api().fp_play( clip ); @@ -630,19 +561,17 @@ function Player( wrapper, params, conf ) { self._api().fp_play(); } } - + if ( api ) { play(); - } else { self.load( function() { play(); } ); } - + return self; }, - getVersion: function() { var js = "flowplayer.js 3.0.0-rc5"; if ( api ) { @@ -652,26 +581,22 @@ function Player( wrapper, params, conf ) { } return js; }, - _api: function() { if ( !api ) { throw "Flowplayer " + self.id() + " not loaded. Try moving your call to player's onLoad event"; } return api; }, - _dump: function() { console.log( listeners ); } - } ); - - + // event handlers each( ( "Click*,Load*,Unload*,Keypress*,Volume*,Mute*,Unmute*,PlaylistReplace,Fullscreen*,FullscreenExit,Error" ).split( "," ), function() { var name = "on" + this; - + // before event if ( name.indexOf( "*" ) != - 1 ) { name = name.substring( 0, name.length - 1 ); @@ -681,7 +606,7 @@ function Player( wrapper, params, conf ) { return self; }; } - + // normal event self[name] = function( fn ) { bind( listeners, name, fn ); @@ -689,13 +614,12 @@ function Player( wrapper, params, conf ) { }; } ); - - + // core API methods each( ( "pause,resume,mute,unmute,stop,toggle,seek,getStatus,getVolume,setVolume,getTime,isPaused,isPlaying,startBuffering,stopBuffering,isFullscreen,reset" ).split( "," ), function() { var name = this; - + self[name] = function( arg ) { if ( !api ) { return self; } try { @@ -707,42 +631,36 @@ function Player( wrapper, params, conf ) { }; } ); - -// }}} - +// }}} // {{{ public method: _fireEvent - self._fireEvent = function( evt, arg0, arg1, arg2 ) { - if ( conf.debug ) { log( arguments ); } - + // internal onLoad if ( evt == 'onLoad' && !api ) { - api = api || el( apiId ); swfHeight = api.clientHeight; - + each( playlist, function() { this._fireEvent( "onLoad" ); } ); - + each( plugins, function( name, p ) { p._fireEvent( "onUpdate" ); } ); - - + commonClip._fireEvent( "onLoad" ); } - - if ( evt == 'onContextMenu' ) { - each( conf.contextMenu[arg0], function( key, fn ) { - fn.call( self ); - } ); - return; - } + + if ( evt == 'onContextMenu' ) { + each( conf.contextMenu[arg0], function( key, fn ) { + fn.call( self ); + } ); + return; + } if ( evt == 'onPluginEvent' ) { var name = arg0.name || arg0; @@ -764,119 +682,113 @@ function Player( wrapper, params, conf ) { playlist.push( new Clip( this, index++ ) ); } ); } - + var ret = true; - + // clip event if ( arg0 === 0 || ( arg0 && arg0 >= 0 ) ) { - activeIndex = arg0; var clip = playlist[arg0]; - + if ( clip ) { ret = clip._fireEvent( evt, arg1, arg2 ); } - + if ( !clip || ret !== false ) { - // clip argument is given for common clip, because it behaves as the target ret = commonClip._fireEvent( evt, arg1, arg2, clip ); } } - - // player event + + // player event var i = 0; each( listeners[evt], function() { ret = this.call( self, arg0 ); - + // remove cached entry if ( this.cached ) { listeners[evt].splice( i, 1 ); } - + // break loop if ( ret === false ) { return false; } i++; - + } ); return ret; }; // }}} - - // {{{ init - - function init() { - + function init() { if ( $f( wrapper ) ) { return null; } - + wrapperHeight = parseInt( wrapper.style.height ) || wrapper.clientHeight; - + // register this player into global array of instances players.push( self ); - - + + // flashembed parameters if ( typeof params == 'string' ) { params = { src: params }; } - - // playerId + + // playerId playerId = wrapper.id || "fp" + makeId(); apiId = params.id || playerId + "_api"; params.id = apiId; conf.playerId = playerId; - - + + // plain url is given as config if ( typeof conf == 'string' ) { conf = { clip: { url:conf } }; } - + // common clip is always there conf.clip = conf.clip || { }; commonClip = new Clip( conf.clip, - 1, self ); - - + + // wrapper href as playlist if ( wrapper.getAttribute( "href" ) ) { conf.playlist = [ { url:wrapper.getAttribute( "href", 2 ) }]; } - + // playlist conf.playlist = conf.playlist || [conf.clip]; - + var index = 0; each( conf.playlist, function() { var clip = this; - + // clip is an array, we don't allow that if ( typeof clip == 'object' && clip.length ) { clip = "" + clip; } - + if ( !clip.url && typeof clip == 'string' ) { clip = { url: clip }; } - + // populate common clip properties to each clip extend( clip, conf.clip, true ); - + // modify configuration playlist conf.playlist[index] = clip; - + // populate playlist array clip = new Clip( clip, index, self ); playlist.push( clip ); index++; } ); - - + + // event listeners each( conf, function( key, val ) { if ( typeof val == 'function' ) { @@ -884,30 +796,30 @@ function Player( wrapper, params, conf ) { delete conf[key]; } } ); - - + + // plugins each( conf.plugins, function( name, val ) { if ( val ) { plugins[name] = new Plugin( name, val, self ); } } ); - - + + // setup controlbar plugin if not explicitly defined if ( !conf.plugins || conf.plugins.controls === undefined ) { plugins.controls = new Plugin( "controls", null, self ); } - + // Flowplayer uses black background by default params.bgcolor = params.bgcolor || "#000000"; - - + + // setup default settings for express install params.version = params.version || [9, 0]; params.expressInstall = 'http://www.flowplayer.org/swf/expressinstall.swf'; - - + + // click function function doClick( e ) { if ( self._fireEvent( "onBeforeClick" ) !== false ) { @@ -915,37 +827,37 @@ function Player( wrapper, params, conf ) { } return stopEvent( e ); } - + // defer loading upon click html = wrapper.innerHTML; if ( html.replace( /\s/g, '' ) !== '' ) { - + if ( wrapper.addEventListener ) { wrapper.addEventListener( "click", doClick, false ); - + } else if ( wrapper.attachEvent ) { wrapper.attachEvent( "onclick", doClick ); } - - // player is loaded upon page load + + // player is loaded upon page load } else { - + // prevent default action from wrapper (safari problem) loaded if ( wrapper.addEventListener ) { wrapper.addEventListener( "click", stopEvent, false ); } - + // load player self.load(); } - + } // possibly defer initialization until DOM get's loaded if ( typeof wrapper == 'string' ) { flashembed.domReady( function() { var node = el( wrapper ); - + if ( !node ) { throw "Flowplayer cannot access element: " + wrapper; } else { @@ -953,34 +865,26 @@ function Player( wrapper, params, conf ) { init(); } } ); - + // we have a DOM element so page is already loaded } else { init(); } - - // }}} - - } - -// {{{ flowplayer() & statics - +// {{{ flowplayer() & statics // container for player instances var players = []; - -// this object is returned when multiple player's are requested +// this object is returned when multiple player's are requested function Iterator( arr ) { - this.length = arr.length; - + this.each = function( fn ) { each( arr, fn ); }; - + this.size = function() { return arr.length; }; @@ -988,11 +892,9 @@ function Iterator( arr ) { // these two variables are the only global variables window.flowplayer = window.$f = function() { - var instance = null; var arg = arguments[0]; - - + // $f() if ( !arguments.length ) { each( players, function() { @@ -1001,25 +903,22 @@ window.flowplayer = window.$f = function() { return false; } } ); - + return instance || players[0]; } - + if ( arguments.length == 1 ) { - // $f(index); if ( typeof arg == 'number' ) { return players[arg]; - - + // $f(wrapper || 'containerId' || '*'); } else { - // $f("*"); if ( arg == '*' ) { return new Iterator( players ); } - + // $f(wrapper || 'containerId'); each( players, function() { if ( this.id() == arg.id || this.id() == arg || this.getParent() == arg ) { @@ -1027,77 +926,68 @@ window.flowplayer = window.$f = function() { return false; } } ); - + return instance; } } - // instance builder + // instance builder if ( arguments.length > 1 ) { - var swf = arguments[1]; var conf = ( arguments.length == 3 ) ? arguments[2] : { }; - + if ( typeof arg == 'string' ) { - // select arg by classname if ( arg.indexOf( "." ) != - 1 ) { var instances = []; - + each( select( arg ), function() { instances.push( new Player( this, clone ( swf ), clone ( conf ) ) ); } ); - + return new Iterator( instances ); - + // select node by id } else { var node = el( arg ); return new Player( node !== null ? node : arg, swf, conf ); } - - + + // arg is a DOM element } else if ( arg ) { return new Player( arg, swf, conf ); } - } - + return null; }; - -extend( window.$f, { - // called by Flash External Interface +extend( window.$f, { + // called by Flash External Interface fireEvent: function( id, evt, a0, a1, a2 ) { var p = $f( id ); return p ? p._fireEvent( evt, a0, a1, a2 ) : null; }, - - + // create plugins by modifying Player's prototype addPlugin: function( name, fn ) { Player.prototype[name] = fn; return $f; }, - + // utility methods for plugin developers each: each, - + extend: extend - } ); - -// }}} - +// }}} // {{{ jQuery support if ( typeof jQuery == 'function' ) { - jQuery.prototype.flowplayer = function( params, conf ) { - + // select instances if ( !arguments.length || typeof arguments[0] == 'number' ) { var arr = []; @@ -1109,56 +999,56 @@ if ( typeof jQuery == 'function' ) { } ); return arguments.length ? arr[arguments[0]] : new Iterator( arr ); } - + // create flowplayer instances return this.each( function() { $f( this, clone ( params ), conf ? clone ( conf ) : { } ); } ); - + }; - + } // }}} } )(); -/** +/** * flashembed 0.34. Adobe Flash embedding script - * + * * http://flowplayer.org/tools/flash-embed.html * * Copyright (c) 2008 Tero Piirainen (support@flowplayer.org) * * Released under the MIT License: * http://www.opensource.org/licenses/mit-license.php - * + * * >> Basically you can do anything you want but leave this header as is << * - * first version 0.01 - 03/11/2008 + * first version 0.01 - 03/11/2008 * version 0.34 - Tue Nov 11 2008 09:09:52 GMT-0000 (GMT+00:00) */ ( function() { - -// {{{ utility functions + +// {{{ utility functions var jQ = typeof jQuery == 'function'; // from "Pro JavaScript techniques" by John Resig function isDomReady() { - + if ( domReady.done ) { return false; } - + var d = document; if ( d && d.getElementsByTagName && d.getElementById && d.body ) { clearInterval( domReady.timer ); domReady.timer = null; - + for ( var i = 0; i < domReady.ready.length; i++ ) { domReady.ready[i].call(); } - + domReady.ready = null; domReady.done = true; } @@ -1166,14 +1056,14 @@ function isDomReady() { // if jQuery is present, use it's more effective domReady method var domReady = jQ ? jQuery : function( f ) { - + if ( domReady.done ) { return f(); } - + if ( domReady.timer ) { domReady.ready.push( f ); - + } else { domReady.ready = [f]; domReady.timer = setInterval( isDomReady, 13 ); @@ -1181,7 +1071,7 @@ var domReady = jQ ? jQuery : function( f ) { }; -// override extend params function +// override extend params function function extend( to, from ) { if ( from ) { for ( key in from ) { @@ -1190,14 +1080,14 @@ function extend( to, from ) { } } } - + return to; } function concatVars( vars ) { var out = ""; - + for ( var key in vars ) { if ( vars[key] ) { out += [key] + '=' + asString( vars[key] ) + '&'; @@ -1214,19 +1104,19 @@ function asString( obj ) { switch ( typeOf( obj ) ) { case 'string': obj = obj.replace( new RegExp( '(["\\\\])', 'g' ), '\\$1' ); - + // flash does not handle %- characters well. transforms "50%" to "50pct" (a dirty hack, I admit) obj = obj.replace( /^\s?(\d+)%/, "$1pct" ); return '"' + obj + '"'; - + case 'array': return '[' + map( obj, function( el ) { return asString( el ); } ).join( ',' ) + ']'; - + case 'function': return '"function()"'; - + case 'object': var str = []; for ( var prop in obj ) { @@ -1236,7 +1126,7 @@ function asString( obj ) { } return '{' + str.join( ',' ) + '}'; } - + // replace ' --> " and remove spaces return String( obj ).replace( /\s/g, " ").replace( /\'/g, "\"" ); } @@ -1259,7 +1149,7 @@ if (window.attachEvent) { } function map(arr, func) { - var newArr = []; + var newArr = []; for (var i in arr) { if (arr.hasOwnProperty(i)) { newArr[i] = func(arr[i]); @@ -1267,14 +1157,14 @@ function map(arr, func) { } return newArr; } - + function getEmbedCode(p, c) { var html = ' < embed type = "application/x-shockwave-flash" '; if (p.id) { extend(p, {name:p.id}); } - - for (var key in p) { - if (p[key] !== null) { + + for (var key in p) { + if (p[key] !== null) { html += key + '="' + p[key] + '"\n\t'; } } @@ -1282,55 +1172,55 @@ function getEmbedCode(p, c) { if (c) { html += 'flashvars=\'' + concatVars( c ) + '\''; } - + // thanks Tom Price (07/17/2008) html += '/>'; - + return html; } function getObjectCode( p, c, embeddable ) { - + var html = ''; var e = extend( { }, p ); e.id = e.width = e.height = e.src = null; - + for ( var k in e ) { if ( e[k] !== null ) { html += '\n\t'; } } - + if ( c ) { html += '\n\t'; } - + if ( embeddable ) { html += getEmbedCode( p, c ); } - + html += ""; - + return html; } @@ -1345,26 +1235,26 @@ function getHTML( p, c ) { // }}} - + window.flashembed = function( root, userParams, flashvars ) { - - + + // {{{ construction // setup params var params = { - + // very common params src: '#', width: '100%', height: '100%', - + // flashembed specific options version:null, onFail:null, expressInstall:null, debug: false, - + // flashembed defaults // bgcolor: 'transparent', allowfullscreen: true, @@ -1373,20 +1263,20 @@ window.flashembed = function( root, userParams, flashvars ) { type: 'application/x-shockwave-flash', pluginspage: 'http://www.adobe.com/go/getflashplayer' }; - - + + if ( typeof userParams == 'string' ) { userParams = { src: userParams }; } - + extend( params, userParams ); - + var version = flashembed.getVersion(); var required = params.version; var express = params.expressInstall; var debug = params.debug; - + if ( typeof root == 'string' ) { var el = document.getElementById( root ); if ( el ) { @@ -1398,14 +1288,14 @@ window.flashembed = function( root, userParams, flashvars ) { return; } } - + if ( !root ) { return; } - - // is supported + + // is supported if ( !required || flashembed.isSupported( required ) ) { params.onFail = params.version = params.expressInstall = params.debug = null; - + // root.innerHTML may cause broplems: http://domscripting.com/blog/display/99 // thanks to: Ryan Rud // var tmp = document.createElement("extradiv"); @@ -1413,29 +1303,29 @@ window.flashembed = function( root, userParams, flashvars ) { // root.appendChild(tmp); root.innerHTML = getHTML( params, flashvars ); - - // return our API + + // return our API return root.firstChild; - + // custom fail event } else if ( params.onFail ) { var ret = params.onFail.call( params, flashembed.getVersion(), flashvars ); if ( ret === true ) { root.innerHTML = ret; } - + // express install } else if ( required && express && flashembed.isSupported( [6, 65] ) ) { - + extend( params, { src: express } ); - + flashvars = { MMredirectURL: location.href, MMplayerType: 'PlugIn', MMdoctitle: document.title }; - + root.innerHTML = getHTML( params, flashvars ); - + // not supported } else { @@ -1455,10 +1345,10 @@ window.flashembed = function( root, userParams, flashvars ) { } return root; - + // }}} - + }; @@ -1468,9 +1358,9 @@ extend( window.flashembed, { // returns arr[major, fix] getVersion: function() { - + var version = [0, 0]; - + if ( navigator.plugins && typeof navigator.plugins["Shockwave Flash"] == "object" ) { var _d = navigator.plugins["Shockwave Flash"].description; if ( typeof _d != "undefined" ) { @@ -1479,17 +1369,17 @@ extend( window.flashembed, { var _r = / r / .test( _d ) ? parseInt( _d.replace( /^.*r(.*)$/ , "$1" ), 10 ) : 0; version = [_m, _r]; } - + } else if ( window.ActiveXObject ) { - + try { // avoid fp 6 crashes var _a = new ActiveXObject( "ShockwaveFlash.ShockwaveFlash.7" ); - + } catch ( e ) { try { _a = new ActiveXObject( "ShockwaveFlash.ShockwaveFlash.6" ); version = [6, 0]; - _a.AllowScriptAccess = "always"; // throws if fp < 6.47 + _a.AllowScriptAccess = "always"; // throws if fp < 6.47 } catch ( ee ) { if ( version[0] == 6 ) { return; } @@ -1497,11 +1387,11 @@ extend( window.flashembed, { try { _a = new ActiveXObject( "ShockwaveFlash.ShockwaveFlash" ); } catch ( eee ) { - + } - + } - + if ( typeof _a == "object" ) { _d = _a.GetVariable( "$version" ); // bugs in fp 6.21 / 6.23 if ( typeof _d != "undefined" ) { @@ -1510,25 +1400,25 @@ extend( window.flashembed, { } } } - + return version; }, - + isSupported: function( version ) { var now = flashembed.getVersion(); var ret = ( now[0] > version[0] ) || ( now[0] == version[0] && now[1] >= version[1] ); return ret; }, - + domReady: domReady, - - // returns a String representation from JSON object + + // returns a String representation from JSON object asString: asString, - + getHTML: getHTML, - + getFullHTML: getFullHTML - + } ); // }}} @@ -1536,7 +1426,7 @@ extend( window.flashembed, { // setup jquery support if ( jQ ) { - + jQuery.prototype.flashembed = function( params, flashvars ) { return this.each( function() { flashembed( this, params, flashvars ); @@ -1586,7 +1476,7 @@ var flowplayerEmbed = { var flowConfig = { clip: { url: this.getSrc(), - // when this is false playback does not start until play button is pressed + // when this is false playback does not start until play button is pressed autoPlay: true }, plugins: { @@ -1604,24 +1494,24 @@ var flowplayerEmbed = { opacity : '1.0' } }; - + // if in preview mode set grey and lower volume until "ready" if ( this.preview_mode ) { flowConfig.screen.opacity = 0.2; } - + $f( this.pid, mv_embed_path + 'binPlayers/flowplayer/flowplayer-3.0.1.swf', flowConfig ); - // get the this.fla value: + // get the this.fla value: this.getFLA(); - // set up bindings (for when interacting with the swf causes action: + // set up bindings (for when interacting with the swf causes action: this.fla.onPause( function() { - _this.parent_pause(); // update the interface + _this.parent_pause(); // update the interface } ) this.fla.onResume( function() { - _this.parent_play(); // update the interface + _this.parent_play(); // update the interface } ); - - // start monitor: + + // start monitor: this.monitor(); this.old_pid++; }, @@ -1632,8 +1522,8 @@ var flowplayerEmbed = { this.parent_play(); if ( this.fla ) { this.fla.play(); - - // on a resume make sure volume and opacity are correct + + // on a resume make sure volume and opacity are correct this.restorePlayer(); setTimeout( '$j(\'#' + this.id + '\').get(0).monitor()', 250 ); } @@ -1644,17 +1534,17 @@ var flowplayerEmbed = { this.getFLA(); if ( this.fla ) { if ( this.muted ) { - + } else { - + } } }, - // @@ Suport UpDateVolumen + // @@ Suport UpDateVolumen updateVolumen:function( perc ) { this.getFLA(); if ( this.fla )this.fla.setVolume( perc * 100 ); - + }, // @@ Get Volumen getVolumen:function() { @@ -1680,8 +1570,8 @@ var flowplayerEmbed = { if ( ! this.fla.isPaused() ) { js_log( 'calling plugin pause' ); this.fla.pause(); - - // restore volume and opacity + + // restore volume and opacity this.restorePlayer(); } } @@ -1695,26 +1585,26 @@ var flowplayerEmbed = { if ( !this.dateStartTime ) { var d = new Date(); this.dateStartTime = d.getTime(); - + } else { var d = new Date(); if ( !this.didDateStartTimeRestore && this.preview_mode ) this.fla.setVolume( 0 ); - + if ( ( d.getTime() - this.dateStartTime ) > 6000 && !this.didDateStartTimeRestore ) { this.restorePlayer(); } } - + var flash_state = this.fla.getStatus(); - // update the duration from the clip if its zero or not set: + // update the duration from the clip if its zero or not set: if ( !this.duration || this.duration == 0 ) { if ( this.fla.getClip() ) { this.duration = this.fla.getClip().fullDuration; js_log( 'set duration via clip value: ' + this.getDuration() ); } } - // update the duration ntp values: + // update the duration ntp values: this.getDuration(); if ( typeof flash_state == 'undefined' ) { @@ -1725,22 +1615,22 @@ var flowplayerEmbed = { this.restorePlayer(); } else { // simplification of buffer state ... should move to support returning time rages like: - // http://www.whatwg.org/specs/web-apps/current-work/#normalized-timeranges-object + // http://www.whatwg.org/specs/web-apps/current-work/#normalized-timeranges-object this.bufferedPercent = flash_state.bufferEnd / this.getDuration(); } - // set the current Time (based on timeFormat) + // set the current Time (based on timeFormat) if ( this.supportsURLTimeEncoding() ) { this.currentTime = flash_state.time; - // js_log('set buffer: ' + flash_state.bufferEnd + ' at time: ' + flash_state.time +' of total dur: ' + this.getDuration()); + // js_log('set buffer: ' + flash_state.bufferEnd + ' at time: ' + flash_state.time +' of total dur: ' + this.getDuration()); } else { this.currentTime = flash_state.time + this.start_offset; - // stop buffering if greater than the duration: + // stop buffering if greater than the duration: if ( flash_state.bufferEnd > this.getDuration() + 5 ) { // js_log('should stop buffering (does not seem to work)' + flash_state.bufferEnd + ' > dur: ' + this.getDuration() ); this.fla.stopBuffering(); } } - + if ( this.currentTime > npt2seconds( this.start_ntp ) && !this.startedTimedPlayback ) { var fail = false; try @@ -1755,7 +1645,7 @@ var flowplayerEmbed = { if ( !fail ) this.startedTimedPlayback = true; } - + /* to support local seeks */ if ( this.currentTime > 1 && this.seek_time_sec != 0 && !this.supportsURLTimeEncoding() ) { @@ -1763,8 +1653,8 @@ var flowplayerEmbed = { this.fla.seek( this.seek_time_sec ); this.seek_time_sec = 0; } - - // checks to see if we reached the end of playback: + + // checks to see if we reached the end of playback: if ( this.duration && this.startedTimedPlayback && ( this.currentTime > ( npt2seconds( this.end_ntp ) + 2 ) || @@ -1774,11 +1664,11 @@ var flowplayerEmbed = { js_log( 'prbally reached end of stream: ' + seconds2npt( this.currentTime ) ); this.onClipDone(); } - + // update the status and check timmer via universal parent monitor this.parent_monitor(); - - + + this.prevTime = this.currentTime; // js_log('cur perc loaded: ' + this.fla.getPercentLoaded() +' cur time : ' + (this.currentTime - npt2seconds(this.start_ntp)) +' / ' +(npt2seconds(this.end_ntp)-npt2seconds(this.start_ntp))); }, @@ -1793,7 +1683,7 @@ var flowplayerEmbed = { this.didDateStartTimeRestore = true; } }, - // get the embed fla object + // get the embed fla object getFLA : function () { this.fla = $f( this.pid ); }, @@ -1811,7 +1701,7 @@ var flowplayerEmbed = { }, onStop: function() { js_log( 'f:onStop' ); - // stop updates: + // stop updates: if ( this.monitorTimerId != 0 ) { clearInterval( this.monitorTimerId ); @@ -1822,14 +1712,14 @@ var flowplayerEmbed = { js_log( 'f:flash:onClipDone' ); if ( ! this.startedTimedPlayback ) { js_log( 'clip done before timed playback started .. not good. (ignoring) ' ); - // keep monitoring: + // keep monitoring: this.monitor(); } else { js_log( 'clip done and ' + this.startedTimedPlayback ); // stop the clip if its not stopped already: this.stop(); this.setStatus( "Clip Done..." ); - // run the onClip done action: + // run the onClip done action: this.parent_onClipDone(); } } diff --git a/js2/mwEmbed/libEmbedVideo/genericEmbed.js b/js2/mwEmbed/libEmbedVideo/genericEmbed.js index 39f7f5c510..3e965e7ef8 100644 --- a/js2/mwEmbed/libEmbedVideo/genericEmbed.js +++ b/js2/mwEmbed/libEmbedVideo/genericEmbed.js @@ -11,7 +11,7 @@ var genericEmbed = { instanceOf:'genericEmbed', getEmbedHTML:function() { return ''; + 'width="' + this.width + '" height="' + this.height + '" ' + + 'data="' + this.getURI( this.seek_time_sec ) + '">'; } -}; \ No newline at end of file +}; diff --git a/js2/mwEmbed/libEmbedVideo/htmlEmbed.js b/js2/mwEmbed/libEmbedVideo/htmlEmbed.js index 484c1a09fe..0004d0dad2 100644 --- a/js2/mwEmbed/libEmbedVideo/htmlEmbed.js +++ b/js2/mwEmbed/libEmbedVideo/htmlEmbed.js @@ -1,36 +1,37 @@ -/* - * used to embed HTML as a movie clip - * for use with mv_playlist SMIL additions +/* + * used to embed HTML as a movie clip + * for use with mv_playlist SMIL additions * (we make assumptions about this.pc (parent clip) being available) */ var pcHtmlEmbedDefaults = { 'dur':4 // default duration of 4 seconds } + var htmlEmbed = { - supports: { + supports: { 'play_head':true, 'pause':true, 'fullscreen':false, 'time_display':true, 'volume_control':true, - + 'overlays':true, - 'playlist_swap_loader':true // if the object supports playlist functions - }, - ready_to_play:true, - pauseTime:0, - currentTime:0, - start_offset:0, - monitorTimerId:false, + 'playlist_swap_loader':true // if the object supports playlist functions + }, + ready_to_play:true, + pauseTime:0, + currentTime:0, + start_offset:0, + monitorTimerId:false, play:function() { // call the parent this.parent_play(); - + js_log( 'f:play: htmlEmbedWrapper' ); var ct = new Date(); this.clockStartTime = ct.getTime(); - - // start up monitor: + + // start up monitor: this.monitor(); }, stop:function() { @@ -43,16 +44,16 @@ var htmlEmbed = { var ct = new Date(); this.pauseTime = this.currentTime; js_log( 'pause time: ' + this.pauseTime ); - + window.clearInterval( this.monitorTimerId ); }, - // monitor just needs to keep track of time (do it at frame rate time) . + // monitor just needs to keep track of time (do it at frame rate time) . monitor:function() { // js_log('html:monitor: '+ this.currentTime); var ct = new Date(); this.currentTime = ( ( ct.getTime() - this.clockStartTime ) / 1000 ) + this.pauseTime; var ct = new Date(); - // js_log('mvPlayList:monitor trueTime: '+ this.currentTime); + // js_log('mvPlayList:monitor trueTime: '+ this.currentTime); if ( ! this.monitorTimerId ) { if ( document.getElementById( this.id ) ) { @@ -62,7 +63,7 @@ var htmlEmbed = { } } }, - // set up minimal media_element emulation: + // set up minimal media_element emulation: media_element: { autoSelectSource:function() { return true; @@ -82,61 +83,60 @@ var htmlEmbed = { }, renderTimelineThumbnail:function( options ) { js_log( "HTMLembed req w, height: " + options.width + ' ' + options.height ); - // generate a scaled down version _that_ we can clone if nessisary - // add a not vissiable container to the body: + // generate a scaled down version _that_ we can clone if nessisary + // add a not vissiable container to the body: var do_refresh = ( typeof options['refresh'] != 'undefined' ) ? true:false; - + var thumb_render_id = this.id + '_thumb_render_' + options.height; if ( $j( '#' + thumb_render_id ).length == 0 || do_refresh ) { - // set the font scale down percentage: (kind of arbitrary) + // set the font scale down percentage: (kind of arbitrary) var scale_perc = options.width / this.pc.pp.width; js_log( 'scale_perc:' + options.width + ' / ' + $j( this ).width() + ' = ' + scale_perc ); - // min scale font percent of 70 (overflow is hidden) + // min scale font percent of 70 (overflow is hidden) var font_perc = ( Math.round( scale_perc * 100 ) < 80 ) ? 80 : Math.round( scale_perc * 100 ); var thumb_class = ( typeof options['thumb_class'] != 'undefined' ) ? options['thumb_class'] : ''; $j( 'body' ).append( '' - ); - // scale down the fonts: + '
    ' + + this.getThumbnailHTML( { + 'width': options.width, + 'height': options.height + } ) + + '
    ' + + '' + ); + // scale down the fonts: $j( '#' + thumb_render_id + ' *' ).filter( 'span,div,p,h,h1,h2,h3,h4,h5,h6' ).css( 'font-size', font_perc + '%' ) - + // replace out links: $j( '#' + thumb_render_id + ' a' ).each( function() { $j( this ).replaceWith( "" + $j( this ).html() + "" ); } ); - + // scale images that have width or height: $j( '#' + thumb_render_id + ' img' ).filter( '[width]' ).each( function() { $j( this ).attr( { - 'width': Math.round( $j( this ).attr( 'width' ) * scale_perc ), - 'height': Math.round( $j( this ).attr( 'height' ) * scale_perc ) - } - ); + 'width': Math.round( $j( this ).attr( 'width' ) * scale_perc ), + 'height': Math.round( $j( this ).attr( 'height' ) * scale_perc ) + } ); } ); } return $j( '#' + thumb_render_id ).html(); }, - // nothing to update in static html display: (return a static representation) + // nothing to update in static html display: (return a static representation) // @@todo render out a mini text "preview" updateThumbTime:function( float_time ) { return ; }, getEmbedHTML:function() { js_log( 'f:html:getEmbedHTML: ' + this.id ); - // set up the css for our parent div: + // set up the css for our parent div: $j( this ).css( { 'width':this.pc.pp.width, 'height':this.pc.pp.height, 'overflow':"hidden" } ); - // @@todo support more smil animation layout stuff: + // @@todo support more smil animation layout stuff: // wrap output in videoPlayer_ div: $j( this ).html( '
    ' + this.getThumbnailHTML() + '
    ' ); @@ -169,7 +169,7 @@ var htmlEmbed = { getDuration:function() { if ( this.pc.dur ) return this.pc.dur; - // return default value: + // return default value: return pcHtmlEmbedDefaults.dur; }, updateVideoTime:function( start_ntp, end_ntp ) { @@ -183,4 +183,4 @@ var htmlEmbed = { this.ready_to_play = true; return ; } -}; \ No newline at end of file +}; diff --git a/js2/mwEmbed/libEmbedVideo/javaEmbed.js b/js2/mwEmbed/libEmbedVideo/javaEmbed.js index 9e1fb424e4..ea85a8cbda 100644 --- a/js2/mwEmbed/libEmbedVideo/javaEmbed.js +++ b/js2/mwEmbed/libEmbedVideo/javaEmbed.js @@ -1,7 +1,7 @@ window.cortadoDomainLocations = { - 'upload.wikimedia.org' : 'http://upload.wikimedia.org/jars/cortado.jar', - 'tinyvid.tv' : 'http://tinyvid.tv/static/cortado.jar', - 'media.tinyvid.tv' : 'http://media.tinyvid.tv/cortado.jar' + 'upload.wikimedia.org' : 'http://upload.wikimedia.org/jars/cortado.jar', + 'tinyvid.tv' : 'http://tinyvid.tv/static/cortado.jar', + 'media.tinyvid.tv' : 'http://media.tinyvid.tv/cortado.jar' } var javaEmbed = { @@ -32,7 +32,7 @@ var javaEmbed = { // @@todo we should have src property in our base embed object var mediaSrc = this.getSrc(); - if ( mediaSrc.indexOf( '://' ) != - 1 & mw.parseUri( document.URL ).host != mw.parseUri( mediaSrc ).host ) { + if ( mediaSrc.indexOf( '://' ) != -1 & mw.parseUri( document.URL ).host != mw.parseUri( mediaSrc ).host ) { if ( window.cortadoDomainLocations[mw.parseUri( mediaSrc ).host] ) { applet_loc = window.cortadoDomainLocations[mw.parseUri( mediaSrc ).host]; } else { @@ -104,9 +104,9 @@ var javaEmbed = { // once currentTime is updated call parent_monitor this.parent_monitor(); }, - /* - * (local cortado seek does not seem to work very well) - */ + /* + * (local cortado seek does not seem to work very well) + */ doSeek:function( perc ) { js_log( 'java:seek:p: ' + perc + ' : ' + this.supportsURLTimeEncoding() + ' dur: ' + this.getDuration() + ' sts:' + this.seek_time_sec ); this.getJCE(); diff --git a/js2/mwEmbed/libEmbedVideo/kplayerEmbed.js b/js2/mwEmbed/libEmbedVideo/kplayerEmbed.js index ad36a8bc0b..a4ca53f194 100644 --- a/js2/mwEmbed/libEmbedVideo/kplayerEmbed.js +++ b/js2/mwEmbed/libEmbedVideo/kplayerEmbed.js @@ -71,4 +71,4 @@ function onKdpReady( playerId ) { attachKdpEvents(); addKdpListners(); */ - } \ No newline at end of file +} diff --git a/js2/mwEmbed/libEmbedVideo/nativeEmbed.js b/js2/mwEmbed/libEmbedVideo/nativeEmbed.js index c4b48af33f..b828a7b53b 100644 --- a/js2/mwEmbed/libEmbedVideo/nativeEmbed.js +++ b/js2/mwEmbed/libEmbedVideo/nativeEmbed.js @@ -5,7 +5,7 @@ var nativeEmbed = { grab_try_count:0, onlyLoadFlag:false, urlAppend:'', - prevCurrentTime: - 1, + prevCurrentTime: -1, supports: { 'play_head':true, 'pause':true, @@ -15,7 +15,7 @@ var nativeEmbed = { 'overlays':true, 'playlist_swap_loader':true // if the object supports playlist functions - }, + }, getEmbedHTML : function () { var embed_code = this.getEmbedObj(); js_log( "embed code: " + embed_code ) @@ -171,7 +171,7 @@ var nativeEmbed = { } // do a seek check (on seeked does not seem fire consistantly) - if ( this.prevCurrentTime != - 1 && this.prevCurrentTime != 0 + if ( this.prevCurrentTime != -1 && this.prevCurrentTime != 0 && this.prevCurrentTime < this.currentTime && this.seeking ) this.seeking = false; @@ -189,7 +189,7 @@ var nativeEmbed = { getSrc:function() { var src = this.parent_getSrc(); if ( this.urlAppend != '' ) - return src + ( ( src.indexOf( '?' ) == - 1 ) ? '?':'&' ) + this.urlAppend; + return src + ( ( src.indexOf( '?' ) == -1 ) ? '?':'&' ) + this.urlAppend; return src; }, /* diff --git a/js2/mwEmbed/libEmbedVideo/vlcEmbed.js b/js2/mwEmbed/libEmbedVideo/vlcEmbed.js index 71c4b26095..41872a01e9 100644 --- a/js2/mwEmbed/libEmbedVideo/vlcEmbed.js +++ b/js2/mwEmbed/libEmbedVideo/vlcEmbed.js @@ -63,7 +63,7 @@ var vlcEmbed = { // @@todo if client supports seeking no need to send seek_offset to URI js_log( 'vlc play::' + this.getSrc() ); var itemId = this.vlc.playlist.add( this.getSrc() ); - if ( itemId != - 1 ) { + if ( itemId != -1 ) { // play this.vlc.playlist.playItem( itemId ); } else { @@ -192,7 +192,7 @@ var vlcEmbed = { // update the status and check timmer via universal parent monitor this.parent_monitor(); }, -/* events */ + /* events */ onOpen: function() { this.setStatus( "Opening..." ); }, @@ -212,16 +212,16 @@ var vlcEmbed = { this.duration = this.vlc.input.length / 1000; } this.currentTime = this.vlc.input.time / 1000; - }, - onPause: function() { + }, + onPause: function() { this.parent_pause(); // update the inteface if paused via native control - }, - onStop: function() { - js_log( 'vlc:onStop:' ); - if ( !this.seeking ) - this.onClipDone(); }, - /* js hooks/controls */ + onStop: function() { + js_log( 'vlc:onStop:' ); + if ( !this.seeking ) + this.onClipDone(); + }, + /* js hooks/controls */ play : function() { js_log( 'f:vlcPlay' ); this.getVLC(); @@ -269,19 +269,19 @@ var vlcEmbed = { this.getVLC(); if ( this.vlc ) this.vlc.audio.toggleMute(); - }, - // @@ Suport UpDateVolumen - updateVolumen:function( perc ) { - this.getVLC(); + }, + // @@ Suport UpDateVolumen + updateVolumen:function( perc ) { + this.getVLC(); if ( this.vlc ) this.vlc.audio.volume = perc * 100; - }, - // @@ Get Volumen - getVolumen:function() { - this.getVLC(); - if ( this.vlc ) - return this.vlc.audio.volume / 100; - }, + }, + // @@ Get Volumen + getVolumen:function() { + this.getVLC(); + if ( this.vlc ) + return this.vlc.audio.volume / 100; + }, fullscreen : function() { if ( this.vlc ) { if ( this.vlc.video ) @@ -305,4 +305,3 @@ var vlcEmbed = { this.vlc = this.getPluginEmbed(); } }; - diff --git a/js2/mwEmbed/libSequencer/mvPlayList.js b/js2/mwEmbed/libSequencer/mvPlayList.js index 12f0ffdb2b..100fbffe9b 100644 --- a/js2/mwEmbed/libSequencer/mvPlayList.js +++ b/js2/mwEmbed/libSequencer/mvPlayList.js @@ -343,9 +343,9 @@ mvPlayList.prototype = { var first_line = this.data.substring( 0, this.data.indexOf( "\n" ) ); js_log( 'first line: ' + first_line ); // string - if ( first_line.indexOf( '#EXTM3U' ) != - 1 ) { + if ( first_line.indexOf( '#EXTM3U' ) != -1 ) { this.srcType = 'm3u'; - } else if ( first_line.indexOf( ' backslash ) { fname = path.substring( slash + 1, 10000 ); @@ -108,7 +108,7 @@ var mwUploadHelper = { // URLs are less likely to have a useful extension. Don't include them in the extension check. if ( wgFileExtensions && $j( targetElm ).attr( 'id' ) != 'wpUploadFileURL' ) { var found = false; - if ( fname.lastIndexOf( '.' ) != - 1 ) { + if ( fname.lastIndexOf( '.' ) != -1 ) { var ext = fname.substr( fname.lastIndexOf( '.' ) + 1 ); for ( var i = 0; i < wgFileExtensions.length; i++ ) { if ( wgFileExtensions[i].toLowerCase() == ext.toLowerCase() ) -- 2.20.1