r59779 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59778‎ | r59779 | r59780 >
Date:08:38, 7 December 2009
Author:dale
Status:deferred (Comments)
Tags:
Comment:
== Major refactor ==
Much remains to be tested, incomplete commit msg:

* Global renamed of mv_embed to mwEmbed

* Lazy loading of JS classes for script-loader
- removed include JS classes init from Setup.php

* Renamed core mwEmbed functions into global mw scope:
loadGM() -> mw.addMessages()
mvJsLoader.doLoad() -> mw.load()
js2AddOnloadHook() -> mw.addOnloadHook()

* New mw.load system
** Unified mw.load entry point
** Module based loaders
** Basic file support

* New mwEmbed Configuration system
* mw.conf -> mw.getConfig( 'configKey' )
* new configuration options:
** alwaysSetupMwEmbed: false
** rewriteTags: 'video,audio,playlist'

* Shifted globals to mw getters:
mv_embed_path -> mw.getMwEmbedPath()

* Renamed embedVideo to embedPlayer
* Added embedPlayer jQuery bindings
* Removed rewrite_by_id global

* Added standard code comments for dozens of functions

* made UploadBase::getRealPath into static method
Modified paths:
  • /branches/js2-work/phase3/includes/DefaultSettings.php (modified) (history)
  • /branches/js2-work/phase3/includes/OutputPage.php (modified) (history)
  • /branches/js2-work/phase3/includes/Setup.php (modified) (history)
  • /branches/js2-work/phase3/includes/upload/UploadFromChunks.php (modified) (history)
  • /branches/js2-work/phase3/js2/ajaxcategories.js (modified) (history)
  • /branches/js2-work/phase3/js2/apiProxyPage.js (modified) (history)
  • /branches/js2-work/phase3/js2/editPage.js (modified) (history)
  • /branches/js2-work/phase3/js2/js2stopgap.js (modified) (history)
  • /branches/js2-work/phase3/js2/js2stopgap.min.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/example_usage/Add_Media_Wizard.html (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/example_usage/Firefogg_Make_Advanced.html (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/example_usage/Multi_Upload.html (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/example_usage/Player_Audio.html (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/example_usage/Player_RelatedVideos.html (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/example_usage/Player_Themable.html (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/example_usage/Player_Timed_Text.html (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/example_usage/Sequence_Editor.html (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/example_usage/Sequence_Render.html (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/jsScriptLoader.php (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libAddMedia/dragDropFile.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libAddMedia/mvAdvFirefogg.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libAddMedia/mvFirefogg.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libAddMedia/remoteSearchDriver.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libAddMedia/simpleUploadForm.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libClipEdit/mvClipEdit.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/embedPlayer.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/flowplayerEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/javaEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/kplayerEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/nativeEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/omtkEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libMwApi/mw.proxy.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libSequencer/mvPlayList.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libSequencer/mvSequencer.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libSequencer/mvTimedEffectsEdit.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libTimedText/mvTextInterface.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libTimedText/mvTimeTextEdit.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/mv_embed.js (deleted) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/mwEmbed.js (added) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/php/jsAutoloadLocalClasses.php (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/php/languages/mwEmbed.i18n.php (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/php/maintenance/mergeJavascriptMsg.php (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/php/noMediaWikiConfig.php (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/skins/ctrlBuilder.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/skins/kskin/kskin.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/tests/testApiProxy.html (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/tests/testLang.html (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/tests/testLang.js (modified) (history)
  • /branches/js2-work/phase3/js2/remoteMwEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js2/uploadPage.js (modified) (history)
  • /branches/js2-work/phase3/skins/common/preview.js (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/skins/common/preview.js
@@ -55,4 +55,4 @@
5656 } );
5757 }
5858
59 -js2AddOnloadHook( setupLivePreview );
 59+mw.addOnloadHook( setupLivePreview );
Index: branches/js2-work/phase3/includes/OutputPage.php
@@ -16,6 +16,9 @@
1717
1818 var $mScriptLoaderClassList = array();
1919
 20+ //Flag if we have initialised javascript Classes
 21+ var $mLoadedJavascriptClasses = false;
 22+
2023 var $mScripts = '', $mLinkColours, $mPageLinkTitle = '', $mHeadItems = array();
2124 var $mInlineMsg = array();
2225
@@ -175,10 +178,10 @@
176179 function addCoreScripts2Top(){
177180 global $wgEnableScriptLoader, $wgJSAutoloadLocalClasses, $wgScriptPath, $wgEnableJS2system;
178181 global $wgUser, $wgJsMimeType;
179 - // @todo We should deprecate wikibits in favor of some mv_embed pieces and jQuery
 182+ // @todo We should deprecate wikibits in favor of some mwEmbed pieces and jQuery
180183
181184 if( $wgEnableJS2system ){
182 - $core_classes = array( 'window.jQuery', 'mv_embed', 'wikibits' );
 185+ $core_classes = array( 'window.jQuery', 'mwEmbed', 'wikibits' );
183186 } else {
184187 $core_classes = array( 'wikibits' );
185188 }
@@ -205,9 +208,18 @@
206209 * @return boolean False if the class wasn't found, true on success
207210 */
208211 function addScriptClass( $js_class ){
209 - global $wgDebugJavaScript, $wgJSAutoloadLocalClasses, $wgJSAutoloadClasses,
 212+ global $wgDebugJavaScript, $wgJSAutoloadLocalClasses, $wgJSAutoloadClasses, $IP,
210213 $wgEnableScriptLoader, $wgStyleVersion, $wgScriptPath, $wgStylePath, $wgEnableJS2system;
211214
 215+ // Load the javascript script class paths
 216+ if( ! $this->mLoadedJavascriptClasses ){
 217+ require_once("$IP/js2/mwEmbed/php/jsAutoloadLocalClasses.php");
 218+ // Issue the load request:
 219+ wfLoadMwEmbedClassPaths();
 220+ // Set the flag to true
 221+ $this->mLoadedJavascriptClasses = true;
 222+ }
 223+
212224 $path = jsScriptLoader::getJsPathFromClass( $js_class );
213225 if( $path !== false ){
214226 if( $wgEnableScriptLoader ) {
@@ -228,7 +240,7 @@
229241 }
230242 $this->addScript( Html::linkedScript( $path . "?" . $this->getURIDparam( $js_class ) ) );
231243
232 - // Merge in language text (if js2 is on and we have loadGM function & scriptLoader is "off")
 244+ // Merge in language text (if js2 is on and we have mw.addMessages function & scriptLoader is "off")
233245 if( $wgEnableJS2system ){
234246 if( !$this->mScriptLoader )
235247 $this->mScriptLoader = new jsScriptLoader();
Index: branches/js2-work/phase3/includes/DefaultSettings.php
@@ -921,7 +921,7 @@
922922 $wgHtml5Version = null;
923923
924924 /**
925 - * Enabled RDFa attributes for use in wikitext.
 925+ * Enabled RDFa attributes for use in wikitext.
926926 * NOTE: Interaction with HTML5 is somewhat underspecified.
927927 */
928928 $wgAllowRdfaAttributes = true;
@@ -2831,7 +2831,7 @@
28322832
28332833 /*
28342834 * enable js2 Script System
2835 - * if enabled we include jquery, mv_embed and js2 versions of editPage.js
 2835+ * if enabled we include jquery, mwEmbed and js2 versions of editPage.js
28362836 */
28372837 $wgEnableJS2system = false;
28382838
@@ -2841,7 +2841,7 @@
28422842 $wgEnableIframeApiProxy = false;
28432843
28442844 /*
2845 - * boolean; if we should enable javascript localization (it loads loadGM json
 2845+ * boolean; if we should enable javascript localization (it loads mw.addMessages json
28462846 * call with mediaWiki msgs)
28472847 */
28482848 $wgEnableScriptLocalization = true;
Index: branches/js2-work/phase3/includes/upload/UploadFromChunks.php
@@ -92,7 +92,7 @@
9393 // first append last chunk (so we can do a real verifyFile check... (check file type etc)
9494 $status = $this->doChunkAppend();
9595 if( $status->isOK() ){
96 - $this->mTempPath = $this->getRealPath( $this->mTempAppendPath );
 96+ $this->mTempPath = UploadBase::getRealPath( $this->mTempAppendPath );
9797 // verify the completed merged chunks as if it was the file that got uploaded:
9898 return parent::verifyFile( $this->mTempPath );
9999 } else {
@@ -172,7 +172,7 @@
173173 ob_clean();
174174 echo FormatJson::encode( array(
175175 'result' => 1,
176 - 'filesize' => filesize( $this->getRealPath( $this->mTempAppendPath ) )
 176+ 'filesize' => filesize( UploadBase::getRealPath( $this->mTempAppendPath ) )
177177 )
178178 );
179179 exit( 0 );
@@ -227,13 +227,13 @@
228228 }
229229 return $status;
230230 } else {
231 - if( is_file( $this->getRealPath( $this->mTempAppendPath ) ) ){
 231+ if( is_file( UploadBase::getRealPath( $this->mTempAppendPath ) ) ){
232232 $status = $this->appendToUploadFile( $this->mTempAppendPath, $this->mTempPath );
233233 } else {
234234 $status = Status::newFatal( 'filenotfound', $this->mTempAppendPath );
235235 }
236236 //check to make sure we have not expanded beyond $wgMaxUploadSize
237 - if( filesize( $this->getRealPath( $this->mTempAppendPath ) ) > $wgMaxUploadSize )
 237+ if( filesize( UploadBase::getRealPath( $this->mTempAppendPath ) ) > $wgMaxUploadSize )
238238 $status = Status::newFatal( 'largefileserver' );
239239
240240 return $status;
Index: branches/js2-work/phase3/includes/Setup.php
@@ -343,11 +343,6 @@
344344 #
345345 $wgExtensionMessagesFiles['mwEmbed'] = "{$IP}/js2/mwEmbed/php/languages/mwEmbed.i18n.php";
346346
347 -# Include the js2/mwEmbed autoLoadClasses if js2 is enabled
348 -if( $wgEnableJS2system ){
349 - require_once("$IP/js2/mwEmbed/php/jsAutoloadLocalClasses.php");
350 -}
351 -
352347 # Extension setup functions for extensions other than skins
353348 # Entries should be added to this variable during the inclusion
354349 # of the extension file. This allows the extension to perform
Index: branches/js2-work/phase3/js2/uploadPage.js
@@ -138,6 +138,6 @@
139139 }
140140
141141
142 -js2AddOnloadHook( function() {
 142+mw.addOnloadHook( function() {
143143 mwUploadHelper.init();
144144 } );
\ No newline at end of file
Index: branches/js2-work/phase3/js2/editPage.js
@@ -20,8 +20,8 @@
2121 'local_wiki_api_url': wgServer + wgScriptPath + '/api.php'
2222 };
2323
24 -js2AddOnloadHook( function() {
25 - js_log( "edit page js2AddOnloadHook::" );
 24+mw.addOnloadHook( function() {
 25+ js_log( "edit page mw.addOnloadHook::" );
2626 var amwConf = $j.extend( true, defaultAddMediaConfig, mwAddMediaConfig );
2727 // kind of tricky, it would be nice to use run on ready "loader" call here
2828 var didWikiEditorBind = false;
Index: branches/js2-work/phase3/js2/mwEmbed/mv_embed.js
@@ -1,2144 +0,0 @@
2 -/*
3 - * ~mv_embed ~
4 - * For details see: http://metavid.org/wiki/index.php/Mv_embed
5 - *
6 - * All Metavid Wiki code is released under the GPL2.
7 - * For more information visit http://metavid.org/wiki/Code
8 - *
9 - * @url http://metavid.org
10 - *
11 - * mw.parseUri:
12 - * http://stevenlevithan.com/demo/parseuri/js/
13 - *
14 - * Config values: you can manually set the location of the mv_embed folder here
15 - * (in cases where media will be hosted in a different place than the embedding page)
16 - *
17 - */
18 -
19 -/**
20 - * AutoLoader paths
21 - * @path The path to the file (or set of files) with ending slash
22 - * @gClasses The set of classes
23 - * if it's an array, $j.className becomes jquery.className.js
24 - * if it's an associative object then key => value pairs are used
25 - */
26 -if ( typeof mvAutoLoadClasses == 'undefined' )
27 - mvAutoLoadClasses = { };
28 -
29 -// The script that loads the class set
30 -function lcPaths( classSet ) {
31 - for ( var i in classSet ) {
32 - mvAutoLoadClasses[i] = classSet[i];
33 - }
34 -}
35 -
36 -function mvGetClassPath( k ) {
37 - if ( mvAutoLoadClasses[k] ) {
38 - // js_log('got class path:' + k + ' : '+ mvClassPaths[k]);
39 - return mvAutoLoadClasses[k];
40 - } else {
41 - js_log( 'Error:: Could not find path for requested class ' + k );
42 - return false;
43 - }
44 -}
45 -
46 -if ( typeof mvCssPaths == 'undefined' )
47 - mvCssPaths = { };
48 -
49 -function lcCssPath( cssSet ) {
50 - for ( var i in cssSet ) {
51 - mvCssPaths[i] = cssSet[i];
52 - }
53 -}
54 -
55 -/*
56 - * -- Load Class Paths --
57 - *
58 - * MUST BE VALID JSON (NOT JS)
59 - * This is used by the script loader to auto-load classes (so we only define
60 - * this once for PHP & JavaScript)
61 - *
62 - * Right now the PHP AutoLoader only reads this mv_embed.js file.
63 - * In the future we could have multiple lcPath calls that PHP reads
64 - * (if our autoloading class list becomes too long)
65 - * or
66 - * we could support direct file requests to the script loader instead
67 - * of shared class names read from a central location.
68 - */
69 -lcPaths( {
70 - "mv_embed" : "mv_embed.js",
71 - "window.jQuery" : "jquery/jquery-1.3.2.js",
72 - "$j.fn.pngFix" : "jquery/plugins/jquery.pngFix.js",
73 - "$j.fn.autocomplete": "jquery/plugins/jquery.autocomplete.js",
74 - "$j.fn.hoverIntent" : "jquery/plugins/jquery.hoverIntent.js",
75 - "$j.fn.datePicker" : "jquery/plugins/jquery.datePicker.js",
76 - "$j.ui" : "jquery/jquery.ui/ui/ui.core.js",
77 - "$j.fn.ColorPicker" : "libClipEdit/colorpicker/js/colorpicker.js",
78 - "$j.Jcrop" : "libClipEdit/Jcrop/js/jquery.Jcrop.js",
79 - "$j.fn.simpleUploadForm" : "libAddMedia/simpleUploadForm.js",
80 -
81 - "mw.proxy" : "libMwApi/mw.proxy.js",
82 -
83 - "mw.testLang" : "tests/testLang.js",
84 -
85 - "ctrlBuilder" : "skins/ctrlBuilder.js",
86 - "kskinConfig" : "skins/kskin/kskin.js",
87 - "mvpcfConfig" : "skins/mvpcf/mvpcf.js",
88 -
89 - "JSON" : "libMwApi/json2.js",
90 - "$j.cookie" : "jquery/plugins/jquery.cookie.js",
91 - "$j.contextMenu" : "jquery/plugins/jquery.contextMenu.js",
92 - "$j.fn.suggestions" : "jquery/plugins/jquery.suggestions.js",
93 - "$j.fn.textSelection" : "jquery/plugins/jquery.textSelection.js",
94 -
95 - "$j.effects.blind" : "jquery/jquery.ui/ui/effects.blind.js",
96 - "$j.effects.drop" : "jquery/jquery.ui/ui/effects.drop.js",
97 - "$j.effects.pulsate" : "jquery/jquery.ui/ui/effects.pulsate.js",
98 - "$j.effects.transfer" : "jquery/jquery.ui/ui/effects.transfer.js",
99 - "$j.ui.droppable" : "jquery/jquery.ui/ui/ui.droppable.js",
100 - "$j.ui.slider" : "jquery/jquery.ui/ui/ui.slider.js",
101 - "$j.effects.bounce" : "jquery/jquery.ui/ui/effects.bounce.js",
102 - "$j.effects.explode" : "jquery/jquery.ui/ui/effects.explode.js",
103 - "$j.effects.scale" : "jquery/jquery.ui/ui/effects.scale.js",
104 - "$j.ui.datepicker" : "jquery/jquery.ui/ui/ui.datepicker.js",
105 - "$j.ui.progressbar" : "jquery/jquery.ui/ui/ui.progressbar.js",
106 - "$j.ui.sortable" : "jquery/jquery.ui/ui/ui.sortable.js",
107 - "$j.effects.clip" : "jquery/jquery.ui/ui/effects.clip.js",
108 - "$j.effects.fold" : "jquery/jquery.ui/ui/effects.fold.js",
109 - "$j.effects.shake" : "jquery/jquery.ui/ui/effects.shake.js",
110 - "$j.ui.dialog" : "jquery/jquery.ui/ui/ui.dialog.js",
111 - "$j.ui.resizable" : "jquery/jquery.ui/ui/ui.resizable.js",
112 - "$j.ui.tabs" : "jquery/jquery.ui/ui/ui.tabs.js",
113 - "$j.effects.core" : "jquery/jquery.ui/ui/effects.core.js",
114 - "$j.effects.highlight" : "jquery/jquery.ui/ui/effects.highlight.js",
115 - "$j.effects.slide" : "jquery/jquery.ui/ui/effects.slide.js",
116 - "$j.ui.accordion" : "jquery/jquery.ui/ui/ui.accordion.js",
117 - "$j.ui.draggable" : "jquery/jquery.ui/ui/ui.draggable.js",
118 - "$j.ui.selectable" : "jquery/jquery.ui/ui/ui.selectable.js",
119 -
120 - "$j.fn.dragDropFile" : "libAddMedia/dragDropFile.js",
121 - "mvFirefogg" : "libAddMedia/mvFirefogg.js",
122 - "mvAdvFirefogg" : "libAddMedia/mvAdvFirefogg.js",
123 - "mvBaseUploadInterface" : "libAddMedia/mvBaseUploadInterface.js",
124 - "remoteSearchDriver" : "libAddMedia/remoteSearchDriver.js",
125 - "seqRemoteSearchDriver" : "libSequencer/seqRemoteSearchDriver.js",
126 -
127 - "baseRemoteSearch" : "libAddMedia/searchLibs/baseRemoteSearch.js",
128 - "mediaWikiSearch" : "libAddMedia/searchLibs/mediaWikiSearch.js",
129 - "metavidSearch" : "libAddMedia/searchLibs/metavidSearch.js",
130 - "archiveOrgSearch" : "libAddMedia/searchLibs/archiveOrgSearch.js",
131 - "flickrSearch" : "libAddMedia/searchLibs/flickrSearch.js",
132 - "baseRemoteSearch" : "libAddMedia/searchLibs/baseRemoteSearch.js",
133 -
134 - "mvClipEdit" : "libClipEdit/mvClipEdit.js",
135 -
136 - "embedPlayer" : "libEmbedPlayer/embedPlayer.js",
137 - "flowplayerEmbed" : "libEmbedPlayer/flowplayerEmbed.js",
138 - "kplayerEmbed" : "libEmbedPlayer/kplayerEmbed.js",
139 - "genericEmbed" : "libEmbedPlayer/genericEmbed.js",
140 - "htmlEmbed" : "libEmbedPlayer/htmlEmbed.js",
141 - "javaEmbed" : "libEmbedPlayer/javaEmbed.js",
142 - "nativeEmbed" : "libEmbedPlayer/nativeEmbed.js",
143 - "quicktimeEmbed" : "libEmbedPlayer/quicktimeEmbed.js",
144 - "vlcEmbed" : "libEmbedPlayer/vlcEmbed.js",
145 -
146 - "mvPlayList" : "libSequencer/mvPlayList.js",
147 - "mvSequencer" : "libSequencer/mvSequencer.js",
148 - "mvFirefoggRender" : "libSequencer/mvFirefoggRender.js",
149 - "mvTimedEffectsEdit": "libSequencer/mvTimedEffectsEdit.js",
150 -
151 - "mvTextInterface" : "libTimedText/mvTextInterface.js",
152 - "mvTimeTextEdit" : "libTimedText/mvTimeTextEdit.js"
153 -} );
154 -
155 -// Dependency mapping for CSS files for self-contained included plugins:
156 -lcCssPath( {
157 - '$j.Jcrop' : 'libClipEdit/Jcrop/css/jquery.Jcrop.css',
158 - '$j.fn.ColorPicker' : 'libClipEdit/colorpicker/css/colorpicker.css'
159 -})
160 -
161 -// For use when mv_embed with script-loader is in the root MediaWiki path
162 -var mediaWiki_mvEmbed_path = 'js2/mwEmbed/';
163 -
164 -// The global scope: will be depreciated once we get everything into mw
165 -var _global = this;
166 -
167 -/*
168 -* setup the empty global mw object
169 -* will ensure all our functions and variables are properly namespaced
170 -* reducing chance of conflicts
171 -*/
172 -if ( !window['mw'] ) {
173 - window['mw'] = { }
174 -}
175 -
176 -
177 -// Inherit the default global config
178 -var mwDefaultConf = {
179 - 'skin_name' : 'mvpcf',
180 - 'jui_skin' : 'redmond',
181 - 'video_size' : '400x300',
182 - 'k_attribution' : true
183 -}
184 -if( !mw.conf )
185 - mw.conf = { }
186 -
187 -for(var i in mwDefaultConf){
188 - if( typeof mw.conf[ i ] == 'undefined' )
189 - mw.conf[ i ] = mwDefaultConf[ i ];
190 -}
191 -
192 -
193 -// @@todo move these into mw
194 -var global_req_cb = new Array(); // The global request callback array
195 -
196 -/**
197 -* The global mw object:
198 -*
199 -* Any global functions/classes that are not jQuery plugins should make
200 -* there way into the mw namespace
201 -*/
202 -( function( $ ) {
203 - // list valid skins here:
204 - $.valid_skins = ['mvpcf', 'kskin'];
205 - // the version of mwEmbed
206 - $.version = '1.0r21';
207 -
208 - // special case of commons api url
209 - // (used for default subtitles server for media with a "wikiTitleKey" atm)
210 - // (@@todo eventually we should have wikiTitleKey be namespaced with interwiki ns
211 - $.commons_api_url = 'http://commons.wikimedia.org/w/api.php';
212 - /*
213 - * some global containers flags
214 - */
215 - $.skin_list = new Array();
216 - $.init_done = false;
217 - $.cb_count = 0;
218 - $.player_list = new Array(), // The global player list per page
219 - $.req_cb = new Array() // The global request callback array
220 -
221 - /*
222 - * Language classes mw.lang
223 - *
224 - * Localized Language support attempts to mirror the functionality of Language.php in MediaWiki
225 - * It contains methods for loading and transforming msg text
226 - *
227 - */
228 - $.lang = { };
229 - /**
230 - * Setup the lang object
231 - */
232 - var gMsg = { };
233 - var gRuleSet = { };
234 -
235 - /**
236 - * loadGM function
237 - * Loads a set of json messages into the lng object.
238 - *
239 - * @param json msgSet The set of msgs to be loaded
240 - */
241 - $.lang.loadGM = function( msgSet ) {
242 - for ( var i in msgSet ) {
243 - gMsg[ i ] = msgSet[i];
244 - }
245 - }
246 -
247 - /**
248 - * loadRS function
249 - * Loads a ruleset by given template key ie PLURAL : { //ruleSetObj }
250 - *
251 - * @param json ruleSet The ruleset object ( extends gRuleSet )
252 - */
253 - $.lang.loadRS = function( ruleSet ) {
254 - for ( var i in ruleSet ) {
255 - gRuleSet[ i ] = ruleSet[ i ];
256 - }
257 - }
258 -
259 - /**
260 - * Returns a transformed msg string
261 - *
262 - * it take a msg key and array of replacement values of form
263 - * $1, $2 and does relevant msgkey transformation returning
264 - * the user msg.
265 - *
266 - * @param string key The msg key as set by loadGm
267 - * @param [mixed] args An array of replacement strings
268 - * @return string
269 - */
270 - $.lang.gM = function( key , args ) {
271 - if ( ! gMsg[ key ] )
272 - return '<' + key + '>';// Missing key placeholder
273 -
274 - // swap in the arg values
275 - var ms = $.lang.gMsgSwap( key, args );
276 -
277 - // a quick check to see if we need to send the msg via the 'parser'
278 - // (we can add more detailed check once we support more wiki syntax)
279 - if ( ms.indexOf( '{{' ) === -1 && ms.indexOf( '[' ) === -1 ) {
280 - return ms;
281 - }
282 -
283 - // make sure we have the lagMagic setup:
284 - // @@todo move to init
285 - $.lang.magicSetup();
286 - // send the msg key through the parser
287 - var pObj = $.parser.pNew( ms );
288 - // return the transformed msg
289 - return pObj.getHTML();
290 - }
291 - /**
292 - * gMsgSwap
293 - *
294 - * @param string key The msg key as set by loadGm
295 - * @param [mixed] args An array or string to be replaced
296 - * @return string
297 - */
298 - $.lang.gMsgSwap = function( key , args ) {
299 - if ( ! gMsg[ key ] )
300 - return '<' + key + '>';// Missing key placeholder
301 - // get the message string:
302 - var ms = gMsg[ key ];
303 -
304 - // replace values
305 - if ( typeof args == 'object' || typeof args == 'array' ) {
306 - for ( var v in args ) {
307 - // Message test replace arguments start at 1 instead of zero:
308 - var rep = new RegExp( '\\$' + ( parseInt( v ) + 1 ), 'g' );
309 - ms = ms.replace( rep, args[v] );
310 - }
311 - } else if ( typeof args == 'string' || typeof args == 'number' ) {
312 - ms = ms.replace( /\$1/g, args );
313 - }
314 - return ms;
315 - }
316 -
317 - /**
318 - * gMsgNoTrans
319 - *
320 - * @returns string The msg key without transforming it
321 - */
322 - $.lang.gMsgNoTrans = function( key ) {
323 - if ( gMsg[ key ] )
324 - return gMsg[ key ]
325 -
326 - // Missing key placeholder
327 - return '<' + key + '>';
328 - }
329 - /**
330 - * Add Supported Magic Words to parser
331 - */
332 - // Set the setupflag to false:
333 - $.lang.doneSetup = false;
334 - $.lang.magicSetup = function() {
335 - if ( !$.lang.doneSetup ) {
336 - $.parser.addMagic ( {
337 - 'PLURAL' : $.lang.procPLURAL
338 - } )
339 -
340 - $.lang.doneSetup = true;
341 - }
342 -
343 - }
344 - /**
345 - * Process the PLURAL special language template key:
346 - */
347 - $.lang.procPLURAL = function( tObj ) {
348 - // setup shortcuts
349 - // (gRuleSet is loaded from script-loader to contains local ruleset)
350 - var rs = gRuleSet['PLURAL'];
351 -
352 - /*
353 - * Plural matchRuleTest
354 - */
355 - function matchRuleTest( cRule, val ) {
356 - js_log("matchRuleTest:: " + typeof cRule + ' ' + cRule + ' == ' + val );
357 - function checkValue( compare, val ) {
358 - if ( typeof compare == 'string' ) {
359 - range = compare.split( '-' );
360 - if ( range.length >= 1 ) {
361 - if ( val >= range[0] && val <= range[1] )
362 - return true;
363 - }
364 - }
365 - // else do a direct compare
366 - if ( compare == val ) {
367 - return true;
368 - }
369 - return false;
370 - }
371 - // check for simple cRule type:
372 - if ( typeof cRule == 'number' ) {
373 - return ( parseInt( val ) == parseInt( cRule ) );
374 - } else if ( typeof cRule == 'object' ) {
375 - var cmatch = { };
376 - // if a list we need to match all for rule match
377 - for ( var i in cRule ) {
378 - var cr = cRule[i];
379 - // set cr type
380 - var crType = '';
381 - for ( var j in cr ) {
382 - if ( j == 'mod' )
383 - crType = 'mod'
384 - }
385 - switch( crType ) {
386 - case 'mod':
387 - if ( cr ['is'] ) {
388 - if ( checkValue( val % cr['mod'], cr ['is'] ) )
389 - cmatch[i] = true;
390 - } else if ( cr['not'] ) {
391 - if ( ! checkValue( val % cr['mod'], cr ['not'] ) )
392 - cmatch[i] = true;
393 - }
394 - break;
395 - }
396 - }
397 - // check all the matches (taking into consideration "or" order)
398 - for ( var i in cRule ) {
399 - if ( ! cmatch[i] )
400 - return false;
401 - }
402 - return true;
403 -
404 - }
405 - }
406 - /**
407 - * Maps a given rule Index to template params:
408 - *
409 - * if index is out of range return last param
410 - * @param
411 - */
412 - function getTempParamFromRuleInx( tObj, ruleInx ) {
413 - // js_log('getTempParamFromRuleInx: ruleInx: ' + ruleInx + ' tempParamLength ' + tObj.param.length );
414 - if ( ruleInx >= tObj.param.length )
415 - return tObj.param[ tObj.param.length - 1 ];
416 - // else return the requested index:
417 - return tObj.param[ ruleInx ];
418 - }
419 - var rCount = 0
420 - // run the actual rule lookup:
421 - for ( var ruleInx in rs ) {
422 - cRule = rs[ruleInx];
423 - if ( matchRuleTest( cRule, tObj.arg ) ) {
424 - js_log("matched rule: " + ruleInx );
425 - return getTempParamFromRuleInx( tObj, rCount );
426 - }
427 - rCount ++;
428 - }
429 - js_log('no match found for: ' + tObj.arg + ' using last/other : ' + tObj.param [ tObj.param.length -1 ] );
430 - //debugger;
431 - // return the last /"other" template param
432 - return tObj.param [ tObj.param.length - 1 ];
433 - }
434 -
435 - /**
436 - * gMsgLoadRemote loads remote msg strings
437 - *
438 - * @param mixed msgSet the set of msg to load remotely
439 - * @param function callback the callback to issue once string is ready
440 - */
441 - $.lang.gMsgLoadRemote = function( msgSet, callback ) {
442 - var ammessages = '';
443 - if ( typeof msgSet == 'object' ) {
444 - for ( var i in msgSet ) {
445 - ammessages += msgSet[i] + '|';
446 - }
447 - } else if ( typeof msgSet == 'string' ) {
448 - ammessages += msgSet;
449 - }
450 - if ( ammessages == '' ) {
451 - js_log( 'gMsgLoadRemote: no message set requested' );
452 - return false;
453 - }
454 - do_api_req( {
455 - 'data': {
456 - 'meta': 'allmessages',
457 - 'ammessages': ammessages
458 - }
459 - }, function( data ) {
460 - if ( data.query.allmessages ) {
461 - var msgs = data.query.allmessages;
462 - for ( var i in msgs ) {
463 - var ld = { };
464 - ld[ msgs[i]['name'] ] = msgs[i]['*'];
465 - loadGM( ld );
466 - }
467 - }
468 - callback();
469 - } );
470 - }
471 - /**
472 - * Format a size in bytes for output, using an appropriate
473 - * unit (B, KB, MB or GB) according to the magnitude in question
474 - *
475 - * @param size Size to format
476 - * @return string Plain text (not HTML)
477 - */
478 - $.lang.formatSize = function ( size ) {
479 - // For small sizes no decimal places are necessary
480 - var round = 0;
481 - var msg = '';
482 - if ( size > 1024 ) {
483 - size = size / 1024;
484 - if ( size > 1024 ) {
485 - size = size / 1024;
486 - // For MB and bigger two decimal places are smarter
487 - round = 2;
488 - if ( size > 1024 ) {
489 - size = size / 1024;
490 - msg = 'mwe-size-gigabytes';
491 - } else {
492 - msg = 'mwe-size-megabytes';
493 - }
494 - } else {
495 - msg = 'mwe-size-kilobytes';
496 - }
497 - } else {
498 - msg = 'mwe-size-bytes';
499 - }
500 - // JavaScript does not let you choose the precision when rounding
501 - var p = Math.pow( 10, round );
502 - var size = Math.round( size * p ) / p;
503 - return gM( msg , size );
504 - };
505 -
506 - $.lang.formatNumber = function( num ) {
507 - /*
508 - * addSeparatorsNF
509 - * @param Str: The number to be formatted, as a string or number.
510 - * @param outD: The decimal character for the output, such as ',' for the number 100,2
511 - * @param sep: The separator character for the output, such as ',' for the number 1,000.2
512 - */
513 - function addSeparatorsNF( nStr, outD, sep ) {
514 - nStr += '';
515 - var dpos = nStr.indexOf( '.' );
516 - var nStrEnd = '';
517 - if ( dpos != -1 ) {
518 - nStrEnd = outD + nStr.substring( dpos + 1, nStr.length );
519 - nStr = nStr.substring( 0, dpos );
520 - }
521 - var rgx = /(\d+)(\d{3})/;
522 - while ( rgx.test( nStr ) ) {
523 - nStr = nStr.replace( rgx, '$1' + sep + '$2' );
524 - }
525 - return nStr + nStrEnd;
526 - }
527 - // @@todo read language code and give periods or comas:
528 - return addSeparatorsNF( num, '.', ',' );
529 - }
530 -
531 -
532 -
533 - /**
534 - * MediaWiki wikitext "Parser"
535 - *
536 - * This is not feature complete but we need a way to get at template properties
537 - *
538 - *
539 - * @param {String} wikiText the wikitext to be parsed
540 - * @return {Object} parserObj returns a parser object that has methods for getting at
541 - * things you would want
542 - */
543 - $.parser = { };
544 - var pMagicSet = { };
545 - /**
546 - * parser addMagic
547 - *
548 - * Lets you add a set of magic keys and associated callback functions
549 - *
550 - * @param object magicSet key:callback
551 - */
552 - $.parser.addMagic = function( magicSet ) {
553 - for ( var i in magicSet )
554 - pMagicSet[ i ] = magicSet[i];
555 - }
556 -
557 - // actual parse call (returns parser object)
558 - $.parser.pNew = function( wikiText, opt ) {
559 - var parseObj = function( wikiText, opt ) {
560 - return this.init( wikiText, opt )
561 - }
562 - parseObj.prototype = {
563 - // the wikiText "DOM"... stores the parsed wikiText structure
564 - // wtDOM : {}, (not yet supported )
565 -
566 - pOut : '', // the parser output string container
567 - init :function( wikiText ) {
568 - this.wikiText = wikiText;
569 - },
570 - updateText : function( wikiText ) {
571 - this.wikiText = wikiText;
572 - // invalidate the output (will force a re-parse )
573 - this.pOut = '';
574 - },
575 - parse : function() {
576 - /*
577 - * quickly recursive / parse out templates:
578 - */
579 -
580 - // ~ probably a better algorithm out there / should mirror php parser flow ~
581 - // (we are already running white-space issues ie php parse strips whitespace differently)
582 - // or at least expose something similar to: http://www.mediawiki.org/wiki/Extension:Page_Object_Model
583 -
584 - // ... but I am having fun with recursion so here it is...
585 - function rdpp ( txt , cn ) {
586 - var node = { };
587 - // inspect each char
588 - for ( var a = 0; a < txt.length; a++ ) {
589 - if ( txt[a] == '{' && txt[a + 1] == '{' ) {
590 - a = a + 2;
591 - node['p'] = node;
592 - if ( !node['c'] )
593 - node['c'] = new Array();
594 -
595 - node['c'].push( rdpp( txt.substr( a ), true ) );
596 - } else if ( txt[a] == '}' && txt[a + 1] == '}' ) {
597 - a = a + 2;
598 - if ( !node['p'] ) {
599 - return node;
600 - }
601 - node = node['p'];
602 - }
603 - if ( !node['t'] )
604 - node['t'] = '';
605 - // don't put closures into output:
606 - if ( txt[a] && txt[a] != '}' )
607 - node['t'] += txt[a];
608 -
609 - }
610 - return node;
611 - }
612 - /**
613 - * parse template text as template name and named params
614 - */
615 - function parseTmplTxt( ts ) {
616 - var tObj = { };
617 - // Get template name:
618 - tname = ts.split( '\|' ).shift() ;
619 - tname = tname.split( '\{' ).shift() ;
620 - tname = tname.replace( /^\s+|\s+$/g, "" ); //trim
621 -
622 - // check for arguments:
623 - if ( tname.split( ':' ).length == 1 ) {
624 - tObj["name"] = tname;
625 - } else {
626 - tObj["name"] = tname.split( ':' ).shift();
627 - tObj["arg"] = tname.split( ':' ).pop();
628 - }
629 -
630 - var pSet = ts.split( '\|' );
631 - pSet.splice( 0, 1 );
632 - if ( pSet.length ) {
633 - tObj.param = new Array();
634 - for ( var pInx in pSet ) {
635 - var tStr = pSet[ pInx ];
636 - // check for empty param
637 - if ( tStr == '' ) {
638 - tObj.param[ pInx ] = '';
639 - continue;
640 - }
641 - for ( var b = 0 ; b < tStr.length ; b++ ) {
642 - if ( tStr[b] == '=' && b > 0 && b < tStr.length && tStr[b - 1] != '\\' ) {
643 - // named param
644 - tObj.param[ tStr.split( '=' ).shift() ] = tStr.split( '=' ).pop();
645 - } else {
646 - // indexed param
647 - tObj.param[ pInx ] = tStr;
648 - }
649 - }
650 - }
651 - }
652 - return tObj;
653 - }
654 - function getMagicTxtFromTempNode( node ) {
655 - node.tObj = parseTmplTxt ( node.t );
656 - // do magic swap if template key found in pMagicSet
657 - if ( node.tObj.name in pMagicSet ) {
658 - var nt = pMagicSet[ node.tObj.name ]( node.tObj );
659 - return nt;
660 - } else {
661 - // don't swap just return text
662 - return node.t;
663 - }
664 - }
665 - /**
666 - * recurse_magic_swap
667 - *
668 - * go last child first swap upward: (could probably be integrated above somehow)
669 - */
670 - var pNode = null;
671 - function recurse_magic_swap( node ) {
672 - if ( !pNode )
673 - pNode = node;
674 -
675 - if ( node['c'] ) {
676 - // swap all the kids:
677 - for ( var i in node['c'] ) {
678 - var nt = recurse_magic_swap( node['c'][i] );
679 - // swap it into current
680 - if ( node.t ) {
681 - node.t = node.t.replace( node['c'][i].t, nt );
682 - }
683 - // swap into parent
684 - pNode.t = pNode.t.replace( node['c'][i].t, nt );
685 - }
686 - // do the current node:
687 - var nt = getMagicTxtFromTempNode( node );
688 - pNode.t = pNode.t.replace( node.t , nt );
689 - // run the swap for the outer most node
690 - return node.t;
691 - } else {
692 - // node.t = getMagicFromTempObj( node.t )
693 - return getMagicTxtFromTempNode( node );
694 - }
695 - }
696 - // parse out the template node structure:
697 - this.pNode = rdpp ( this.wikiText );
698 - // strip out the parent from the root
699 - this.pNode['p'] = null;
700 -
701 - // do the recursive magic swap text:
702 - this.pOut = recurse_magic_swap( this.pNode );
703 -
704 - },
705 - /*
706 - * parsed template api ~loosely based off of ~POM~
707 - * http://www.mediawiki.org/wiki/Extension:Page_Object_Model
708 - */
709 -
710 - /**
711 - * templates
712 - *
713 - * gets a requested template from the wikitext (if available)
714 - *
715 - */
716 - templates: function( tname ) {
717 - this.parse();
718 - var tmplSet = new Array();
719 - function getMatchingTmpl( node ) {
720 - if ( node['c'] ) {
721 - for ( var i in node['c'] ) {
722 - getMatchingTmpl( node['c'] );
723 - }
724 - }
725 - if ( tname && node.tObj ) {
726 - if ( node.tObj['name'] == tname )
727 - tmplSet.push( node.tObj );
728 - } else if ( node.tObj ) {
729 - tmplSet.push( node.tObj );
730 - }
731 - }
732 - getMatchingTmpl( this.pNode );
733 - return tmplSet;
734 - },
735 -
736 - /**
737 - * getTemplateVars
738 - * returns a set of template values in a given wikitext page
739 - *
740 - * NOTE: should be integrated with the parser
741 - */
742 - getTemplateVars: function(){
743 - //js_log('matching against: ' + wikiText);
744 - templateVars = new Array();
745 - var tempVars = wikiText.match(/\{\{\{([^\}]*)\}\}\}/gi);
746 -
747 - // Clean up results:
748 - for(var i=0; i < tempVars.length; i++){
749 - //match
750 - var tvar = tempVars[i].replace('{{{','').replace('}}}','');
751 -
752 - // Strip anything after a |
753 - if(tvar.indexOf('|') != -1){
754 - tvar = tvar.substr(0, tvar.indexOf('|'));
755 - }
756 -
757 - // Check for duplicates:
758 - var do_add=true;
759 - for(var j=0; j < templateVars.length; j++){
760 - if( templateVars[j] == tvar)
761 - do_add=false;
762 - }
763 -
764 - // Add the template vars to the output obj
765 - if(do_add)
766 - templateVars.push( tvar );
767 - }
768 - return templateVars;
769 - },
770 -
771 - /**
772 - * Returns the transformed wikitext
773 - *
774 - * Build output from swapable index
775 - * (all transforms must be expanded in parse stage and linearly rebuilt)
776 - * Alternatively we could build output using a place-holder & replace system
777 - * (this lets us be slightly more sloppy with ordering and indexes, but probably slower)
778 - *
779 - * Ideal: we build a 'wiki DOM'
780 - * When editing you update the data structure directly
781 - * Then in output time you just go DOM->html-ish output without re-parsing anything
782 - */
783 - getHTML : function() {
784 - // wikiText updates should invalidate pOut
785 - if ( this.pOut == '' ) {
786 - this.parse();
787 - }
788 - return this.pOut;
789 - }
790 - };
791 - // return the parserObj
792 - return new parseObj( wikiText, opt ) ;
793 - }
794 -
795 - /*
796 - * API and request functions
797 - */
798 - $.getLocalApiUrl = function() {
799 - if ( typeof wgServer != 'undefined' && typeof wgScriptPath != 'undefined' ) {
800 - return wgServer + wgScriptPath + '/api.php';
801 - }
802 - return false;
803 - }
804 -
805 - /**
806 - * Utility Functions
807 - */
808 -
809 -
810 - /**
811 - * parseUri 1.2.2
812 - * (c) Steven Levithan <stevenlevithan.com>
813 - * MIT License
814 - */
815 - $.parseUri = function (str) {
816 - var o = $.parseUri.options,
817 - m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
818 - uri = {},
819 - i = 14;
820 -
821 - while (i--) uri[o.key[i]] = m[i] || "";
822 -
823 - uri[o.q.name] = {};
824 - uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
825 - if ($1) uri[o.q.name][$1] = $2;
826 - });
827 -
828 - return uri;
829 - };
830 - $.parseUri.options = {
831 - strictMode: false,
832 - key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
833 - q: {
834 - name: "queryKey",
835 - parser: /(?:^|&)([^&=]*)=?([^&]*)/g
836 - },
837 - parser: {
838 - strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
839 - loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
840 - }
841 - };
842 -
843 - /**
844 - * getAbsoluteUrl takes a src and returns the absolute location given the document.URL
845 - * @param {String} src path or url
846 - */
847 - $.absoluteUrl = function( src, contextUrl ){
848 - var pSrc = mw.parseUri( src );
849 - if( pSrc.protocol != '')
850 - return src;
851 -
852 - // Get parent Url location the context URL
853 - if( contextUrl){
854 - var pUrl = mw.parseUri( contextUrl );
855 - } else {
856 - var pUrl = mw.parseUri( document.URL );
857 - }
858 - // If a leading slash:
859 - if( src.indexOf( '/' ) == 1 ){
860 - return pUrl.protocol + '://' + pUrl.authority + src;
861 - }else{
862 - return pUrl.protocol + '://' + pUrl.authority + pUrl.directory + src;
863 - }
864 - };
865 - /**
866 - * Takes in a string returns an xml dom object
867 - */
868 - $.parseXML = function ( str ){
869 - if ( $j.browser.msie ) {
870 - // Attempt to parse as XML for IE
871 - var xmldata = new ActiveXObject( "Microsoft.XMLDOM" );
872 - xmldata.async = "false";
873 - try{
874 - xmldata.loadXML( str );
875 - return xmldata;
876 - } catch (e){
877 - js_log( 'XML parse ERROR: ' + e.message );
878 - return false;
879 - }
880 - }
881 -
882 - // For others (Firefox, Safari etc, older browsers
883 - // Some don't have native DOMParser either fallback defined bellow.
884 - try {
885 - var xmldata = ( new DOMParser() ).parseFromString( str, "text/xml" );
886 - } catch ( e ) {
887 - js_log( 'XML parse ERROR: ' + e.message );
888 - return false;
889 - }
890 - return xmldata;
891 - }
892 -} )( window.mw );
893 -
894 -// Get the mv_embed location if it has not been set
895 -if ( !mv_embed_path ) {
896 - var mv_embed_path = getMvEmbedPath();
897 -}
898 -
899 -// load in js2 stopgap into proper location:
900 -if ( typeof gMsg != 'undefined' ) {
901 - mw.lang.loadGM( gMsg )
902 -}
903 -
904 -// setup legacy global shortcuts:
905 -var loadGM = mw.lang.loadGM;
906 -var loadRS = mw.lang.loadRS;
907 -var gM = mw.lang.gM;
908 -
909 -// All default messages in [English] should be overwritten by the CMS language message system.
910 -mw.lang.loadGM( {
911 - "mwe-loading_txt" : "Loading ...",
912 - "mwe-size-gigabytes" : "$1 GB",
913 - "mwe-size-megabytes" : "$1 MB",
914 - "mwe-size-kilobytes" : "$1 K",
915 - "mwe-size-bytes" : "$1 B",
916 - "mwe-error_load_lib" : "Error: JavaScript $1 was not retrievable or does not define $2",
917 - "mwe-loading-add-media-wiz" : "Loading add media wizard",
918 - "mwe-apiproxy-setup" : "Setting up API proxy",
919 - "mwe-load-drag-item" : "Loading dragged item",
920 - "mwe-ok" : "OK",
921 - "mwe-cancel" : "Cancel"
922 -} );
923 -
924 -
925 -// Get the loading image
926 -function mv_get_loading_img( style, class_attr ) {
927 - var style_txt = ( style ) ? style:'';
928 - var class_attr = ( class_attr ) ? 'class="' + class_attr + '"' : 'class="mv_loading_img"';
929 - return '<div ' + class_attr + ' style="' + style + '"></div>';
930 -}
931 -
932 -function mv_set_loading( target, load_id ) {
933 - var id_attr = ( load_id ) ? ' id="' + load_id + '" ':'';
934 - $j( target ).append( '<div ' + id_attr + ' style="position:absolute;top:0px;left:0px;height:100%;width:100%;' +
935 - 'background-color:#FFF;">' +
936 - mv_get_loading_img( 'top:30px;left:30px' ) +
937 - '</div>' );
938 -}
939 -
940 -/**
941 -* mvJsLoader class handles initialization and js file loads
942 -*/
943 -var mvJsLoader = {
944 - libreq : { },
945 - libs : { },
946 -
947 - // Base lib flags
948 - onReadyEvents: new Array(),
949 - doneReadyEvents: false,
950 - jQuerySetupFlag: false,
951 -
952 - // To keep consistency across threads
953 - ptime: 0,
954 - ctime: 0,
955 -
956 - load_error: false, // Load error flag (false by default)
957 - load_time: 0,
958 - callbacks: new Array(),
959 - cur_path: null,
960 - missing_path : null,
961 - doLoad: function( loadLibs, callback ) {
962 - this.ctime++;
963 - if ( loadLibs && loadLibs.length != 0 ) {
964 - // js_log("doLoad setup::" + JSON.stringify( loadLibs ) );
965 - // Set up this.libs
966 - // First check if we already have this library loaded
967 - var all_libs_loaded = true;
968 - for ( var i = 0; i < loadLibs.length; i++ ) {
969 - // Check if the library is already loaded
970 - if ( ! this.checkObjPath( loadLibs[i] ) ) {
971 - all_libs_loaded = false;
972 - }
973 - }
974 - if ( all_libs_loaded ) {
975 - js_log( 'Libraries ( ' + loadLibs + ') already loaded... skipping load request' );
976 - callback();
977 - return;
978 - }
979 -
980 - // Do a check for any CSS we may need and get it
981 - for ( var i = 0; i < loadLibs.length; i++ ) {
982 - if ( typeof mvCssPaths[ loadLibs[i] ] != 'undefined' ) {
983 - loadExternalCss( mv_embed_path + mvCssPaths[ loadLibs[i] ] );
984 - }
985 - }
986 -
987 - // Check if we should use the script loader to combine all the requests into one
988 - // ( the scriptloader defines the mwSlScript global )
989 - if ( typeof mwSlScript != 'undefined' ) {
990 - var class_set = '';
991 - var last_class = '';
992 - var coma = '';
993 - for ( var i = 0; i < loadLibs.length; i++ ) {
994 - var curLib = loadLibs[i];
995 - // Only add if not included yet:
996 - if ( ! this.checkObjPath( curLib ) ) {
997 - class_set += coma + curLib;
998 - last_class = curLib;
999 - coma = ',';
1000 - }
1001 - }
1002 - // Build the url to the scriptServer striping its request parameters:
1003 - var puri = mw.parseUri( getMvEmbedURL() );
1004 - if ( ( getMvEmbedURL().indexOf( '://' ) != -1 )
1005 - && puri.host != mw.parseUri( document.URL ).host )
1006 - {
1007 - var scriptPath = puri.protocol + '://' + puri.authority + puri.path;
1008 - } else {
1009 - var scriptPath = puri.path;
1010 - }
1011 - // js_log('scriptServer Path is: ' + scriptPath + "\n host script path:" + getMvEmbedURL() );
1012 - this.libs[ last_class ] = scriptPath + '?class=' + class_set +
1013 - '&' + getMwReqParam();
1014 -
1015 - } else {
1016 - // Do many requests
1017 - for ( var i = 0; i < loadLibs.length; i++ ) {
1018 - var curLib = loadLibs[i];
1019 - if ( curLib ) {
1020 - var libLoc = mvGetClassPath( curLib );
1021 - // Do a direct load of the file (pass along unique request id from
1022 - // request or mv_embed Version )
1023 - var qmark = ( libLoc.indexOf( '?' ) !== true ) ? '?' : '&';
1024 - this.libs[curLib] = mv_embed_path + libLoc + qmark + getMwReqParam();
1025 - }
1026 - }
1027 - }
1028 - }
1029 -
1030 - if ( callback ) {
1031 - this.callbacks.push( callback );
1032 - }
1033 - if ( this.checkLoading() ) {
1034 - // @@todo we should check the <script> Element .onLoad property to
1035 - // make sure its just not a very slow connection
1036 - // (even though the class is not loaded)
1037 - if ( this.load_time++ > 4000 ) { // Time out after ~80 seconds
1038 - js_log( gM( 'mwe-error_load_lib', [mvGetClassPath( this.missing_path ), this.missing_path] ) );
1039 - this.load_error = true;
1040 - } else {
1041 - setTimeout( 'mvJsLoader.doLoad()', 20 );
1042 - }
1043 - } else {
1044 - // js_log('checkLoading passed. Running callbacks...');
1045 - // Only do callbacks if we are in the same instance (weird concurrency issue)
1046 - var cb_count = 0;
1047 - for ( var i = 0; i < this.callbacks.length; i++ )
1048 - cb_count++;
1049 - // js_log('RESET LIBS: loading is: '+ loading + ' callback count: '+cb_count +
1050 - // ' p:'+ this.ptime +' c:'+ this.ctime);
1051 -
1052 - // Reset the libs
1053 - this.libs = { };
1054 - // js_log('done loading, do call: ' + this.callbacks[0] );
1055 - while ( this.callbacks.length != 0 ) {
1056 - if ( this.ptime == this.ctime - 1 ) { // Enforce thread consistency
1057 - this.callbacks.pop()();
1058 - // func = this.callbacks.pop();
1059 - // js_log(' run: '+this.ctime+ ' p: ' + this.ptime + ' ' +loading+ ' :'+ func);
1060 - // func();
1061 - } else {
1062 - // Re-issue doLoad ( ptime will be set to ctime so we should catch up)
1063 - setTimeout( 'mvJsLoader.doLoad()', 25 );
1064 - break;
1065 - }
1066 - }
1067 - }
1068 - this.ptime = this.ctime;
1069 - },
1070 - doLoadDepMode: function( loadChain, callback ) {
1071 - // Firefox executes JS in the order in which it is included, so just directly issue the request
1072 - if ( $j.browser.firefox ) {
1073 - var loadSet = [];
1074 - for ( var i = 0; i < loadChain.length; i++ ) {
1075 - for ( var j = 0; j < loadChain[i].length; j++ ) {
1076 - loadSet.push( loadChain[i][j] );
1077 - }
1078 - }
1079 - mvJsLoader.doLoad( loadSet, callback );
1080 - } else {
1081 - // Safari and IE tend to execute out of order so load with dependency checks
1082 - mvJsLoader.doLoad( loadChain.shift(), function() {
1083 - if ( loadChain.length != 0 ) {
1084 - mvJsLoader.doLoadDepMode( loadChain, callback );
1085 - } else {
1086 - callback();
1087 - }
1088 - } );
1089 - }
1090 - },
1091 - checkLoading: function() {
1092 - var loading = 0;
1093 - var i = null;
1094 - for ( var i in this.libs ) { // for/in loop is OK on an object
1095 - if ( !this.checkObjPath( i ) ) {
1096 - if ( !this.libreq[i] ) {
1097 - loadExternalJs( this.libs[i] );
1098 - }
1099 - this.libreq[i] = 1;
1100 - // js_log("has not yet loaded: " + i);
1101 - loading = 1;
1102 - }
1103 - }
1104 - return loading;
1105 - },
1106 - checkObjPath: function( libVar ) {
1107 - if ( !libVar )
1108 - return false;
1109 - var objPath = libVar.split( '.' )
1110 - var cur_path = '';
1111 - for ( var p = 0; p < objPath.length; p++ ) {
1112 - cur_path = ( cur_path == '' ) ? cur_path + objPath[p] : cur_path + '.' + objPath[p];
1113 - eval( 'var ptest = typeof ( ' + cur_path + ' ); ' );
1114 - if ( ptest == 'undefined' ) {
1115 - this.missing_path = cur_path;
1116 - return false;
1117 - }
1118 - }
1119 - this.cur_path = cur_path;
1120 - return true;
1121 - },
1122 - /**
1123 - * checks for jQuery and adds the $j noConflict var
1124 - */
1125 - jQueryCheck: function( callback ) {
1126 - // js_log( 'jQueryCheck::' + this.jQuerySetupFlag);
1127 - var _this = this;
1128 - if ( _global['$j'] && _this.jQuerySetupFlag ) {
1129 - callback(); // call the callback now
1130 - }
1131 - // Load jQuery
1132 - _this.doLoad( [
1133 - 'window.jQuery'
1134 - ], function() {
1135 - // only do the $j setup once:
1136 - if ( !_global['$j'] ) {
1137 - _global['$j'] = jQuery.noConflict();
1138 - }
1139 - if ( _this.jQuerySetupFlag == false ) {
1140 - // js_log('setup mv_embed jQuery bindings');
1141 - // Setup our global settings using the (jQuery helper)
1142 -
1143 - // Set up the skin path
1144 - _global['mv_jquery_skin_path'] = mv_embed_path + 'jquery/jquery.ui/themes/' + mw.conf['jui_skin'] + '/';
1145 - _global['mv_skin_img_path'] = mv_embed_path + 'skins/' + mw.conf['skin_name'] + '/images/';
1146 - _global['mv_default_thumb_url'] = mv_skin_img_path + 'vid_default_thumb.jpg';
1147 -
1148 - // Make sure the skin/style sheets are always available:
1149 - loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' );
1150 - loadExternalCss( mv_embed_path + 'skins/' + mw.conf['skin_name'] + '/styles.css' );
1151 -
1152 - // Set up AJAX to not send dynamic URLs for loading scripts (we control that with
1153 - // the scriptLoader)
1154 - $j.ajaxSetup( {
1155 - cache: true
1156 - } );
1157 -
1158 - js_log( 'jQuery loaded into $j' );
1159 - // Set up mvEmbed jQuery bindings and config based dependencies
1160 - mv_jqueryBindings();
1161 - _this.jQuerySetupFlag = true;
1162 -
1163 - // js_log('should run callback: ' + callback);
1164 - // Run the callback if not already run above
1165 - if ( callback ) {
1166 - callback();
1167 - }
1168 - }
1169 - } );
1170 - },
1171 - embedPlayerCheck:function( callback ) {
1172 - var _this = this;
1173 - js_log( 'embedPlayerCheck:' );
1174 - // Make sure we have jQuery
1175 - _this.jQueryCheck( function() {
1176 - // set class videonojs to loading
1177 - $j( '.videonojs' ).html( gM( 'mwe-loading_txt' ) );
1178 - // Set up the embed video player class request: (include the skin js as well)
1179 - var depReq = [
1180 - [
1181 - '$j.ui',
1182 - 'embedPlayer',
1183 - 'ctrlBuilder',
1184 - '$j.cookie'
1185 - ],
1186 - [
1187 - '$j.ui.slider'
1188 - ]
1189 - ];
1190 -
1191 - // add any requested skins (supports multiple skins per single page)
1192 - if ( mw.skin_list ) {
1193 - for ( var i in mw.skin_list ) {
1194 - depReq[0].push( mw.skin_list[i] + 'Config' );
1195 - }
1196 - }
1197 -
1198 - // Add PNG fix if needed:
1199 - if ( $j.browser.msie || $j.browser.version < 7 )
1200 - depReq[0].push( '$j.fn.pngFix' );
1201 -
1202 - // load the video libs:
1203 - _this.doLoadDepMode( depReq, function() {
1204 - embedTypes.init();
1205 - callback();
1206 - $j( '.videonojs' ).remove();
1207 - } );
1208 - } );
1209 - },
1210 - addLoadEvent: function( fn ) {
1211 - // js_log('add ready event: ' + fn );
1212 - this.onReadyEvents.push( fn );
1213 - },
1214 - // Check the jQuery flag. This way, when remote embedding, we don't load jQuery
1215 - // unless js2AddOnloadHook was used or there is video on the page.
1216 - runQueuedFunctions: function() {
1217 - js_log( "runQueuedFunctions" );
1218 - var _this = this;
1219 - this.jQueryCheck( function() {
1220 - _this.runReadyEvents();
1221 - _this.doneReadyEvents = true;
1222 - } );
1223 - },
1224 - runReadyEvents: function() {
1225 - js_log( "runReadyEvents" + this.onReadyEvents.length );
1226 - while ( this.onReadyEvents.length ) {
1227 - var func = this.onReadyEvents.shift();
1228 - // js_log('run onReady:: ' + func );
1229 - func();
1230 - }
1231 - }
1232 -}
1233 -
1234 -// Shortcut ( @@todo consolidate shortcuts & re-factor mvJsLoader )
1235 -function mwLoad( loadSet, callback ) {
1236 - mvJsLoader.doLoad( loadSet, callback );
1237 -}
1238 -// mw.shortcut
1239 -mw.load = mwLoad;
1240 -
1241 -// Load an external JS file. Similar to jquery .require plugin,
1242 -// but checks for object availability rather than load state.
1243 -
1244 -/*********** INITIALIZATION CODE *************
1245 - * This will get called when the DOM is ready
1246 - *********************************************/
1247 -/* jQuery .ready does not work when jQuery is loaded dynamically.
1248 - * For an example of the problem see: 1.1.3 working: http://pastie.caboo.se/92588
1249 - * and >= 1.1.4 not working: http://pastie.caboo.se/92595
1250 - * $j(document).ready( function(){ */
1251 -function mwdomReady( force ) {
1252 - js_log( 'f:mwdomReady:' );
1253 - if ( !force && mw.init_done ) {
1254 - js_log( "mw done, do nothing..." );
1255 - return false;
1256 - }
1257 - mw.init_done = true;
1258 - // Handle the execution of queued functions with jQuery "ready"
1259 -
1260 - // Check if this page has a video, audio or playlist tag
1261 - var e = [
1262 - document.getElementsByTagName( "video" ),
1263 - document.getElementsByTagName( "audio" ),
1264 - document.getElementsByTagName( "playlist" )
1265 - ];
1266 - if ( e[0].length != 0 || e[1].length != 0 || e[2].length != 0 ) {
1267 - // look for any skin classes we have to load:
1268 - for ( var j in e ) {
1269 - for ( var k in e[j] ) {
1270 - if ( e[j][k] && typeof( e[j][k] ) == 'object' ) {
1271 - var sn = e[j][k].getAttribute( 'class' );
1272 - // Try "className" for good old IE
1273 - if( !sn ){
1274 - var sn = e[j][k].getAttribute( 'className' );
1275 - }
1276 - if ( sn && sn != '' ) {
1277 - for ( var n = 0; n < mw.valid_skins.length; n++ ) {
1278 - if ( sn.indexOf( mw.valid_skins[n] ) !== -1 ) {
1279 - mw.skin_list.push( mw.valid_skins[n] );
1280 - }
1281 - }
1282 - }
1283 - }
1284 - }
1285 - }
1286 - // Load libs and process videos
1287 - mvJsLoader.embedPlayerCheck( function() {
1288 - // Convert all supported elements into embed players:
1289 - $j.embedPlayers( function(){
1290 - // Run any queued global events:
1291 - mvJsLoader.runQueuedFunctions();
1292 - });
1293 - } );
1294 - } else {
1295 - mvJsLoader.runQueuedFunctions();
1296 - }
1297 -}
1298 -
1299 -// js2AddOnloadHook: ensure jQuery and the DOM are ready
1300 -function js2AddOnloadHook( func ) {
1301 - // js_log('js2AddOnloadHook:: jquery:' +func);
1302 - // If we are ready run directly else add load event:
1303 - if ( mvJsLoader.doneReadyEvents ) {
1304 - //js_log( 'run queued event: ' + func );
1305 - func();
1306 - } else {
1307 - //js_log( 'add to load event: ' + func );
1308 - mvJsLoader.addLoadEvent( func );
1309 - }
1310 -}
1311 -// Deprecated mwAddOnloadHook in favour of js2 naming (for clear separation of js2 code from old MW code
1312 -var mwAddOnloadHook = js2AddOnloadHook;
1313 -/*
1314 - * This function allows for targeted rewriting
1315 - */
1316 -function rewrite_by_id( vid_id, ready_callback ) {
1317 - js_log( 'f:rewrite_by_id: ' + vid_id );
1318 - // Force a re-check of the DOM for playlist or video elements:
1319 - mvJsLoader.eembedPlayerheck( function() {
1320 - mv_video_embed( ready_callback, vid_id );
1321 - } );
1322 -}
1323 -
1324 -
1325 -/*********** INITIALIZATION CODE *************
1326 - * set DOM-ready callback to init_mv_embed
1327 - *********************************************/
1328 -// for Mozilla / modern browsers
1329 -if ( document.addEventListener ) {
1330 - document.addEventListener( "DOMContentLoaded", mwdomReady, false );
1331 -}
1332 -var temp_f;
1333 -if ( window.onload ) {
1334 - temp_f = window.onload;
1335 -}
1336 -// Use the onload method as a backup
1337 -window.onload = function () {
1338 - if ( temp_f )
1339 - temp_f();
1340 - mwdomReady();
1341 -}
1342 -
1343 -/*
1344 - * Store all the mwEmbed jQuery-specific bindings
1345 - * (set up after jQuery is available).
1346 - *
1347 - * These functions are generally are loaders that do the dynamic mapping of
1348 - * dependencies for a given component
1349 - *
1350 - *
1351 - */
1352 -function mv_jqueryBindings() {
1353 - js_log( 'mv_jqueryBindings' );
1354 - ( function( $ ) {
1355 - /*
1356 - * dragDrop file loader
1357 - */
1358 - $.fn.dragFileUpload = function ( conf ) {
1359 - if ( this.selector ) {
1360 - var _this = this;
1361 - // load the dragger and "setup"
1362 - mw.load( ['$j.fn.dragDropFile'], function() {
1363 - $j( _this.selector ).dragDropFile();
1364 - } );
1365 - }
1366 - }
1367 - /*
1368 - * apiProxy Loader loader:
1369 - *
1370 - * @param mode is either 'server' or 'client'
1371 - */
1372 - $.apiProxy = function( mode, pConf, callback ) {
1373 - js_log( 'do apiProxy setup' );
1374 - mvJsLoader.doLoad( [
1375 - 'mw.proxy',
1376 - 'JSON'
1377 - ], function() {
1378 - // do the proxy setup or
1379 - if ( mode == 'client' ) {
1380 - // just do the setup (no callbcak for client setup)
1381 - mw.proxy.client( pConf );
1382 - if ( callback )
1383 - callback();
1384 - } else if ( mode == 'server' ) {
1385 - // do the request with the callback
1386 - mw.proxy.server( pConf , callback );
1387 - }
1388 - } );
1389 - }
1390 -
1391 - // non selector based add-media-wizard direct invocation with loader
1392 - $.addMediaWiz = function( iObj, callback ) {
1393 - js_log( ".addMediaWiz call" );
1394 - // check if already loaded:
1395 - if ( _global['rsdMVRS'] ) {
1396 - _global['rsdMVRS'].showDialog();
1397 - if ( callback )
1398 - callback( _global['rsdMVRS'] );
1399 - return ;
1400 - }
1401 - // display a loader:
1402 - $.addLoaderDialog( gM( 'mwe-loading-add-media-wiz' ) );
1403 - // load the addMedia wizard without a target:
1404 - $.fn.addMediaWiz ( iObj, function( amwObj ) {
1405 - // close the dialog
1406 - $.closeLoaderDialog();
1407 - // do the add-media-wizard display
1408 - amwObj.createUI();
1409 - // call the parent callback:
1410 - if ( callback )
1411 - callback( _global['rsdMVRS'] );
1412 - } );
1413 - }
1414 - $.fn.addMediaWiz = function( iObj, callback ) {
1415 - if ( this.selector ) {
1416 - // First set the cursor for the button to "loading"
1417 - $j( this.selector ).css( 'cursor', 'wait' ).attr( 'title', gM( 'mwe-loading_txt' ) );
1418 - // set the target:
1419 - iObj['target_invoke_button'] = this.selector;
1420 - }
1421 -
1422 - // Load the mv_embed_base skin:
1423 - loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' );
1424 - loadExternalCss( mv_embed_path + 'skins/' + mw.conf['skin_name'] + '/styles.css' );
1425 - // Load all the required libs:
1426 - mvJsLoader.jQueryCheck( function() {
1427 - // Load with staged dependencies (for IE that does not execute in order)
1428 - mvJsLoader.doLoadDepMode( [
1429 - [ 'remoteSearchDriver',
1430 - '$j.cookie',
1431 - '$j.fn.textSelection',
1432 - '$j.ui'
1433 - ], [
1434 - '$j.ui.resizable',
1435 - '$j.ui.draggable',
1436 - '$j.ui.dialog',
1437 - '$j.ui.tabs',
1438 - '$j.ui.sortable'
1439 - ]
1440 - ], function() {
1441 - iObj['instance_name'] = 'rsdMVRS';
1442 - if ( ! _global['rsdMVRS'] )
1443 - _global['rsdMVRS'] = new remoteSearchDriver( iObj );
1444 - if ( callback ) {
1445 - callback( _global['rsdMVRS'] );
1446 - }
1447 - } );
1448 - } );
1449 - }
1450 - /*
1451 - * Sequencer loader
1452 - */
1453 - $.fn.sequencer = function( iObj, callback ) {
1454 - // Debugger
1455 - iObj['target_sequence_container'] = this.selector;
1456 - // Issue a request to get the CSS file (if not already included):
1457 - loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' );
1458 - loadExternalCss( mv_embed_path + 'skins/' + mw.conf['skin_name'] + '/mv_sequence.css' );
1459 - // Make sure we have the required mv_embed libs (they are not loaded when no video
1460 - // element is on the page)
1461 - mvJsLoader.eembedPlayerheck( function() {
1462 - // Load the playlist object and then the jQuery UI stuff:
1463 - mvJsLoader.doLoadDepMode( [
1464 - [
1465 - 'mvPlayList',
1466 - '$j.ui',
1467 - '$j.contextMenu',
1468 - 'JSON',
1469 - 'mvSequencer'
1470 - ],
1471 - [
1472 - '$j.ui.accordion',
1473 - '$j.ui.dialog',
1474 - '$j.ui.droppable',
1475 - '$j.ui.draggable',
1476 - '$j.ui.progressbar',
1477 - '$j.ui.sortable',
1478 - '$j.ui.resizable',
1479 - '$j.ui.slider',
1480 - '$j.ui.tabs'
1481 - ]
1482 - ], function() {
1483 - js_log( 'calling new mvSequencer' );
1484 - // Initialise the sequence object (it will take over from there)
1485 - // No more than one mvSeq obj for now:
1486 - if ( !_global['mvSeq'] ) {
1487 - _global['mvSeq'] = new mvSequencer( iObj );
1488 - } else {
1489 - js_log( 'mvSeq already init' );
1490 - }
1491 - } );
1492 - } );
1493 - }
1494 - /*
1495 - * The Firefogg jQuery function:
1496 - * @@note This Firefogg invocation could be made to work more like real jQuery plugins
1497 - */
1498 - var queuedFirefoggConf = { };
1499 - $.fn.firefogg = function( iObj, callback ) {
1500 - if ( !iObj )
1501 - iObj = { };
1502 - // Add the base theme CSS:
1503 - loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' );
1504 - loadExternalCss( mv_embed_path + 'skins/' + mw.conf['skin_name'] + '/styles.css' );
1505 -
1506 - // Check if we already have Firefogg loaded (the call just updates the element's
1507 - // properties)
1508 - var sElm = $j( this.selector ).get( 0 );
1509 - if ( sElm['firefogg'] ) {
1510 - if ( sElm['firefogg'] == 'loading' ) {
1511 - js_log( "Queued firefogg operations ( firefogg " +
1512 - "not done loading ) " );
1513 - $j.extend( queuedFirefoggConf, iObj );
1514 - return false;
1515 - }
1516 - // Update properties
1517 - for ( var i in iObj ) {
1518 - js_log( "firefogg::updated: " + i + ' to ' + iObj[i] );
1519 - sElm['firefogg'][i] = iObj[i];
1520 - }
1521 - return sElm['firefogg'];
1522 - } else {
1523 - // Avoid concurrency
1524 - sElm['firefogg'] = 'loading';
1525 - }
1526 - // Add the selector
1527 - iObj['selector'] = this.selector;
1528 -
1529 - var loadSet = [
1530 - [
1531 - 'mvBaseUploadInterface',
1532 - 'mvFirefogg',
1533 - '$j.ui'
1534 - ],
1535 - [
1536 - '$j.ui.progressbar',
1537 - '$j.ui.dialog',
1538 - '$j.ui.draggable'
1539 - ]
1540 - ];
1541 - if ( iObj.encoder_interface ) {
1542 - loadSet.push( [
1543 - 'mvAdvFirefogg',
1544 - '$j.cookie',
1545 - '$j.ui.accordion',
1546 - '$j.ui.slider',
1547 - '$j.ui.datepicker'
1548 - ] );
1549 - }
1550 - // Make sure we have everything loaded that we need:
1551 - mvJsLoader.doLoadDepMode( loadSet, function() {
1552 - js_log( 'firefogg libs loaded. target select:' + iObj.selector );
1553 - // Select interface provider based on whether we want to include the
1554 - // encoder interface or not
1555 - if ( iObj.encoder_interface ) {
1556 - var myFogg = new mvAdvFirefogg( iObj );
1557 - } else {
1558 - var myFogg = new mvFirefogg( iObj );
1559 - }
1560 - if ( myFogg ) {
1561 - myFogg.doRewrite( callback );
1562 - var selectorElement = $j( iObj.selector ).get( 0 );
1563 - selectorElement['firefogg'] = myFogg;
1564 -
1565 - js_log( 'pre:' + selectorElement['firefogg']['firefogg_form_action'] )
1566 - if ( queuedFirefoggConf )
1567 - $j.extend( selectorElement['firefogg'], queuedFirefoggConf );
1568 - js_log( 'post:' + selectorElement['firefogg']['firefogg_form_action'] )
1569 - }
1570 - } );
1571 - }
1572 - // Take an input player as the selector and expose basic rendering controls
1573 - $.fn.firefoggRender = function( iObj, callback ) {
1574 - // Check if we already have render loaded then just pass on updates/actions
1575 - var sElm = $j( this.selector ).get( 0 );
1576 - //add a special attribute to the selector:
1577 - if ( sElm['fogg_render'] ) {
1578 - if ( sElm['fogg_render'] == 'loading' ) {
1579 - js_log( "Error: called firefoggRender while loading" );
1580 - return false;
1581 - }
1582 - // Call or update the property:
1583 - }
1584 - sElm['fogg_render'] = 'loading';
1585 - // Add the selector
1586 - iObj['player_target'] = this.selector;
1587 - mvJsLoader.doLoad( [
1588 - 'mvBaseUploadInterface',
1589 - 'mvFirefogg',
1590 - 'mvFirefoggRender'
1591 - ], function() {
1592 - // Attach the firefoggRender obj to the selected elm:
1593 - sElm['fogg_render'] = new mvFirefoggRender( iObj );
1594 - if ( callback && typeof callback == 'function' )
1595 - callback( sElm['fogg_render'] );
1596 - } );
1597 - }
1598 -
1599 - $.fn.baseUploadInterface = function( iObj ) {
1600 - mvJsLoader.doLoadDepMode( [
1601 - [
1602 - 'mvBaseUploadInterface',
1603 - '$j.ui',
1604 - ],
1605 - [
1606 - '$j.ui.progressbar',
1607 - '$j.ui.dialog'
1608 - ]
1609 - ], function() {
1610 - myUp = new mvBaseUploadInterface( iObj );
1611 - myUp.setupForm();
1612 - } );
1613 - }
1614 -
1615 - // Shortcut to a themed button
1616 - $.btnHtml = function( msg, className, iconId, opt ) {
1617 - if ( !opt )
1618 - opt = { };
1619 - var href = ( opt.href ) ? opt.href : '#';
1620 - var target_attr = ( opt.target ) ? ' target="' + opt.target + '" ' : '';
1621 - var style_attr = ( opt.style ) ? ' style="' + opt.style + '" ' : '';
1622 - return '<a href="' + href + '" ' + target_attr + style_attr +
1623 - ' class="ui-state-default ui-corner-all ui-icon_link ' +
1624 - className + '"><span class="ui-icon ui-icon-' + iconId + '" ></span>' +
1625 - '<span class="btnText">' + msg + '</span></a>';
1626 - }
1627 - // Shortcut to bind hover state
1628 - $.fn.btnBind = function() {
1629 - $j( this ).hover(
1630 - function() {
1631 - $j( this ).addClass( 'ui-state-hover' );
1632 - },
1633 - function() {
1634 - $j( this ).removeClass( 'ui-state-hover' );
1635 - }
1636 - )
1637 - return this;
1638 - }
1639 - /**
1640 - * resize the dialog to fit the window
1641 - */
1642 - $.fn.dialogFitWindow = function( opt ) {
1643 - var opt_default = { 'hspace':50, 'vspace':50 };
1644 - if ( !opt )
1645 - var opt = { };
1646 - $j.extend( opt, opt_default );
1647 - $j( this.selector ).dialog( 'option', 'width', $j( window ).width() - opt.hspace );
1648 - $j( this.selector ).dialog( 'option', 'height', $j( window ).height() - opt.vspace );
1649 - $j( this.selector ).dialog( 'option', 'position', 'center' );
1650 - // update the child position: (some of this should be pushed up-stream via dialog config options
1651 - $j( this.selector + '~ .ui-dialog-buttonpane' ).css( {
1652 - 'position':'absolute',
1653 - 'left':'0px',
1654 - 'right':'0px',
1655 - 'bottom':'0px'
1656 - } );
1657 - }
1658 -
1659 - /**
1660 - * addLoaderDialog
1661 - * small helper for putting a loading dialog box on top of everything
1662 - * (helps block for request that
1663 - *
1664 - * @param msg text text of the loader msg
1665 - */
1666 - $.addLoaderDialog = function( msg_txt ) {
1667 - $.addDialog( msg_txt, msg_txt + '<br>' + mv_get_loading_img() );
1668 - }
1669 -
1670 - $.addDialog = function ( title, msg_txt, btn ) {
1671 - $( '#mwe_tmp_loader' ).remove();
1672 - // append the style free loader ontop:
1673 - $( 'body' ).append( '<div id="mwe_tmp_loader" style="display:none" title="' + title + '" >' +
1674 - msg_txt +
1675 - '</div>' );
1676 - // special btn == ok gives empty give a single "oky" -> "close"
1677 - if ( btn == 'ok' ) {
1678 - btn[ gM( 'mwe-ok' ) ] = function() {
1679 - $j( '#mwe_tmp_loader' ).close();
1680 - }
1681 - }
1682 - // turn the loader into a real dialog loader:
1683 - mvJsLoader.doLoadDepMode( [
1684 - [
1685 - '$j.ui'
1686 - ],
1687 - [
1688 - '$j.ui.dialog'
1689 - ]
1690 - ], function() {
1691 - $( '#mwe_tmp_loader' ).dialog( {
1692 - bgiframe: true,
1693 - draggable: false,
1694 - resizable: false,
1695 - modal: true,
1696 - width:400,
1697 - buttons: btn
1698 - } );
1699 - } );
1700 - }
1701 - $.closeLoaderDialog = function() {
1702 - mvJsLoader.doLoadDepMode( [
1703 - [
1704 - '$j.ui'
1705 - ],
1706 - [
1707 - '$j.ui.dialog'
1708 - ]
1709 - ], function() {
1710 - $j( '#mwe_tmp_loader' ).dialog( 'destroy' ).remove();
1711 - } );
1712 - }
1713 -
1714 - $.mwProxy = function( apiConf ) {
1715 - mvJsLoader.doLoad( ['mw.apiProxy'],
1716 - function() {
1717 - mw.apiProxy( apiConf );
1718 - } );
1719 - }
1720 - } )( jQuery );
1721 -}
1722 -/*
1723 -* Utility functions:
1724 -*/
1725 -// Simple URL rewriter (could probably be refactored into an inline regular exp)
1726 -function getURLParamReplace( url, opt ) {
1727 - var pSrc = mw.parseUri( url );
1728 - if ( pSrc.protocol != '' ) {
1729 - var new_url = pSrc.protocol + '://' + pSrc.authority + pSrc.path + '?';
1730 - } else {
1731 - var new_url = pSrc.path + '?';
1732 - }
1733 - var amp = '';
1734 - for ( var key in pSrc.queryKey ) {
1735 - var val = pSrc.queryKey[ key ];
1736 - // Do override if requested
1737 - if ( opt[ key ] )
1738 - val = opt[ key ];
1739 - new_url += amp + key + '=' + val;
1740 - amp = '&';
1741 - };
1742 - // Add any vars that were not already there:
1743 - for ( var i in opt ) {
1744 - if ( !pSrc.queryKey[i] ) {
1745 - new_url += amp + i + '=' + opt[i];
1746 - amp = '&';
1747 - }
1748 - }
1749 - return new_url;
1750 -}
1751 -/**
1752 - * Given a float number of seconds, returns npt format response.
1753 - *
1754 - * @param float Seconds
1755 - * @param boolean If we should show milliseconds or not.
1756 - */
1757 -function seconds2npt( sec, show_ms ) {
1758 - if ( isNaN( sec ) ) {
1759 - // js_log("warning: trying to get npt time on NaN:" + sec);
1760 - return '0:0:0';
1761 - }
1762 - var hours = Math.floor( sec / 3600 );
1763 - var minutes = Math.floor( ( sec / 60 ) % 60 );
1764 - var seconds = sec % 60;
1765 - // Round the number of seconds to the required number of significant digits
1766 - if ( show_ms ) {
1767 - seconds = Math.round( seconds * 1000 ) / 1000;
1768 - } else {
1769 - seconds = Math.round( seconds );
1770 - }
1771 - if ( seconds < 10 )
1772 - seconds = '0' + seconds;
1773 - if ( minutes < 10 )
1774 - minutes = '0' + minutes;
1775 -
1776 - return hours + ":" + minutes + ":" + seconds;
1777 -}
1778 -/*
1779 - * Take hh:mm:ss,ms or hh:mm:ss.ms input, return the number of seconds
1780 - */
1781 -function npt2seconds( npt_str ) {
1782 - if ( !npt_str ) {
1783 - // js_log('npt2seconds:not valid ntp:'+ntp);
1784 - return false;
1785 - }
1786 - // Strip {npt:}01:02:20 or 32{s} from time if present
1787 - npt_str = npt_str.replace( /npt:|s/g, '' );
1788 -
1789 - var hour = 0;
1790 - var min = 0;
1791 - var sec = 0;
1792 -
1793 - times = npt_str.split( ':' );
1794 - if ( times.length == 3 ) {
1795 - sec = times[2];
1796 - min = times[1];
1797 - hour = times[0];
1798 - } else if ( times.length == 2 ) {
1799 - sec = times[1];
1800 - min = times[0];
1801 - } else {
1802 - sec = times[0];
1803 - }
1804 - // Sometimes a comma is used instead of period for ms
1805 - sec = sec.replace( /,\s?/, '.' );
1806 - // Return seconds float
1807 - return parseInt( hour * 3600 ) + parseInt( min * 60 ) + parseFloat( sec );
1808 -}
1809 -/*
1810 - * Simple helper to grab an edit token
1811 - *
1812 - * @param title The wiki page title you want to edit
1813 - * @param api_url 'optional' The target API URL
1814 - * @param callback The callback function to pass the token to
1815 - */
1816 -function get_mw_token( title, api_url, callback ) {
1817 - js_log( ':get_mw_token:' );
1818 - if ( !title && wgUserName ) {
1819 - title = 'User:' + wgUserName;
1820 - }
1821 - var reqObj = {
1822 - 'action': 'query',
1823 - 'prop': 'info',
1824 - 'intoken': 'edit',
1825 - 'titles': title
1826 - };
1827 - do_api_req( {
1828 - 'data': reqObj,
1829 - 'url' : api_url
1830 - }, function( data ) {
1831 - for ( var i in data.query.pages ) {
1832 - if ( data.query.pages[i]['edittoken'] ) {
1833 - if ( typeof callback == 'function' )
1834 - callback ( data.query.pages[i]['edittoken'] );
1835 - }
1836 - }
1837 - // No token found:
1838 - return false;
1839 - }
1840 - );
1841 -}
1842 -// Do a remote or local API request based on request URL
1843 -// @param options: url, data, cbParam, callback
1844 -function do_api_req( options, callback ) {
1845 - if ( typeof options.data != 'object' ) {
1846 - return js_error( 'Error: request paramaters must be an object' );
1847 - }
1848 - // Generate the URL if it's missing
1849 - if ( typeof options.url == 'undefined' || !options.url ) {
1850 - if ( typeof wgServer == 'undefined' ) {
1851 - return js_error( 'Error: no api url for api request' );
1852 - }
1853 - options.url = mw.getLocalApiUrl();
1854 - }
1855 - if ( typeof options.data == 'undefined' )
1856 - options.data = { };
1857 -
1858 - // Force format to JSON
1859 - options.data['format'] = 'json';
1860 -
1861 - // If action is not set, assume query
1862 - if ( ! options.data['action'] )
1863 - options.data['action'] = 'query';
1864 -
1865 - // js_log('do api req: ' + options.url +'?' + jQuery.param(options.data) );
1866 - if ( options.url == 'proxy' && mw.proxy ) {
1867 - // assume the proxy is already "setup" since mw.proxy is defined.
1868 - // @@todo should probably integrate that setup into the api call
1869 - mw.proxy.doRequest( options.data, callback );
1870 - } else if ( mw.parseUri( document.URL ).host == mw.parseUri( options.url ).host ) {
1871 - // Local request: do API request directly
1872 - $j.ajax( {
1873 - type: "POST",
1874 - url: options.url,
1875 - data: options.data,
1876 - dataType: 'json', // API requests _should_ always return JSON data:
1877 - async: false,
1878 - success: function( data ) {
1879 - callback( data );
1880 - },
1881 - error: function( e ) {
1882 - js_error( ' error' + e + ' in getting: ' + options.url );
1883 - }
1884 - } );
1885 - } else {
1886 - // Remote request
1887 - // Set the callback param if it's not already set
1888 - if ( typeof options.jsonCB == 'undefined' )
1889 - options.jsonCB = 'callback';
1890 -
1891 - var req_url = options.url;
1892 - var paramAnd = ( req_url.indexOf( '?' ) == -1 ) ? '?' : '&';
1893 - // Put all the parameters into the URL
1894 - for ( var i in options.data ) {
1895 - req_url += paramAnd + encodeURIComponent( i ) + '=' + encodeURIComponent( options.data[i] );
1896 - paramAnd = '&';
1897 - }
1898 - var fname = 'mycpfn_' + ( mw.cb_count++ );
1899 - _global[ fname ] = callback;
1900 - req_url += '&' + options.jsonCB + '=' + fname;
1901 - loadExternalJs( req_url );
1902 - }
1903 -}
1904 -// Do a request:
1905 -// @@note this contains metavid specific local vs remote api remapping.
1906 -// this should be depreciated and we should use "$j.get" or an explicate api call
1907 -// (we should not mix the two request types)
1908 -function do_request( req_url, callback ) {
1909 - js_log( 'do_request::req_url:' + mw.parseUri( document.URL ) + ' != ' + mw.parseUri( req_url ).host );
1910 - // If we are doing a request to the same domain or relative link, do a normal GET
1911 - if ( mw.parseUri( document.URL ).host == mw.parseUri( req_url ).host ||
1912 - req_url.indexOf( '://' ) == -1 ){ // if its a relative url go directly as well
1913 - // Do a direct request
1914 - $j.ajax( {
1915 - type: "GET",
1916 - url: req_url,
1917 - async: false,
1918 - success: function( data ) {
1919 - callback( data );
1920 - }
1921 - } );
1922 - } else {
1923 - // Get data via DOM injection with callback
1924 - global_req_cb.push( callback );
1925 - // Prepend json_ to feed_format if not already requesting json format (metavid specific)
1926 - if ( req_url.indexOf( "feed_format=" ) != -1 && req_url.indexOf( "feed_format=json" ) == -1 )
1927 - req_url = req_url.replace( /feed_format=/, 'feed_format=json_' );
1928 - loadExternalJs( req_url + '&cb=mv_jsdata_cb&cb_inx=' + ( global_req_cb.length -1 ) );
1929 - }
1930 -}
1931 -
1932 -function mv_jsdata_cb( response ) {
1933 - js_log( 'f:mv_jsdata_cb:' + response['cb_inx'] );
1934 - // Run the callback from the global request callback object
1935 - if ( !global_req_cb[response['cb_inx']] ) {
1936 - js_log( 'missing req cb index' );
1937 - return false;
1938 - }
1939 - if ( !response['pay_load'] ) {
1940 - js_log( "missing pay load" );
1941 - return false;
1942 - }
1943 - switch( response['content-type'] ) {
1944 - case 'text/plain':
1945 - break;
1946 - case 'text/xml':
1947 - if ( typeof response['pay_load'] == 'string' ) {
1948 - response['pay_load'] = mw.parseXML( response['pay_load'] );
1949 - }
1950 - break
1951 - default:
1952 - js_log( 'bad response type' + response['content-type'] );
1953 - return false;
1954 - break;
1955 - }
1956 - global_req_cb[response['cb_inx']]( response['pay_load'] );
1957 -}
1958 -// Load external JS via DOM injection
1959 -function loadExternalJs( url, callback ) {
1960 - js_log( 'load js: ' + url );
1961 - // if(window['$j']) // use jquery call:
1962 - /*$j.ajax({
1963 - type: "GET",
1964 - url: url,
1965 - dataType: 'script',
1966 - cache: true
1967 - });*/
1968 - // else{
1969 - var e = document.createElement( "script" );
1970 - e.setAttribute( 'src', url );
1971 - e.setAttribute( 'type', "text/javascript" );
1972 - /*if(callback)
1973 - e.onload = callback;
1974 - */
1975 - // e.setAttribute('defer', true);
1976 - document.getElementsByTagName( "head" )[0].appendChild( e );
1977 - // }
1978 -}
1979 -function styleSheetPresent( url ) {
1980 - style_elements = document.getElementsByTagName( 'link' );
1981 - if ( style_elements.length > 0 ) {
1982 - for ( i = 0; i < style_elements.length; i++ ) {
1983 - if ( style_elements[i].href == url )
1984 - return true;
1985 - }
1986 - }
1987 - return false;
1988 -}
1989 -function loadExternalCss( url ) {
1990 - // We could have the script loader group these CSS requests.
1991 - // But it's debatable: it may hurt more than it helps with caching and all
1992 - if ( typeof url == 'object' ) {
1993 - for ( var i in url ) {
1994 - loadExternalCss( url[i] );
1995 - }
1996 - return ;
1997 - }
1998 -
1999 - if ( url.indexOf( '?' ) == -1 ) {
2000 - url += '?' + getMwReqParam();
2001 - }
2002 - if ( !styleSheetPresent( url ) ) {
2003 - js_log( 'load css: ' + url );
2004 - var e = document.createElement( "link" );
2005 - e.href = url;
2006 - e.type = "text/css";
2007 - e.rel = 'stylesheet';
2008 - document.getElementsByTagName( "head" )[0].appendChild( e );
2009 - }
2010 -}
2011 -function getMvEmbedURL() {
2012 - if ( _global['mv_embed_url'] )
2013 - return _global['mv_embed_url'];
2014 - var js_elements = document.getElementsByTagName( "script" );
2015 - for ( var i = 0; i < js_elements.length; i++ ) {
2016 - // Check for mv_embed.js and/or script loader
2017 - var src = js_elements[i].getAttribute( "src" );
2018 - if ( src ) {
2019 - if ( src.indexOf( 'mv_embed.js' ) != -1 || (
2020 - ( src.indexOf( 'mwScriptLoader.php' ) != -1 || src.indexOf( 'jsScriptLoader.php' ) != -1 )
2021 - && src.indexOf( 'mv_embed' ) != -1 ) ) // (check for class=mv_embed script_loader call)
2022 - {
2023 - _global['mv_embed_url'] = src;
2024 - return src;
2025 - }
2026 - }
2027 - }
2028 - js_error( 'Error: getMvEmbedURL failed to get Embed Path' );
2029 - return false;
2030 -}
2031 -// Get a unique request ID to ensure fresh JavaScript
2032 -function getMwReqParam() {
2033 - if ( _global['req_param'] )
2034 - return _global['req_param'];
2035 - var mv_embed_url = getMvEmbedURL();
2036 -
2037 - var req_param = '';
2038 -
2039 - // If we have a URI, add it to the req
2040 - var urid = mw.parseUri( mv_embed_url ).queryKey['urid']
2041 - // If we're in debug mode, get a fresh unique request key and pass on "debug" param
2042 - if ( mw.parseUri( mv_embed_url ).queryKey['debug'] == 'true' ) {
2043 - var d = new Date();
2044 - req_param += 'urid=' + d.getTime() + '&debug=true';
2045 - } else if ( urid ) {
2046 - // Set from request urid:
2047 - req_param += 'urid=' + urid;
2048 - } else {
2049 - // Otherwise, just use the mv_embed version
2050 - req_param += 'urid=' + mw.version;
2051 - }
2052 - // add the lang param:
2053 - var langKey = mw.parseUri( mv_embed_url ).queryKey['uselang'];
2054 - if ( langKey )
2055 - req_param += '&uselang=' + langKey;
2056 -
2057 - _global['req_param'] = req_param;
2058 -
2059 - return _global['req_param'];
2060 -}
2061 -/*
2062 - * Set the global mv_embed path based on the script's location
2063 - */
2064 -function getMvEmbedPath() {
2065 - if ( _global['mv_embed_path'] )
2066 - return _global['mv_embed_path'];
2067 - var mv_embed_url = getMvEmbedURL();
2068 - if ( mv_embed_url.indexOf( 'mv_embed.js' ) !== -1 ) {
2069 - mv_embed_path = mv_embed_url.substr( 0, mv_embed_url.indexOf( 'mv_embed.js' ) );
2070 - } else if ( mv_embed_url.indexOf( 'mwScriptLoader.php' ) !== -1 ) {
2071 - // Script loader is in the root of MediaWiki, so include the default mv_embed extension path
2072 - mv_embed_path = mv_embed_url.substr( 0, mv_embed_url.indexOf( 'mwScriptLoader.php' ) )
2073 - + mediaWiki_mvEmbed_path;
2074 - } else {
2075 - mv_embed_path = mv_embed_url.substr( 0, mv_embed_url.indexOf( 'jsScriptLoader.php' ) );
2076 - }
2077 - // Make an absolute URL (if it's relative and we don't have an mv_embed path)
2078 - if ( mv_embed_path.indexOf( '://' ) == -1 ) {
2079 - var pURL = mw.parseUri( document.URL );
2080 - if ( mv_embed_path.charAt( 0 ) == '/' ) {
2081 - mv_embed_path = pURL.protocol + '://' + pURL.authority + mv_embed_path;
2082 - } else {
2083 - // Relative
2084 - if ( mv_embed_path == '' ) {
2085 - mv_embed_path = pURL.protocol + '://' + pURL.authority + pURL.directory + mv_embed_path;
2086 - }
2087 - }
2088 - }
2089 - _global['mv_embed_path'] = mv_embed_path;
2090 - return mv_embed_path;
2091 -}
2092 -
2093 -if ( typeof DOMParser == "undefined" ) {
2094 - DOMParser = function () { }
2095 - DOMParser.prototype.parseFromString = function ( str, contentType ) {
2096 - if ( typeof ActiveXObject != "undefined" ) {
2097 - var d = new ActiveXObject( "MSXML.DomDocument" );
2098 - d.loadXML( str );
2099 - return d;
2100 - } else if ( typeof XMLHttpRequest != "undefined" ) {
2101 - var req = new XMLHttpRequest;
2102 - req.open( "GET", "data:" + ( contentType || "application/xml" ) +
2103 - ";charset=utf-8," + encodeURIComponent( str ), false );
2104 - if ( req.overrideMimeType ) {
2105 - req.overrideMimeType( contentType );
2106 - }
2107 - req.send( null );
2108 - return req.responseXML;
2109 - }
2110 - }
2111 -}
2112 -/*
2113 -* Utility functions
2114 -*/
2115 -function js_log( string ) {
2116 - // Add any prepend debug strings if necessary (used for cross browser)
2117 - if ( mw.conf['debug_pre'] )
2118 - string = mw.conf['debug_pre'] + string;
2119 -
2120 - if ( window.console ) {
2121 - window.console.log( string );
2122 - } else {
2123 - /*
2124 - * IE and non-Firebug debug:
2125 - */
2126 - /*var log_elm = document.getElementById('mv_js_log');
2127 - if(!log_elm){
2128 - document.getElementsByTagName("body")[0].innerHTML = document.getElementsByTagName("body")[0].innerHTML +
2129 - '<div style="position:absolute;z-index:500;top:0px;left:0px;right:0px;height:10px;">'+
2130 - '<textarea id="mv_js_log" cols="120" rows="5"></textarea>'+
2131 - '</div>';
2132 -
2133 - var log_elm = document.getElementById('mv_js_log');
2134 - }
2135 - if(log_elm){
2136 - log_elm.value+=string+"\n";
2137 - }*/
2138 - }
2139 - return false;
2140 -}
2141 -
2142 -function js_error( string ) {
2143 - alert( string );
2144 - return false;
2145 -}
Index: branches/js2-work/phase3/js2/mwEmbed/php/noMediaWikiConfig.php
@@ -43,6 +43,8 @@
4444
4545 // Get the autoload classes
4646 require_once( realpath( dirname( __FILE__ ) ) . '/jsAutoloadLocalClasses.php' );
 47+// Load the javascript Classes
 48+wfLoadMwEmbedClassPaths();
4749
4850 // Get the JSmin class:
4951 require_once( realpath( dirname( __FILE__ ) ) . '/minify/JSMin.php' );
Index: branches/js2-work/phase3/js2/mwEmbed/php/maintenance/mergeJavascriptMsg.php
@@ -96,7 +96,7 @@
9797 $jsFileText = file_get_contents( $fname );
9898 $mwPos = strpos( $fname, 'mwEmbed' ) + 7;
9999 $curFileName = substr( $fname, $mwPos );
100 - if ( preg_match( '/loadGM\s*\(\s*{(.*)}\s*\)\s*/siU', // @@todo fix: will break down if someone does }) in their msg text
 100+ if ( preg_match( '/mw\.addMessages\s*\(\s*{(.*)}\s*\)\s*/siU', // @@todo fix: will break down if someone does }) in their msg text
101101 $jsFileText,
102102 $matches ) ) {
103103 $msgSet .= doJsonMerge( $matches[1] );
@@ -147,8 +147,8 @@
148148 // escape $1 for preg replace:
149149 $json_txt = str_replace( '$', '\$', $json_txt );
150150 // print "json:\n$json_txt \n";
151 - $str = preg_replace ( '/loadGM\s*\(\s*{(.*)}\s*\)\s*/siU',
152 - "loadGM(" . $json_txt . ")",
 151+ $str = preg_replace ( '/mw.addMessages\s*\(\s*{(.*)}\s*\)\s*/siU',
 152+ "mw.addMessages(" . $json_txt . ")",
153153 $jsFileText );
154154
155155 // print substr($str, 0, 600);
Index: branches/js2-work/phase3/js2/mwEmbed/php/jsAutoloadLocalClasses.php
@@ -1,36 +1,38 @@
22 <?php
 3+
34 if ( !defined( 'MEDIAWIKI' ) ) die( 1 );
45
56 global $wgJSAutoloadLocalClasses, $wgMwEmbedDirectory;
67
7 -// Load classes from mv_embed.js
8 -if ( is_file( $wgMwEmbedDirectory . 'mv_embed.js' ) ) {
 8+/**
 9+ * loads javascript class name paths from mwEmbed.js
 10+ */
 11+function wfLoadMwEmbedClassPaths ( ) {
 12+ global $wgMwEmbedDirectory;
 13+ // Load classes from mwEmbed.js
 14+ if ( is_file( $wgMwEmbedDirectory . 'mwEmbed.js' ) ) {
915
10 - //read the head of the file::
11 - $f = fopen( $wgMwEmbedDirectory . 'mv_embed.js' , 'r');
12 - $jsvar = '';
13 - $file_head='';
14 - while (!feof($f)) {
15 - $file_head.= fread($f, 8192);
 16+ // NOTE: ideally we could cache this json var and or update it php side per release
 17+
 18+ // Read the file:
 19+ $file_content = file_get_contents( $wgMwEmbedDirectory . 'mwEmbed.js' );
1620 // Call jsClassPathLoader() for each lcPaths() call in the JS source
1721 $replace_test = preg_replace_callback(
18 - '/lcPaths\s*\(\s*{(.*)}\s*\)\s*/siU',
19 - 'jsClassPathLoader',
20 - $file_head
 22+ '/mw\.addClassFilePaths\s*\(\s*{(.*)}\s*\)\s*/siU',
 23+ 'wfClassPathLoader',
 24+ $file_content
2125 );
22 - if( $replace_test !== false )
23 - break;
2426 }
25 - fclose( $f );
2627 }
27 -function jsClassPathLoader( $jvar ) {
 28+function wfClassPathLoader( $jvar ) {
2829 global $wgJSAutoloadLocalClasses, $wgMwEmbedDirectory;
2930 if ( !isset( $jvar[1] ) )
3031 return false;
31 - $jClassSet = json_decode( '{' . $jvar[1] . '}', true );
 32+ $jClassSet = FormatJson::decode( '{' . $jvar[1] . '}', true );
3233 foreach ( $jClassSet as $jClass => $jPath ) {
3334 // Strip $ from jClass (as they are stripped on URL request parameter input)
3435 $jClass = str_replace( '$', '', $jClass );
35 - $wgJSAutoloadLocalClasses[$jClass] = $wgMwEmbedDirectory . $jPath;
 36+ $wgJSAutoloadLocalClasses[ $jClass ] = $wgMwEmbedDirectory . $jPath;
3637 }
 38+
3739 }
Index: branches/js2-work/phase3/js2/mwEmbed/php/languages/mwEmbed.i18n.php
@@ -111,7 +111,7 @@
112112 'mwe-sequencer_credit_line' => 'Developed by <a href="http://kaltura.com">Kaltura, Inc.</a> in partnership with the <a href="http://wikimediafoundation.org/wiki/Home">Wikimedia Foundation</a> (<a href="#">more information</a>).',
113113
114114 /*
115 - * js file: /mv_embed.js
 115+ * js file: /mwEmbed.js
116116 */
117117 'mwe-loading_txt' => 'Loading ...',
118118 'mwe-size-gigabytes' => '$1 GB',
@@ -347,7 +347,7 @@
348348 'mwe-loading_plugin' => 'loading plugin ...',
349349 'mwe-select_playback' => 'Set playback preference',
350350 'mwe-link_back' => 'Link back',
351 - 'mwe-error_swap_vid' => 'Error: mv_embed was unable to swap the video tag for the mv_embed interface',
 351+ 'mwe-error_swap_vid' => 'Error: mwEmbed was unable to swap the video tag for the mwEmbed interface',
352352 'mwe-add_to_end_of_sequence' => 'Add to end of sequence',
353353 'mwe-missing_video_stream' => 'The video file for this stream is missing',
354354 'mwe-play_clip' => 'Play clip',
Index: branches/js2-work/phase3/js2/mwEmbed/skins/kskin/kskin.js
@@ -2,7 +2,7 @@
33 * skin js allows you to override contrlBuilder html/class output
44 */
55
6 -loadGM( {
 6+mw.addMessages( {
77 "mwe-credit-title" : "Title: $1",
88 "mwe-kaltura-platform-title" : "Kaltura open source video platform"
99 } );
@@ -160,7 +160,7 @@
161161 '</div>'
162162 );
163163
164 - if( mw.conf.k_attribution == true ){
 164+ if( mw.getConfig( 'k_attribution' ) == true ){
165165 $target.append(
166166 $j('<div/>').addClass( 'k-attribution' )
167167 .attr({
Index: branches/js2-work/phase3/js2/mwEmbed/skins/ctrlBuilder.js
@@ -59,7 +59,7 @@
6060 },
6161
6262 /**
63 - * Gets the controlls html
 63+ * Gets the controls html
6464 * @return {String} html output of controls
6565 */
6666 getControls:function() {
Index: branches/js2-work/phase3/js2/mwEmbed/mwEmbed.js
@@ -0,0 +1,2698 @@
 2+/*
 3+ * ~mwEmbed ~
 4+ * For details see: http://www.mediawiki.org/wiki/MwEmbed
 5+ *
 6+ * All MediaWiki code is released under the GPL2.
 7+ * For more information visit http://metavid.org/wiki/Code
 8+ *
 9+ * @author Michael Dale
 10+ *
 11+ * mwEmbed uses the following libraries:
 12+ *
 13+ * jQuery:
 14+ * http://jquery.com/
 15+ *
 16+ * mw.parseUri:
 17+ * http://stevenlevithan.com/demo/parseuri/js/
 18+ *
 19+ */
 20+
 21+/**
 22+ * AutoLoader paths
 23+ * @path The path to the file (or set of files) with ending slash
 24+ * @gClasses The set of classes
 25+ * if it's an array, $j.className becomes jquery.className.js
 26+ * if it's an associative object then key => value pairs are used
 27+ */
 28+if ( typeof mvAutoLoadClasses == 'undefined' )
 29+ mvAutoLoadClasses = { };
 30+
 31+// The script that loads the class set
 32+function lcPaths( classSet ) {
 33+ for ( var i in classSet ) {
 34+ mvAutoLoadClasses[i] = classSet[i];
 35+ }
 36+}
 37+
 38+function mvGetClassPath( k ) {
 39+ if ( mvAutoLoadClasses[k] ) {
 40+ // js_log('got class path:' + k + ' : '+ mvClassPaths[k]);
 41+ return mvAutoLoadClasses[k];
 42+ } else {
 43+ js_log( 'Error:: Could not find path for requested class ' + k );
 44+ return false;
 45+ }
 46+}
 47+
 48+if ( typeof mvCssPaths == 'undefined' )
 49+ mvCssPaths = { };
 50+
 51+function lcCssPath( cssSet ) {
 52+ for ( var i in cssSet ) {
 53+ mvCssPaths[i] = cssSet[i];
 54+ }
 55+}
 56+
 57+// Dependency mapping for CSS files for self-contained included plugins:
 58+lcCssPath( {
 59+ '$j.Jcrop' : 'libClipEdit/Jcrop/css/jquery.Jcrop.css',
 60+ '$j.fn.ColorPicker' : 'libClipEdit/colorpicker/css/colorpicker.css'
 61+})
 62+
 63+// The global scope: will be depreciated once we get everything into mw
 64+var _global = this;
 65+
 66+/*
 67+* setup the empty global mw object
 68+* will ensure all our functions and variables are properly namespaced
 69+* reducing chance of conflicts
 70+*/
 71+if ( !window['mw'] ) {
 72+ window['mw'] = { }
 73+}
 74+
 75+
 76+/**
 77+* Default global config values. Configuration values are set via mw.setConfig
 78+* Configuration values should genneraly be set prior to dom-ready
 79+*/
 80+var mwDefaultConf = {
 81+ // Default skin name
 82+ 'skin_name' : 'mvpcf',
 83+
 84+ // Default jquery ui skin name
 85+ 'jui_skin' : 'redmond',
 86+
 87+ // What tags will be re-written to video player by default
 88+ // set to empty string or null to avoid automatic rewrites
 89+ 'rewriteTags' : 'video,audio,playlist',
 90+
 91+ /**
 92+ * If jQuery / mwEmbed should always be loaded.
 93+ *
 94+ * mwEmbedSetup ignores this flag and is run if:
 95+ * If your js calls mw.addOnloadHook ( callback_function )
 96+ * If your page includes any tags set in config.rewriteTags
 97+ *
 98+ * This flag increases page performace on pages that do not use mwEmbed
 99+ * and don't already load jQuery
 100+ *
 101+ * For examle when including the mwEmbed.js in your blog template
 102+ * mwEmbed will only load extra js on blog posts that include the video tag.
 103+ *
 104+ * NOTE: Future articture will probably do away with this flag and refactor it into
 105+ * a smaller "remotePageMwEmbed.js" script similar to remoteMwEmbed.js in the js2 folder
 106+ */
 107+ 'alwaysSetupMwEmbed' : false,
 108+
 109+ // Default video size ( if no size provided )
 110+ 'video_size' : '400x300',
 111+
 112+ // If the k-skin video player should attribute kaltura
 113+ 'k_attribution' : true,
 114+
 115+ // The path of mvEmbed in mediaWiki folder
 116+ 'mediaWikiPath' : 'js2/mwEmbed/'
 117+}
 118+
 119+
 120+// @@todo move these into mw
 121+var global_req_cb = new Array(); // The global request callback array
 122+
 123+/**
 124+* The global mw object:
 125+*
 126+* Any global functions/classes that are not jQuery plugins should make
 127+* there way into the mw namespace
 128+*/
 129+( function( $ ) {
 130+ // list valid skins here:
 131+ $.valid_skins = [ 'mvpcf', 'kskin' ];
 132+ // the version of mwEmbed
 133+ $.version = '1.1';
 134+
 135+ // special case of commons api url
 136+ // (used for default subtitles server for media with a "wikiTitleKey" atm)
 137+ // (@@todo eventually we should have wikiTitleKey be namespaced with interwiki ns
 138+ $.commons_api_url = 'http://commons.wikimedia.org/w/api.php';
 139+
 140+ /**
 141+ * Some global containers flags
 142+ */
 143+ $.skin_list = new Array();
 144+ $.init_done = false;
 145+ $.cb_count = 0;
 146+ $.player_list = new Array(), // The global player list per page
 147+ $.req_cb = new Array() // The global request callback array
 148+
 149+ /**
 150+ * Configuration System:
 151+ *
 152+ * Simple system of inherit defauts, with getter setter functions:
 153+ */
 154+
 155+ // Local scope configuration var:
 156+ mwConfig = { };
 157+
 158+ for(var i in mwDefaultConf){
 159+ if( typeof mwConfig[ i ] == 'undefined' )
 160+ mwConfig[ i ] = mwDefaultConf[ i ];
 161+ }
 162+
 163+ /**
 164+ * Setter for configuration values
 165+ *
 166+ * @param {String} name Name of configuration value
 167+ * @param {String} value Value of configuration name
 168+ */
 169+ $.setConfig = function ( name, value ){
 170+ mwConfig[ name ] = value;
 171+ }
 172+
 173+ /**
 174+ * Getter for configuration values
 175+ *
 176+ * @param {String} name of configuration value to get
 177+ * @return {Mixed} value of configuration key
 178+ * returns "false" if key not found
 179+ */
 180+ $.getConfig = function ( name ){
 181+ if(mwConfig[ name ] )
 182+ return mwConfig[ name ];
 183+ return false;
 184+ }
 185+
 186+
 187+
 188+ /**
 189+ * Language classes mw.lang
 190+ *
 191+ * Localized Language support attempts to mirror some of the functionality of Language.php in MediaWiki
 192+ * It contains methods for loading and transforming msg text
 193+ *
 194+ */
 195+ $.lang = { };
 196+
 197+ /**
 198+ * Setup the lang object
 199+ */
 200+ var messageCache = { };
 201+ var gRuleSet = { };
 202+
 203+ /**
 204+ * mw.addMessages function
 205+ * Loads a set of json messages into the messegeCache object.
 206+ *
 207+ * @param json msgSet The set of msgs to be loaded
 208+ */
 209+ $.addMessages = function( msgSet ) {
 210+ for ( var i in msgSet ) {
 211+ messageCache[ i ] = msgSet[i];
 212+ }
 213+ }
 214+
 215+ /**
 216+ * loadRS function
 217+ * Loads a ruleset by given template key ie PLURAL : { //ruleSetObj }
 218+ *
 219+ * @param json ruleSet The ruleset object ( extends gRuleSet )
 220+ */
 221+ $.lang.loadRS = function( ruleSet ) {
 222+ for ( var i in ruleSet ) {
 223+ gRuleSet[ i ] = ruleSet[ i ];
 224+ }
 225+ }
 226+
 227+ /**
 228+ * Returns a transformed msg string
 229+ *
 230+ * it take a msg key and array of replacement values of form
 231+ * $1, $2 and does relevant msgkey transformation returning
 232+ * the user msg.
 233+ *
 234+ * @param {String} key The msg key as set by mw.addMessages
 235+ * @param [mixed] args An array of replacement strings
 236+ * @return string
 237+ */
 238+ $.lang.gM = function( key , args ) {
 239+
 240+ // Check for missing message key
 241+ if ( ! messageCache[ key ] )
 242+ return '&lt;' + key + '&gt;';
 243+
 244+ // swap in the arg values
 245+ var ms = $.lang.gMsgSwap( key, args );
 246+
 247+ // a quick check to see if we need to send the msg via the 'parser'
 248+ // (we can add more detailed check once we support more wiki syntax)
 249+ if ( ms.indexOf( '{{' ) === -1 && ms.indexOf( '[' ) === -1 ) {
 250+ return ms;
 251+ }
 252+
 253+ // make sure we have the lagMagic setup:
 254+ // @@todo move to init
 255+ $.lang.magicSetup();
 256+ // send the msg key through the parser
 257+ var pObj = $.parser.pNew( ms );
 258+ // return the transformed msg
 259+ return pObj.getHTML();
 260+ }
 261+ /**
 262+ * gMsgSwap
 263+ *
 264+ * @param string key The msg key as set by mw.addMessages
 265+ * @param [mixed] args An array or string to be replaced
 266+ * @return string
 267+ */
 268+ $.lang.gMsgSwap = function( key , args ) {
 269+ if ( ! messageCache[ key ] )
 270+ return '&lt;' + key + '&gt;';// Missing key placeholder
 271+ // get the message string:
 272+ var ms = messageCache[ key ];
 273+
 274+ // replace values
 275+ if ( typeof args == 'object' || typeof args == 'array' ) {
 276+ for ( var v in args ) {
 277+ // Message test replace arguments start at 1 instead of zero:
 278+ var rep = new RegExp( '\\$' + ( parseInt( v ) + 1 ), 'g' );
 279+ ms = ms.replace( rep, args[v] );
 280+ }
 281+ } else if ( typeof args == 'string' || typeof args == 'number' ) {
 282+ ms = ms.replace( /\$1/g, args );
 283+ }
 284+ return ms;
 285+ }
 286+
 287+ /**
 288+ * gMsgNoTrans
 289+ *
 290+ * @returns string The msg key without transforming it
 291+ */
 292+ $.lang.gMsgNoTrans = function( key ) {
 293+ if ( messageCache[ key ] )
 294+ return messageCache[ key ]
 295+
 296+ // Missing key placeholder
 297+ return '&lt;' + key + '&gt;';
 298+ }
 299+
 300+ /**
 301+ * Add Supported Magic Words to parser
 302+ */
 303+ // Set the setupflag to false:
 304+ $.lang.doneSetup = false;
 305+ $.lang.magicSetup = function() {
 306+ if ( !$.lang.doneSetup ) {
 307+ $.parser.addTemplateTransform ( {
 308+ 'PLURAL' : $.lang.procPLURAL
 309+ } )
 310+
 311+ $.lang.doneSetup = true;
 312+ }
 313+
 314+ }
 315+
 316+ /**
 317+ * Process the PLURAL special language template key:
 318+ */
 319+ $.lang.procPLURAL = function( tObj ) {
 320+ // setup shortcuts
 321+ // (gRuleSet is loaded from script-loader to contains local ruleset)
 322+ var rs = gRuleSet['PLURAL'];
 323+
 324+ /*
 325+ * Plural matchRuleTest
 326+ */
 327+ function matchRuleTest( cRule, val ) {
 328+ js_log("matchRuleTest:: " + typeof cRule + ' ' + cRule + ' == ' + val );
 329+ function checkValue( compare, val ) {
 330+ if ( typeof compare == 'string' ) {
 331+ range = compare.split( '-' );
 332+ if ( range.length >= 1 ) {
 333+ if ( val >= range[0] && val <= range[1] )
 334+ return true;
 335+ }
 336+ }
 337+ // else do a direct compare
 338+ if ( compare == val ) {
 339+ return true;
 340+ }
 341+ return false;
 342+ }
 343+ // check for simple cRule type:
 344+ if ( typeof cRule == 'number' ) {
 345+ return ( parseInt( val ) == parseInt( cRule ) );
 346+ } else if ( typeof cRule == 'object' ) {
 347+ var cmatch = { };
 348+ // if a list we need to match all for rule match
 349+ for ( var i in cRule ) {
 350+ var cr = cRule[i];
 351+ // set cr type
 352+ var crType = '';
 353+ for ( var j in cr ) {
 354+ if ( j == 'mod' )
 355+ crType = 'mod'
 356+ }
 357+ switch( crType ) {
 358+ case 'mod':
 359+ if ( cr ['is'] ) {
 360+ if ( checkValue( val % cr['mod'], cr ['is'] ) )
 361+ cmatch[i] = true;
 362+ } else if ( cr['not'] ) {
 363+ if ( ! checkValue( val % cr['mod'], cr ['not'] ) )
 364+ cmatch[i] = true;
 365+ }
 366+ break;
 367+ }
 368+ }
 369+ // check all the matches (taking into consideration "or" order)
 370+ for ( var i in cRule ) {
 371+ if ( ! cmatch[i] )
 372+ return false;
 373+ }
 374+ return true;
 375+
 376+ }
 377+ }
 378+ /**
 379+ * Maps a given rule Index to template params:
 380+ *
 381+ * if index is out of range return last param
 382+ * @param
 383+ */
 384+ function getTempParamFromRuleInx( tObj, ruleInx ) {
 385+ // js_log('getTempParamFromRuleInx: ruleInx: ' + ruleInx + ' tempParamLength ' + tObj.param.length );
 386+ if ( ruleInx >= tObj.param.length )
 387+ return tObj.param[ tObj.param.length - 1 ];
 388+ // else return the requested index:
 389+ return tObj.param[ ruleInx ];
 390+ }
 391+ var rCount = 0
 392+ // run the actual rule lookup:
 393+ for ( var ruleInx in rs ) {
 394+ cRule = rs[ruleInx];
 395+ if ( matchRuleTest( cRule, tObj.arg ) ) {
 396+ js_log("matched rule: " + ruleInx );
 397+ return getTempParamFromRuleInx( tObj, rCount );
 398+ }
 399+ rCount ++;
 400+ }
 401+ js_log('no match found for: ' + tObj.arg + ' using last/other : ' + tObj.param [ tObj.param.length -1 ] );
 402+ //debugger;
 403+ // return the last /"other" template param
 404+ return tObj.param [ tObj.param.length - 1 ];
 405+ }
 406+
 407+ /**
 408+ * gMsgLoadRemote loads remote msg strings
 409+ *
 410+ * @param mixed msgSet the set of msg to load remotely
 411+ * @param function callback the callback to issue once string is ready
 412+ */
 413+ $.lang.gMsgLoadRemote = function( msgSet, callback ) {
 414+ var ammessages = '';
 415+ if ( typeof msgSet == 'object' ) {
 416+ for ( var i in msgSet ) {
 417+ ammessages += msgSet[i] + '|';
 418+ }
 419+ } else if ( typeof msgSet == 'string' ) {
 420+ ammessages += msgSet;
 421+ }
 422+ if ( ammessages == '' ) {
 423+ js_log( 'gMsgLoadRemote: no message set requested' );
 424+ return false;
 425+ }
 426+ do_api_req( {
 427+ 'data': {
 428+ 'meta': 'allmessages',
 429+ 'ammessages': ammessages
 430+ }
 431+ }, function( data ) {
 432+ if ( data.query.allmessages ) {
 433+ var msgs = data.query.allmessages;
 434+ for ( var i in msgs ) {
 435+ var ld = { };
 436+ ld[ msgs[i]['name'] ] = msgs[i]['*'];
 437+ mw.addMessages( ld );
 438+ }
 439+ }
 440+ callback();
 441+ } );
 442+ }
 443+
 444+ /**
 445+ * Format a size in bytes for output, using an appropriate
 446+ * unit (B, KB, MB or GB) according to the magnitude in question
 447+ *
 448+ * @param size Size to format
 449+ * @return string Plain text (not HTML)
 450+ */
 451+ $.lang.formatSize = function ( size ) {
 452+ // For small sizes no decimal places are necessary
 453+ var round = 0;
 454+ var msg = '';
 455+ if ( size > 1024 ) {
 456+ size = size / 1024;
 457+ if ( size > 1024 ) {
 458+ size = size / 1024;
 459+ // For MB and bigger two decimal places are smarter
 460+ round = 2;
 461+ if ( size > 1024 ) {
 462+ size = size / 1024;
 463+ msg = 'mwe-size-gigabytes';
 464+ } else {
 465+ msg = 'mwe-size-megabytes';
 466+ }
 467+ } else {
 468+ msg = 'mwe-size-kilobytes';
 469+ }
 470+ } else {
 471+ msg = 'mwe-size-bytes';
 472+ }
 473+ // JavaScript does not let you choose the precision when rounding
 474+ var p = Math.pow( 10, round );
 475+ var size = Math.round( size * p ) / p;
 476+ return gM( msg , size );
 477+ };
 478+
 479+ $.lang.formatNumber = function( num ) {
 480+ /*
 481+ * addSeparatorsNF
 482+ * @param Str: The number to be formatted, as a string or number.
 483+ * @param outD: The decimal character for the output, such as ',' for the number 100,2
 484+ * @param sep: The separator character for the output, such as ',' for the number 1,000.2
 485+ */
 486+ function addSeparatorsNF( nStr, outD, sep ) {
 487+ nStr += '';
 488+ var dpos = nStr.indexOf( '.' );
 489+ var nStrEnd = '';
 490+ if ( dpos != -1 ) {
 491+ nStrEnd = outD + nStr.substring( dpos + 1, nStr.length );
 492+ nStr = nStr.substring( 0, dpos );
 493+ }
 494+ var rgx = /(\d+)(\d{3})/;
 495+ while ( rgx.test( nStr ) ) {
 496+ nStr = nStr.replace( rgx, '$1' + sep + '$2' );
 497+ }
 498+ return nStr + nStrEnd;
 499+ }
 500+ // @@todo read language code and give periods or comas:
 501+ return addSeparatorsNF( num, '.', ',' );
 502+ }
 503+
 504+
 505+
 506+ /**
 507+ * MediaWiki wikitext "Parser"
 508+ *
 509+ * This is not feature complete but we need a way to get at template properties
 510+ *
 511+ *
 512+ * @param {String} wikiText the wikitext to be parsed
 513+ * @return {Object} parserObj returns a parser object that has methods for getting at
 514+ * things you would want
 515+ */
 516+ $.parser = { };
 517+ var pMagicSet = { };
 518+
 519+ /**
 520+ * parser addTemplateTransform
 521+ *
 522+ * Lets you add a set template key to be transformed by a callback function
 523+ *
 524+ * @param {Object} magicSet key:callback
 525+ */
 526+ $.parser.addTemplateTransform = function( magicSet ) {
 527+ for ( var i in magicSet )
 528+ pMagicSet[ i ] = magicSet[i];
 529+ }
 530+
 531+ // Create a new parser Object
 532+ $.parser.pNew = function( wikiText, opt ) {
 533+ var parseObj = function( wikiText, opt ) {
 534+ return this.init( wikiText, opt )
 535+ }
 536+ parseObj.prototype = {
 537+ // the wikiText "DOM"... stores the parsed wikiText structure
 538+ // wtDOM : {}, (not yet supported )
 539+
 540+ pOut : '', // the parser output string container
 541+ init :function( wikiText ) {
 542+ this.wikiText = wikiText;
 543+ },
 544+ updateText : function( wikiText ) {
 545+ this.wikiText = wikiText;
 546+ // invalidate the output (will force a re-parse )
 547+ this.pOut = '';
 548+ },
 549+ parse : function() {
 550+ /*
 551+ * quickly recursive / parse out templates:
 552+ */
 553+
 554+ // ~ probably a better algorithm out there / should mirror php parser flow ~
 555+ // (we are already running white-space issues ie php parse strips whitespace differently)
 556+ // or at least expose something similar to: http://www.mediawiki.org/wiki/Extension:Page_Object_Model
 557+
 558+ // ... but I am having fun with recursion so here it is...
 559+ function rdpp ( txt , cn ) {
 560+ var node = { };
 561+ // inspect each char
 562+ for ( var a = 0; a < txt.length; a++ ) {
 563+ if ( txt[a] == '{' && txt[a + 1] == '{' ) {
 564+ a = a + 2;
 565+ node['p'] = node;
 566+ if ( !node['c'] )
 567+ node['c'] = new Array();
 568+
 569+ node['c'].push( rdpp( txt.substr( a ), true ) );
 570+ } else if ( txt[a] == '}' && txt[a + 1] == '}' ) {
 571+ a = a + 2;
 572+ if ( !node['p'] ) {
 573+ return node;
 574+ }
 575+ node = node['p'];
 576+ }
 577+ if ( !node['t'] )
 578+ node['t'] = '';
 579+ // don't put closures into output:
 580+ if ( txt[a] && txt[a] != '}' )
 581+ node['t'] += txt[a];
 582+
 583+ }
 584+ return node;
 585+ }
 586+ /**
 587+ * parse template text as template name and named params
 588+ */
 589+ function parseTmplTxt( ts ) {
 590+ var tObj = { };
 591+ // Get template name:
 592+ tname = ts.split( '\|' ).shift() ;
 593+ tname = tname.split( '\{' ).shift() ;
 594+ tname = tname.replace( /^\s+|\s+$/g, "" ); //trim
 595+
 596+ // check for arguments:
 597+ if ( tname.split( ':' ).length == 1 ) {
 598+ tObj["name"] = tname;
 599+ } else {
 600+ tObj["name"] = tname.split( ':' ).shift();
 601+ tObj["arg"] = tname.split( ':' ).pop();
 602+ }
 603+
 604+ var pSet = ts.split( '\|' );
 605+ pSet.splice( 0, 1 );
 606+ if ( pSet.length ) {
 607+ tObj.param = new Array();
 608+ for ( var pInx in pSet ) {
 609+ var tStr = pSet[ pInx ];
 610+ // check for empty param
 611+ if ( tStr == '' ) {
 612+ tObj.param[ pInx ] = '';
 613+ continue;
 614+ }
 615+ for ( var b = 0 ; b < tStr.length ; b++ ) {
 616+ if ( tStr[b] == '=' && b > 0 && b < tStr.length && tStr[b - 1] != '\\' ) {
 617+ // named param
 618+ tObj.param[ tStr.split( '=' ).shift() ] = tStr.split( '=' ).pop();
 619+ } else {
 620+ // indexed param
 621+ tObj.param[ pInx ] = tStr;
 622+ }
 623+ }
 624+ }
 625+ }
 626+ return tObj;
 627+ }
 628+ function getMagicTxtFromTempNode( node ) {
 629+ node.tObj = parseTmplTxt ( node.t );
 630+ // do magic swap if template key found in pMagicSet
 631+ if ( node.tObj.name in pMagicSet ) {
 632+ var nt = pMagicSet[ node.tObj.name ]( node.tObj );
 633+ return nt;
 634+ } else {
 635+ // don't swap just return text
 636+ return node.t;
 637+ }
 638+ }
 639+ /**
 640+ * recurse_magic_swap
 641+ *
 642+ * go last child first swap upward: (could probably be integrated above somehow)
 643+ */
 644+ var pNode = null;
 645+ function recurse_magic_swap( node ) {
 646+ if ( !pNode )
 647+ pNode = node;
 648+
 649+ if ( node['c'] ) {
 650+ // swap all the kids:
 651+ for ( var i in node['c'] ) {
 652+ var nt = recurse_magic_swap( node['c'][i] );
 653+ // swap it into current
 654+ if ( node.t ) {
 655+ node.t = node.t.replace( node['c'][i].t, nt );
 656+ }
 657+ // swap into parent
 658+ pNode.t = pNode.t.replace( node['c'][i].t, nt );
 659+ }
 660+ // do the current node:
 661+ var nt = getMagicTxtFromTempNode( node );
 662+ pNode.t = pNode.t.replace( node.t , nt );
 663+ // run the swap for the outer most node
 664+ return node.t;
 665+ } else {
 666+ // node.t = getMagicFromTempObj( node.t )
 667+ return getMagicTxtFromTempNode( node );
 668+ }
 669+ }
 670+ // parse out the template node structure:
 671+ this.pNode = rdpp ( this.wikiText );
 672+ // strip out the parent from the root
 673+ this.pNode['p'] = null;
 674+
 675+ // do the recursive magic swap text:
 676+ this.pOut = recurse_magic_swap( this.pNode );
 677+ },
 678+ /*
 679+ * parsed template api ~loosely based off of ~POM~
 680+ * http://www.mediawiki.org/wiki/Extension:Page_Object_Model
 681+ */
 682+
 683+ /**
 684+ * templates
 685+ *
 686+ * gets a requested template from the wikitext (if available)
 687+ *
 688+ */
 689+ templates: function( tname ) {
 690+ this.parse();
 691+ var tmplSet = new Array();
 692+ function getMatchingTmpl( node ) {
 693+ if ( node['c'] ) {
 694+ for ( var i in node['c'] ) {
 695+ getMatchingTmpl( node['c'] );
 696+ }
 697+ }
 698+ if ( tname && node.tObj ) {
 699+ if ( node.tObj['name'] == tname )
 700+ tmplSet.push( node.tObj );
 701+ } else if ( node.tObj ) {
 702+ tmplSet.push( node.tObj );
 703+ }
 704+ }
 705+ getMatchingTmpl( this.pNode );
 706+ return tmplSet;
 707+ },
 708+
 709+ /**
 710+ * getTemplateVars
 711+ * returns a set of template values in a given wikitext page
 712+ *
 713+ * NOTE: should be integrated with the parser
 714+ */
 715+ getTemplateVars: function(){
 716+ //js_log('matching against: ' + wikiText);
 717+ templateVars = new Array();
 718+ var tempVars = wikiText.match(/\{\{\{([^\}]*)\}\}\}/gi);
 719+
 720+ // Clean up results:
 721+ for(var i=0; i < tempVars.length; i++){
 722+ //match
 723+ var tvar = tempVars[i].replace('{{{','').replace('}}}','');
 724+
 725+ // Strip anything after a |
 726+ if(tvar.indexOf('|') != -1){
 727+ tvar = tvar.substr(0, tvar.indexOf('|'));
 728+ }
 729+
 730+ // Check for duplicates:
 731+ var do_add=true;
 732+ for(var j=0; j < templateVars.length; j++){
 733+ if( templateVars[j] == tvar)
 734+ do_add=false;
 735+ }
 736+
 737+ // Add the template vars to the output obj
 738+ if(do_add)
 739+ templateVars.push( tvar );
 740+ }
 741+ return templateVars;
 742+ },
 743+
 744+ /**
 745+ * Returns the transformed wikitext
 746+ *
 747+ * Build output from swappable index
 748+ * (all transforms must be expanded in parse stage and linearly rebuilt)
 749+ * Alternatively we could build output using a place-holder & replace system
 750+ * (this lets us be slightly more sloppy with ordering and indexes, but probably slower)
 751+ *
 752+ * Ideal: we build a 'wiki DOM'
 753+ * When editing you update the data structure directly
 754+ * Then in output time you just go DOM->html-ish output without re-parsing anything
 755+ */
 756+ getHTML : function() {
 757+ // wikiText updates should invalidate pOut
 758+ if ( this.pOut == '' ) {
 759+ this.parse();
 760+ }
 761+ return this.pOut;
 762+ }
 763+ };
 764+ // return the parserObj
 765+ return new parseObj( wikiText, opt ) ;
 766+ };
 767+
 768+
 769+ /**
 770+ * The loader prototype:
 771+ */
 772+ $.loader = {
 773+ /*
 774+ * Javascript Module Set
 775+ * @key Name of Module
 776+ * @value function code to load module
 777+ */
 778+ moduleNames : { },
 779+
 780+ /**
 781+ * Javascript Class Names
 782+ * @key Name of class
 783+ * @value Class file path
 784+ */
 785+ classNames : { },
 786+
 787+ /**
 788+ * Load a set of scripts.
 789+ * Will issue many load requests or package the request for the script-loader
 790+ *
 791+ * @param {Object} loadSet Set of scripts to be loaded
 792+ * @param {Function} callback Function to call once all scripts are loaded.
 793+ */
 794+ loadMany: function( loadSet, callback ){
 795+ //Setup up the local "loadState"
 796+ var loadState = { };
 797+ // Check if its a dependency set ( nested objects )
 798+ if( typeof loadSet [ 0 ] == 'object' ){
 799+ //Load sets of classes ( to preserver order for some browsers )
 800+ this.loadDependencyChain( loadSet, callback );
 801+ return ;
 802+ }
 803+
 804+ // Set the initial load state for every item in the loadSet
 805+ for( var i in loadSet ){
 806+ var loadName = loadSet[ i ];
 807+ loadState[ loadName ] = 0;
 808+ }
 809+
 810+ // Issue the load request check check loadState to see if we are "done"
 811+ for( var i in loadSet ){
 812+ var loadName = loadSet[ i ];
 813+ $.load( loadName, function ( loadName ){
 814+ loadState[ loadName ] = 1;
 815+
 816+ var loadDone = true;
 817+ for( var j in loadState ){
 818+ if( loadState[ j ] === 0 )
 819+ loadDone = false;
 820+ }
 821+ // Run the parent scope callback for "loadMany"
 822+ if( loadDone )
 823+ callback();
 824+ } );
 825+ }
 826+ },
 827+
 828+ /**
 829+ * Load a sets of scripts satisfy dependency order for browsers that execute out of order
 830+ *
 831+ * @param {Object} loadChain A set of javascript arrays to be loaded.
 832+ * Sets are requested in array order.
 833+ */
 834+ loadDependencyChain: function( loadChain, callback ){
 835+ var _this = this;
 836+ // Load with dependency checks
 837+ this.load( loadChain.shift(), function() {
 838+ if ( loadChain.length != 0 ) {
 839+ _this.loadDependencyChain( loadChain, callback );
 840+ } else {
 841+ callback();
 842+ }
 843+ } );
 844+ },
 845+
 846+ /**
 847+ * Core load function:
 848+ *
 849+ * @param {Mixed} loadRequest:
 850+ *
 851+ * {String} Name of a module to be loaded
 852+ * Modules are added via addModuleLoader and can define custom
 853+ * code needed to load the module dependencies
 854+ * Module loader function should accept a callback argument
 855+ *
 856+ * {String} Name of a class to loaded.
 857+ * Using defined class names avoids loading the same class
 858+ * twice by first checking if the "class variable" is defined
 859+ *
 860+ * {String} Absolute or relative to mwEmbed file path.
 861+ * The same file won't be loaded twice
 862+ *
 863+ * {Array} can be an array of any combination of the above strings.
 864+ * Will be loaded in-order or in a single
 865+ * script-loader request if scriptLoader is enabled
 866+ *
 867+ * {Array} {Array} Can be a set of Arrays for loading.
 868+ * Some browsers execute included scripts out of order.
 869+ * This lets you chain sets of request for thouse browers.
 870+ * If using the script-loader order is preserved in output and
 871+ * a single request will be used.
 872+ *
 873+ * @param {Function} callback Function called once loading is complete
 874+ */
 875+ load: function( loadRequest, callback ){
 876+
 877+ // Check if its a multi-part request:
 878+ if( typeof loadRequest == 'object' ){
 879+ this.loadMany ( loadRequest, callback );
 880+ return ;
 881+ }
 882+
 883+ // Check for the module name loader function
 884+ if( this.moduleNames[ loadRequest ] &&
 885+ typeof ( this.moduleNames[ loadRequest ] ) == 'function'
 886+ ){
 887+ //Run the module with the parent callback
 888+ this.moduleNames[ loadRequest ]( callback );
 889+ return ;
 890+ }
 891+
 892+ // Check for javascript class
 893+ if( this.classNames[ loadRequest ] ){
 894+ this.loadClass( loadRequest, callback );
 895+ return ;
 896+ }
 897+
 898+ // Try loading as a "file"
 899+ if( loadRequest ) {
 900+ $.getScript( loadRequest, callback );
 901+ return ;
 902+ }
 903+
 904+ //possible error?
 905+ js_log( "Error could not handle load request" );
 906+ },
 907+
 908+ /**
 909+ * Loads javascript associated with a className
 910+ *
 911+ * @param {String} className Name of class to load
 912+ * @param {Function} callback Function to run once class is loaded
 913+ */
 914+ loadClass: function( className , callback){
 915+
 916+ // Make sure the class is not already defined:
 917+ if ( $.isset( className ) ){
 918+ js_log( 'Class ( ' + className + ' ) already defined ' );
 919+ return ;
 920+ }
 921+
 922+ // Get the class url:
 923+ var baseClassPath = this.classNames[ className ];
 924+
 925+ var url = null;
 926+ // Load the mwEmbed path ( if not a root dir url )
 927+ if( baseClassPath.indexOf( '/' ) !== 0 ){
 928+ url = $.getMwEmbedPath() + baseClassPath;
 929+ }else{
 930+ url = baseClassPath;
 931+ }
 932+
 933+ if( ! url ){
 934+ js_log( "Could not get url for class " + className );
 935+ return ;
 936+ }
 937+
 938+ // Issue the request to load the class (include class name in result callback:
 939+ $.getScript( url, function( ) {
 940+ callback( className );
 941+ } );
 942+
 943+ },
 944+
 945+ /**
 946+ * Adds a module to the mwLoader object
 947+ *
 948+ * @param {String} name Name of module
 949+ * @param {Function} moduleLoader Function that
 950+ * loads dependencies for a module
 951+ */
 952+ addModuleLoader: function( name, moduleLoader ){
 953+ this.moduleNames [ name ] = moduleLoader;
 954+ },
 955+
 956+ /**
 957+ * Adds file path key value pairs
 958+ *
 959+ * @param {Object} classSet JSON formated list of
 960+ * class name file path pairs.
 961+ *
 962+ * classSet must be strict JSON to allow the
 963+ * scriptLoader to parse the file paths.
 964+ */
 965+ addClassFilePaths: function( classSet ){
 966+ for( var i in classSet ){
 967+ this.classNames[ i ] = classSet[ i ];
 968+ }
 969+ }
 970+ }
 971+
 972+ /**
 973+ * Shortcut entry points / convenience functions:
 974+ *
 975+ * Lets you write mw.load() instead of mw.loader.load()
 976+ */
 977+
 978+ /**
 979+ * Load Object entry point: Loads a requested set of javascript
 980+ */
 981+ $.load = function( loadRequest, callback ){
 982+ return $.loader.load( loadRequest, callback );
 983+ }
 984+
 985+ /**
 986+ * Add module entry point: Adds a module to the mwLoader object
 987+ */
 988+ $.addModuleLoader = function ( name, loaderFunction ){
 989+ return $.loader.addModuleLoader( name, loaderFunction );
 990+ }
 991+
 992+ /**
 993+ * Add Class File Paths entry point:
 994+ */
 995+ $.addClassFilePaths = function ( classSet ) {
 996+ return $.loader.addClassFilePaths( classSet );
 997+ }
 998+
 999+
 1000+ /**
 1001+ * Utility Functions
 1002+ */
 1003+
 1004+ /**
 1005+ * Similar to php isset function checks if the variable exists.
 1006+ * Does a safe check of a descendent method or variable
 1007+ *
 1008+ * @param {String} objectPath
 1009+ * @return {Boolean}
 1010+ * true if objectPath exists
 1011+ * false if objectPath is undefined
 1012+ */
 1013+ $.isset = function( objectPath ) {
 1014+ if ( !objectPath )
 1015+ return false;
 1016+ var pathSet = objectPath.split( '.' );
 1017+ var cur_path = '';
 1018+ for ( var p = 0; p < pathSet.length; p++ ) {
 1019+ cur_path = ( cur_path == '' ) ? cur_path + pathSet[p] : cur_path + '.' + pathSet[p];
 1020+ eval( 'var ptest = typeof ( ' + cur_path + ' ); ' );
 1021+ if ( ptest == 'undefined' ) {
 1022+ return false;
 1023+ }
 1024+ }
 1025+ return true;
 1026+ }
 1027+
 1028+
 1029+ //Setup the local mwOnLoadFuncitons array:
 1030+ var mwOnLoadFuncitons = new Array();
 1031+
 1032+ //mw Ready flag ( set once mwEmbed is ready )
 1033+ var mwReadyFlag = false;
 1034+
 1035+ /**
 1036+ * Enables load hooks to run once DOM is "ready"
 1037+ * Will ensure jQuery is available, is in the $j namespace
 1038+ * and mw interfaces and configuration has been loaded and applied
 1039+ *
 1040+ * @param {Function} callback Function to run once DOM and jQuery are ready
 1041+ */
 1042+ $.addOnloadHook = function( callback ){
 1043+ if( mwReadyFlag == false ){
 1044+ mwOnLoadFuncitons.push ( callback );
 1045+
 1046+ // If the dom is ready but we have not run mwSetup::
 1047+ // Have a rare case where a dynamically included script is calling mw.addOnloadHook ::
 1048+ if ( mwDomReadyFlag && !mwSetupFlag ){
 1049+ $.setupMwEmbed();
 1050+ }
 1051+ return ;
 1052+ }
 1053+ // If mwReadyFlag is already "ready" call the callback directly:
 1054+ callback();
 1055+ }
 1056+
 1057+ /**
 1058+ * Runs all the queued functions
 1059+ */
 1060+ $.runLoadHooks = function ( ){
 1061+ // Sets mwReadyFlag to true so that future addOnLoadHook calls
 1062+ // know to call the callback directly
 1063+ mwReadyFlag = true;
 1064+
 1065+ // Run all the queued functions:
 1066+ while( mwOnLoadFuncitons.length )
 1067+ mwOnLoadFuncitons.pop()();
 1068+ }
 1069+
 1070+ /**
 1071+ * One time "setup" for mwEmbed
 1072+ * run onDomReady ( so calls to setConfg apply to setup )
 1073+ */
 1074+
 1075+ // Flag to ensure setup is only run once:
 1076+ var mwSetupFlag = false;
 1077+
 1078+ $.setupMwEmbed = function ( ) {
 1079+
 1080+ // Only run the setup once:
 1081+ if( mwSetupFlag )
 1082+ return ;
 1083+ mwSetupFlag = true;
 1084+
 1085+ // Make sure jQuery is loaded:
 1086+ $.load( 'window.jQuery', function(){
 1087+ if ( !_global['$j'] ) {
 1088+ _global['$j'] = jQuery.noConflict();
 1089+ }
 1090+
 1091+ // Set up the skin paths
 1092+ _global['mv_jquery_skin_path'] = mw.getMwEmbedPath() + 'jquery/jquery.ui/themes/' + mw.getConfig( 'jui_skin' ) + '/';
 1093+ _global['mv_skin_img_path'] = mw.getMwEmbedPath() + 'skins/' + mw.getConfig( 'skin_name' ) + '/images/';
 1094+ _global['mv_default_thumb_url'] = mv_skin_img_path + 'vid_default_thumb.jpg';
 1095+
 1096+ // Make Core skin/style sheets are always available:
 1097+ loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' );
 1098+ loadExternalCss( mw.getMwEmbedPath() + 'skins/' + mw.getConfig( 'skin_name' ) + '/styles.css' );
 1099+
 1100+ // Set up AJAX to not send dynamic URLs for loading scripts
 1101+ $j.ajaxSetup( {
 1102+ cache: true
 1103+ } );
 1104+
 1105+ // Set up mvEmbed jQuery bindings
 1106+ mwDojQueryBindings();
 1107+
 1108+ // Check for tag-rewrites ( sometimes checked twice but ensures fresh dom check )
 1109+ if( $.documentHasRewriteTags() ){
 1110+ // Load the embedPlayer module ( then run queued hooks )
 1111+ ms.load( 'embedPlayer', function ( ) {
 1112+ mw.runLoadHooks();
 1113+ } );
 1114+ }else{
 1115+ // Set ready state and run the callback
 1116+ mw.runLoadHooks();
 1117+ }
 1118+ } );
 1119+ }
 1120+ //Flag to register the domReady has been called
 1121+ var mwDomReadyFlag = false;
 1122+ /**
 1123+ * This will get called when the DOM is ready
 1124+ * Will check configuration and issue a mw.setupMwEmbed call if needed
 1125+ */
 1126+ $.domReady = function ( ) {
 1127+ if( mwDomReadyFlag )
 1128+ return ;
 1129+ js_log( 'run:domReady' );
 1130+ // Set the onDomReady Flag
 1131+ mwDomReadyFlag = true;
 1132+
 1133+ // Check for the force setup flag:
 1134+ if ( $.getConfig( 'alwaysSetupMwEmbed' ) ){
 1135+ $.setupMwEmbed();
 1136+ return ;
 1137+ }
 1138+
 1139+ // Check for rewrite tags:
 1140+ if ( $.documentHasRewriteTags() ) {
 1141+ $.setupMwEmbed();
 1142+ return ;
 1143+ }
 1144+
 1145+ // Check for queued functions that use mw interfaces:
 1146+ if ( mwOnLoadFuncitons.length ){
 1147+ $.setupMwEmbed();
 1148+ return ;
 1149+ }
 1150+
 1151+ // If we have any queued functions we need to run setup as well:
 1152+
 1153+ /*
 1154+ // Load libs and process videos
 1155+ mvJsLoader.embedPlayerCheck( function() {
 1156+ // Convert all supported elements into embed players:
 1157+ $j.embedPlayers( function(){
 1158+ // Run any queued global events:
 1159+ mvJsLoader.runQueuedFunctions();
 1160+ });
 1161+ } );
 1162+ } else {
 1163+ mvJsLoader.runQueuedFunctions();
 1164+ }
 1165+ */
 1166+ }
 1167+
 1168+ /**
 1169+ * Check the current DOM for any tags in "rewriteTags"
 1170+ */
 1171+ $.documentHasRewriteTags = function(){
 1172+ var tags = $.getRewriteTags();
 1173+ return ( tags && tags.length );
 1174+ }
 1175+ $.getRewriteTags = function(){
 1176+ var tagString = $.getConfig( 'rewriteTags' );
 1177+ if( ! tagString || tagString == '' )
 1178+ return false;
 1179+
 1180+ // Tags should be separated by ","
 1181+ var tags = tagString.split(',');
 1182+
 1183+ // Check for tags:
 1184+ for( var i in tags ){
 1185+ var tagsInDOM = document.getElementsByTagName( tags[ i ] );
 1186+ // If tags found return true
 1187+ if( tagsInDOM.length > 0 ){
 1188+ return true;
 1189+ }
 1190+ }
 1191+ return false;
 1192+ }
 1193+
 1194+ /**
 1195+ * Wrapper for jQuery getScript
 1196+ *
 1197+ * If jQuery is not ready load it.
 1198+ *
 1199+ * @param {String} url Url of script
 1200+ * @param {Function} callback Function to call once script is loaded
 1201+ */
 1202+ $.getScript = function( url, callback ){
 1203+
 1204+ js_log( 'mw.getScript: ' + url );
 1205+
 1206+ // If jQuery is available just use getScript
 1207+ if( $.isset( 'window.jQuery' ) ) {
 1208+ $j.getScript( url, callback );
 1209+ return ;
 1210+ }
 1211+
 1212+ // No jQuery load and bind manually: ( copied from jQuery ajax function )
 1213+ var head = document.getElementsByTagName("head")[0];
 1214+ var script = document.createElement("script");
 1215+ script.setAttribute( 'src', url );
 1216+
 1217+ // Attach handlers for all browsers ( might not work in safari < version 2.0 )
 1218+ var done = false;
 1219+ script.onload = script.onreadystatechange = function(){
 1220+ if ( !done && (!this.readyState ||
 1221+ this.readyState == "loaded" || this.readyState == "complete") ) {
 1222+ done = true;
 1223+ callback();
 1224+ }
 1225+ };
 1226+ // Append the script to the DOM:
 1227+ head.appendChild( script );
 1228+ }
 1229+
 1230+ /**
 1231+ * Get Api URL from mediaWiki output page defined variables
 1232+ */
 1233+ $.getLocalApiUrl = function() {
 1234+ if ( typeof wgServer != 'undefined' && typeof wgScriptPath != 'undefined' ) {
 1235+ return wgServer + wgScriptPath + '/api.php';
 1236+ }
 1237+ return false;
 1238+ }
 1239+
 1240+ // Local mwEmbedPath variable ( for cache of $.getMwEmbedPath )
 1241+ var mwEmbedPath = null;
 1242+
 1243+ /**
 1244+ * Gets the path to the mwEmbed folder
 1245+ */
 1246+ $.getMwEmbedPath = function() {
 1247+ if ( mwEmbedPath )
 1248+ return mwEmbedPath;
 1249+
 1250+ // Get mwEmbed src:
 1251+ var src = $.getMwEmbedSrc();
 1252+ var mwpath = null;
 1253+ // Check for direct include of the mwEmbed.js
 1254+ if ( src.indexOf( 'mwEmbed.js' ) !== -1 ) {
 1255+ mwpath = src.substr( 0, src.indexOf( 'mwEmbed.js' ) );
 1256+ }
 1257+
 1258+ // Check for scriptLoader include of mwEmbed:
 1259+ if ( src.indexOf( 'mwScriptLoader.php' ) !== -1 ) {
 1260+ // Script loader is in the root of MediaWiki, Include the default mwEmbed extension path:
 1261+ mwpath = src.substr( 0, src.indexOf( 'mwScriptLoader.php' ) ) + $.conf.mediaWikiPath;
 1262+ }
 1263+
 1264+ // Script-loader has jsScriptLoader name when local:
 1265+ if( src.indexOf( 'jsScriptLoader.php' ) !== -1 ){
 1266+ mwpath = src.substr( 0, src.indexOf( 'jsScriptLoader.php' ) );
 1267+ }
 1268+
 1269+ // Error out if we could not get the path:
 1270+ if( ! mwpath ){
 1271+ js_log( "Error could not get mwEmbed path " );
 1272+ return ;
 1273+ }
 1274+
 1275+ // Update the cached var with the absolute path:
 1276+ mwEmbedPath = $.absoluteUrl( mwpath ) ;
 1277+ return mwEmbedPath;
 1278+ }
 1279+
 1280+ // Local mwEmbedSrc variable ( for cache of $.getMwEmbedSrc )
 1281+ var mwEmbedSrc = null;
 1282+
 1283+ /**
 1284+ * Gets the mwEmbed script src attribute
 1285+ */
 1286+ $.getMwEmbedSrc = function() {
 1287+ if ( mwEmbedSrc )
 1288+ return mwEmbedSrc;
 1289+
 1290+ // Get all the javascript includes:
 1291+ var js_elements = document.getElementsByTagName( "script" );
 1292+ for ( var i = 0; i < js_elements.length; i++ ) {
 1293+ // Check for mwEmbed.js and/or script loader
 1294+ var src = js_elements[i].getAttribute( "src" );
 1295+ if ( src ) {
 1296+ if ( src.indexOf( 'mwEmbed.js' ) !== -1 || (
 1297+ ( src.indexOf( 'mwScriptLoader.php' ) !== -1 || src.indexOf( 'jsScriptLoader.php' ) !== -1 )
 1298+ && src.indexOf( 'mwEmbed' ) !== -1 ) ) // (check for class=mwEmbed script_loader call)
 1299+ {
 1300+ mwEmbedSrc = src;
 1301+ return mwEmbedSrc;
 1302+ }
 1303+ }
 1304+ }
 1305+ js_log( 'Error: getMwEmbedScriptURL failed to get script path' );
 1306+ return false;
 1307+ }
 1308+
 1309+ // Local mwUrlParam variable ( for cache of $.getUrlParam )
 1310+ var mwUrlParam = null;
 1311+
 1312+ /**
 1313+ * Get URL Paramaters per paramaters in the host script include
 1314+ */
 1315+ $.getUrlParam = function() {
 1316+ if ( mwUrlParam )
 1317+ return mwUrlParam;
 1318+
 1319+ var mwEmbedSrc = $.getMwEmbedSrc();
 1320+ var req_param = '';
 1321+
 1322+ // If we already have a URI, add it to the param request:
 1323+ var urid = mw.parseUri( mwEmbedSrc ).queryKey['urid']
 1324+
 1325+ // If we're in debug mode, get a fresh unique request key and pass on "debug" param
 1326+ if ( mw.parseUri( mwEmbedSrc ).queryKey['debug'] == 'true' ) {
 1327+
 1328+ var d = new Date();
 1329+ req_param += 'urid=' + d.getTime() + '&debug=true';
 1330+
 1331+ } else if ( urid ) { // Just pass on the existing urid:
 1332+
 1333+ req_param += 'urid=' + urid;
 1334+ } else {
 1335+ // Otherwise, Use the mwEmbed version
 1336+ req_param += 'urid=' + mw.version;
 1337+ }
 1338+
 1339+ // Add the language param:
 1340+ var langKey = mw.parseUri( mwEmbedSrc ).queryKey['uselang'];
 1341+ if ( langKey )
 1342+ req_param += '&uselang=' + langKey;
 1343+
 1344+ // Update the local cache and return the value
 1345+ mwUrlParam = req_param;
 1346+ return mwUrlParam;
 1347+ }
 1348+
 1349+ /**
 1350+ * parseUri 1.2.2
 1351+ * (c) Steven Levithan <stevenlevithan.com>
 1352+ * MIT License
 1353+ */
 1354+ $.parseUri = function (str) {
 1355+ var o = $.parseUri.options,
 1356+ m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
 1357+ uri = {},
 1358+ i = 14;
 1359+
 1360+ while (i--) uri[o.key[i]] = m[i] || "";
 1361+
 1362+ uri[o.q.name] = {};
 1363+ uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
 1364+ if ($1) uri[o.q.name][$1] = $2;
 1365+ });
 1366+
 1367+ return uri;
 1368+ };
 1369+
 1370+ /**
 1371+ * Parse URI function
 1372+ *
 1373+ * For documentation on its usage see:
 1374+ * http://stevenlevithan.com/demo/parseuri/js/
 1375+ */
 1376+ $.parseUri.options = {
 1377+ strictMode: false,
 1378+ key: ["source", "protocol", "authority", "userInfo", "user","password","host","port","relative","path","directory","file","query","anchor"],
 1379+ q: {
 1380+ name: "queryKey",
 1381+ parser: /(?:^|&)([^&=]*)=?([^&]*)/g
 1382+ },
 1383+ parser: {
 1384+ strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
 1385+ loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
 1386+ }
 1387+ };
 1388+
 1389+ /**
 1390+ * getAbsoluteUrl takes a src and returns the absolute location given the document.URL
 1391+ *
 1392+ * @param {String} src path or url
 1393+ * @return {String} absolute url
 1394+ */
 1395+ $.absoluteUrl = function( src, contextUrl ){
 1396+ var pSrc = mw.parseUri( src );
 1397+ if( pSrc.protocol != '')
 1398+ return src;
 1399+
 1400+ // Get parent Url location the context URL
 1401+ if( contextUrl){
 1402+ var pUrl = mw.parseUri( contextUrl );
 1403+ } else {
 1404+ var pUrl = mw.parseUri( document.URL );
 1405+ }
 1406+ // If a leading slash:
 1407+ if( src.indexOf( '/' ) == 1 ){
 1408+ return pUrl.protocol + '://' + pUrl.authority + src;
 1409+ }else{
 1410+ return pUrl.protocol + '://' + pUrl.authority + pUrl.directory + src;
 1411+ }
 1412+ };
 1413+
 1414+ /**
 1415+ * Takes in a string returns an xml dom object
 1416+ *
 1417+ * @param {String} str String of XML content to be parsed
 1418+ * @return
 1419+ * {Object} XML
 1420+ * false If XML could not be parsed
 1421+ *
 1422+ */
 1423+ $.parseXML = function ( str ){
 1424+ if ( $j.browser.msie ) {
 1425+ // Attempt to parse as XML for IE
 1426+ var xmldata = new ActiveXObject( "Microsoft.XMLDOM" );
 1427+ xmldata.async = "false";
 1428+ try{
 1429+ xmldata.loadXML( str );
 1430+ return xmldata;
 1431+ } catch (e){
 1432+ js_log( 'XML parse ERROR: ' + e.message );
 1433+ return false;
 1434+ }
 1435+ }
 1436+
 1437+ // For others (Firefox, Safari etc, older browsers
 1438+ // Some don't have native DOMParser either fallback defined bellow.
 1439+ try {
 1440+ var xmldata = ( new DOMParser() ).parseFromString( str, "text/xml" );
 1441+ } catch ( e ) {
 1442+ js_log( 'XML parse ERROR: ' + e.message );
 1443+ return false;
 1444+ }
 1445+ return xmldata;
 1446+ }
 1447+} )( window.mw );
 1448+
 1449+// load in js2 stopgap into proper location:
 1450+if ( typeof gMsg != 'undefined' ) {
 1451+ mw.addMessages( gMsg )
 1452+}
 1453+
 1454+var gM = mw.lang.gM;
 1455+// setup legacy global shortcuts:
 1456+var loadRS = mw.lang.loadRS;
 1457+
 1458+/**
 1459+ * -- Load Class Paths --
 1460+ *
 1461+ * MUST BE VALID JSON (NOT JS)
 1462+ * This is used by the script loader to auto-load classes (so we only define
 1463+ * this once for PHP & JavaScript)
 1464+ *
 1465+ * Right now the PHP AutoLoader only reads this mwEmbed.js file.
 1466+ * In the future we could have multiple "loader" files
 1467+ *
 1468+ */
 1469+
 1470+
 1471+mw.addClassFilePaths( {
 1472+ "mwEmbed" : "mwEmbed.js",
 1473+ "window.jQuery" : "jquery/jquery-1.3.2.js",
 1474+ "$j.fn.pngFix" : "jquery/plugins/jquery.pngFix.js",
 1475+ "$j.fn.autocomplete": "jquery/plugins/jquery.autocomplete.js",
 1476+ "$j.fn.hoverIntent" : "jquery/plugins/jquery.hoverIntent.js",
 1477+ "$j.fn.datePicker" : "jquery/plugins/jquery.datePicker.js",
 1478+ "$j.ui" : "jquery/jquery.ui/ui/ui.core.js",
 1479+ "$j.fn.ColorPicker" : "libClipEdit/colorpicker/js/colorpicker.js",
 1480+ "$j.Jcrop" : "libClipEdit/Jcrop/js/jquery.Jcrop.js",
 1481+ "$j.fn.simpleUploadForm" : "libAddMedia/simpleUploadForm.js",
 1482+
 1483+ "mw.proxy" : "libMwApi/mw.proxy.js",
 1484+
 1485+ "mw.testLang" : "tests/testLang.js",
 1486+
 1487+ "ctrlBuilder" : "skins/ctrlBuilder.js",
 1488+ "kskinConfig" : "skins/kskin/kskin.js",
 1489+ "mvpcfConfig" : "skins/mvpcf/mvpcf.js",
 1490+
 1491+ "JSON" : "libMwApi/json2.js",
 1492+ "$j.cookie" : "jquery/plugins/jquery.cookie.js",
 1493+ "$j.contextMenu" : "jquery/plugins/jquery.contextMenu.js",
 1494+ "$j.fn.suggestions" : "jquery/plugins/jquery.suggestions.js",
 1495+ "$j.fn.textSelection" : "jquery/plugins/jquery.textSelection.js",
 1496+
 1497+ "$j.effects.blind" : "jquery/jquery.ui/ui/effects.blind.js",
 1498+ "$j.effects.drop" : "jquery/jquery.ui/ui/effects.drop.js",
 1499+ "$j.effects.pulsate" : "jquery/jquery.ui/ui/effects.pulsate.js",
 1500+ "$j.effects.transfer" : "jquery/jquery.ui/ui/effects.transfer.js",
 1501+ "$j.ui.droppable" : "jquery/jquery.ui/ui/ui.droppable.js",
 1502+ "$j.ui.slider" : "jquery/jquery.ui/ui/ui.slider.js",
 1503+ "$j.effects.bounce" : "jquery/jquery.ui/ui/effects.bounce.js",
 1504+ "$j.effects.explode" : "jquery/jquery.ui/ui/effects.explode.js",
 1505+ "$j.effects.scale" : "jquery/jquery.ui/ui/effects.scale.js",
 1506+ "$j.ui.datepicker" : "jquery/jquery.ui/ui/ui.datepicker.js",
 1507+ "$j.ui.progressbar" : "jquery/jquery.ui/ui/ui.progressbar.js",
 1508+ "$j.ui.sortable" : "jquery/jquery.ui/ui/ui.sortable.js",
 1509+ "$j.effects.clip" : "jquery/jquery.ui/ui/effects.clip.js",
 1510+ "$j.effects.fold" : "jquery/jquery.ui/ui/effects.fold.js",
 1511+ "$j.effects.shake" : "jquery/jquery.ui/ui/effects.shake.js",
 1512+ "$j.ui.dialog" : "jquery/jquery.ui/ui/ui.dialog.js",
 1513+ "$j.ui.resizable" : "jquery/jquery.ui/ui/ui.resizable.js",
 1514+ "$j.ui.tabs" : "jquery/jquery.ui/ui/ui.tabs.js",
 1515+ "$j.effects.core" : "jquery/jquery.ui/ui/effects.core.js",
 1516+ "$j.effects.highlight" : "jquery/jquery.ui/ui/effects.highlight.js",
 1517+ "$j.effects.slide" : "jquery/jquery.ui/ui/effects.slide.js",
 1518+ "$j.ui.accordion" : "jquery/jquery.ui/ui/ui.accordion.js",
 1519+ "$j.ui.draggable" : "jquery/jquery.ui/ui/ui.draggable.js",
 1520+ "$j.ui.selectable" : "jquery/jquery.ui/ui/ui.selectable.js",
 1521+
 1522+ "$j.fn.dragDropFile" : "libAddMedia/dragDropFile.js",
 1523+ "mvFirefogg" : "libAddMedia/mvFirefogg.js",
 1524+ "mvAdvFirefogg" : "libAddMedia/mvAdvFirefogg.js",
 1525+ "mvBaseUploadInterface" : "libAddMedia/mvBaseUploadInterface.js",
 1526+ "remoteSearchDriver" : "libAddMedia/remoteSearchDriver.js",
 1527+ "seqRemoteSearchDriver" : "libSequencer/seqRemoteSearchDriver.js",
 1528+
 1529+ "baseRemoteSearch" : "libAddMedia/searchLibs/baseRemoteSearch.js",
 1530+ "mediaWikiSearch" : "libAddMedia/searchLibs/mediaWikiSearch.js",
 1531+ "metavidSearch" : "libAddMedia/searchLibs/metavidSearch.js",
 1532+ "archiveOrgSearch" : "libAddMedia/searchLibs/archiveOrgSearch.js",
 1533+ "flickrSearch" : "libAddMedia/searchLibs/flickrSearch.js",
 1534+ "baseRemoteSearch" : "libAddMedia/searchLibs/baseRemoteSearch.js",
 1535+
 1536+ "mvClipEdit" : "libClipEdit/mvClipEdit.js",
 1537+
 1538+ "mvPlayList" : "libSequencer/mvPlayList.js",
 1539+ "mvSequencer" : "libSequencer/mvSequencer.js",
 1540+ "mvFirefoggRender" : "libSequencer/mvFirefoggRender.js",
 1541+ "mvTimedEffectsEdit": "libSequencer/mvTimedEffectsEdit.js",
 1542+
 1543+ "mvTextInterface" : "libTimedText/mvTextInterface.js",
 1544+ "mvTimeTextEdit" : "libTimedText/mvTimeTextEdit.js"
 1545+
 1546+} );
 1547+
 1548+/**
 1549+* libEmbedPlayer Depenency Module Loader:
 1550+*
 1551+* NOTE: this code block could eventually be put in:
 1552+* "libEmbedPlayer/loader.js"
 1553+*
 1554+* That it could be dynamically inserted into mwEmbed requests
 1555+* at poit of release or at runtime via the script-loader.
 1556+*
 1557+* A per module loader enables a dynamic set of modules with only minimal
 1558+* loader code per module in the core mwEmbed included js
 1559+*
 1560+*/
 1561+// Add class file paths:
 1562+mw.addClassFilePaths( {
 1563+ "embedPlayer" : "libEmbedPlayer/embedPlayer.js",
 1564+ "flowplayerEmbed" : "libEmbedPlayer/flowplayerEmbed.js",
 1565+ "kplayerEmbed" : "libEmbedPlayer/kplayerEmbed.js",
 1566+ "genericEmbed" : "libEmbedPlayer/genericEmbed.js",
 1567+ "htmlEmbed" : "libEmbedPlayer/htmlEmbed.js",
 1568+ "javaEmbed" : "libEmbedPlayer/javaEmbed.js",
 1569+ "nativeEmbed" : "libEmbedPlayer/nativeEmbed.js",
 1570+ "quicktimeEmbed" : "libEmbedPlayer/quicktimeEmbed.js",
 1571+ "vlcEmbed" : "libEmbedPlayer/vlcEmbed.js",
 1572+
 1573+} );
 1574+
 1575+// Add the module loader function:
 1576+mw.addModuleLoader( 'player', function(){
 1577+ var _this = this;
 1578+ js_log( 'loadModule: player :' );
 1579+
 1580+ // Set module specifc class videonojs to loading:
 1581+ $j( '.videonojs' ).html( gM( 'mwe-loading_txt' ) );
 1582+
 1583+ // Set up the embed video player class request: (include the skin js as well)
 1584+ var dependencyRequest = [
 1585+ [
 1586+ '$j.ui',
 1587+ 'embedPlayer',
 1588+ 'ctrlBuilder',
 1589+ '$j.cookie'
 1590+ ],
 1591+ [
 1592+ '$j.ui.slider'
 1593+ ]
 1594+ ];
 1595+
 1596+ // Get any other skins that we need to load
 1597+ // That way skin js can be part of the single script-loader request:
 1598+
 1599+ var sn = e[j][k].getAttribute('class');
 1600+ if( sn && sn != ''){
 1601+ for(var n=0;n< $mw.valid_skins.length;n++){
 1602+ if( sn.indexOf($mw.valid_skins[n]) !== -1){
 1603+ $mw.skin_list.push( $mw.valid_skins[n] );
 1604+ }
 1605+ }
 1606+ }
 1607+ // Add any requested skins (supports multiple skins per single page)
 1608+ if ( mw.skin_list ) {
 1609+ for ( var i in mw.skin_list ) {
 1610+ depReq[0].push( mw.skin_list[i] + 'Config' );
 1611+ }
 1612+ }
 1613+
 1614+ // Add PNG fix if needed:
 1615+ if ( $j.browser.msie || $j.browser.version < 7 )
 1616+ depReq[0].push( '$j.fn.pngFix' );
 1617+
 1618+ // Load the video libs:
 1619+ _this.doLoadDepMode( depReq, function() {
 1620+ embedTypes.init();
 1621+ callback();
 1622+ $j( '.videonojs' ).remove();
 1623+ } );
 1624+
 1625+} );
 1626+
 1627+
 1628+
 1629+
 1630+
 1631+
 1632+
 1633+
 1634+
 1635+// Add the core mvEmbed Messages ( will be localized by script server )
 1636+mw.addMessages( {
 1637+ "mwe-loading_txt" : "Loading ...",
 1638+ "mwe-size-gigabytes" : "$1 GB",
 1639+ "mwe-size-megabytes" : "$1 MB",
 1640+ "mwe-size-kilobytes" : "$1 K",
 1641+ "mwe-size-bytes" : "$1 B",
 1642+ "mwe-error_load_lib" : "Error: JavaScript $1 was not retrievable or does not define $2",
 1643+ "mwe-loading-add-media-wiz" : "Loading add media wizard",
 1644+ "mwe-apiproxy-setup" : "Setting up API proxy",
 1645+ "mwe-load-drag-item" : "Loading dragged item",
 1646+ "mwe-ok" : "OK",
 1647+ "mwe-cancel" : "Cancel"
 1648+} );
 1649+
 1650+
 1651+
 1652+
 1653+/**
 1654+* Set DOM-ready call
 1655+* Does not use jQuery( document ).ready( ) because
 1656+* mwEmbed could have been included without jQuery.
 1657+*/
 1658+// For Mozilla / modern browsers
 1659+if ( document.addEventListener ) {
 1660+ document.addEventListener( "DOMContentLoaded", mw.domReady, false );
 1661+}
 1662+// Preserve any existing window.onload binding:
 1663+var mwOriginalOnLoad;
 1664+if ( window.onload && typeof window.onload == 'function' ) {
 1665+ mwOriginalOnLoad = window.onload;
 1666+}
 1667+// Use the onload method as a backup:
 1668+window.onload = function () {
 1669+ if ( mwOriginalOnLoad )
 1670+ mwOriginalOnLoad();
 1671+ mw.domReady();
 1672+}
 1673+
 1674+
 1675+
 1676+
 1677+
 1678+
 1679+
 1680+
 1681+
 1682+
 1683+
 1684+
 1685+
 1686+
 1687+
 1688+
 1689+
 1690+// Get the loading image
 1691+function mv_get_loading_img( style, class_attr ) {
 1692+ var style_txt = ( style ) ? style:'';
 1693+ var class_attr = ( class_attr ) ? 'class="' + class_attr + '"' : 'class="mv_loading_img"';
 1694+ return '<div ' + class_attr + ' style="' + style + '"></div>';
 1695+}
 1696+
 1697+function mv_set_loading( target, load_id ) {
 1698+ var id_attr = ( load_id ) ? ' id="' + load_id + '" ':'';
 1699+ $j( target ).append( '<div ' + id_attr + ' style="position:absolute;top:0px;left:0px;height:100%;width:100%;' +
 1700+ 'background-color:#FFF;">' +
 1701+ mv_get_loading_img( 'top:30px;left:30px' ) +
 1702+ '</div>' );
 1703+}
 1704+
 1705+/**
 1706+* mvJsLoader class handles initialization and js file loads
 1707+
 1708+var mvJsLoader = {
 1709+ libreq : { },
 1710+ libs : { },
 1711+
 1712+ // Base lib flags
 1713+ onReadyEvents: new Array(),
 1714+ doneReadyEvents: false,
 1715+ jQuerySetupFlag: false,
 1716+
 1717+ // To keep consistency across threads
 1718+ ptime: 0,
 1719+ ctime: 0,
 1720+
 1721+ load_error: false, // Load error flag (false by default)
 1722+ load_time: 0,
 1723+ callbacks: new Array(),
 1724+ cur_path: null,
 1725+ missing_path : null,
 1726+ doLoad: function( loadLibs, callback ) {
 1727+ this.ctime++;
 1728+ if ( loadLibs && loadLibs.length != 0 ) {
 1729+ // js_log("doLoad setup::" + JSON.stringify( loadLibs ) );
 1730+ // Set up this.libs
 1731+ // First check if we already have this library loaded
 1732+ var all_libs_loaded = true;
 1733+ for ( var i = 0; i < loadLibs.length; i++ ) {
 1734+ // Check if the library is already loaded
 1735+ if ( ! this.checkObjPath( loadLibs[i] ) ) {
 1736+ all_libs_loaded = false;
 1737+ }
 1738+ }
 1739+
 1740+ if ( all_libs_loaded ) {
 1741+ js_log( 'Libraries ( ' + loadLibs + ') already loaded... skipping load request' );
 1742+ callback();
 1743+ return;
 1744+ }
 1745+
 1746+ // Do a check for any CSS we may need and get it
 1747+ for ( var i = 0; i < loadLibs.length; i++ ) {
 1748+ if ( typeof mvCssPaths[ loadLibs[i] ] != 'undefined' ) {
 1749+ loadExternalCss( mw.getMwEmbedPath() + mvCssPaths[ loadLibs[i] ] );
 1750+ }
 1751+ }
 1752+
 1753+ // Check if we should use the script loader to combine all the requests into one
 1754+ // ( the scriptloader defines the mwSlScript global )
 1755+ if ( typeof mwSlScript != 'undefined' ) {
 1756+ var class_set = '';
 1757+ var last_class = '';
 1758+ var coma = '';
 1759+ for ( var i = 0; i < loadLibs.length; i++ ) {
 1760+ var curLib = loadLibs[i];
 1761+ // Only add if not included yet:
 1762+ if ( ! this.checkObjPath( curLib ) ) {
 1763+ class_set += coma + curLib;
 1764+ last_class = curLib;
 1765+ coma = ',';
 1766+ }
 1767+ }
 1768+ // Build the url to the scriptServer striping its request parameters:
 1769+ var puri = mw.parseUri( getMwEmbedURL() );
 1770+ if ( ( getMwEmbedURL().indexOf( '://' ) != -1 )
 1771+ && puri.host != mw.parseUri( document.URL ).host )
 1772+ {
 1773+ var scriptPath = puri.protocol + '://' + puri.authority + puri.path;
 1774+ } else {
 1775+ var scriptPath = puri.path;
 1776+ }
 1777+ // js_log('scriptServer Path is: ' + scriptPath + "\n host script path:" + getMwEmbedURL() );
 1778+ this.libs[ last_class ] = scriptPath + '?class=' + class_set +
 1779+ '&' + mw.getUrlParam();
 1780+
 1781+ } else {
 1782+ // Do many requests
 1783+ for ( var i = 0; i < loadLibs.length; i++ ) {
 1784+ var curLib = loadLibs[i];
 1785+ if ( curLib ) {
 1786+ var libLoc = mvGetClassPath( curLib );
 1787+ // Do a direct load of the file (pass along unique request id from
 1788+ // request or mwEmbed Version )
 1789+ var qmark = ( libLoc.indexOf( '?' ) !== true ) ? '?' : '&';
 1790+ this.libs[curLib] = mw.getMwEmbedPath() + libLoc + qmark + mw.getUrlParam();
 1791+ }
 1792+ }
 1793+ }
 1794+ }
 1795+
 1796+ if ( callback ) {
 1797+ this.callbacks.push( callback );
 1798+ }
 1799+ if ( this.checkLoading() ) {
 1800+ // @@todo we should check the <script> Element .onLoad property to
 1801+ // make sure its just not a very slow connection
 1802+ // (even though the class is not loaded)
 1803+ if ( this.load_time++ > 4000 ) { // Time out after ~80 seconds
 1804+ js_log( gM( 'mwe-error_load_lib', [mvGetClassPath( this.missing_path ), this.missing_path] ) );
 1805+ this.load_error = true;
 1806+ } else {
 1807+ setTimeout( 'mw.load()', 20 );
 1808+ }
 1809+ } else {
 1810+ // js_log('checkLoading passed. Running callbacks...');
 1811+ // Only do callbacks if we are in the same instance (weird concurrency issue)
 1812+ var cb_count = 0;
 1813+ for ( var i = 0; i < this.callbacks.length; i++ )
 1814+ cb_count++;
 1815+ // js_log('RESET LIBS: loading is: '+ loading + ' callback count: '+cb_count +
 1816+ // ' p:'+ this.ptime +' c:'+ this.ctime);
 1817+
 1818+ // Reset the libs
 1819+ this.libs = { };
 1820+ // js_log('done loading, do call: ' + this.callbacks[0] );
 1821+ while ( this.callbacks.length != 0 ) {
 1822+ if ( this.ptime == this.ctime - 1 ) { // Enforce thread consistency
 1823+ this.callbacks.pop()();
 1824+ // func = this.callbacks.pop();
 1825+ // js_log(' run: '+this.ctime+ ' p: ' + this.ptime + ' ' +loading+ ' :'+ func);
 1826+ // func();
 1827+ } else {
 1828+ // Re-issue doLoad ( ptime will be set to ctime so we should catch up)
 1829+ setTimeout( 'mw.load()', 25 );
 1830+ break;
 1831+ }
 1832+ }
 1833+ }
 1834+ this.ptime = this.ctime;
 1835+ },
 1836+ doLoadDepMode: function( loadChain, callback ) {
 1837+ // Firefox executes JS in the order in which it is included, so just directly issue the request
 1838+ if ( $j.browser.firefox ) {
 1839+ var loadSet = [];
 1840+ for ( var i = 0; i < loadChain.length; i++ ) {
 1841+ for ( var j = 0; j < loadChain[i].length; j++ ) {
 1842+ loadSet.push( loadChain[i][j] );
 1843+ }
 1844+ }
 1845+ mw.load( loadSet, callback );
 1846+ } else {
 1847+ // Safari and IE tend to execute out of order so load with dependency checks
 1848+ mw.load( loadChain.shift(), function() {
 1849+ if ( loadChain.length != 0 ) {
 1850+ mw.load( loadChain, callback );
 1851+ } else {
 1852+ callback();
 1853+ }
 1854+ } );
 1855+ }
 1856+ },
 1857+ checkLoading: function() {
 1858+ var loading = 0;
 1859+ var i = null;
 1860+ for ( var i in this.libs ) { // for/in loop is OK on an object
 1861+ if ( !this.checkObjPath( i ) ) {
 1862+ if ( !this.libreq[i] ) {
 1863+ loadExternalJs( this.libs[i] );
 1864+ }
 1865+ this.libreq[i] = 1;
 1866+ // js_log("has not yet loaded: " + i);
 1867+ loading = 1;
 1868+ }
 1869+ }
 1870+ return loading;
 1871+ },
 1872+ checkObjPath: function( libVar ) {
 1873+ if ( !libVar )
 1874+ return false;
 1875+ var objPath = libVar.split( '.' )
 1876+ var cur_path = '';
 1877+ for ( var p = 0; p < objPath.length; p++ ) {
 1878+ cur_path = ( cur_path == '' ) ? cur_path + objPath[p] : cur_path + '.' + objPath[p];
 1879+ eval( 'var ptest = typeof ( ' + cur_path + ' ); ' );
 1880+ if ( ptest == 'undefined' ) {
 1881+ this.missing_path = cur_path;
 1882+ return false;
 1883+ }
 1884+ }
 1885+ this.cur_path = cur_path;
 1886+ return true;
 1887+ },
 1888+ //
 1889+ // checks for jQuery and adds the $j noConflict var
 1890+ //
 1891+ jQueryCheck: function( callback ) {
 1892+ // js_log( 'jQueryCheck::' + this.jQuerySetupFlag);
 1893+ var _this = this;
 1894+ if ( _global['$j'] && _this.jQuerySetupFlag ) {
 1895+ callback(); // call the callback now
 1896+ }
 1897+ // Load jQuery
 1898+ _this.doLoad( [
 1899+ 'window.jQuery'
 1900+ ], function() {
 1901+
 1902+ } );
 1903+ },
 1904+ embedPlayerCheck:function( callback ) {
 1905+ var _this = this;
 1906+ js_log( 'embedPlayerCheck:' );
 1907+ // Make sure we have jQuery
 1908+ _this.jQueryCheck( function() {
 1909+ // set class videonojs to loading
 1910+ $j( '.videonojs' ).html( gM( 'mwe-loading_txt' ) );
 1911+ // Set up the embed video player class request: (include the skin js as well)
 1912+ var depReq = [
 1913+ [
 1914+ '$j.ui',
 1915+ 'embedPlayer',
 1916+ 'ctrlBuilder',
 1917+ '$j.cookie'
 1918+ ],
 1919+ [
 1920+ '$j.ui.slider'
 1921+ ]
 1922+ ];
 1923+
 1924+ // add any requested skins (supports multiple skins per single page)
 1925+ if ( mw.skin_list ) {
 1926+ for ( var i in mw.skin_list ) {
 1927+ depReq[0].push( mw.skin_list[i] + 'Config' );
 1928+ }
 1929+ }
 1930+
 1931+ // Add PNG fix if needed:
 1932+ if ( $j.browser.msie || $j.browser.version < 7 )
 1933+ depReq[0].push( '$j.fn.pngFix' );
 1934+
 1935+ // load the video libs:
 1936+ _this.doLoadDepMode( depReq, function() {
 1937+ embedTypes.init();
 1938+ callback();
 1939+ $j( '.videonojs' ).remove();
 1940+ } );
 1941+ } );
 1942+ },
 1943+ addLoadEvent: function( fn ) {
 1944+ // js_log('add ready event: ' + fn );
 1945+ this.onReadyEvents.push( fn );
 1946+ },
 1947+ // Check the jQuery flag. This way, when remote embedding, we don't load jQuery
 1948+ // unless mw.addOnloadHook was used or there is video on the page.
 1949+ runQueuedFunctions: function() {
 1950+ js_log( "runQueuedFunctions" );
 1951+ var _this = this;
 1952+ this.jQueryCheck( function() {
 1953+ _this.runReadyEvents();
 1954+ _this.doneReadyEvents = true;
 1955+ } );
 1956+ },
 1957+ runReadyEvents: function() {
 1958+ js_log( "runReadyEvents" + this.onReadyEvents.length );
 1959+ while ( this.onReadyEvents.length ) {
 1960+ var func = this.onReadyEvents.shift();
 1961+ // js_log('run onReady:: ' + func );
 1962+ func();
 1963+ }
 1964+ }
 1965+}
 1966+*/
 1967+
 1968+
 1969+/*
 1970+* js2AddOnloadHook depreciated use mw.addOnloadHook instead
 1971+*/
 1972+function js2AddOnloadHook( func ) {
 1973+ mw.addOnloadHook( func );
 1974+}
 1975+
 1976+
 1977+/*
 1978+ * Store all the mwEmbed jQuery-specific bindings
 1979+ * (set up after jQuery is available).
 1980+ *
 1981+ * These functions are generally are loaders that do the dynamic mapping of
 1982+ * dependencies for a given component
 1983+ *
 1984+ * Should be repaced by "loader" calls
 1985+ *
 1986+ *
 1987+ */
 1988+function mwDojQueryBindings() {
 1989+ js_log( 'mv_jqueryBindings' );
 1990+ ( function( $ ) {
 1991+ /*
 1992+ * dragDrop file loader
 1993+ */
 1994+ $.fn.dragFileUpload = function ( conf ) {
 1995+ if ( this.selector ) {
 1996+ var _this = this;
 1997+ // load the dragger and "setup"
 1998+ mw.load( ['$j.fn.dragDropFile'], function() {
 1999+ $j( _this.selector ).dragDropFile();
 2000+ } );
 2001+ }
 2002+ }
 2003+ /*
 2004+ * apiProxy Loader loader:
 2005+ *
 2006+ * @param mode is either 'server' or 'client'
 2007+ */
 2008+ $.apiProxy = function( mode, pConf, callback ) {
 2009+ js_log( 'do apiProxy setup' );
 2010+ mw.load( [
 2011+ 'mw.proxy',
 2012+ 'JSON'
 2013+ ], function() {
 2014+ // do the proxy setup or
 2015+ if ( mode == 'client' ) {
 2016+ // just do the setup (no callbcak for client setup)
 2017+ mw.proxy.client( pConf );
 2018+ if ( callback )
 2019+ callback();
 2020+ } else if ( mode == 'server' ) {
 2021+ // do the request with the callback
 2022+ mw.proxy.server( pConf , callback );
 2023+ }
 2024+ } );
 2025+ }
 2026+
 2027+ // non selector based add-media-wizard direct invocation with loader
 2028+ $.addMediaWiz = function( options, callback ) {
 2029+ js_log( ".addMediaWiz call" );
 2030+ // check if already loaded:
 2031+ if ( _global['rsdMVRS'] ) {
 2032+ _global['rsdMVRS'].showDialog();
 2033+ if ( callback )
 2034+ callback( _global['rsdMVRS'] );
 2035+ return ;
 2036+ }
 2037+ // display a loader:
 2038+ $.addLoaderDialog( gM( 'mwe-loading-add-media-wiz' ) );
 2039+ // load the addMedia wizard without a target:
 2040+ $.fn.addMediaWiz ( options, function( amwObj ) {
 2041+ // close the dialog
 2042+ $.closeLoaderDialog();
 2043+ // do the add-media-wizard display
 2044+ amwObj.createUI();
 2045+ // call the parent callback:
 2046+ if ( callback )
 2047+ callback( _global['rsdMVRS'] );
 2048+ } );
 2049+ }
 2050+
 2051+ $.fn.addMediaWiz = function( options, callback ) {
 2052+ if ( this.selector ) {
 2053+ // First set the cursor for the button to "loading"
 2054+ $j( this.selector ).css( 'cursor', 'wait' ).attr( 'title', gM( 'mwe-loading_txt' ) );
 2055+ // set the target:
 2056+ options['target_invoke_button'] = this.selector;
 2057+ }
 2058+
 2059+ // Load the mwEmbed_base skin:
 2060+ loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' );
 2061+ loadExternalCss( mw.getMwEmbedPath() + 'skins/' + mw.getConfig( 'skin_name' ) + '/styles.css' );
 2062+ // Load all the required libs:
 2063+ mw.load( [
 2064+ [ 'remoteSearchDriver',
 2065+ '$j.cookie',
 2066+ '$j.fn.textSelection',
 2067+ '$j.ui'
 2068+ ], [
 2069+ '$j.ui.resizable',
 2070+ '$j.ui.draggable',
 2071+ '$j.ui.dialog',
 2072+ '$j.ui.tabs',
 2073+ '$j.ui.sortable'
 2074+ ]
 2075+ ], function() {
 2076+ options['instance_name'] = 'rsdMVRS';
 2077+ if ( ! _global['rsdMVRS'] )
 2078+ _global['rsdMVRS'] = new remoteSearchDriver( options );
 2079+ if ( callback ) {
 2080+ callback( _global['rsdMVRS'] );
 2081+ }
 2082+ } );
 2083+ }
 2084+ /*
 2085+ * Sequencer loader
 2086+ */
 2087+ $.fn.sequencer = function( options, callback ) {
 2088+ // Debugger
 2089+ options['target_sequence_container'] = this.selector;
 2090+ // Issue a request to get the CSS file (if not already included):
 2091+ loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' );
 2092+ loadExternalCss( mw.getMwEmbedPath() + 'skins/' + mw.getConfig( 'skin_name' ) + '/mv_sequence.css' );
 2093+ // Make sure we have the required mwEmbed libs (they are not loaded when no video
 2094+ // element is on the page)
 2095+ mvJsLoader.eembedPlayerheck( function() {
 2096+ // Load the playlist object and then the jQuery UI stuff:
 2097+ mw.load( [
 2098+ [
 2099+ 'mvPlayList',
 2100+ '$j.ui',
 2101+ '$j.contextMenu',
 2102+ 'JSON',
 2103+ 'mvSequencer'
 2104+ ],
 2105+ [
 2106+ '$j.ui.accordion',
 2107+ '$j.ui.dialog',
 2108+ '$j.ui.droppable',
 2109+ '$j.ui.draggable',
 2110+ '$j.ui.progressbar',
 2111+ '$j.ui.sortable',
 2112+ '$j.ui.resizable',
 2113+ '$j.ui.slider',
 2114+ '$j.ui.tabs'
 2115+ ]
 2116+ ], function() {
 2117+ js_log( 'calling new mvSequencer' );
 2118+ // Initialise the sequence object (it will take over from there)
 2119+ // No more than one mvSeq obj for now:
 2120+ if ( !_global['mvSeq'] ) {
 2121+ _global['mvSeq'] = new mvSequencer( options );
 2122+ } else {
 2123+ js_log( 'mvSeq already init' );
 2124+ }
 2125+ } );
 2126+ } );
 2127+ }
 2128+ /*
 2129+ * The Firefogg jQuery function:
 2130+ * @@note This Firefogg invocation could be made to work more like real jQuery plugins
 2131+ */
 2132+ var queuedFirefoggConf = { };
 2133+ $.fn.firefogg = function( iObj, callback ) {
 2134+ if ( !iObj )
 2135+ iObj = { };
 2136+ // Add the base theme CSS:
 2137+ loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' );
 2138+ loadExternalCss( mw.getMwEmbedPath() + 'skins/' + mw.getConfig( 'skin_name' ) + '/styles.css' );
 2139+
 2140+ // Check if we already have Firefogg loaded (the call just updates the element's
 2141+ // properties)
 2142+ var sElm = $j( this.selector ).get( 0 );
 2143+ if ( sElm['firefogg'] ) {
 2144+ if ( sElm['firefogg'] == 'loading' ) {
 2145+ js_log( "Queued firefogg operations ( firefogg " +
 2146+ "not done loading ) " );
 2147+ $j.extend( queuedFirefoggConf, iObj );
 2148+ return false;
 2149+ }
 2150+ // Update properties
 2151+ for ( var i in iObj ) {
 2152+ js_log( "firefogg::updated: " + i + ' to ' + iObj[i] );
 2153+ sElm['firefogg'][i] = iObj[i];
 2154+ }
 2155+ return sElm['firefogg'];
 2156+ } else {
 2157+ // Avoid concurrency
 2158+ sElm['firefogg'] = 'loading';
 2159+ }
 2160+ // Add the selector
 2161+ iObj['selector'] = this.selector;
 2162+
 2163+ var loadSet = [
 2164+ [
 2165+ 'mvBaseUploadInterface',
 2166+ 'mvFirefogg',
 2167+ '$j.ui'
 2168+ ],
 2169+ [
 2170+ '$j.ui.progressbar',
 2171+ '$j.ui.dialog',
 2172+ '$j.ui.draggable'
 2173+ ]
 2174+ ];
 2175+ if ( iObj.encoder_interface ) {
 2176+ loadSet.push( [
 2177+ 'mvAdvFirefogg',
 2178+ '$j.cookie',
 2179+ '$j.ui.accordion',
 2180+ '$j.ui.slider',
 2181+ '$j.ui.datepicker'
 2182+ ] );
 2183+ }
 2184+ // Make sure we have everything loaded that we need:
 2185+ mw.load( loadSet, function() {
 2186+ js_log( 'firefogg libs loaded. target select:' + iObj.selector );
 2187+ // Select interface provider based on whether we want to include the
 2188+ // encoder interface or not
 2189+ if ( iObj.encoder_interface ) {
 2190+ var myFogg = new mvAdvFirefogg( iObj );
 2191+ } else {
 2192+ var myFogg = new mvFirefogg( iObj );
 2193+ }
 2194+ if ( myFogg ) {
 2195+ myFogg.doRewrite( callback );
 2196+ var selectorElement = $j( iObj.selector ).get( 0 );
 2197+ selectorElement['firefogg'] = myFogg;
 2198+
 2199+ js_log( 'pre:' + selectorElement['firefogg']['firefogg_form_action'] )
 2200+ if ( queuedFirefoggConf )
 2201+ $j.extend( selectorElement['firefogg'], queuedFirefoggConf );
 2202+ js_log( 'post:' + selectorElement['firefogg']['firefogg_form_action'] )
 2203+ }
 2204+ } );
 2205+ }
 2206+ // Take an input player as the selector and expose basic rendering controls
 2207+ $.fn.firefoggRender = function( iObj, callback ) {
 2208+ // Check if we already have render loaded then just pass on updates/actions
 2209+ var sElm = $j( this.selector ).get( 0 );
 2210+ //add a special attribute to the selector:
 2211+ if ( sElm['fogg_render'] ) {
 2212+ if ( sElm['fogg_render'] == 'loading' ) {
 2213+ js_log( "Error: called firefoggRender while loading" );
 2214+ return false;
 2215+ }
 2216+ // Call or update the property:
 2217+ }
 2218+ sElm['fogg_render'] = 'loading';
 2219+ // Add the selector
 2220+ iObj['player_target'] = this.selector;
 2221+ mw.load( [
 2222+ 'mvBaseUploadInterface',
 2223+ 'mvFirefogg',
 2224+ 'mvFirefoggRender'
 2225+ ], function() {
 2226+ // Attach the firefoggRender obj to the selected elm:
 2227+ sElm['fogg_render'] = new mvFirefoggRender( iObj );
 2228+ if ( callback && typeof callback == 'function' )
 2229+ callback( sElm['fogg_render'] );
 2230+ } );
 2231+ }
 2232+
 2233+ $.fn.baseUploadInterface = function( iObj ) {
 2234+ mw.load( [
 2235+ [
 2236+ 'mvBaseUploadInterface',
 2237+ '$j.ui',
 2238+ ],
 2239+ [
 2240+ '$j.ui.progressbar',
 2241+ '$j.ui.dialog'
 2242+ ]
 2243+ ], function() {
 2244+ myUp = new mvBaseUploadInterface( iObj );
 2245+ myUp.setupForm();
 2246+ } );
 2247+ }
 2248+
 2249+ // Shortcut to a themed button
 2250+ $.btnHtml = function( msg, className, iconId, opt ) {
 2251+ if ( !opt )
 2252+ opt = { };
 2253+ var href = ( opt.href ) ? opt.href : '#';
 2254+ var target_attr = ( opt.target ) ? ' target="' + opt.target + '" ' : '';
 2255+ var style_attr = ( opt.style ) ? ' style="' + opt.style + '" ' : '';
 2256+ return '<a href="' + href + '" ' + target_attr + style_attr +
 2257+ ' class="ui-state-default ui-corner-all ui-icon_link ' +
 2258+ className + '"><span class="ui-icon ui-icon-' + iconId + '" ></span>' +
 2259+ '<span class="btnText">' + msg + '</span></a>';
 2260+ }
 2261+ // Shortcut to bind hover state
 2262+ $.fn.btnBind = function() {
 2263+ $j( this ).hover(
 2264+ function() {
 2265+ $j( this ).addClass( 'ui-state-hover' );
 2266+ },
 2267+ function() {
 2268+ $j( this ).removeClass( 'ui-state-hover' );
 2269+ }
 2270+ )
 2271+ return this;
 2272+ }
 2273+ /**
 2274+ * resize the dialog to fit the window
 2275+ */
 2276+ $.fn.dialogFitWindow = function( opt ) {
 2277+ var opt_default = { 'hspace':50, 'vspace':50 };
 2278+ if ( !opt )
 2279+ var opt = { };
 2280+ $j.extend( opt, opt_default );
 2281+ $j( this.selector ).dialog( 'option', 'width', $j( window ).width() - opt.hspace );
 2282+ $j( this.selector ).dialog( 'option', 'height', $j( window ).height() - opt.vspace );
 2283+ $j( this.selector ).dialog( 'option', 'position', 'center' );
 2284+ // update the child position: (some of this should be pushed up-stream via dialog config options
 2285+ $j( this.selector + '~ .ui-dialog-buttonpane' ).css( {
 2286+ 'position':'absolute',
 2287+ 'left':'0px',
 2288+ 'right':'0px',
 2289+ 'bottom':'0px'
 2290+ } );
 2291+ }
 2292+
 2293+ /**
 2294+ * addLoaderDialog
 2295+ * small helper for putting a loading dialog box on top of everything
 2296+ * (helps block for request that
 2297+ *
 2298+ * @param msg text text of the loader msg
 2299+ */
 2300+ $.addLoaderDialog = function( msg_txt ) {
 2301+ $.addDialog( msg_txt, msg_txt + '<br>' + mv_get_loading_img() );
 2302+ }
 2303+
 2304+ $.addDialog = function ( title, msg_txt, btn ) {
 2305+ $( '#mwe_tmp_loader' ).remove();
 2306+ // append the style free loader ontop:
 2307+ $( 'body' ).append( '<div id="mwe_tmp_loader" style="display:none" title="' + title + '" >' +
 2308+ msg_txt +
 2309+ '</div>' );
 2310+ // special btn == ok gives empty give a single "oky" -> "close"
 2311+ if ( btn == 'ok' ) {
 2312+ btn[ gM( 'mwe-ok' ) ] = function() {
 2313+ $j( '#mwe_tmp_loader' ).close();
 2314+ }
 2315+ }
 2316+ // turn the loader into a real dialog loader:
 2317+ mw.load( [
 2318+ [
 2319+ '$j.ui'
 2320+ ],
 2321+ [
 2322+ '$j.ui.dialog'
 2323+ ]
 2324+ ], function() {
 2325+ $( '#mwe_tmp_loader' ).dialog( {
 2326+ bgiframe: true,
 2327+ draggable: false,
 2328+ resizable: false,
 2329+ modal: true,
 2330+ width:400,
 2331+ buttons: btn
 2332+ } );
 2333+ } );
 2334+ }
 2335+ $.closeLoaderDialog = function() {
 2336+ mw.load( [
 2337+ [
 2338+ '$j.ui'
 2339+ ],
 2340+ [
 2341+ '$j.ui.dialog'
 2342+ ]
 2343+ ], function() {
 2344+ $j( '#mwe_tmp_loader' ).dialog( 'destroy' ).remove();
 2345+ } );
 2346+ }
 2347+
 2348+ $.mwProxy = function( apiConf ) {
 2349+ mw.load( ['mw.apiProxy'],
 2350+ function() {
 2351+ mw.apiProxy( apiConf );
 2352+ } );
 2353+ }
 2354+ } )( jQuery );
 2355+}
 2356+/*
 2357+* Utility functions:
 2358+*/
 2359+// Simple URL rewriter (could probably be refactored into an inline regular exp)
 2360+function getURLParamReplace( url, opt ) {
 2361+ var pSrc = mw.parseUri( url );
 2362+ if ( pSrc.protocol != '' ) {
 2363+ var new_url = pSrc.protocol + '://' + pSrc.authority + pSrc.path + '?';
 2364+ } else {
 2365+ var new_url = pSrc.path + '?';
 2366+ }
 2367+ var amp = '';
 2368+ for ( var key in pSrc.queryKey ) {
 2369+ var val = pSrc.queryKey[ key ];
 2370+ // Do override if requested
 2371+ if ( opt[ key ] )
 2372+ val = opt[ key ];
 2373+ new_url += amp + key + '=' + val;
 2374+ amp = '&';
 2375+ };
 2376+ // Add any vars that were not already there:
 2377+ for ( var i in opt ) {
 2378+ if ( !pSrc.queryKey[i] ) {
 2379+ new_url += amp + i + '=' + opt[i];
 2380+ amp = '&';
 2381+ }
 2382+ }
 2383+ return new_url;
 2384+}
 2385+/**
 2386+ * Given a float number of seconds, returns npt format response.
 2387+ *
 2388+ * @param float Seconds
 2389+ * @param boolean If we should show milliseconds or not.
 2390+ */
 2391+function seconds2npt( sec, show_ms ) {
 2392+ if ( isNaN( sec ) ) {
 2393+ // js_log("warning: trying to get npt time on NaN:" + sec);
 2394+ return '0:0:0';
 2395+ }
 2396+ var hours = Math.floor( sec / 3600 );
 2397+ var minutes = Math.floor( ( sec / 60 ) % 60 );
 2398+ var seconds = sec % 60;
 2399+ // Round the number of seconds to the required number of significant digits
 2400+ if ( show_ms ) {
 2401+ seconds = Math.round( seconds * 1000 ) / 1000;
 2402+ } else {
 2403+ seconds = Math.round( seconds );
 2404+ }
 2405+ if ( seconds < 10 )
 2406+ seconds = '0' + seconds;
 2407+ if ( minutes < 10 )
 2408+ minutes = '0' + minutes;
 2409+
 2410+ return hours + ":" + minutes + ":" + seconds;
 2411+}
 2412+/*
 2413+ * Take hh:mm:ss,ms or hh:mm:ss.ms input, return the number of seconds
 2414+ */
 2415+function npt2seconds( npt_str ) {
 2416+ if ( !npt_str ) {
 2417+ // js_log('npt2seconds:not valid ntp:'+ntp);
 2418+ return false;
 2419+ }
 2420+ // Strip {npt:}01:02:20 or 32{s} from time if present
 2421+ npt_str = npt_str.replace( /npt:|s/g, '' );
 2422+
 2423+ var hour = 0;
 2424+ var min = 0;
 2425+ var sec = 0;
 2426+
 2427+ times = npt_str.split( ':' );
 2428+ if ( times.length == 3 ) {
 2429+ sec = times[2];
 2430+ min = times[1];
 2431+ hour = times[0];
 2432+ } else if ( times.length == 2 ) {
 2433+ sec = times[1];
 2434+ min = times[0];
 2435+ } else {
 2436+ sec = times[0];
 2437+ }
 2438+ // Sometimes a comma is used instead of period for ms
 2439+ sec = sec.replace( /,\s?/, '.' );
 2440+ // Return seconds float
 2441+ return parseInt( hour * 3600 ) + parseInt( min * 60 ) + parseFloat( sec );
 2442+}
 2443+/*
 2444+ * Simple helper to grab an edit token
 2445+ *
 2446+ * @param title The wiki page title you want to edit
 2447+ * @param api_url 'optional' The target API URL
 2448+ * @param callback The callback function to pass the token to
 2449+ */
 2450+function get_mw_token( title, api_url, callback ) {
 2451+ js_log( ':get_mw_token:' );
 2452+ if ( !title && wgUserName ) {
 2453+ title = 'User:' + wgUserName;
 2454+ }
 2455+ var reqObj = {
 2456+ 'action': 'query',
 2457+ 'prop': 'info',
 2458+ 'intoken': 'edit',
 2459+ 'titles': title
 2460+ };
 2461+ do_api_req( {
 2462+ 'data': reqObj,
 2463+ 'url' : api_url
 2464+ }, function( data ) {
 2465+ for ( var i in data.query.pages ) {
 2466+ if ( data.query.pages[i]['edittoken'] ) {
 2467+ if ( typeof callback == 'function' )
 2468+ callback ( data.query.pages[i]['edittoken'] );
 2469+ }
 2470+ }
 2471+ // No token found:
 2472+ return false;
 2473+ }
 2474+ );
 2475+}
 2476+// Do a remote or local API request based on request URL
 2477+// @param options: url, data, cbParam, callback
 2478+function do_api_req( options, callback ) {
 2479+ if ( typeof options.data != 'object' ) {
 2480+ return js_error( 'Error: request paramaters must be an object' );
 2481+ }
 2482+ // Generate the URL if it's missing
 2483+ if ( typeof options.url == 'undefined' || !options.url ) {
 2484+ if ( typeof wgServer == 'undefined' ) {
 2485+ return js_error( 'Error: no api url for api request' );
 2486+ }
 2487+ options.url = mw.getLocalApiUrl();
 2488+ }
 2489+ if ( typeof options.data == 'undefined' )
 2490+ options.data = { };
 2491+
 2492+ // Force format to JSON
 2493+ options.data['format'] = 'json';
 2494+
 2495+ // If action is not set, assume query
 2496+ if ( ! options.data['action'] )
 2497+ options.data['action'] = 'query';
 2498+
 2499+ // js_log('do api req: ' + options.url +'?' + jQuery.param(options.data) );
 2500+ if ( options.url == 'proxy' && mw.proxy ) {
 2501+ // assume the proxy is already "setup" since mw.proxy is defined.
 2502+ // @@todo should probably integrate that setup into the api call
 2503+ mw.proxy.doRequest( options.data, callback );
 2504+ } else if ( mw.parseUri( document.URL ).host == mw.parseUri( options.url ).host ) {
 2505+ // Local request: do API request directly
 2506+ $j.ajax( {
 2507+ type: "POST",
 2508+ url: options.url,
 2509+ data: options.data,
 2510+ dataType: 'json', // API requests _should_ always return JSON data:
 2511+ async: false,
 2512+ success: function( data ) {
 2513+ callback( data );
 2514+ },
 2515+ error: function( e ) {
 2516+ js_error( ' error' + e + ' in getting: ' + options.url );
 2517+ }
 2518+ } );
 2519+ } else {
 2520+ // Remote request
 2521+ // Set the callback param if it's not already set
 2522+ if ( typeof options.jsonCB == 'undefined' )
 2523+ options.jsonCB = 'callback';
 2524+
 2525+ var req_url = options.url;
 2526+ var paramAnd = ( req_url.indexOf( '?' ) == -1 ) ? '?' : '&';
 2527+ // Put all the parameters into the URL
 2528+ for ( var i in options.data ) {
 2529+ req_url += paramAnd + encodeURIComponent( i ) + '=' + encodeURIComponent( options.data[i] );
 2530+ paramAnd = '&';
 2531+ }
 2532+ var fname = 'mycpfn_' + ( mw.cb_count++ );
 2533+ _global[ fname ] = callback;
 2534+ req_url += '&' + options.jsonCB + '=' + fname;
 2535+ loadExternalJs( req_url );
 2536+ }
 2537+}
 2538+// Do a request:
 2539+// @@note this contains metavid specific local vs remote api remapping.
 2540+// this should be depreciated and we should use "$j.get" or an explicate api call
 2541+// (we should not mix the two request types)
 2542+function do_request( req_url, callback ) {
 2543+ js_log( 'do_request::req_url:' + mw.parseUri( document.URL ) + ' != ' + mw.parseUri( req_url ).host );
 2544+ // If we are doing a request to the same domain or relative link, do a normal GET
 2545+ if ( mw.parseUri( document.URL ).host == mw.parseUri( req_url ).host ||
 2546+ req_url.indexOf( '://' ) == -1 ){ // if its a relative url go directly as well
 2547+ // Do a direct request
 2548+ $j.ajax( {
 2549+ type: "GET",
 2550+ url: req_url,
 2551+ async: false,
 2552+ success: function( data ) {
 2553+ callback( data );
 2554+ }
 2555+ } );
 2556+ } else {
 2557+ // Get data via DOM injection with callback
 2558+ global_req_cb.push( callback );
 2559+ // Prepend json_ to feed_format if not already requesting json format (metavid specific)
 2560+ if ( req_url.indexOf( "feed_format=" ) != -1 && req_url.indexOf( "feed_format=json" ) == -1 )
 2561+ req_url = req_url.replace( /feed_format=/, 'feed_format=json_' );
 2562+ loadExternalJs( req_url + '&cb=mv_jsdata_cb&cb_inx=' + ( global_req_cb.length -1 ) );
 2563+ }
 2564+}
 2565+
 2566+function mv_jsdata_cb( response ) {
 2567+ js_log( 'f:mv_jsdata_cb:' + response['cb_inx'] );
 2568+ // Run the callback from the global request callback object
 2569+ if ( !global_req_cb[response['cb_inx']] ) {
 2570+ js_log( 'missing req cb index' );
 2571+ return false;
 2572+ }
 2573+ if ( !response['pay_load'] ) {
 2574+ js_log( "missing pay load" );
 2575+ return false;
 2576+ }
 2577+ switch( response['content-type'] ) {
 2578+ case 'text/plain':
 2579+ break;
 2580+ case 'text/xml':
 2581+ if ( typeof response['pay_load'] == 'string' ) {
 2582+ response['pay_load'] = mw.parseXML( response['pay_load'] );
 2583+ }
 2584+ break
 2585+ default:
 2586+ js_log( 'bad response type' + response['content-type'] );
 2587+ return false;
 2588+ break;
 2589+ }
 2590+ global_req_cb[response['cb_inx']]( response['pay_load'] );
 2591+}
 2592+// Load external JS via DOM injection
 2593+function loadExternalJs( url, callback ) {
 2594+ js_log( 'load js: ' + url );
 2595+ // if(window['$j']) // use jquery call:
 2596+ /*$j.ajax({
 2597+ type: "GET",
 2598+ url: url,
 2599+ dataType: 'script',
 2600+ cache: true
 2601+ });*/
 2602+ // else{
 2603+ var e = document.createElement( "script" );
 2604+ e.setAttribute( 'src', url );
 2605+ e.setAttribute( 'type', "text/javascript" );
 2606+ /*if(callback)
 2607+ e.onload = callback;
 2608+ */
 2609+ // e.setAttribute('defer', true);
 2610+ document.getElementsByTagName( "head" )[0].appendChild( e );
 2611+ // }
 2612+}
 2613+function styleSheetPresent( url ) {
 2614+ style_elements = document.getElementsByTagName( 'link' );
 2615+ if ( style_elements.length > 0 ) {
 2616+ for ( i = 0; i < style_elements.length; i++ ) {
 2617+ if ( style_elements[i].href == url )
 2618+ return true;
 2619+ }
 2620+ }
 2621+ return false;
 2622+}
 2623+function loadExternalCss( url ) {
 2624+ // We could have the script loader group these CSS requests.
 2625+ // But it's debatable: it may hurt more than it helps with caching and all
 2626+ if ( typeof url == 'object' ) {
 2627+ for ( var i in url ) {
 2628+ loadExternalCss( url[i] );
 2629+ }
 2630+ return ;
 2631+ }
 2632+
 2633+ if ( url.indexOf( '?' ) == -1 ) {
 2634+ url += '?' + mw.getUrlParam();
 2635+ }
 2636+ if ( !styleSheetPresent( url ) ) {
 2637+ js_log( 'load css: ' + url );
 2638+ var e = document.createElement( "link" );
 2639+ e.href = url;
 2640+ e.type = "text/css";
 2641+ e.rel = 'stylesheet';
 2642+ document.getElementsByTagName( "head" )[0].appendChild( e );
 2643+ }
 2644+}
 2645+
 2646+
 2647+if ( typeof DOMParser == "undefined" ) {
 2648+ DOMParser = function () { }
 2649+ DOMParser.prototype.parseFromString = function ( str, contentType ) {
 2650+ if ( typeof ActiveXObject != "undefined" ) {
 2651+ var d = new ActiveXObject( "MSXML.DomDocument" );
 2652+ d.loadXML( str );
 2653+ return d;
 2654+ } else if ( typeof XMLHttpRequest != "undefined" ) {
 2655+ var req = new XMLHttpRequest;
 2656+ req.open( "GET", "data:" + ( contentType || "application/xml" ) +
 2657+ ";charset=utf-8," + encodeURIComponent( str ), false );
 2658+ if ( req.overrideMimeType ) {
 2659+ req.overrideMimeType( contentType );
 2660+ }
 2661+ req.send( null );
 2662+ return req.responseXML;
 2663+ }
 2664+ }
 2665+}
 2666+/*
 2667+* Utility functions
 2668+*/
 2669+function js_log( string ) {
 2670+ // Add any prepend debug strings if necessary (used for cross browser)
 2671+ if ( mw.getConfig( 'pre-append-log' ) )
 2672+ string = mw.getConfig( 'pre-append-log' ) + string;
 2673+
 2674+ if ( window.console ) {
 2675+ window.console.log( string );
 2676+ } else {
 2677+ /**
 2678+ * old IE and non-Firebug debug:
 2679+ */
 2680+ /*var log_elm = document.getElementById('mv_js_log');
 2681+ if(!log_elm){
 2682+ document.getElementsByTagName("body")[0].innerHTML = document.getElementsByTagName("body")[0].innerHTML +
 2683+ '<div style="position:absolute;z-index:500;top:0px;left:0px;right:0px;height:10px;">'+
 2684+ '<textarea id="mv_js_log" cols="120" rows="5"></textarea>'+
 2685+ '</div>';
 2686+
 2687+ var log_elm = document.getElementById('mv_js_log');
 2688+ }
 2689+ if(log_elm){
 2690+ log_elm.value+=string+"\n";
 2691+ }*/
 2692+ }
 2693+ return false;
 2694+}
 2695+
 2696+function js_error( string ) {
 2697+ alert( string );
 2698+ return false;
 2699+}
Property changes on: branches/js2-work/phase3/js2/mwEmbed/mwEmbed.js
___________________________________________________________________
Added: svn:mergeinfo
12700 Merged /branches/REL1_15/phase3/js2/mwEmbed/mv_embed.js:r51646
22701 Merged /branches/sqlite/js2/mwEmbed/mv_embed.js:r58211-58321
Added: svn:eol-style
32702 + native
Index: branches/js2-work/phase3/js2/mwEmbed/jsScriptLoader.php
@@ -420,7 +420,7 @@
421421 }
422422 static public function getLoadGmIndex( $str ){
423423 $returnIndex = array();
424 - preg_match('/loadGM\s*\(\s*\{/', $str, $matches, PREG_OFFSET_CAPTURE );
 424+ preg_match('/mw.addMessages\s*\(\s*\{/', $str, $matches, PREG_OFFSET_CAPTURE );
425425 if( count($matches) == 0){
426426 return false;
427427 }
@@ -460,7 +460,7 @@
461461 $jsmsg = $this->getMsgKeysFromClass( $class );
462462 if( $jsmsg ){
463463 self::getMsgKeys ( $jsmsg );
464 - return 'loadGM(' . FormatJson::encode( $jsmsg ) . ');';
 464+ return 'mw.addMessages(' . FormatJson::encode( $jsmsg ) . ');';
465465 }else{
466466 //if could not parse return empty string:
467467 return '';
@@ -503,7 +503,7 @@
504504 //developers will read the js source when its not behaving as expected.
505505 return "\n/*
506506 * Could not parse JSON language messages in this file,
507 -* Please check that loadGM call contains valid JSON (not javascript)
 507+* Please check that mw.addMessages call contains valid JSON (not javascript)
508508 */\n\n" . $json_str; //include the original fallback loadGM
509509
510510 }
@@ -609,7 +609,8 @@
610610 $mydir2 = substr( $this->filename, 0, strrpos( $this->filename, '/' ) ); # subdirectory level 2
611611 $mydir1 = substr( $mydir2, 0, strrpos( $mydir2, '/' ) ); # subdirectory level 1
612612
613 - if ( wfMkdirParents( $mydir1 ) === false || wfMkdirParents( $mydir2 ) === false ) {
 613+ // Suppress error so javascript can format it
 614+ if ( @wfMkdirParents( $mydir1 ) === false || @wfMkdirParents( $mydir2 ) === false ) {
614615 return 'Could not create cache directory. Check your cache directory permissions?';
615616 } else {
616617 return true;
Index: branches/js2-work/phase3/js2/mwEmbed/libTimedText/mvTextInterface.js
@@ -1,4 +1,4 @@
2 -loadGM( {
 2+mw.addMessages( {
33 "mwe-select_transcript_set" : "Select subtitles",
44 "mwe-auto_scroll" : "auto scroll",
55 "mwe-close" : "close",
Index: branches/js2-work/phase3/js2/mwEmbed/libTimedText/mvTimeTextEdit.js
@@ -8,7 +8,7 @@
99
1010 var mvTimeTextEdit = { };
1111
12 -loadGM( {
 12+mw.addMessages( {
1313 "mwe-upload-subs-file" : "Upload subtitle",
1414 "mwe-add-subs-file-title" : "Select subtitle to upload",
1515 "mwe-error-only-srt" : "You can only upload srt files.",
@@ -18,7 +18,7 @@
1919 } )
2020
2121
22 -js2AddOnloadHook( function() {
 22+mw.addOnloadHook( function() {
2323 function getSubtitle( f ) {
2424 var name = f.files[0].name;
2525 var srtData = f.files[0].getAsBinary();
Index: branches/js2-work/phase3/js2/mwEmbed/example_usage/Player_RelatedVideos.html
@@ -3,7 +3,7 @@
44 <html>
55 <head>
66 <title>Simple Video Tag Usage</title>
7 - <script type="text/javascript" src="../mv_embed.js?debug=true"></script>
 7+ <script type="text/javascript" src="../mwEmbed.js?debug=true"></script>
88 </head>
99 <body>
1010 <h3> Related Videos </h3>
Index: branches/js2-work/phase3/js2/mwEmbed/example_usage/Add_Media_Wizard.html
@@ -1,8 +1,8 @@
2 -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 2+<!DOCTYPE HT ML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
33 "http://www.w3.org/TR/html4/loose.dtd">
44 <html>
55 <head>
6 - <title> Sample mv Embed</title>
 6+ <title> Sample mwEmbed Add Media Wizard</title>
77 <style type="text/css">
88 body{
99 font-size:80%;
@@ -11,16 +11,16 @@
1212 border:medium none;
1313 }
1414 </style>
15 - <script type="text/javascript" src="../mv_embed.js?debug=true"></script>
16 - <!--<script type="text/javascript" src="../jsScriptLoader.php?class=window.jQuery,mv_embed,remoteSearchDriver,$j.ui,$j.ui.resizable,$j.ui.draggable,$j.ui.dialog,$j.ui.tabs,$j.ui.sortable,$j.cookie,baseRemoteSearch&urid=1257728132531&debug=true&uselang=en"></script> -->
 15+ <script type="text/javascript" src="../mwEmbed.js?debug=true"></script>
 16+ <!-- <script type="text/javascript" src="../jsScriptLoader.php?class=window.jQuery,mwEmbed,remoteSearchDriver,$j.ui,$j.ui.resizable,$j.ui.draggable,$j.ui.dialog,$j.ui.tabs,$j.ui.sortable,$j.cookie,baseRemoteSearch&urid=1257728132531&debug=true&uselang=en"></script> -->
1717 <script type="text/javascript">
18 - js2AddOnloadHook(function(){
 18+ mw.addOnloadHook(function(){
1919
2020 $j('#add_media_link').addMediaWiz( {
21 - 'profile':'html_edit',
22 - 'target_textbox': '#wpTextbox1',
23 - 'target_render_area':'#inline_append',
24 - 'import_url_mode':'remote_link',
 21+ 'profile' : 'html_edit',
 22+ 'target_textbox' : '#wpTextbox1',
 23+ 'target_render_area' : '#inline_append',
 24+ 'import_url_mode' : 'remote_link',
2525 'remote_insert_description' : true,
2626 //note selections in the textbox will take over the default query
2727 'default_query': 'fish',
Index: branches/js2-work/phase3/js2/mwEmbed/example_usage/Sequence_Render.html
@@ -2,7 +2,7 @@
33 <html>
44 <head>
55 <title>Seeking Render Example</title>
6 - <script type="text/javascript" src="../mv_embed.js?debug=true"></script>
 6+ <script type="text/javascript" src="../mwEmbed.js?debug=true"></script>
77 <style>
88 #render_box {
99 position:absolute;
Index: branches/js2-work/phase3/js2/mwEmbed/example_usage/Firefogg_Make_Advanced.html
@@ -2,8 +2,8 @@
33 <html><head>
44 <meta http-equiv="content-type" content="text/html; charset=UTF-8">
55 <title>Firefogg - Make Ogg Video in your Browser</title>
6 - <script type="text/javascript" src="../jsScriptLoader.php?urid=r58125&class=mv_embed,window.jQuery,mvBaseUploadInterface,mvFirefogg,mvAdvFirefogg,$j.ui,$j.ui.progressbar,$j.ui.dialog,$j.cookie,$j.ui.accordion,$j.ui.slider,$j.ui.datepicker,$j.ui.draggable"></script>
7 - <!-- <script type="text/javascript" src="../mv_embed.js"></script> -->
 6+ <script type="text/javascript" src="../jsScriptLoader.php?urid=r58125&class=mwEmbed,window.jQuery,mvBaseUploadInterface,mvFirefogg,mvAdvFirefogg,$j.ui,$j.ui.progressbar,$j.ui.dialog,$j.cookie,$j.ui.accordion,$j.ui.slider,$j.ui.datepicker,$j.ui.draggable"></script>
 7+ <!-- <script type="text/javascript" src="../mwEmbed.js"></script> -->
88 <style type="text/css" media="all">body {
99 margin: 0;
1010 padding: 0;
Index: branches/js2-work/phase3/js2/mwEmbed/example_usage/Player_Audio.html
@@ -2,7 +2,7 @@
33 <html>
44 <head>
55 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6 - <script type="text/javascript" src="../mv_embed.js?debug=true"></script>
 6+ <script type="text/javascript" src="../mwEmbed.js?debug=true"></script>
77 <title>Audio Player sample</title>
88 </head>
99 <body>
Index: branches/js2-work/phase3/js2/mwEmbed/example_usage/Player_Themable.html
@@ -3,8 +3,8 @@
44 <html>
55 <head>
66 <title>Sample Themed Player</title>
7 - <!-- <script type="text/javascript" src="../jsScriptLoader.php?class=mv_embed,embedVideo&urid=1"></script> -->
8 - <script type="text/javascript" src="../mv_embed.js?debug=true"></script>
 7+ <!-- <script type="text/javascript" src="../jsScriptLoader.php?class=mwEmbed,embedVideo&urid=1"></script> -->
 8+ <script type="text/javascript" src="../mwEmbed.js?debug=true"></script>
99 </head>
1010 <script type="text/javascript">
1111 </script>
Index: branches/js2-work/phase3/js2/mwEmbed/example_usage/Multi_Upload.html
@@ -3,7 +3,7 @@
44 <html>
55 <head>
66 <title>Sample Themed Player</title>
7 - <script type="text/javascript" src="../mv_embed.js"></script>
 7+ <script type="text/javascript" src="../mwEmbed.js"></script>
88 </head>
99 <script type="text/javascript">
1010 mwAddOnloadHook(function(){
Index: branches/js2-work/phase3/js2/mwEmbed/example_usage/Sequence_Editor.html
@@ -3,7 +3,7 @@
44 <html>
55 <head>
66 <title>SMIL Sequence Editor example</title>
7 - <script type="text/javascript" src="../mv_embed.js?debug=true"></script>
 7+ <script type="text/javascript" src="../mwEmbed.js?debug=true"></script>
88 <script type="text/javascript">
99 mwAddOnloadHook(function(){
1010 $j('#seqcontainer').sequencer({
Index: branches/js2-work/phase3/js2/mwEmbed/example_usage/Player_Timed_Text.html
@@ -3,10 +3,10 @@
44 <html>
55 <head>
66 <title>sample mv embed</title>
7 - <script type="text/javascript" src="../mv_embed.js?debug=true"></script>
 7+ <script type="text/javascript" src="../mwEmbed.js?debug=true"></script>
88 </head>
99 <body>
10 -<h3> Mv_Embed Timed Text Examples:</h3>
 10+<h3> mwEmbed Timed Text Examples:</h3>
1111 Click on the little lower right "CC" icon to expose the timed text
1212 <table border="1" cellpadding="6" width="950">
1313 <tr>
Index: branches/js2-work/phase3/js2/mwEmbed/libAddMedia/mvFirefogg.js
@@ -2,7 +2,7 @@
33 * autodetects: new upload api or old http POST.
44 */
55
6 -loadGM({
 6+mw.addMessages({
77 "fogg-select_file" : "Select file",
88 "fogg-select_new_file" : "Select new file",
99 "fogg-select_url" : "Select URL",
@@ -152,7 +152,7 @@
153153
154154 /**
155155 * Rewrite the upload form, or create our own upload controls for local transcoding.
156 - * Called from $j.firefogg(), in mv_embed.js.
 156+ * Called from $j.firefogg(), in mwEmbed.js.
157157 */
158158 doRewrite: function( callback ) {
159159 var _this = this;
Index: branches/js2-work/phase3/js2/mwEmbed/libAddMedia/remoteSearchDriver.js
@@ -6,7 +6,7 @@
77 * Is optionally extended by Sequence Remote Search Driver
88 */
99
10 -loadGM( {
 10+mw.addMessages( {
1111 "mwe-add_media_wizard" : "Add media wizard",
1212 "mwe-media_search" : "Media search",
1313 "rsd_box_layout" : "Box layout",
@@ -817,7 +817,7 @@
818818 */
819819 showUploadForm: function() {
820820 var _this = this;
821 - mvJsLoader.doLoad( ['$j.fn.simpleUploadForm'], function() {
 821+ mw.load( ['$j.fn.simpleUploadForm'], function() {
822822 var provider = _this.content_providers['this_wiki'];
823823
824824 // check for "this_wiki" enabled
@@ -1083,7 +1083,7 @@
10841084 loadSearchLib: function( provider, callback ) {
10851085 var _this = this;
10861086 // Set up the library req:
1087 - mvJsLoader.doLoad( [
 1087+ mw.load( [
10881088 'baseRemoteSearch',
10891089 provider.lib + 'Search'
10901090 ], function() {
@@ -1149,7 +1149,7 @@
11501150 var content = '';
11511151 for ( var providerName in this.content_providers ) {
11521152 var provider = this.content_providers[providerName];
1153 - var tabImage = mv_embed_path + '/skins/common/remote_cp/' + providerName + '_tab.png';
 1153+ var tabImage = mw.getMwEmbedPath() + '/skins/common/remote_cp/' + providerName + '_tab.png';
11541154 if ( provider.enabled && provider.checked && provider.api_url ) {
11551155 // Add selected default if set
11561156 if ( this.currentProvider == providerName )
@@ -1673,7 +1673,7 @@
16741674 var _this = this;
16751675 var options = _this.getClipEditOptions( resource );
16761676 // Display the mvClipEdit obj once we are done loading:
1677 - mvJsLoader.doLoad( ['mvClipEdit'], function() {
 1677+ mw.load( ['mvClipEdit'], function() {
16781678 // Run the image clip tools
16791679 _this.clipEdit = new mvClipEdit( options );
16801680 } );
@@ -1710,25 +1710,29 @@
17111711 { id : 'embed_vid' } );
17121712 js_log( 'append html: ' + embedHtml );
17131713 $j( '#clip_edit_disp' ).html( embedHtml );
1714 - js_log( "about to call rewrite_by_id::embed_vid" );
17151714
1716 - // Rewrite by id
1717 - rewrite_by_id( 'embed_vid', function() {
 1715+ js_log( "about to call $j.embedPlayer::embed_vid" );
17181716
1719 - // Grab information available from the embed instance
1720 - resource.pSobj.addResourceInfoFromEmbedInstance( resource, 'embed_vid' );
1721 -
1722 - // Add libraries resizable and hoverIntent to support video edit tools
1723 - var librarySet = [
1724 - 'mvClipEdit',
1725 - '$j.ui.resizable',
1726 - '$j.fn.hoverIntent'
1727 - ]
1728 - mvJsLoader.doLoad( librarySet, function() {
1729 - // Make sure the rsd_edit_img is removed:
1730 - $j( '#rsd_edit_img' ).remove();
1731 - // Run the image clip tools
1732 - _this.clipEdit = new mvClipEdit( options );
 1717+ //Make sure we have embedPlayer libs:
 1718+ mvJsLoader.embedPlayerCheck( function() {
 1719+ // Rewrite by id
 1720+ $j( '#embed_vid').embedPlayer ( function() {
 1721+
 1722+ // Grab information available from the embed instance
 1723+ resource.pSobj.addResourceInfoFromEmbedInstance( resource, 'embed_vid' );
 1724+
 1725+ // Add libraries resizable and hoverIntent to support video edit tools
 1726+ var librarySet = [
 1727+ 'mvClipEdit',
 1728+ '$j.ui.resizable',
 1729+ '$j.fn.hoverIntent'
 1730+ ]
 1731+ mw.load( librarySet, function() {
 1732+ // Make sure the rsd_edit_img is removed:
 1733+ $j( '#rsd_edit_img' ).remove();
 1734+ // Run the image clip tools
 1735+ _this.clipEdit = new mvClipEdit( options );
 1736+ } );
17331737 } );
17341738 } );
17351739 } );
@@ -1960,8 +1964,10 @@
19611965 );
19621966
19631967 // Update video tag (if a video)
1964 - if ( resource.mime.indexOf( 'video/' ) !== -1 )
1965 - rewrite_by_id( $j( _this.target_container ).attr( 'id' ) + '_rsd_pv_vid' );
 1968+ if ( resource.mime.indexOf( 'video/' ) !== -1 ){
 1969+ var target_rewrite_id = $j( _this.target_container ).attr( 'id' ) + '_rsd_pv_vid';
 1970+ $j('#' + target_rewrite_id ).embedPlayer();
 1971+ }
19661972
19671973 // Load the preview text:
19681974 _this.parse(
@@ -2102,7 +2108,7 @@
21032109 $j.addLoaderDialog( gM( 'mwe-importing_asset' ) );
21042110
21052111 // Load the BaseUploadInterface:
2106 - mvJsLoader.doLoad(
 2112+ mw.load(
21072113 [
21082114 'mvBaseUploadInterface',
21092115 '$j.ui.progressbar'
Index: branches/js2-work/phase3/js2/mwEmbed/libAddMedia/dragDropFile.js
@@ -2,7 +2,7 @@
33 *
44 * Note: this file is still under development
55 */
6 -loadGM( {
 6+mw.addMessages( {
77 "mwe-upload-multi" : "Upload {{PLURAL:$1|file|files}}",
88 "mwe-review-upload": "Review file {{PLURAL:$1|upload|uploads}}"
99 } );
Index: branches/js2-work/phase3/js2/mwEmbed/libAddMedia/simpleUploadForm.js
@@ -4,7 +4,7 @@
55 *
66 */
77
8 -loadGM( {
 8+mw.addMessages( {
99 "mwe-select_file" : "Select file",
1010 "mwe-more_license_options" : "For more license options, view the <a href=\"$1\">normal upload page<\/a>",
1111 "mwe-select_ownwork" : "I am uploading entirely my own work, and licencing it under:",
Index: branches/js2-work/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js
@@ -4,7 +4,7 @@
55 * This base upload class is optionally extended by Firefogg
66 *
77 */
8 -loadGM({
 8+mw.addMessages({
99 "mwe-upload-transcode-in-progress" : "Transcode and upload in progress (do not close this window)",
1010 "mwe-upload-in-progress" : "Upload in progress (do not close this window)",
1111 "mwe-upload-transcoded-status" : "Transcoded",
@@ -467,7 +467,7 @@
468468 //update status to 100%
469469 _this.updateProgress( 1 );
470470 //see if we need JSON
471 - mvJsLoader.doLoad( [
 471+ mw.load( [
472472 'JSON'
473473 ], function() {
474474 var apiResult = {};
Index: branches/js2-work/phase3/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js
@@ -2,7 +2,7 @@
33 * Base remote search Object.
44 * provides the base class for the other search system to extend.
55 */
6 -loadGM( {
 6+mw.addMessages( {
77 "mwe-imported_from" : "$1 imported from [$2 $3]. See the original [$4 resource page] for more information.",
88 "mwe-import-description" : "$1, imported from $2"
99 } );
Index: branches/js2-work/phase3/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js
@@ -1,7 +1,7 @@
22 /*
33 * API modes (implementations should call these objects which inherit the mvBaseRemoteSearch
44 */
5 -loadGM( {
 5+mw.addMessages( {
66 "mwe-stream_title" : "$1 $2 to $3"
77 } );
88 var metavidSearch = function( iObj ) {
Index: branches/js2-work/phase3/js2/mwEmbed/libAddMedia/mvAdvFirefogg.js
@@ -2,7 +2,7 @@
33 * Advanced Firefogg support. Lets you control many aspects of video encoding.
44 */
55
6 -loadGM({
 6+mw.addMessages({
77 "fogg-help-sticky" : "Help (click to stick)",
88 "fogg-cg-preset" : "Preset: <strong>$1<\/strong>",
99 "fogg-cg-quality" : "Basic quality and resolution control",
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/javaEmbed.js
@@ -40,7 +40,7 @@
4141 }
4242 } else {
4343 // should be identical to cortado.jar
44 - applet_loc = mv_embed_path + 'libEmbedPlayer/binPlayers/cortado/cortado-ovt-stripped-0.5.0.jar';
 44+ applet_loc = mw.getMwEmbedPath() + 'libEmbedPlayer/binPlayers/cortado/cortado-ovt-stripped-0.5.0.jar';
4545 }
4646 // load directly in the page..
4747 // (media must be on the same server or applet must be signed)
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/flowplayerEmbed.js
@@ -1438,7 +1438,7 @@
14391439 } )();
14401440
14411441 /************************************************
1442 -********* mv_embed extension to flowplayer.js ***
 1442+********* mwEmbed extension to flowplayer.js ***
14431443 ************************************************/
14441444 var flowplayerEmbed = {
14451445 instanceOf:'flowplayerEmbed',
@@ -1472,7 +1472,7 @@
14731473 postEmbedJS: function()
14741474 {
14751475 var _this = this;
1476 - js_log( 'embedFlow: uri:' + this.getSrc() + "\n" + mv_embed_path + 'libEmbedPlayer/binPlayers/flowplayer/flowplayer-3.0.1.swf' ) ;
 1476+ js_log( 'embedFlow: uri:' + this.getSrc() + "\n" + mw.getMwEmbedPath() + 'libEmbedPlayer/binPlayers/flowplayer/flowplayer-3.0.1.swf' ) ;
14771477 var flowConfig = {
14781478 clip: {
14791479 url: this.getSrc(),
@@ -1500,7 +1500,7 @@
15011501 flowConfig.screen.opacity = 0.2;
15021502 }
15031503
1504 - $f( this.pid, mv_embed_path + 'binPlayers/flowplayer/flowplayer-3.0.1.swf', flowConfig );
 1504+ $f( this.pid, mwEmbed_path + 'binPlayers/flowplayer/flowplayer-3.0.1.swf', flowConfig );
15051505 // get the this.fla value:
15061506 this.getFLA();
15071507 // set up bindings (for when interacting with the swf causes action:
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/nativeEmbed.js
@@ -1,4 +1,9 @@
2 -// native embed library:
 2+
 3+/*
 4+* Native embed library:
 5+*
 6+* Enables embedPlayer support for native html5 browser playback system
 7+*/
38 var nativeEmbed = {
49 instanceOf:'nativeEmbed',
510 canPlayThrough:false,
@@ -24,7 +29,7 @@
2530 return this.wrapEmebedContainer( embed_code );
2631 },
2732 getEmbedObj:function() {
28 - // we want to let mv_embed handle the controls so notice the absence of control attribute
 33+ // we want to let mwEmbed handle the controls so notice the absence of control attribute
2934 // controls=false results in controls being displayed:
3035 // http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2008-August/016159.html
3136 js_log( "native play url:" + this.getSrc() + ' start_offset: ' + this.start_ntp + ' end: ' + this.end_ntp );
@@ -37,7 +42,8 @@
3843 /*if(!this.onlyLoadFlag)
3944 eb+='autoplay="true" ';*/
4045
41 - // continue with the other attr:
 46+ // continue with the other attr:
 47+ // NOTE: could be binded in "post embed js"
4248 eb += 'oncanplaythrough="$j(\'#' + this.id + '\').get(0).oncanplaythrough();return false;" ' +
4349 'onloadedmetadata="$j(\'#' + this.id + '\').get(0).onloadedmetadata();return false;" ' +
4450 'loadedmetadata="$j(\'#' + this.id + '\').get(0).onloadedmetadata();return false;" ' +
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/kplayerEmbed.js
@@ -20,7 +20,7 @@
2121 return this.wrapEmebedContainer( embed_code );
2222 },
2323 getEmbedObj:function() {
24 - var player_path = mv_embed_path + 'libEmbedPlayer/binPlayers/kaltura-player';
 24+ var player_path = mw.getMwEmbedPath() + 'libEmbedPlayer/binPlayers/kaltura-player';
2525 return '<object width="' + this.width + '" height="' + this.height + '" '+
2626 'data="' + player_path + '/wrapper.swf" allowfullscreen="true" '+
2727 'allownetworking="all" allowscriptaccess="always" '+
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/omtkEmbed.js
@@ -11,7 +11,7 @@
1212 return this.wrapEmebedContainer( embed_code );
1313 },
1414 getEmbedObj:function() {
15 - var player_path = mv_embed_path + 'libEmbedPlayer/binPlayers/omtk-fx/omtkp.swf';
 15+ var player_path = mw.getMwEmbedPath() + 'libEmbedPlayer/binPlayers/omtk-fx/omtkp.swf';
1616 // player_path = 'omtkp.swf';
1717 js_log( "player path: " + player_path );
1818 return '<object id="' + this.pid + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="1" height="1">' +
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/embedPlayer.js
@@ -8,11 +8,11 @@
99 *
1010 */
1111
12 -loadGM( {
 12+mw.addMessages( {
1313 "mwe-loading_plugin" : "loading plugin ...",
1414 "mwe-select_playback" : "Set playback preference",
1515 "mwe-link_back" : "Link back",
16 - "mwe-error_swap_vid" : "Error: mv_embed was unable to swap the video tag for the mv_embed interface",
 16+ "mwe-error_swap_vid" : "Error: mwEmbed was unable to swap the video tag for the mwEmbed interface",
1717 "mwe-add_to_end_of_sequence" : "Add to end of sequence",
1818 "mwe-missing_video_stream" : "The video file for this stream is missing",
1919 "mwe-play_clip" : "Play clip",
@@ -216,17 +216,6 @@
217217 * Adds jQuery binding for embedPlayer
218218 */
219219 ( function( $ ) {
220 -
221 - /**
222 - * The base embedPlayers function converts all
223 - * video, audio, playlist tags into javascript player interfaces
224 - *
225 - * @param {Object} attributes Attributes applied to all players
226 - * @param [ Optional ] {Function} callback Function to be called once player interfaces are ready
227 - */
228 - $.embedPlayers = function( attributes, callback ){
229 - $( 'video,audio,playlist' ).embedPlayer( attributes, callback );
230 - }
231220
232221 /**
233222 * Selector based embedPlayer jQuery binding
@@ -281,6 +270,7 @@
282271 //Set the selector to IE compatible set and continue processing
283272 j_selector = ie_compatible_selector;
284273 }
 274+
285275 // Run the selector
286276 $j( j_selector ).each( function() {
287277 mw.playerManager.addElement( this, attributes);
@@ -351,7 +341,7 @@
352342 break;
353343 case 'playlist':
354344 // Make sure we have the necessary playlist libs loaded:
355 - mvJsLoader.doLoad( [
 345+ mw.load( [
356346 'mvPlayList',
357347 '$j.ui', // Include dialog for pop-ing up things
358348 '$j.ui.dialog'
@@ -1142,7 +1132,7 @@
11431133
11441134 // Set the default skin if unset:
11451135 if ( !this.skin_name )
1146 - this.skin_name = mw.conf.skin_name;
 1136+ this.skin_name = mw.getConfig( 'skin_name' );
11471137
11481138 // Make sure startOffset is cast as an int
11491139 if ( this.startOffset && this.startOffset.split( ':' ).length >= 2 )
@@ -1181,7 +1171,7 @@
11821172 this.ctrlBuilder = new ctrlBuilder( this );
11831173 }
11841174 // Load player skin css:
1185 - loadExternalCss( mv_embed_path + 'skins/' + this.skin_name + '/playerSkin.css' );
 1175+ loadExternalCss( mw.getMwEmbedPath() + 'skins/' + this.skin_name + '/playerSkin.css' );
11861176 },
11871177
11881178 /**
@@ -1196,7 +1186,7 @@
11971187 if( element.tagName.toLowerCase() == 'audio' && dim == 'height' )
11981188 return this[ dim ] = 0;
11991189 // Grab width/height from default value (for video)
1200 - var dwh = mw.conf['video_size'].split( 'x' );
 1190+ var dwh = mw.getConfig( 'video_size' ).split( 'x' );
12011191 this[ dim ] = ( dim == 'width' )? dwh[0] : dwh[1];
12021192 }
12031193 },
@@ -1251,7 +1241,7 @@
12521242 },
12531243
12541244 /**
1255 - * Sources Ready Innitialization
 1245+ * Sources Ready Initialisation
12561246 *
12571247 * issues autoSelectSource call
12581248 *
@@ -1379,7 +1369,7 @@
13801370 return false;
13811371 }
13821372 }
1383 - // See if we are using mv_embed without a ogg source in which case no point in promoting firefox :P
 1373+ // See if we are using mwEmbed without a ogg source in which case no point in promoting firefox :P
13841374 if ( this.media_element && this.media_element.sources ) {
13851375 var foundOgg = false;
13861376 var playable_sources = this.media_element.getPlayableSources();
@@ -1456,16 +1446,16 @@
14571447 /*
14581448 * Seek function (should be implemented by embed player interface )
14591449 */
1460 - doSeek : function( perc ) {
 1450+ doSeek : function( percent ) {
14611451 var _this = this;
14621452 if ( this.supportsURLTimeEncoding() ) {
14631453 // Make sure this.seek_time_sec is up-to-date:
1464 - this.seek_time_sec = npt2seconds( this.start_npt ) + parseFloat( perc * this.getDuration() );
 1454+ this.seek_time_sec = npt2seconds( this.start_npt ) + parseFloat( percent * this.getDuration() );
14651455 js_log( 'updated seek_time_sec: ' + seconds2npt ( this.seek_time_sec ) );
14661456 this.stop();
14671457 this.didSeekJump = true;
14681458 // Update the slider
1469 - this.setSliderValue( perc );
 1459+ this.setSliderValue( percent );
14701460 }
14711461 // Do play request in 100ms ( give the dom time to swap out the embed player )
14721462 setTimeout( function(){
@@ -1948,8 +1938,8 @@
19491939 }
19501940 }
19511941 },
1952 - updateThumbPerc:function( perc ) {
1953 - return this.updateThumbTime( ( this.getDuration() * perc ) );
 1942+ updateThumbPerc:function( percent ) {
 1943+ return this.updateThumbTime( ( this.getDuration() * percent ) );
19541944 },
19551945 // Updates the thumbnail if the thumbnail is being displayed
19561946 updateThumbnail : function( src, quick_switch ) {
@@ -2029,14 +2019,14 @@
20302020
20312021 var embed_thumb_html;
20322022 if ( thumbnail.substring( 0, 1 ) == '/' ) {
2033 - eURL = mw.parseUri( mv_embed_path );
 2023+ eURL = mw.parseUri( mw.getMwEmbedPath() );
20342024 embed_thumb_url = eURL.protocol + '://' + eURL.host + thumbnail;
2035 - // js_log('set from mv_embed_path:'+embed_thumb_html);
 2025+ // js_log('set from mwEmbed_path:'+embed_thumb_html);
20362026 } else {
2037 - embed_thumb_url = ( thumbnail.indexOf( 'http://' ) != -1 ) ? thumbnail:mv_embed_path + thumbnail;
 2027+ embed_thumb_url = ( thumbnail.indexOf( 'http://' ) != -1 ) ? thumbnail : mw.getMwEmbedPath() + thumbnail;
20382028 }
20392029 var embed_code_html = '&lt;script type=&quot;text/javascript&quot; ' +
2040 - 'src=&quot;' + mv_embed_path + 'mv_embed.js&quot;&gt;&lt;/script&gt' +
 2030+ 'src=&quot;' + mw.getMwEmbedPath() + 'mwEmbed.js&quot;&gt;&lt;/script&gt' +
20412031 '&lt;video ';
20422032 if ( this.roe ) {
20432033 embed_code_html += 'roe=&quot;' + escape( this.roe ) + '&quot; ';
@@ -2145,7 +2135,7 @@
21462136 // check if textObj present:
21472137 if ( typeof this.textInterface == 'undefined' ) {
21482138 // load the default text interface:
2149 - mvJsLoader.doLoad( [
 2139+ mw.load( [
21502140 'mvTextInterface',
21512141 '$j.fn.hoverIntent'
21522142 ], function() {
@@ -2166,9 +2156,9 @@
21672157 }
21682158 },
21692159 /**
2170 - * Generic function to display custom HTML inside the mv_embed element.
 2160+ * Generic function to display custom HTML inside the mwEmbed element.
21712161 * The code should call the closeDisplayedHTML function to close the
2172 - * display of the custom HTML and restore the regular mv_embed display.
 2162+ * display of the custom HTML and restore the regular mwEmbed display.
21732163 * @param {String} html_code code for the selection list.
21742164 */
21752165 displayHTML:function( html_code )
@@ -2212,7 +2202,7 @@
22132203 },
22142204 /**
22152205 * Close the custom HTML displayed using displayHTML and restores the
2216 - * regular mv_embed display.
 2206+ * regular mwEmbed display.
22172207 */
22182208 closeDisplayedHTML:function() {
22192209 var sel_id = ( this.pc != null ) ? this.pc.pp.id:this.id;
@@ -2367,7 +2357,7 @@
23682358 pause: function() {
23692359 var _this = this;
23702360 var eid = ( this.pc != null ) ? this.pc.pp.id:this.id;
2371 - // js_log('mv_embed:do pause');
 2361+ // js_log('mwEmbed:do pause');
23722362 // (playing) do pause
23732363 this.paused = true;
23742364 var $pt = $j( '#' + eid);
@@ -2670,21 +2660,23 @@
26712661 library:null,
26722662 loaded:false,
26732663 loading_callbacks:null,
2674 - supportsMIMEType : function( type )
 2664+ supportsMIMEType: function( type )
26752665 {
26762666 for ( var i = 0; i < this.supported_types.length; i++ )
26772667 if ( this.supported_types[i] == type )
26782668 return true;
26792669 return false;
26802670 },
2681 - getName : function()
 2671+ getName: function()
26822672 {
26832673 return gM( 'mwe-ogg-player-' + this.id );
26842674 },
2685 - load : function( callback ) {
2686 - mvJsLoader.doLoad( [
 2675+ load: function( callback ) {
 2676+ debugger;
 2677+ mw.load( [
26872678 this.library + 'Embed'
26882679 ], function() {
 2680+ var cat = nativeEmbed;
26892681 callback();
26902682 } );
26912683 }
Index: branches/js2-work/phase3/js2/mwEmbed/libSequencer/mvPlayList.js
@@ -174,7 +174,7 @@
175175 },
176176 showShare:function() {
177177 var embed_code = '&lt;script type=&quot;text/javascript&quot; ' +
178 - 'src=&quot;' + mv_embed_path + 'mv_embed.js&quot;&gt;&lt;/script&gt ' + "\n" +
 178+ 'src=&quot;' + mw.getMwEmbedPath() + 'mwEmbed.js&quot;&gt;&lt;/script&gt ' + "\n" +
179179 '&lt;playlist id=&quot;' + this.id + '&quot; ';
180180 if ( this.src ) {
181181 embed_code += 'src=&quot;' + this.src + '&quot; /&gt;';
@@ -1130,7 +1130,7 @@
11311131
11321132 this.embed = null;
11331133 // js_log('setup embed for clip '+ this.id + ':id is a function?');
1134 - // set up the pl_mv_embed object:
 1134+ // set up the pl_mwEmbed object:
11351135 var init_pl_embed = { id:'e_' + this.id,
11361136 pc:this, // parent clip
11371137 src:this.src
@@ -1270,7 +1270,7 @@
12711271 return mv_clip_colors[num];
12721272 }
12731273 }
1274 -/* mv_embed extensions for playlists */
 1274+/* mwEmbed extensions for playlists */
12751275 var PlMvEmbed = function( vid_init ) {
12761276 // js_log('PlMvEmbed: '+ vid_init.id);
12771277 // create the div container
@@ -1733,7 +1733,7 @@
17341734 this[ 'type' ][ tObj.type ][ tObj.subtype ].u( tObj, percent, callback);
17351735 },
17361736 getTransitionIcon:function( type, subtype ) {
1737 - return mv_embed_path + '/skins/common/transition_images/' + type + '_' + subtype + '.png';
 1737+ return mw.getMwEmbedPath() + '/skins/common/transition_images/' + type + '_' + subtype + '.png';
17381738 },
17391739 /*
17401740 * mvTransLib: functional library mapping:
@@ -2040,7 +2040,7 @@
20412041 var mvSMILClip = function( sClipElm, mvClipInit ) {
20422042 return this.init( sClipElm, mvClipInit );
20432043 }
2044 -// all the overwritten and new methods for SMIL extension of mv_embed
 2044+// all the overwritten and new methods for SMIL extension of mwEmbed
20452045 mvSMILClip.prototype = {
20462046 instanceOf:'mvSMILClip',
20472047 params : { }, // support param as child of ref clips per SMIL spec
@@ -2076,7 +2076,7 @@
20772077 js_log( "SET wholeText for: " + this['tagName'] + ' ' + this['wholeText'] );
20782078 }
20792079 // debugger;
2080 - // mv_embed specific property:
 2080+ // mwEmbed specific property:
20812081 if ( $j( sClipElm ).attr( 'poster' ) )
20822082 this['img'] = $j( sClipElm ).attr( 'poster' );
20832083
Index: branches/js2-work/phase3/js2/mwEmbed/libSequencer/mvTimedEffectsEdit.js
@@ -6,7 +6,7 @@
77 */
88
99 // add our local msgs
10 -loadGM( {
 10+mw.addMessages( {
1111 "mwe-transition_in" : "Transition in",
1212 "mwe-transition_out" : "Transition out",
1313 "mwe-effects" : "Effects stack",
@@ -128,11 +128,11 @@
129129 js_log( 'type:' + _this.rObj['type'] );
130130 $j( appendTarget ).html( gM( 'mwe-loading_txt' ) );
131131 // @@todo integrate into core and loading system:
132 - loadExternalJs( mv_embed_path + 'libClipEdit/pixastic-editor/editor.js?' + getMwReqParam() );
133 - loadExternalJs( mv_embed_path + 'libClipEdit/pixastic-editor/pixastic.all.js?' + getMwReqParam() );
134 - loadExternalJs( mv_embed_path + 'libClipEdit/pixastic-editor/ui.js?' + getMwReqParam() );
135 - loadExternalJs( mv_embed_path + 'libClipEdit/pixastic-editor/uidata.js?' + getMwReqParam() );
136 - loadExternalCss( mv_embed_path + 'libClipEdit/pixastic-editor/pixastic.all.js?' + getMwReqParam() );
 132+ loadExternalJs( mw.getMwEmbedPath() + 'libClipEdit/pixastic-editor/editor.js?' + getMwReqParam() );
 133+ loadExternalJs( mw.getMwEmbedPath() + 'libClipEdit/pixastic-editor/pixastic.all.js?' + getMwReqParam() );
 134+ loadExternalJs( mw.getMwEmbedPath() + 'libClipEdit/pixastic-editor/ui.js?' + getMwReqParam() );
 135+ loadExternalJs( mw.getMwEmbedPath() + 'libClipEdit/pixastic-editor/uidata.js?' + getMwReqParam() );
 136+ loadExternalCss( mw.getMwEmbedPath() + 'libClipEdit/pixastic-editor/pixastic.all.js?' + getMwReqParam() );
137137
138138 var isPixasticReady = function() {
139139 if ( typeof PixasticEditor != 'undefined' ) {
Index: branches/js2-work/phase3/js2/mwEmbed/libSequencer/mvSequencer.js
@@ -18,7 +18,7 @@
1919 * exports back out to json or inline format
2020 */
2121
22 -loadGM( {
 22+mw.addMessages( {
2323 "mwe-menu_clipedit" : "Edit media",
2424 "mwe-menu_transition" : "Transitions and effects",
2525 "mwe-menu_cliplib" : "Add media",
@@ -155,7 +155,7 @@
156156 'html': gM( 'mwe-loading_txt' ),
157157 'js':function( this_seq ) {
158158 // Load the search interface with sequence tool targets
159 - mvJsLoader.doLoad( [
 159+ mw.load( [
160160 'remoteSearchDriver',
161161 'seqRemoteSearchDriver'
162162 ], function() {
@@ -384,16 +384,16 @@
385385 '<div id="' + this.timeline_id + '_left_cnt" class="mv_tl_left_cnt">' +
386386 '<div id="' + this.timeline_id + '_head_control" style="position:absolute;top:0px;left:0px;right:0px;height:30px;">' +
387387 '<a title="' + gM( 'mwe-play_from_position' ) + '" href="javascript:' + this.instance_name + '.play_jt()">' +
388 - '<img style="width:16px;height:16px;border:0" src="' + mv_embed_path + 'images/control_play_blue.png">' +
 388+ '<img style="width:16px;height:16px;border:0" src="' + mw.getMwEmbedPath() + 'images/control_play_blue.png">' +
389389 '</a>' +
390390 '<a title="' + gM( 'mwe-zoom_in' ) + '" href="javascript:' + this.instance_name + '.zoom_in()">' +
391 - '<img style="width:16px;height:16px;border:0" src="' + mv_embed_path + 'images/zoom_in.png">' +
 391+ '<img style="width:16px;height:16px;border:0" src="' + mw.getMwEmbedPath() + 'images/zoom_in.png">' +
392392 '</a>' +
393393 '<a title="' + gM( 'mwe-zoom_out' ) + '" href="javascript:' + this.instance_name + '.zoom_out()">' +
394 - '<img style="width:16px;height:16px;border:0" src="' + mv_embed_path + 'images/zoom_out.png">' +
 394+ '<img style="width:16px;height:16px;border:0" src="' + mw.getMwEmbedPath() + 'images/zoom_out.png">' +
395395 '</a>' +
396396 '<a title="' + gM( 'mwe-cut_clip' ) + '" href="javascript:' + this.instance_name + '.cut_mode()">' +
397 - '<img style="width:16px;height:16px;border:0" src="' + mv_embed_path + 'images/cut.png">' +
 397+ '<img style="width:16px;height:16px;border:0" src="' + mw.getMwEmbedPath() + 'images/cut.png">' +
398398 '</a>' +
399399 '</div>' +
400400 '</div>' +
@@ -430,7 +430,7 @@
431431 '<div id="track_cnt_' + i + '" style="top:' + top_pos + 'px;height:' + track_height + 'px;" class="track_name">' +
432432 '<a id="mv_exc_' + i + '" title="' + exc_msg + '" href="javascript:' + this_sq.instance_name + '.exc_track(' + i + ',\'' + exc_action + '\')">' +
433433 '<img id="' + this_sq.timeline_id + '_close_expand" style="width:16px;height:16px;border:0" ' +
434 - ' src="' + mv_embed_path + 'images/' + exc_img + '.png">' +
 434+ ' src="' + mw.getMwEmbedPath() + 'images/' + exc_img + '.png">' +
435435 '</a>' +
436436 track.title + '</div>'
437437 );
@@ -776,7 +776,7 @@
777777 var _this = this;
778778 // Add a loading image
779779 mv_get_loading_img( '#transitions_ic' );
780 - mvJsLoader.doLoad( [
 780+ mw.load( [
781781 '$j.fn.ColorPicker',
782782 'mvTimedEffectsEdit'
783783 ], function() {
@@ -800,7 +800,7 @@
801801 mv_get_loading_img( '#clipedit_ic' );
802802
803803 // Load the clipEdit library if not already loaded:
804 - mvJsLoader.doLoad( [
 804+ mw.load( [
805805 'mvClipEdit'
806806 ], function() {
807807 // Zero out the current editor:
@@ -1022,7 +1022,7 @@
10231023 this_seq = this;
10241024 if ( req == 'close' ) {
10251025 $j( '#mv_exc_' + inx ).attr( 'href', 'javascript:' + this.instance_name + '.exc_track(' + inx + ',\'open\')' );
1026 - $j( '#mv_exc_' + inx + ' > img' ).attr( 'src', mv_embed_path + 'images/closed.png' );
 1026+ $j( '#mv_exc_' + inx + ' > img' ).attr( 'src', mw.getMwEmbedPath() + 'images/closed.png' );
10271027 $j( '#track_cnt_' + inx + ',#container_track_' + inx ).animate( { height:this.track_text_height }, "slow", '',
10281028 function() {
10291029 this_seq.plObj.tracks[inx].disp_mode = 'text';
@@ -1030,7 +1030,7 @@
10311031 } );
10321032 } else if ( req == 'open' ) {
10331033 $j( '#mv_exc_' + inx ).attr( 'href', 'javascript:' + this.instance_name + '.exc_track(' + inx + ',\'close\')' );
1034 - $j( '#mv_exc_' + inx + ' > img' ).attr( 'src', mv_embed_path + 'images/opened.png' );
 1034+ $j( '#mv_exc_' + inx + ' > img' ).attr( 'src', mw.getMwEmbedPath() + 'images/opened.png' );
10351035 $j( '#track_cnt_' + inx + ',#container_track_' + inx ).animate( { height:this.track_thumb_height }, "slow", '',
10361036 function() {
10371037 this_seq.plObj.tracks[inx].disp_mode = 'timeline_thumb';
@@ -1154,9 +1154,9 @@
11551155 '" class="mv_time_clip_text mv_clip_drag">' + clip.title;
11561156 }
11571157 // add in per clip controls
1158 - track_html += '<div title="' + gM( 'mwe-clip_in' ) + ' ' + clip.embed.start_ntp + '" class="ui-resizable-w ui-resizable-handle" style="width: 16px; height: 16px; left: 0px; top: 2px;background:url(\'' + mv_embed_path + 'images/application_side_contract.png\');" ></div>' + "\n";
1159 - track_html += '<div title="' + gM( 'mwe-clip_out' ) + ' ' + clip.embed.end_ntp + '" class="ui-resizable-e ui-resizable-handle" style="width: 16px; height: 16px; right: 0px; top: 2px;background:url(\'' + mv_embed_path + 'images/application_side_expand.png\');" ></div>' + "\n";
1160 - track_html += '<div title="' + gM( 'mwe-rmclip' ) + '" onClick="' + this.instance_name + '.removeClips(new Array([' + track_id + ',' + j + ']))" style="position:absolute;cursor:pointer;width: 16px; height: 16px; left: 0px; bottom:2px;background:url(\'' + mv_embed_path + 'images/delete.png\');"></div>' + "\n";
 1158+ track_html += '<div title="' + gM( 'mwe-clip_in' ) + ' ' + clip.embed.start_ntp + '" class="ui-resizable-w ui-resizable-handle" style="width: 16px; height: 16px; left: 0px; top: 2px;background:url(\'' + mw.getMwEmbedPath() + 'images/application_side_contract.png\');" ></div>' + "\n";
 1159+ track_html += '<div title="' + gM( 'mwe-clip_out' ) + ' ' + clip.embed.end_ntp + '" class="ui-resizable-e ui-resizable-handle" style="width: 16px; height: 16px; right: 0px; top: 2px;background:url(\'' + mw.getMwEmbedPath() + 'images/application_side_expand.png\');" ></div>' + "\n";
 1160+ track_html += '<div title="' + gM( 'mwe-rmclip' ) + '" onClick="' + this.instance_name + '.removeClips(new Array([' + track_id + ',' + j + ']))" style="position:absolute;cursor:pointer;width: 16px; height: 16px; left: 0px; bottom:2px;background:url(\'' + mw.getMwEmbedPath() + 'images/delete.png\');"></div>' + "\n";
11611161 track_html += '<span style="display:none;" class="mv_clip_stats"></span>';
11621162
11631163 track_html += '</span>';
Index: branches/js2-work/phase3/js2/mwEmbed/tests/testApiProxy.html
@@ -3,14 +3,14 @@
44 <head>
55 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
66 <title>Api Proxy Test</title>
7 -<script type="text/javascript" src="../mv_embed.js"></script>
 7+<script type="text/javascript" src="../mwEmbed.js"></script>
88
99 <script type="text/javascript" >
1010 //HARD coded local test:
1111 var remote_wiki_host = 'http://test.wikipedia.org';
1212 var remote_script_path = '/w';
1313
14 -js2AddOnloadHook( function(){
 14+mw.addOnloadHook( function(){
1515 $j('#hostName').text( remote_wiki_host );
1616 //run the api-proxy setup:
1717 $j.apiProxy(
Index: branches/js2-work/phase3/js2/mwEmbed/tests/testLang.html
@@ -1,7 +1,7 @@
22 <html>
33 <head>
44 <title>Test Plural Conversions (should match php) </title>
5 -<script type="text/javascript" src="../mv_embed.js"></script>
 5+<script type="text/javascript" src="../mwEmbed.js"></script>
66 <style>
77 td{
88 border:solid thin black;
@@ -174,7 +174,7 @@
175175 'cy'
176176 ];
177177
178 -js2AddOnloadHook( function(){
 178+mw.addOnloadHook( function(){
179179 //do mauall script loaders calls to test multiple languages:
180180 function doLangTable( langSet ){
181181 //build table output:
Index: branches/js2-work/phase3/js2/mwEmbed/tests/testLang.js
@@ -1,7 +1,7 @@
22 /* a simple language tester replacements
33 */
44
5 -loadGM( {
 5+mw.addMessages( {
66 "undelete_short" : "Undelete {{PLURAL:$1|one edit|$1 edits}}",
77 "category-subcat-count" : "{{PLURAL:$2|This category has only the following subcategory.|This category has the following {{PLURAL:$1|subcategory|$1 subcategories}}, out of $2 total.}}",
88 "mwe-upload-multi" : "Upload {{PLURAL:$1|file|files}}"
Index: branches/js2-work/phase3/js2/mwEmbed/libClipEdit/mvClipEdit.js
@@ -1,8 +1,8 @@
2 -k/*
 2+/*
33 mvClipEdit hanndles the edit interfaces for images and video
44 */
55 // set gMsg object:
6 -loadGM( {
 6+mw.addMessages( {
77 "mwe-crop" : "Crop image",
88 "mwe-apply_crop" : "Apply crop to image",
99 "mwe-reset_crop" : "Reset crop",
@@ -862,7 +862,7 @@
863863 $j( '.mv_crop_msg' ).hide();
864864 $j( '.mv_crop_msg_load' ).show();
865865 // load the jcrop library if needed:
866 - mvJsLoader.doLoad( [
 866+ mw.load( [
867867 '$j.Jcrop'
868868 ], function() {
869869 _this.bindCrop();
Index: branches/js2-work/phase3/js2/mwEmbed/libMwApi/mw.proxy.js
@@ -34,7 +34,7 @@
3535 *
3636 */
3737
38 -loadGM( {
 38+mw.addMessages( {
3939 "mwe-setting-up-proxy" : "Setting up proxy...",
4040 "mwe-re-try" : "Retry API request",
4141 "mwe-re-trying" : "Retrying API request...",
Index: branches/js2-work/phase3/js2/apiProxyPage.js
@@ -8,7 +8,7 @@
99 * Since this is proxy server set a pre-append debug flag to know which debug msgs are coming from where
1010 */
1111
12 -mw.conf['debug_pre'] = 'Proxy';
 12+mw.getConfig( 'pre-append-log' ) = 'Proxy';
1313
1414 if ( !mwApiProxyConfig )
1515 var mwApiProxyConfig = { };
@@ -21,7 +21,7 @@
2222 };
2323
2424 // User white_list should also be checked and configured at runtime.
25 -js2AddOnloadHook( function() {
 25+mw.addOnloadHook( function() {
2626 // build our configuration from the default and mwApiProxyConfig vars
2727 mwApiProxyConfig = $j.extend( true, mwApiProxyDefaultConfig, mwApiProxyConfig );
2828 $j.apiProxy( 'server', mwApiProxyConfig );
Index: branches/js2-work/phase3/js2/ajaxcategories.js
@@ -1,4 +1,4 @@
2 -loadGM( {
 2+mw.addMessages( {
33 "ajax-add-category" : "[Add Category]",
44 "ajax-add-category-submit" : "[Add]",
55 "ajax-confirm-prompt" : "[Confirmation Text]",
@@ -17,7 +17,7 @@
1818 e.preventDefault();
1919
2020 // Make sure the suggestion plugin is loaded. Load everything else while we're at it
21 - mvJsLoader.doLoad(
 21+ mw.load(
2222 ['$j.ui', '$j.ui.dialog', '$j.fn.suggestions'],
2323 function() {
2424 $j( '#mw-addcategory-prompt' ).toggle();
@@ -80,7 +80,7 @@
8181
8282 confirmEdit : function( page, fn, actionSummary, doneFn ) {
8383 // Load jQuery UI
84 - mvJsLoader.doLoad(
 84+ mw.load(
8585 ['$j.ui', '$j.ui.dialog', '$j.fn.suggestions'],
8686 function() {
8787 // Produce a confirmation dialog
@@ -323,4 +323,4 @@
324324 }
325325 };
326326
327 -js2AddOnloadHook( ajaxCategories.setupAJAXCategories );
 327+mw.addOnloadHook( ajaxCategories.setupAJAXCategories );
Index: branches/js2-work/phase3/js2/js2stopgap.js
@@ -9455,7 +9455,7 @@
94569456
94579457 /**
94589458 * This is designed to be directly compatible with (and is essentially taken
9459 - * directly from) the mv_embed code for bringing internationalized messages into
 9459+ * directly from) the mwEmbed code for bringing internationalized messages into
94609460 * the JavaScript space. As such, if we get to the point of merging that stuff
94619461 * into the main branch this code will be uneeded and probably cause issues.
94629462 */
@@ -9465,7 +9465,7 @@
94669466 * Caches a list of messages for later retrieval
94679467 * @param {Object} msgSet Hash of key:value pairs of messages to cache
94689468 */
9469 -function loadGM( msgSet ){
 9469+function mw.addMessages( msgSet ){
94709470 for ( var i in msgSet ){
94719471 gMsg[ i ] = msgSet[i];
94729472 }
@@ -9497,13 +9497,17 @@
94989498 * Mimics the no-conflict method used by the js2 stuff
94999499 */
95009500 $j = jQuery.noConflict();
 9501+
 9502+if( !mw )
 9503+ mw = { };
 9504+
95019505 /**
95029506 * Provides js2 compatible onload hook
95039507 * @param func Function to call when ready
95049508 */
9505 -function js2AddOnloadHook( func ) {
 9509+mw.addOnloadHook = function( func ) {
95069510 $j(document).ready( func );
95079511 }
95089512
9509 -// Define a dummy mvJsLoader.doLoad() function
 9513+// Define a dummy mw.load() function
95109514 mvJsLoader = { doLoad: function( deps, callback ) { callback(); } };
Index: branches/js2-work/phase3/js2/remoteMwEmbed.js
@@ -18,8 +18,8 @@
1919 }
2020
2121 addOnloadHook( function() {
22 - // Only do rewrites if MV_EMBED / js2 is "off"
23 - if ( typeof MV_EMBED_VERSION == 'undefined' ) {
 22+ // Only do rewrites if mwEmbed / js2 is "off"
 23+ if ( typeof mwEmbed_VERSION == 'undefined' ) {
2424 doPageSpecificRewrite();
2525 }
2626 } );
@@ -28,14 +28,14 @@
2929 // Add media wizard
3030 if ( wgAction == 'edit' || wgAction == 'submit' ) {
3131 var jsSetEdit = [ 'remoteSearchDriver', '$j.fn.textSelection', '$j.ui', '$j.ui.sortable' ]
32 - mwr_load_mv_embed( jsSetEdit, function() {
 32+ mwr_load_mwEmbed( jsSetEdit, function() {
3333 loadExternalJs( mwEmbedHostPath + '/editPage.js?' + mwGetReqArgs() );
3434 } );
3535 }
3636
3737 // Timed text display:
3838 if ( wgPageName.indexOf( "TimedText" ) === 0 ) {
39 - mwr_load_mv_embed( function() {
 39+ mwr_load_mwEmbed( function() {
4040 // Load with mw loader to get localized interface:
4141 mw.load( ['mvTimeTextEdit'], function() {
4242 // Could run init here (but mvTimeTextEdit already included onLoad actions)
@@ -47,7 +47,7 @@
4848 if ( wgPageName == "Special:Upload" ) {
4949 var jsSetUpload = [ 'mvBaseUploadInterface', 'mvFirefogg' , '$j.ui',
5050 '$j.ui.progressbar', '$j.ui.dialog', '$j.ui.draggable' ];
51 - mwr_load_mv_embed( jsSetUpload, function() {
 51+ mwr_load_mwEmbed( jsSetUpload, function() {
5252 loadExternalJs( mwEmbedHostPath + '/uploadPage.js?' + mwGetReqArgs() );
5353 } );
5454 }
@@ -55,7 +55,7 @@
5656 // Special api proxy page
5757 if ( wgPageName == 'MediaWiki:ApiProxy' ) {
5858 var wgEnableIframeApiProxy = true;
59 - mwr_load_mv_embed( [ 'mw.proxy' ], function() {
 59+ mwr_load_mwEmbed( [ 'mw.proxy' ], function() {
6060 loadExternalJs( mwEmbedHostPath + '/apiProxyPage.js?' + mwGetReqArgs() );
6161 } );
6262 }
@@ -78,7 +78,7 @@
7979 if ( navigator.userAgent && navigator.userAgent.indexOf("Firefox") != -1 )
8080 jsSetVideo.push( 'nativeEmbed' );
8181
82 - mwr_load_mv_embed( jsSetVideo, function() {
 82+ mwr_load_mwEmbed( jsSetVideo, function() {
8383 mvJsLoader.embedPlayerCheck( function() {
8484 // Do utility rewrite of OggHandler content:
8585 rewrite_for_OggHandler( vidIdList );
@@ -199,16 +199,16 @@
200200 /**
201201 * @param {mixed} function or classSet to preload
202202 * classSet saves round trips to the server by grabbing things we will likely need in the first request.
203 -* ( this is essentially a shortcut to mv_jqueryBindings in mv_embed.js )
204 -* @param {callback} function callback to be called once mv_embed is ready
 203+* ( this is essentially a shortcut to mv_jqueryBindings in mwEmbed.js )
 204+* @param {callback} function callback to be called once mwEmbed is ready
205205 */
206 -function mwr_load_mv_embed( classSet, callback ) {
 206+function mwr_load_mwEmbed( classSet, callback ) {
207207 if( typeof classSet == 'function')
208208 callback = classSet;
209 - // Inject mv_embed if needed
 209+ // Inject mwEmbed if needed
210210 if ( typeof mw == 'undefined' ) {
211211 if ( ( mwReqParam['uselang'] || mwReqParam['useloader'] ) && mwUseScriptLoader ) {
212 - var rurl = mwEmbedHostPath + '/mwEmbed/jsScriptLoader.php?class=mv_embed';
 212+ var rurl = mwEmbedHostPath + '/mwEmbed/jsScriptLoader.php?class=mwEmbed';
213213
214214 // Add jQuery too if we need it:
215215 if ( typeof window.jQuery == 'undefined' ) {
@@ -229,16 +229,16 @@
230230 importScriptURI( rurl );
231231 } else {
232232 // Ingore classSet (will be loaded onDemand )
233 - importScriptURI( mwEmbedHostPath + '/mwEmbed/mv_embed.js?' + mwGetReqArgs() );
 233+ importScriptURI( mwEmbedHostPath + '/mwEmbed/mwEmbed.js?' + mwGetReqArgs() );
234234 }
235235 }
236 - mwr_check_for_mv_embed( callback );
 236+ mwr_check_for_mwEmbed( callback );
237237 }
238238
239 -function mwr_check_for_mv_embed( callback ) {
 239+function mwr_check_for_mwEmbed( callback ) {
240240 if ( typeof mw == 'undefined' ) {
241241 setTimeout( function() {
242 - mwr_check_for_mv_embed( callback );
 242+ mwr_check_for_mwEmbed( callback );
243243 }, 25 );
244244 } else {
245245 callback();
Index: branches/js2-work/phase3/js2/js2stopgap.min.js
@@ -778,5 +778,5 @@
779779 return $.datepicker['_'+options+'Datepicker'].apply($.datepicker,[this[0]].concat(otherArgs));return this.each(function(){typeof options=='string'?$.datepicker['_'+options+'Datepicker'].apply($.datepicker,[this].concat(otherArgs)):$.datepicker._attachDatepicker(this,options);});};$.datepicker=new Datepicker();$.datepicker.initialized=false;$.datepicker.uuid=new Date().getTime();$.datepicker.version="1.7.2";window.DP_jQuery=$;})(jQuery);if(!gMsg)var gMsg={};function loadGM(msgSet){for(var i in msgSet){gMsg[i]=msgSet[i];}}
780780 function gM(key,args){var ms='';if(key in gMsg){ms=gMsg[key];if(typeof args=='object'||typeof args=='array'){for(var v in args){var rep='\$'+(parseInt(v)+1);ms=ms.replace(rep,args[v]);}}else if(typeof args=='string'||typeof args=='number'){ms=ms.replace(/\$1/,args);}
781781 return ms;}else{return'['+key+']';}}
782 -$j=jQuery.noConflict();function js2AddOnloadHook(func){$j(document).ready(func);}
 782+$j=jQuery.noConflict();function mw.addOnloadHook(func){$j(document).ready(func);}
783783 mvJsLoader={doLoad:function(deps,callback){callback();}};
\ No newline at end of file

Comments

#Comment by Locos epraix (talk | contribs)   14:55, 7 December 2009

for: branches/js2-work/phase3/js2/mwEmbed/example_usage/Add_Media_Wizard.html

-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" +<!DOCTYPE HT ML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

#Comment by Locos epraix (talk | contribs)   14:55, 7 December 2009

I mean

-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

+<!DOCTYPE HT ML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

Status & tagging log