r50110 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50109‎ | r50110 | r50111 >
Date:18:47, 1 May 2009
Author:dale
Status:deferred
Tags:
Comment:
mv_embed refactoring to only load videoEmbed code when needed.
* add_media_wizard loads embed code on-demand now...
* .jQueryCheck & .embedVideoCheck replace the loadBaseLibs method so we are better at loading only load what we need.
* updated sequencer to output API link
Modified paths:
  • /trunk/extensions/MetavidWiki/includes/articlepages/MV_SequencePage.php (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/add_media_wizard.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_allpages.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/example_usage/testing_page.php (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/remoteSearchDriver.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libEmbedVideo/mv_baseEmbed.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_search.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_stream.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MetavidWiki/includes/articlepages/MV_SequencePage.php
@@ -81,7 +81,7 @@
8282 $talkTitle = $this->mTitle->getTalkPage();
8383 $metaData = array(
8484 'title' => $this->mTitle->getText(),
85 - 'interface_url' => $wgServer . $wgScript,
 85+ 'interface_url' => str_replace('index.php', 'api.php', $wgServer . $wgScript), //api link (might be a better way to grab that)
8686 'linkback' => $this->mTitle->getFullURL(),
8787 'mTitle' => $this->mTitle->getPrefixedDBKey(),
8888 'mTalk' => $talkTitle->getPrefixedDBKey()
Index: trunk/extensions/MetavidWiki/skins/add_media_wizard.js
@@ -44,7 +44,7 @@
4545 }
4646 if( vidIdList.length > 0){
4747 load_mv_embed( function(){
48 - mvJsLoader.loadBaseLibs(function(){
 48+ mvJsLoader.embedVideoCheck(function(){
4949 //do utilty rewrite of oggHanlder content:
5050 rewrite_for_oggHanlder( vidIdList );
5151 });
@@ -85,7 +85,7 @@
8686 //alert("!!upload hook");
8787 load_mv_embed( function(){
8888 //load jQuery and what not
89 - mvJsLoader.loadBaseLibs(function(){
 89+ mvJsLoader.jQueryCheck(function(){
9090 mvJsLoader.doLoad( {
9191 'mvFirefogg' : 'libAddMedia/mvFirefogg.js',
9292 'mvUploader' : 'libAddMedia/mvUploader.js'
Index: trunk/extensions/MetavidWiki/skins/mv_search.js
@@ -4,7 +4,7 @@
55 var mv_search_action='';
66 function mv_pre_setup_search(req_mode){
77 //make sure we have jQuery and any base required libs:
8 - mvJsLoader.loadBaseLibs(function(){
 8+ mvJsLoader.jQueryCheck(function(){
99 mv_setup_search(req_mode);
1010 });
1111 }
Index: trunk/extensions/MetavidWiki/skins/mv_allpages.js
@@ -18,7 +18,7 @@
1919 function mv_setup_allpage(){
2020 js_log("mv embed done loading now setup 'all page'");
2121 //make sure we have jQuery and any base required libs:
22 - mvJsLoader.loadBaseLibs(function(){
 22+ mvJsLoader.jQueryCheck(function(){
2323 js_log('allpage_ did jquery check');
2424 mvJsLoader.doLoad( {
2525 '$j.fn.autocomplete':'jquery/plugins/jquery.autocomplete.js',
Index: trunk/extensions/MetavidWiki/skins/mv_stream.js
@@ -54,7 +54,7 @@
5555 function mv_load_interface_libs(){
5656 js_log('f:mv_load_interface_libs');
5757 //make sure the mv_embed stuff is loaded
58 - mvJsLoader.loadBaseLibs(function(){
 58+ mvJsLoader.jQueryCheck(function(){
5959 js_log('load stream js');
6060 //load some additional plugins/components:
6161 //:hoverIntent
Index: trunk/extensions/MetavidWiki/skins/mv_embed/example_usage/testing_page.php
@@ -17,7 +17,16 @@
1818 <h3>testing embed</h3>
1919 <table border="1" cellpadding="6" width="600">
2020 <tr>
21 - <td valign="top"><video id="vogg" src="http://tinyvid.tv/file/27wsh8kw4vmwi.ogg"></video></td>
 21+ <td valign="top">
 22+ <video id="embed_vid"
 23+thumbnail="http://metavid.org/wiki/index.php?action=ajax&rs=mv_frame_server&stream_id=501&t=0:01:32&amp;size=400x300"
 24+roe="http://metavid.org/wiki/index.php?title=Special:MvExportStream&stream_name=House_proceeding_01-28-08&feed_format=roe&t=0:01:32/0:03:20"
 25+style="width:400px;height:300px"
 26+controls="true" embed_link="true" >
 27+ <source type="video/x-flv" src="http://mvbox2.cse.ucsc.edu/mvFlvServer.php/house_proceeding_01-28-08.flv?t=0:01:32/0:03:20"></source>
 28+ <source type="video/ogg" src="http://metavidstorage01.ucsc.edu/media/house_proceeding_01-28-08.ogg?t=0:01:32/0:03:20"></source>
 29+</video>
 30+</td>
2231 <td valign="top"><b>Test embed</b><br />
2332 </td>
2433 </tr>
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/remoteSearchDriver.js
@@ -932,23 +932,26 @@
933933 });
934934 }
935935 if( mediaType == 'video' || mediaType == 'audio'){
936 - js_log('append html: ' + rObj.pSobj.getEmbedHTML( rObj, {id:'embed_vid'}) );
937 - $j('#clip_edit_disp').append(
938 - rObj.pSobj.getEmbedHTML( rObj, {id:'embed_vid'})
939 - );
940 - //rewrite by id handldes getting any libs we are missing:
941 - rewrite_by_id('embed_vid',function(){
942 - //grab any information that we got from the ROE xml or parsed from the media file
943 - rObj = rObj.pSobj.getEmbedObjParsedInfo( rObj, 'embed_vid' );
944 - //add the re-sizable to the doLoad request:
945 - clibs['$j.ui.resizable'] ='jquery/jquery.ui-1.5.2/ui/minified/ui.resizable.min.js';
946 - clibs['$j.fn.hoverIntent'] ='jquery/plugins/jquery.hoverIntent.js';
947 - mvJsLoader.doLoad(clibs, function(){
948 - //make sure the rsd_edit_img is hidden:
949 - $j('#rsd_edit_img').hide();
950 - //run the image clip tools
951 - _this.cEdit = new mvClipEdit( mvClipInit );
952 - });
 936+ //make sure we have the embedVideo libs:
 937+ mvJsLoader.embedVideoCheck(function(){
 938+ js_log('append html: ' + rObj.pSobj.getEmbedHTML( rObj, {id:'embed_vid'}) );
 939+ $j('#clip_edit_disp').append(
 940+ rObj.pSobj.getEmbedHTML( rObj, {id:'embed_vid'})
 941+ );
 942+ //rewrite by id handldes getting any libs we are missing:
 943+ rewrite_by_id('embed_vid',function(){
 944+ //grab any information that we got from the ROE xml or parsed from the media file
 945+ rObj = rObj.pSobj.getEmbedObjParsedInfo( rObj, 'embed_vid' );
 946+ //add the re-sizable to the doLoad request:
 947+ clibs['$j.ui.resizable'] ='jquery/jquery.ui-1.5.2/ui/minified/ui.resizable.min.js';
 948+ clibs['$j.fn.hoverIntent'] ='jquery/plugins/jquery.hoverIntent.js';
 949+ mvJsLoader.doLoad(clibs, function(){
 950+ //make sure the rsd_edit_img is hidden:
 951+ $j('#rsd_edit_img').hide();
 952+ //run the image clip tools
 953+ _this.cEdit = new mvClipEdit( mvClipInit );
 954+ });
 955+ });
953956 });
954957 }
955958 },
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js
@@ -143,66 +143,6 @@
144144 mv_get_loading_img('top:30px;left:30px') +
145145 '</div>');
146146 }
147 -//library to load core mv_embed libraries
148 -var mvBaseLoader = {
149 - calledloadBaseLibs:false,
150 - callbacks:new Array(),
151 - done:false,
152 - load:function( callback){
153 - //if we are done loading the libs just jump directly to the callback
154 - if(this.done==true){
155 - callback();
156 - return ;
157 - }
158 - //queue the callback:
159 - if(callback)
160 - mvBaseLoader.addLoadEvent(callback);
161 - //run if not already running:
162 - if( ! mvBaseLoader.calledloadBaseLibs ){
163 - js_log("called loadBaseLibs");
164 - //only call load base libs once
165 - mvBaseLoader.calledloadBaseLibs=true;
166 - //issue a style sheet request can come in whenever:
167 - if(!styleSheetPresent( mv_embed_path + 'skins/'+mv_skin_name+'/styles.css'))
168 - loadExternalCss( mv_embed_path + 'skins/'+mv_skin_name+'/styles.css');
169 -
170 - //two loading stages, first get jQuery
171 - var _this = this;
172 - mvJsLoader.doLoad({
173 - 'window.jQuery' :'jquery/jquery-1.2.6.js'
174 - },function(){
175 - //once jQuery is loaded set up no conflict & load plugins:
176 - _global['$j'] = jQuery.noConflict();
177 - //set up ajax to not send dynamic urls for loading scripts
178 - $j.ajaxSetup({
179 - cache: true
180 - });
181 - js_log('jquery loaded');
182 - //load the jQuery dependent plugins:
183 - mvJsLoader.doLoad({
184 - 'embedVideo' : 'libEmbedVideo/mv_baseEmbed.js',
185 - '$j.ui.mouse' : 'jquery/jquery.ui-1.5.2/ui/minified/ui.core.min.js',
186 - '$j.ui.droppable' : 'jquery/jquery.ui-1.5.2/ui/minified/ui.droppable.min.js',
187 - '$j.ui.draggable' : 'jquery/jquery.ui-1.5.2/ui/minified/ui.draggable.min.js'
188 - },function(){
189 - js_log('plugins loaded: ');
190 - mvBaseLoader.done = true;
191 - // run queued functions from (addLoadEvent)
192 - mvBaseLoader.runQuededFunctions();
193 - });
194 - });
195 - }
196 - },
197 - runQuededFunctions:function(){
198 - js_log('runQuededFunctions::');
199 - while( mvBaseLoader.callbacks.length ){
200 - mvBaseLoader.callbacks.shift()();
201 - }
202 - },
203 - addLoadEvent:function(fn){
204 - mvBaseLoader.callbacks.push(fn);
205 - }
206 -}
207147
208148 /**
209149 * mvJsLoader class handles initialization and js file loads
@@ -210,6 +150,8 @@
211151 var mvJsLoader = {
212152 libreq:{},
213153 libs:{},
 154+ //base lib flags:
 155+ onReadyEvents:new Array(),
214156 //to keep consistency across threads:
215157 ptime:0,
216158 ctime:0,
@@ -319,9 +261,51 @@
320262 this.cur_path = cur_path;
321263 return true;
322264 },
323 - loadBaseLibs:function( callback ){
324 - mvBaseLoader.load( callback);
325 - }
 265+ /**
 266+ * checks for jQuery and adds the $j noConflict var
 267+ */
 268+ jQueryCheck:function(callback){
 269+ var _this = this;
 270+ _this.doLoad({
 271+ 'window.jQuery' :'jquery/jquery-1.2.6.js'
 272+ },function(){
 273+ _global['$j'] = jQuery.noConflict();
 274+ //set up ajax to not send dynamic urls for loading scripts (we control that with the scriptLoader)
 275+ $j.ajaxSetup({
 276+ cache: true
 277+ });
 278+ js_log('jquery loaded');
 279+ //run the callback
 280+ callback();
 281+ });
 282+ },
 283+ embedVideoCheck:function( callback ){
 284+ var _this = this;
 285+ //issue a style sheet request (no load checks on style sheets):
 286+ if(!styleSheetPresent( mv_embed_path + 'skins/'+mv_skin_name+'/styles.css'))
 287+ loadExternalCss( mv_embed_path + 'skins/'+mv_skin_name+'/styles.css');
 288+ //make sure we have jQuery
 289+ _this.jQueryCheck(function(){
 290+ _this.doLoad({
 291+ 'embedVideo' : 'libEmbedVideo/mv_baseEmbed.js',
 292+ '$j.ui.mouse' : 'jquery/jquery.ui-1.5.2/ui/minified/ui.core.min.js',
 293+ '$j.ui.droppable' : 'jquery/jquery.ui-1.5.2/ui/minified/ui.droppable.min.js',
 294+ '$j.ui.draggable' : 'jquery/jquery.ui-1.5.2/ui/minified/ui.draggable.min.js'
 295+ },function(){
 296+ js_log('embedVideo libs ready run callback:: ');
 297+ callback();
 298+ });
 299+ });
 300+ },
 301+ addLoadEvent:function(fn){
 302+ this.onReadyEvents.push(fn);
 303+ },
 304+ runQuededFunctions:function(){
 305+ js_log('runQuededFunctions:: onReadyEvents');
 306+ while( this.onReadyEvents.length ){
 307+ this.onReadyEvents.shift()();
 308+ }
 309+ }
326310 }
327311
328312
@@ -369,7 +353,7 @@
370354 document.getElementsByTagName("playlist").length!=0){
371355 js_log('we have vids to process');
372356 //load libs and proccess:
373 - mvJsLoader.loadBaseLibs(function(){
 357+ mvJsLoader.embedVideoCheck(function(){
374358 //run any queded global events:
375359 mv_embed( function(){
376360 while(mvLoadEvent.length){
@@ -390,7 +374,7 @@
391375 function rewrite_by_id( vid_id, ready_callback ){
392376 js_log('f:rewrite_by_id: ' + vid_id);
393377 //force a recheck of the dom for playlist or video element:
394 - mvJsLoader.loadBaseLibs(function(){
 378+ mvJsLoader.embedVideoCheck(function(){
395379 mv_embed(ready_callback, vid_id );
396380 });
397381 }
@@ -546,7 +530,7 @@
547531 if(method=='style'){
548532 embed_video.setAttribute('style', videoInterface[method]);
549533 }else if(method=='class'){
550 - if(embedTypes.msie)
 534+ if( $j.browser.msie )
551535 embed_video.setAttribute("className", videoInterface['class']);
552536 else
553537 embed_video.setAttribute("class", videoInterface['class']);
@@ -603,8 +587,13 @@
604588 /* init remote search */
605589 function mv_do_remote_search(initObj){
606590 js_log(':::::mv_do_remote_search::::');
 591+
 592+ //issue a load skin request:
 593+ if(!styleSheetPresent( mv_embed_path + 'skins/'+mv_skin_name+'/styles.css'))
 594+ loadExternalCss( mv_embed_path + 'skins/'+mv_skin_name+'/styles.css');
 595+
607596 //insure we have the basic libs (jquery etc) :
608 - mvJsLoader.loadBaseLibs(function(){
 597+ mvJsLoader.jQueryCheck(function(){
609598 //load search specifc extra stuff
610599 mvJsLoader.doLoad({
611600 'remoteSearchDriver':'libAddMedia/remoteSearchDriver.js'
@@ -623,7 +612,7 @@
624613 if(!styleSheetPresent(mv_embed_path+'skins/'+mv_skin_name+'/mv_sequence.css'))
625614 loadExternalCss(mv_embed_path+'skins/'+mv_skin_name+'/mv_sequence.css');
626615 //make sure we have the required mv_embed libs (they are not loaded when no video element is on the page)
627 - mvJsLoader.loadBaseLibs(function(){
 616+ mvJsLoader.embedVideoCheck(function(){
628617 //load playlist object and drag,drop,resize,hoverintent,libs
629618 mvJsLoader.doLoad({
630619 'mvPlayList':'libSequencer/mvPlayList.js',
@@ -722,6 +711,7 @@
723712 }
724713
725714 //addLoadEvent for adding functions to be run when the page DOM is done loading
 715+//@@todo depricate in favor of:
726716 function mv_addLoadEvent(func) {
727717 mvLoadEvent.push(func);
728718 }
@@ -858,7 +848,7 @@
859849 //js_log('load string:'+"\n"+ response['pay_load']);
860850 //debugger;
861851 //attempt to parse as xml for IE
862 - if( embedTypes.msie ){
 852+ if( $j.browser.msie ){
863853 var xmldata=new ActiveXObject("Microsoft.XMLDOM");
864854 xmldata.async="false";
865855 xmldata.loadXML(response['pay_load']);
@@ -1035,7 +1025,7 @@
10361026 log_elm.value+=string+"\n";
10371027 }*/
10381028 }
1039 - //return false;
 1029+ return false;
10401030 }
10411031
10421032 function js_error(string){
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libEmbedVideo/mv_baseEmbed.js
@@ -2365,13 +2365,15 @@
23662366 {
23672367 //do another test for safari:
23682368 if( this.safari ){
2369 - var dummyvid = document.createElement("video");
2370 - if (dummyvid.canPlayType("video/ogg;codecs=\"theora,vorbis\"") == "probably")
2371 - {
2372 - this.players.addPlayer( videoElementPlayer );
2373 - } else {
2374 - /* could add some user nagging to install the xiph qt */
2375 - }
 2369+ /*var dummyvid = document.createElement("video");
 2370+ try{
 2371+ if (dummyvid.canPlayType("video/ogg;codecs=\"theora,vorbis\"") == "probably")
 2372+ {
 2373+ this.players.addPlayer( videoElementPlayer );
 2374+ } else {
 2375+ could add some user nagging to install the xiph qt
 2376+ }
 2377+ }*/
23762378 }else{
23772379 this.players.addPlayer( videoElementPlayer );
23782380 }

Status & tagging log