r67679 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67678‎ | r67679 | r67680 >
Date:00:18, 9 June 2010
Author:dale
Status:deferred
Tags:
Comment:
some code cleanup and more stubs for smilPlayer
Modified paths:
  • /branches/MwEmbedStandAlone/README (modified) (history)
  • /branches/MwEmbedStandAlone/jsScriptLoader.php (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SmilPlayer/mw.EmbedPlayerSmil.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SmilPlayer/mw.Smil.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilBody.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilLayout.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SwarmTransport/loader.js (modified) (history)
  • /branches/MwEmbedStandAlone/mwEmbed.i18n.php (modified) (history)
  • /branches/MwEmbedStandAlone/mwEmbed.js (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/mwEmbed.i18n.php
@@ -495,6 +495,13 @@
496496 'mwe-loading_txt' => 'A caria ...',
497497 );
498498
 499+/** Pashto (پښتو)
 500+ * @author Ahmed-Najib-Biabani-Ibrahimkhel
 501+ */
 502+$messages['ps'] = array(
 503+ 'mwe-ok' => 'ښه',
 504+);
 505+
499506 /** Portuguese (Português)
500507 * @author Hamilton Abreu
501508 * @author Malafaya
@@ -536,6 +543,16 @@
537544 'mwe-error_load_lib' => 'Error: JavaScript $1 nebolo možné získať alebo neobsahuje definíciu $2',
538545 );
539546
 547+/** Serbian Cyrillic ekavian (Српски (ћирилица))
 548+ * @author Михајло Анђелковић
 549+ */
 550+$messages['sr-ec'] = array(
 551+ 'mwe-loading_txt' => 'Учитавање ...',
 552+ 'mwe-ok' => 'ОК',
 553+ 'mwe-cancel' => 'Поништи',
 554+ 'mwe-test-plural' => 'Покренуо/ла сам {{PLURAL:$1|$1 тест|$1 тестова}}',
 555+);
 556+
540557 /** Swedish (Svenska)
541558 * @author Dafer45
542559 * @author GameOn
@@ -558,7 +575,7 @@
559576 * @author AnakngAraw
560577 */
561578 $messages['tl'] = array(
562 - 'mwe-loading_txt' => 'Ikinakarga ...',
 579+ 'mwe-loading_txt' => 'Ikinakarga...',
563580 'mwe-error_load_lib' => 'Kamalian: hindi makukuha ang JavaScript na $1 o hindi nagbigay kahulugan sa $2',
564581 'mwe-apiproxy-setup' => 'Nagtatalaga ng pamalit na API',
565582 'mwe-load-drag-item' => 'Ikinakarga ang hinilang bagay',
Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilBody.js
@@ -84,6 +84,7 @@
8585 this.elementsInRange.push( $node );
8686 mw.log("Add ref to elementsInRange:: " + nodeType + " length:" + this.elementsInRange.length);
8787 }
 88+
8889 // Return the node Duration for startOffset updates
8990 return this.getNodeDuration( $node );
9091 },
@@ -118,7 +119,7 @@
119120 if( $node.children().length ){
120121 $node.children().each( function( inx, childNode ){
121122 // If in a sequence add to duration
122 - var childDuration = _this.getNodeDuration( $j( childNode ) );
 123+ var childDuration = _this.getNodeDuration( $j( childNode ), forceRefresh );
123124 if( blockType == 'seq' ){
124125 $node.data( 'implictDuration', $node.data('implictDuration') + childDuration );
125126 }
@@ -157,7 +158,7 @@
158159 */
159160 getNodeSmilType: function( $node ){
160161 var blockType = $j( $node ).get(0).nodeName;
161 - blockMap = {
 162+ var blockMap = {
162163 'body':'seq',
163164 'animation':'ref',
164165 'audio' : 'ref',
@@ -171,77 +172,4 @@
172173 return blockType;
173174 }
174175
175 -
176 - /**
177 - * Recurse parse out smil elements
178 -
179 - recurseSmilBlocks: function( $node, blockStore ){
180 - var _this = this;
181 -
182 - // Recursively parse the body for "<par>" and <seq>"
183 - $node.children().each( function( inx, childNode ){
184 - debugger;
185 - mw.log( 'on node: ' + childNode.nodeName);
186 - var smilBlock = {
187 - 'name' : childNode.nodeName
188 - };
189 - switch( childNode.nodeName ) {
190 - case 'par':
191 - smilBlock = new mw.SmilPar( childNode );
192 - break;
193 - case 'seq':
194 - smilBlock = new mw.SmilSeq( childNode );
195 - break;
196 - default:
197 - mw.log(childNode.nodeName + ' ( not recognized tag )');
198 - smilBlock = new mw.SmilElement( childNode );
199 - break;
200 - }
201 -
202 - // Add smilBlock to the current smilBlock
203 - blockStore.push( smilBlock );
204 -
205 - // If children have children add a block store and recurse
206 - if( $j( childNode ).children().length ) {
207 - _this.recurseSmilBlocks( $j( childNode ), smilBlock.smilBlocks );
208 - }
209 - });
210 - },
211 - */
212 -
213 -}
214 -
215 -/**
216 - * Base smil element
217 -
218 -mw.SmilElement = function( parElement ){
219 - this.init( parElement );
220 -}
221 -mw.SmilElement.prototype = {
222 - init: function( element ){
223 - this.tag = element.nodeName;
224 - this.$dom = $j( element );
225 - this.blockStore = [];
226 - }
227 -} */
228 -
229 -/**
230 -* Par Block
231 -* http://www.w3.org/TR/2008/REC-SMIL3-20081201/smil-timing.html#edef-par
232 -
233 -mw.SmilPar = function( parElement ){
234 - this.init( parElement );
235 -}
236 -// Inhert the SmilElement prototype
237 -mw.SmilPar.prototype = mw.SmilElement.prototype
238 -*/
239 -/**
240 -* Seq Block
241 -* http://www.w3.org/TR/2008/REC-SMIL3-20081201/smil-timing.html#edef-seq
242 -
243 -mw.SmilSeq = function( seqElement ){
244 - this.init( seqElement );
245 -}
246 -//Inhert the SmilElement prototype
247 -mw.SmilSeq.prototype = mw.SmilElement.prototype;
248 -*/
\ No newline at end of file
 176+}
\ No newline at end of file
Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilLayout.js
@@ -189,7 +189,7 @@
190190 // XXX get context of smil document for relative or absolute paths:
191191 return $j('<img />')
192192 .attr( {
193 - 'src' : 'panzoom/' + $j( smilElement ).attr( 'src' )
 193+ 'src' : this.smil.getAssetPath( $j( smilElement ).attr( 'src' ) )
194194 } )
195195 .css( {
196196 'width': '100%',
@@ -198,7 +198,8 @@
199199 },
200200
201201 /**
202 - * Parse pan attribute zoom strings
 202+ * Parse pan zoom attribute string
 203+ * @param panZoomString
203204 */
204205 parsePanZoom: function( panZoomString ){
205206 var pz = panZoomString.split(',');
Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.Smil.js
@@ -31,7 +31,10 @@
3232 // Stores the mw.SmilBody object
3333 body : null,
3434
 35+ // Stores the smil document for this object ( for relative image paths )
 36+ smilUrl: null,
3537
 38+
3639 /**
3740 * Constructor
3841 * @param {Object} options Set of options for the smil interface
@@ -47,6 +50,7 @@
4851 */
4952 loadFromUrl: function( url , callback ) {
5053 var _this = this;
 54+ this.smilUrl = url;
5155 mw.log( 'Smil: loadFromUrl : ' + url );
5256 // Set the loading flag to true:
5357 this.loadingSmil = true;
@@ -133,6 +137,15 @@
134138 this.duration = this.getBody().getDuration();
135139 }
136140 return this.duration;
 141+ },
 142+
 143+ /**
 144+ * Check if a supplied asset path is relative if and return absolute path
 145+ */
 146+ getAssetPath: function( assetPath ){
 147+ if( this.smilUrl ){
 148+ // get the smilUrl path
 149+ }
137150 }
138151 }
139152 /**
Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.EmbedPlayerSmil.js
@@ -1,4 +1,3 @@
2 -
32 /**
43 * Extends EmbedPlayer to wrap smil playback in the html5 video tag abstraction.
54 */
@@ -37,12 +36,8 @@
3837 'height' : '100%',
3938 'position' : 'relative'
4039 })
41 - );
42 - // Add a loading spinner if we don't already have one
43 - /*if( $j('#loadingSpinner_' + this.id ).length ){
44 - $j('#smilCanvas_' + this.id ).loadingSpinner();
45 - }*/
46 -
 40+ );
 41+
4742 // Update the embed player
4843 this.getSmil( function( smil ){
4944 // XXX might want to move this into mw.SMIL
@@ -52,10 +47,13 @@
5348 'height': _this.getHeight()
5449 } )
5550 )
56 - });
57 -
 51+ });
5852 },
5953
 54+ /**
 55+ * Get the smil object. If the smil object does not exist create one with the source url:
 56+ * @param callback
 57+ */
6058 getSmil: function( callback ){
6159 if( !this.smil ) {
6260 // Create the Smil engine object
@@ -70,6 +68,9 @@
7169 }
7270 },
7371
 72+ /**
 73+ * Get the duration of smil document.
 74+ */
7475 getDuration: function(){
7576 if( this.smil ){
7677 return this.smil.getDuration();
@@ -85,7 +86,7 @@
8687 },
8788
8889 /**
89 - * update the thumbnail html
 90+ * Update the thumbnail html
9091 */
9192 updateThumbnailHTML: function() {
9293 // If we have a "poster" use that;
Index: branches/MwEmbedStandAlone/modules/SwarmTransport/loader.js
@@ -13,9 +13,9 @@
1414
1515 mw.setDefaultConfig({
1616 /**
17 - * If SwarmTransport should be enabled as a video transport mechanism
 17+ * If SwarmTransport should be enabled by default as video transport mechanism
1818 */
19 - 'enableSwarmTransport': true,
 19+ 'enableSwarmTransport': false,
2020
2121 /**
2222 * If the swarm transport plugin should be recommended if the user does not have it installed.
Index: branches/MwEmbedStandAlone/mwEmbed.js
@@ -2287,6 +2287,7 @@
22882288 if( ! $j( targetObject ).data( 'events' ) ||
22892289 ! $j( targetObject ).data( 'events' )[ triggerName ] ) {
22902290 callback();
 2291+ return ;
22912292 }
22922293 var callbackCount = $j( targetObject ).data( 'events' )[ triggerName ].length;
22932294 if( !callbackCount ){
Index: branches/MwEmbedStandAlone/README
@@ -9,12 +9,12 @@
1010 * All mwEmbed code is Released under the GPL2 as
1111 * a stand alone component of mediaWiki
1212 *
13 -* Libraries used include their licence info in their included path
 13+* Libraries used include their license info in their included path
1414 *
1515 * Copyright (C) 2007 - 2010 Kaltura, Wikimedia Foundation
1616 *
1717 * Sub modules and libraries carry specific copyright while the
18 -* the entire package is always reasleasable under the GPL 2
 18+* the entire package is always releasable under the GPL 2
1919 *
2020 * Author Michael Dale <mdale@wikimedia.org>,
2121 * and many others.
Index: branches/MwEmbedStandAlone/jsScriptLoader.php
@@ -60,6 +60,9 @@
6161 // The includeAllModuleMessages string regular expression
6262 private static $includeAllMsgsRegEx = "/mw\.includeAllModuleMessages\s*\(\s*\)\;?/";
6363
 64+ //Temporary store for message js
 65+ private static $addMessageJs = '';
 66+
6467 /**
6568 * Output the javascript from cache
6669 *
@@ -98,7 +101,7 @@
99102 try {
100103 jsClassLoader::loadClassPaths();
101104 } catch( Exception $e ) {
102 - $this->errorMsg .= $e->getMessage() ;
 105+ $this->errorMsg .= $e->getMessage() ;
103106 }
104107
105108 // Reset the requestKey:
@@ -148,15 +151,15 @@
149152 // Output the current language class js
150153 $this->output .= jsClassLoader::getLanguageJs( $this->langCode );
151154
152 - // Add the required core mwEmbed style sheets Commted out
153 - // because when creating stand alone packages js package with css
154 - // the paths get messed up.
155 - /*
 155+ // Add the required core mwEmbed style sheets Commted out
 156+ // because when creating stand alone packages js package with css
 157+ // the paths get messed up.
 158+ /*
156159 if( !isset( $this->namedFileList[ 'mw.style.mwCommon' ] ) ) {
157160 $this->output .= $this->getScriptText( 'mw.style.mwCommon' );
158161 }
159162 */
160 -
 163+
161164 // Output "special" IE comment tag to support "special" mwEmbed tags.
162165 $this->notMinifiedTopOutput .='/*@cc_on@if(@_jscript_version<9){\'video audio source itext playlist\'.replace(/\w+/g,function(n){document.createElement(n)})}@end@*/'."\n";
163166 }
@@ -725,7 +728,7 @@
726729 try {
727730 jsClassLoader::loadClassPaths();
728731 } catch( Exception $e ) {
729 - $this->errorMsg .= $e->getMessage() ;
 732+ $this->errorMsg .= $e->getMessage() ;
730733 }
731734
732735 if ( isset( $wgScriptLoaderNamedPaths[ $reqClass ] ) ) {
@@ -813,13 +816,23 @@
814817
815818 // Do language swap by index:
816819 if ( $wgEnableScriptLocalization ){
817 - // Get the mw.addMessage javascript from scriptText and moduleName
818 - $addMessageJs = $this->getAddMessagesFromScriptText( $scriptText , $moduleName);
819820 //@@NOTE getAddMessagesFromClass could identify which mode we are in and we would not need to
820821 // try each of these search patterns in the same order as before.
821822
 823+ // Get the mw.addMessage javascript
 824+ self::$addMessageJs = $this->getAddMessagesFromScriptText( $scriptText , $moduleName);
 825+
822826 // Check for mw.includeAllModuleMsgs() call to be replaced with all the msgs
823 - $scriptText = preg_replace( self::$includeAllMsgsRegEx, $addMessageJs, $scriptText, 1, $count );
 827+ // Use preg_replace_callback to avoid back-refrence substitution
 828+ $scriptText = preg_replace_callback(
 829+ self::$includeAllMsgsRegEx,
 830+ 'jsScriptLoader::preg_addMessageJs',
 831+ $scriptText,
 832+ 1,
 833+ $count
 834+ );
 835+
 836+
824837 if( $count != 0 ){
825838 return $scriptText;
826839 }
@@ -828,21 +841,23 @@
829842 $inx = self::getAddMessagesIndex( $scriptText );
830843 if( $inx ){
831844 // Return the final string (without double {})
832 - return substr($scriptText, 0, $inx['sfull']) . $addMessageJs . substr($scriptText, $inx['efull']);
 845+ return substr($scriptText, 0, $inx['sfull']) . self::$addMessageJs . substr($scriptText, $inx['efull']);
833846 }
834847
835848 // Replace mw.addMessageKeys with localized msgs in javascript string
836849 $inx = self::getAddMessageKeyIndex( $scriptText );
837850 if( $inx ) {
838851 // Return the final string (without double {})
839 - return substr( $scriptText, 0, $inx['sfull'] ). $addMessageJs . substr($scriptText, $inx['efull']);
 852+ return substr( $scriptText, 0, $inx['sfull'] ). self::$addMessageJs . substr($scriptText, $inx['efull']);
840853 }
841854 }
842855 // Return the javascript str unmodified if we did not transform with the localisation
843856 return $scriptText;
844857 }
845 -
846 -
 858+ /* simple function to return addMessageJs without preg_replace back reference substitution */
 859+ private static function preg_addMessageJs(){
 860+ return self::$addMessageJs;
 861+ }
847862 /**
848863 * Get the "addMesseges" function index ( for replacing msg text with localized json )
849864 *

Status & tagging log