From dae333c42a535f4d81651aea55f3c9cd0126da93 Mon Sep 17 00:00:00 2001 From: Michael Dale Date: Fri, 13 Nov 2009 15:34:01 +0000 Subject: [PATCH] * added in language mapping for commons upload form language hack * fixed issue of mwUploadHelper not being ready by moving init call past define of mwUploadHelper * moved parseUri to mw.parseUri * fixed jCrop css loading * other minor fixes realted to style.php and regEx --- js2/mwEmbed/libAddMedia/remoteSearchDriver.js | 8 +- .../searchLibs/baseRemoteSearch.js | 4 +- .../libAddMedia/searchLibs/metavidSearch.js | 2 +- js2/mwEmbed/libClipEdit/mvClipEdit.js | 2 +- js2/mwEmbed/libEmbedVideo/embedVideo.js | 31 ++--- js2/mwEmbed/libEmbedVideo/javaEmbed.js | 6 +- js2/mwEmbed/libEmbedVideo/vlcEmbed.js | 1 + js2/mwEmbed/libMwApi/mw.proxy.js | 10 +- js2/mwEmbed/libSequencer/mvPlayList.js | 2 +- js2/mwEmbed/libSequencer/mvSequencer.js | 2 +- js2/mwEmbed/libTimedText/mvTextInterface.js | 2 +- js2/mwEmbed/libTimedText/mvTimeTextEdit.js | 2 +- js2/mwEmbed/mv_embed.js | 119 +++++++++--------- js2/mwEmbed/php/noMediaWikiConfig.php | 5 +- js2/remoteMwEmbed.js | 4 +- js2/uploadPage.js | 11 +- 16 files changed, 109 insertions(+), 102 deletions(-) diff --git a/js2/mwEmbed/libAddMedia/remoteSearchDriver.js b/js2/mwEmbed/libAddMedia/remoteSearchDriver.js index e9f5355310..4b229a6a3a 100644 --- a/js2/mwEmbed/libAddMedia/remoteSearchDriver.js +++ b/js2/mwEmbed/libAddMedia/remoteSearchDriver.js @@ -418,7 +418,7 @@ remoteSearchDriver.prototype = { } else { var keyCheck = jL; } - if ( parseUri( license_url ).path.indexOf( '/' + keyCheck + '/' ) != - 1 ) { + if ( mw.parseUri( license_url ).path.indexOf( '/' + keyCheck + '/' ) != - 1 ) { return this.getLicenceFromKey( jL , license_url ); } }; @@ -943,9 +943,9 @@ remoteSearchDriver.prototype = { }, // @@todo we could load the id with the content provider id to find the object faster... getResourceFromId:function( rid ) { - js_log('getResourceFromId:' + rid ); + //js_log('getResourceFromId:' + rid ); // strip out /res/ if preset: - rid = rid.replace( /res_/ , '' ); + rid = rid.replace( /res_/, '' ); // js_log("looking at: " + rid); p = rid.split( '__' ); var cp_id = p[0]; @@ -1307,7 +1307,7 @@ remoteSearchDriver.prototype = { return true; } else { // Check if we can embed the content locally per a domain name check: - var local_host = parseUri( this.local_wiki_api_url ).host; + var local_host = mw.parseUri( this.local_wiki_api_url ).host; if ( cp.local_domains ) { for ( var i = 0; i < cp.local_domains.length; i++ ) { var ld = cp.local_domains[i]; diff --git a/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js b/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js index 7b43a6e643..92bc29f57d 100644 --- a/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js +++ b/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js @@ -67,7 +67,7 @@ baseRemoteSearch.prototype = { var http_host = ''; var http_path = ''; if ( provider_url ) { - pUrl = parseUri( provider_url ); + pUrl = mw.parseUri( provider_url ); http_host = pUrl.protocol + '://' + pUrl.authority; http_path = pUrl.directory; } @@ -132,7 +132,7 @@ baseRemoteSearch.prototype = { if ( rObj[p].substr( 0, 1 ) == '/' ) { rObj[p] = http_host + rObj[p]; } - if ( parseUri( rObj[i] ).host == rObj[p] ) { + if ( mw.parseUri( rObj[i] ).host == rObj[p] ) { rObj[p] = http_host + http_path + rObj[p]; } } diff --git a/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js b/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js index 0b7a5f3c96..c32009939c 100644 --- a/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js +++ b/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js @@ -49,7 +49,7 @@ metavidSearch.prototype = { // do some metavid specific pos processing on the rObj data: for ( var i in _this.resultsObj ) { var rObj = _this.resultsObj[i]; - var proe = parseUri( rObj['roe_url'] ); + var proe = mw.parseUri( rObj['roe_url'] ); rObj['start_time'] = proe.queryKey['t'].split( '/' )[0]; rObj['end_time'] = proe.queryKey['t'].split( '/' )[1]; rObj['stream_name'] = proe.queryKey['stream_name']; diff --git a/js2/mwEmbed/libClipEdit/mvClipEdit.js b/js2/mwEmbed/libClipEdit/mvClipEdit.js index 7ff9aff36f..e81ae65139 100644 --- a/js2/mwEmbed/libClipEdit/mvClipEdit.js +++ b/js2/mwEmbed/libClipEdit/mvClipEdit.js @@ -246,7 +246,7 @@ mvClipEdit.prototype = { } else { // var res_page = var res_src = _this.rObj.src; - var res_title = parseUri( _this.rObj.src ).file; + var res_title = mw.parseUri( _this.rObj.src ).file; } o += '' + '' + gM( 'mwe-other_properties' ) + '' + diff --git a/js2/mwEmbed/libEmbedVideo/embedVideo.js b/js2/mwEmbed/libEmbedVideo/embedVideo.js index c6f7fa57e2..f0c0b8d716 100644 --- a/js2/mwEmbed/libEmbedVideo/embedVideo.js +++ b/js2/mwEmbed/libEmbedVideo/embedVideo.js @@ -325,7 +325,7 @@ mediaSource.prototype = { // Set default URLTimeEncoding if we have a time url: // not ideal way to discover if content is on an oggz_chop server. // should check some other way. - var pUrl = parseUri ( this.src ); + var pUrl = mw.parseUri ( this.src ); if ( typeof pUrl['queryKey']['t'] != 'undefined' ) { this['URLTimeEncoding'] = true; } @@ -443,7 +443,7 @@ mediaSource.prototype = { parseURLDuration : function() { // check if we have a URLTimeEncoding: if ( this.URLTimeEncoding ) { - var annoURL = parseUri( this.src ); + var annoURL = mw.parseUri( this.src ); if ( annoURL.queryKey['t'] ) { var times = annoURL.queryKey['t'].split( '/' ); this.start_ntp = times[0]; @@ -1146,16 +1146,16 @@ embedVideo.prototype = { }, relatedTitleKeySearch:function() { var _this = this; - js_log( 'Switch video Relational' ); var reqObj = { 'action' : 'query', - 'titles' : this.wikiTitleKey, + //normalize the File NS (ie sometimes its present in wikiTitleKey other times not + 'titles' : 'File:' + this.wikiTitleKey.replace(/File:|Image:/,''), 'generator' : 'categories' }; var req_categories = new Array(); do_api_req( { - 'data' : reqObj, - 'url' : commons_api_url + 'url' : mw.commons_api_url, + 'data' : reqObj }, function( data ) { req_categories = Array(); if ( data.query && data.query.pages ) { @@ -1320,7 +1320,7 @@ embedVideo.prototype = { js_log( 'we have annotative track:' + anno_track_url ); // Zero out seconds (should improve cache hit rate and generally expands metadata search) // @@todo this could be replaced with a regExp - var annoURL = parseUri( anno_track_url ); + var annoURL = mw.parseUri( anno_track_url ); var times = annoURL.queryKey['t'].split( '/' ); var stime_parts = times[0].split( ':' ); var etime_parts = times[1].split( ':' ); @@ -1670,7 +1670,7 @@ embedVideo.prototype = { var embed_thumb_html; if ( thumbnail.substring( 0, 1 ) == '/' ) { - eURL = parseUri( mv_embed_path ); + eURL = mw.parseUri( mv_embed_path ); embed_thumb_url = eURL.protocol + '://' + eURL.host + thumbnail; // js_log('set from mv_embed_path:'+embed_thumb_html); } else { @@ -1761,22 +1761,25 @@ embedVideo.prototype = { }, showTextInterface:function() { var _this = this; + if( $j( '#metaBox_' + this.id ).is( ':visible' ) ) { + $j( '#metaBox_' + this.id ).fadeOut("fast"); + }else{ + $j( '#metaBox_' + this.id ).fadeIn( "fast" ); + } // display the text container with loading text: // @@todo support position config var loc = $j( this ).position(); - if ( $j( '#metaBox_' + this.id ).length == 0 ) { - var theight = ( parseInt( this.height ) < 200 ) ? 200 : parseInt( this.height ); + if ( $j( '#metaBox_' + this.id ).length == 0 ) { + var theight = ( ( parseInt( this.height ) + this.ctrlBuilder.height ) < 200 ) ? 200 : ( parseInt( this.height ) + this.ctrlBuilder.height ); $j( this ).after( '
' + mv_get_loading_img() + '
' ); - } - // fade in the text display - $j( '#metaBox_' + this.id ).fadeIn( "fast" ); + } // check if textObj present: if ( typeof this.textInterface == 'undefined' ) { // load the default text interface: diff --git a/js2/mwEmbed/libEmbedVideo/javaEmbed.js b/js2/mwEmbed/libEmbedVideo/javaEmbed.js index bd96038af4..9e1fb424e4 100644 --- a/js2/mwEmbed/libEmbedVideo/javaEmbed.js +++ b/js2/mwEmbed/libEmbedVideo/javaEmbed.js @@ -32,9 +32,9 @@ var javaEmbed = { // @@todo we should have src property in our base embed object var mediaSrc = this.getSrc(); - if ( mediaSrc.indexOf( '://' ) != - 1 & parseUri( document.URL ).host != parseUri( mediaSrc ).host ) { - if ( window.cortadoDomainLocations[parseUri( mediaSrc ).host] ) { - applet_loc = window.cortadoDomainLocations[parseUri( mediaSrc ).host]; + if ( mediaSrc.indexOf( '://' ) != - 1 & mw.parseUri( document.URL ).host != mw.parseUri( mediaSrc ).host ) { + if ( window.cortadoDomainLocations[mw.parseUri( mediaSrc ).host] ) { + applet_loc = window.cortadoDomainLocations[mw.parseUri( mediaSrc ).host]; } else { applet_loc = 'http://theora.org/cortado.jar'; } diff --git a/js2/mwEmbed/libEmbedVideo/vlcEmbed.js b/js2/mwEmbed/libEmbedVideo/vlcEmbed.js index 8ebda9dd36..71c4b26095 100644 --- a/js2/mwEmbed/libEmbedVideo/vlcEmbed.js +++ b/js2/mwEmbed/libEmbedVideo/vlcEmbed.js @@ -88,6 +88,7 @@ var vlcEmbed = { }, // disable local seeking (while we don't know what we have avaliable) doSeek : function( perc ) { + this.getVLC(); if ( this.supportsURLTimeEncoding() ) { this.parent_doSeek( perc ); } else if ( this.vlc ) { diff --git a/js2/mwEmbed/libMwApi/mw.proxy.js b/js2/mwEmbed/libMwApi/mw.proxy.js index 81b80b78f2..e513b5b257 100644 --- a/js2/mwEmbed/libMwApi/mw.proxy.js +++ b/js2/mwEmbed/libMwApi/mw.proxy.js @@ -67,7 +67,7 @@ loadGM( { $.proxy.client_frame_path = wgScriptPath + '/js2/mwEmbed/libMwApi/NestedCallbackIframe.html'; } - if ( parseUri( $.proxy.server_frame ).host == parseUri( document.URL ).host ) { + if ( mw.parseUri( $.proxy.server_frame ).host == mw.parseUri( document.URL ).host ) { js_log( "Error: why are you trying to proxy yourself? " ); return false; } @@ -78,7 +78,7 @@ loadGM( { /* setup a iframe request hash */ $.proxy.doFrameProxy = function( reqObj ) { var hashPack = { - 'cd': parseUri( document.URL ).host, + 'cd': mw.parseUri( document.URL ).host, 'cfp': $.proxy.client_frame_path, 'req': reqObj } @@ -114,7 +114,7 @@ loadGM( { btn[ gM( 'mwe-cancel' ) ] = function() { $j.closeLoaderDialog(); } - var pUri = parseUri( $.proxy.server_frame ); + var pUri = mw.parseUri( $.proxy.server_frame ); // this is sort of a temporary hack if we change the MediaWiki:ApiProxy key // we will have to deal with that here as well: var login_url = pUri.protocol + '://' + pUri.host + @@ -165,7 +165,7 @@ loadGM( { $j( 'body' ).html( 'proxy setup' ); // read the anchor action from the requesting url - var jmsg = unescape( parseUri( document.URL ).anchor ); + var jmsg = unescape( mw.parseUri( document.URL ).anchor ); try { var aObj = JSON.parse( jmsg ); } catch ( e ) { @@ -176,7 +176,7 @@ loadGM( { return false; } - js_log( "Setup server on: " + parseUri( document.URL ).host + + js_log( "Setup server on: " + mw.parseUri( document.URL ).host + ' client from: ' + aObj.cd + ' to nested target: ' + aObj.cfp ); diff --git a/js2/mwEmbed/libSequencer/mvPlayList.js b/js2/mwEmbed/libSequencer/mvPlayList.js index 80a15e8e28..12f0ffdb2b 100644 --- a/js2/mwEmbed/libSequencer/mvPlayList.js +++ b/js2/mwEmbed/libSequencer/mvPlayList.js @@ -368,7 +368,7 @@ mvPlayList.prototype = { makeURLAbsolute:function() { if ( this.src ) { if ( this.src.indexOf( '://' ) == - 1 ) { - var purl = parseUri( document.URL ); + var purl = mw.parseUri( document.URL ); if ( this.src.charAt( 0 ) == '/' ) { this.src = purl.protocol + '://' + purl.host + this.src; } else { diff --git a/js2/mwEmbed/libSequencer/mvSequencer.js b/js2/mwEmbed/libSequencer/mvSequencer.js index 6180ad1580..fe26eb5f33 100644 --- a/js2/mwEmbed/libSequencer/mvSequencer.js +++ b/js2/mwEmbed/libSequencer/mvSequencer.js @@ -803,7 +803,7 @@ mvSequencer.prototype = { this_seq.clipboard.push( cur_clip.getAttributeObj() ); } ); // upload clipboard to the server (if possible) - if ( parseUri( document.URL ).host != parseUri( this_seq.plObj.interface_url ).host ) { + if ( mw.parseUri( document.URL ).host != mw.parseUri( this_seq.plObj.interface_url ).host ) { js_log( 'error: presently we can\'t copy clips across domains' ); } else { // @@we need a api entry point to store a "clipboard" diff --git a/js2/mwEmbed/libTimedText/mvTextInterface.js b/js2/mwEmbed/libTimedText/mvTextInterface.js index 0e63f20b64..695fe4bbed 100644 --- a/js2/mwEmbed/libTimedText/mvTextInterface.js +++ b/js2/mwEmbed/libTimedText/mvTextInterface.js @@ -571,7 +571,7 @@ timedTextCMML = { js_log( 'textCMML: loading track: ' + this.src ); // :: Load transcript range :: - var pcurl = parseUri( _this.getSRC() ); + var pcurl = mw.parseUri( _this.getSRC() ); // check for urls without time keys: if ( typeof pcurl.queryKey['t'] == 'undefined' ) { // in which case just get the full time req: diff --git a/js2/mwEmbed/libTimedText/mvTimeTextEdit.js b/js2/mwEmbed/libTimedText/mvTimeTextEdit.js index 787e2f4426..b85af71fdd 100644 --- a/js2/mwEmbed/libTimedText/mvTimeTextEdit.js +++ b/js2/mwEmbed/libTimedText/mvTimeTextEdit.js @@ -6,7 +6,7 @@ if ( !mwAddMediaConfig ) var mwAddMediaConfig = { }; -var mvTimedTextEdit = { }; +var mvTimeTextEdit = { }; loadGM( { "mwe-upload-subs-file" : "Upload subtitle", diff --git a/js2/mwEmbed/mv_embed.js b/js2/mwEmbed/mv_embed.js index 0b13d7a04f..9bc69c3fa6 100644 --- a/js2/mwEmbed/mv_embed.js +++ b/js2/mwEmbed/mv_embed.js @@ -7,7 +7,7 @@ * * @url http://metavid.org * - * parseUri: + * mw.parseUri: * http://stevenlevithan.com/demo/parseuri/js/ * * Config values: you can manually set the location of the mv_embed folder here @@ -47,7 +47,7 @@ if ( typeof mvCssPaths == 'undefined' ) function lcCssPath( cssSet ) { for ( var i in cssSet ) { - mvCssPaths[i] = mv_embed_path + cssSet[i]; + mvCssPaths[i] = cssSet[i]; } } @@ -155,39 +155,7 @@ lcPaths( { lcCssPath( { '$j.Jcrop' : 'libClipEdit/Jcrop/css/jquery.Jcrop.css', '$j.fn.ColorPicker' : 'libClipEdit/colorpicker/css/colorpicker.css' -} ) - - -// parseUri 1.2.2 -// (c) Steven Levithan -// MIT License -function parseUri (str) { - var o = parseUri.options, - m = o.parser[o.strictMode ? "strict" : "loose"].exec(str), - uri = {}, - i = 14; - - while (i--) uri[o.key[i]] = m[i] || ""; - - uri[o.q.name] = {}; - uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) { - if ($1) uri[o.q.name][$1] = $2; - }); - - return uri; -}; -parseUri.options = { - strictMode: false, - key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"], - q: { - name: "queryKey", - parser: /(?:^|&)([^&=]*)=?([^&]*)/g - }, - parser: { - strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, - loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ - } -}; +}) // For use when mv_embed with script-loader is in the root MediaWiki path var mediaWiki_mvEmbed_path = 'js2/mwEmbed/'; @@ -207,10 +175,6 @@ if ( !window['mw'] ) { // @@todo move these into mw var global_req_cb = new Array(); // The global request callback array -// Get the mv_embed location if it has not been set -if ( !mv_embed_path ) { - var mv_embed_path = getMvEmbedPath(); -} /** * The global mw object: * @@ -298,13 +262,11 @@ if ( !mv_embed_path ) { return '<' + key + '>';// Missing key placeholder // swap in the arg values - var ms = $.lang.gMsgSwap( key, args ) ; - - + var ms = $.lang.gMsgSwap( key, args ); // a quick check to see if we need to send the msg via the 'parser' // (we can add more detailed check once we support more wiki syntax) - if ( ms.indexOf( '{{' ) === - 1 && ms.indexOf( '[' ) === - 1 ) { + if ( ms.indexOf( '{{' ) === -1 && ms.indexOf( '[' ) === -1 ) { return ms; } @@ -326,9 +288,9 @@ if ( !mv_embed_path ) { $.lang.gMsgSwap = function( key , args ) { if ( ! gMsg[ key ] ) return '<' + key + '>';// Missing key placeholder - // get the messeage string: + // get the message string: var ms = gMsg[ key ]; - + // replace values if ( typeof args == 'object' || typeof args == 'array' ) { for ( var v in args ) { @@ -820,9 +782,48 @@ if ( !mv_embed_path ) { } return false; } - + + /** + * Utility Functions + * + * parseUri 1.2.2 + * (c) Steven Levithan + * MIT License + */ + $.parseUri = function (str) { + var o = $.parseUri.options, + m = o.parser[o.strictMode ? "strict" : "loose"].exec(str), + uri = {}, + i = 14; + + while (i--) uri[o.key[i]] = m[i] || ""; + + uri[o.q.name] = {}; + uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) { + if ($1) uri[o.q.name][$1] = $2; + }); + + return uri; + }; + $.parseUri.options = { + strictMode: false, + key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"], + q: { + name: "queryKey", + parser: /(?:^|&)([^&=]*)=?([^&]*)/g + }, + parser: { + strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, + loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ + } + }; } )( window.mw ); +// Get the mv_embed location if it has not been set +if ( !mv_embed_path ) { + var mv_embed_path = getMvEmbedPath(); +} + // load in js2 stopgap into proper location: if ( typeof gMsg != 'undefined' ) { mw.lang.loadGM( gMsg ) @@ -906,7 +907,7 @@ var mvJsLoader = { // Do a check for any CSS we may need and get it for ( var i = 0; i < loadLibs.length; i++ ) { if ( typeof mvCssPaths[ loadLibs[i] ] != 'undefined' ) { - loadExternalCss( mvCssPaths[ loadLibs[i] ] ); + loadExternalCss( mv_embed_path + mvCssPaths[ loadLibs[i] ] ); } } @@ -925,9 +926,9 @@ var mvJsLoader = { } } // Build the url to the scriptServer striping its request parameters: - var puri = parseUri( getMvEmbedURL() ); + var puri = mw.parseUri( getMvEmbedURL() ); if ( ( getMvEmbedURL().indexOf( '://' ) != - 1 ) - && puri.host != parseUri( document.URL ).host ) + && puri.host != mw.parseUri( document.URL ).host ) { var scriptPath = puri.protocol + '://' + puri.authority + puri.path; } else { @@ -1226,10 +1227,10 @@ function js2AddOnloadHook( func ) { // js_log('js2AddOnloadHook:: jquery:' +func); // If we are ready run directly else add load event: if ( mvJsLoader.doneReadyEvents ) { - js_log( 'run queued event: ' + func ); + //js_log( 'run queued event: ' + func ); func(); } else { - js_log( 'add to load event: ' + func ); + //js_log( 'add to load event: ' + func ); mvJsLoader.addLoadEvent( func ); } } @@ -1646,7 +1647,7 @@ function mv_jqueryBindings() { */ // Simple URL rewriter (could probably be refactored into an inline regular exp) function getURLParamReplace( url, opt ) { - var pSrc = parseUri( url ); + var pSrc = mw.parseUri( url ); if ( pSrc.protocol != '' ) { var new_url = pSrc.protocol + '://' + pSrc.authority + pSrc.path + '?'; } else { @@ -1789,7 +1790,7 @@ function do_api_req( options, callback ) { // assume the proxy is already "setup" since mw.proxy is defined. // @@todo we probably integrate that setup into the api call mw.proxy.doRequest( options.data, callback ); - } else if ( parseUri( document.URL ).host == parseUri( options.url ).host ) { + } else if ( mw.parseUri( document.URL ).host == mw.parseUri( options.url ).host ) { // Local request: do API request directly $j.ajax( { type: "POST", @@ -1825,9 +1826,9 @@ function do_api_req( options, callback ) { } // Do a "normal" request function do_request( req_url, callback ) { - js_log( 'do_request::req_url:' + req_url + ' != ' + parseUri( req_url ).host ); + js_log( 'do_request::req_url:' + req_url + ' != ' + mw.parseUri( req_url ).host ); // If we are doing a request to the same domain or relative link, do a normal GET - if ( parseUri( document.URL ).host == parseUri( req_url ).host || + if ( mw.parseUri( document.URL ).host == mw.parseUri( req_url ).host || req_url.indexOf( '://' ) == - 1 ) // Relative url { // Do a direct request @@ -1974,9 +1975,9 @@ function getMwReqParam() { var req_param = ''; // If we have a URI, add it to the req - var urid = parseUri( mv_embed_url ).queryKey['urid'] + var urid = mw.parseUri( mv_embed_url ).queryKey['urid'] // If we're in debug mode, get a fresh unique request key and pass on "debug" param - if ( parseUri( mv_embed_url ).queryKey['debug'] == 'true' ) { + if ( mw.parseUri( mv_embed_url ).queryKey['debug'] == 'true' ) { var d = new Date(); req_param += 'urid=' + d.getTime() + '&debug=true'; } else if ( urid ) { @@ -1987,7 +1988,7 @@ function getMwReqParam() { req_param += 'urid=' + mw.version; } // add the lang param: - var langKey = parseUri( mv_embed_url ).queryKey['uselang']; + var langKey = mw.parseUri( mv_embed_url ).queryKey['uselang']; if ( langKey ) req_param += '&uselang=' + langKey; @@ -2013,7 +2014,7 @@ function getMvEmbedPath() { } // Make an absolute URL (if it's relative and we don't have an mv_embed path) if ( mv_embed_path.indexOf( '://' ) == - 1 ) { - var pURL = parseUri( document.URL ); + var pURL = mw.parseUri( document.URL ); if ( mv_embed_path.charAt( 0 ) == '/' ) { mv_embed_path = pURL.protocol + '://' + pURL.authority + mv_embed_path; } else { diff --git a/js2/mwEmbed/php/noMediaWikiConfig.php b/js2/mwEmbed/php/noMediaWikiConfig.php index a18aaf405f..66ec1ccc2f 100644 --- a/js2/mwEmbed/php/noMediaWikiConfig.php +++ b/js2/mwEmbed/php/noMediaWikiConfig.php @@ -47,6 +47,9 @@ require_once( realpath( dirname( __FILE__ ) ) . '/jsAutoloadLocalClasses.php' ); // Get the JSmin class: require_once( realpath( dirname( __FILE__ ) ) . '/minify/JSMin.php' ); +// Get the messages file: +require_once( realpath( dirname( __FILE__ ) ) . '/languages/mwEmbed.i18n.php' ); + function wfDebug() { return false; } @@ -79,8 +82,6 @@ function wfMsgGetKey( $msgKey, $na, $langKey=false ) { if(!$langKey){ $langKey = $mwLanguageCode; } - // Make sure we have the messages file: - require_once( realpath( dirname( __FILE__ ) ) . '/languages/mwEmbed.i18n.php' ); if ( isset( $messages[$mwLanguageCode] ) && isset( $messages[$langKey][$msgKey] ) ) { return $messages[$langKey][$msgKey]; } else { diff --git a/js2/remoteMwEmbed.js b/js2/remoteMwEmbed.js index 19f5f72a02..02e1a70887 100644 --- a/js2/remoteMwEmbed.js +++ b/js2/remoteMwEmbed.js @@ -1,11 +1,11 @@ /* - * this file exposes some of the functionality of mwEmbed to wikis + * This file exposes some of the functionality of mwEmbed to wikis * that do not yet have js2 enabled */ var urlparts = getRemoteEmbedPath(); var mwEmbedHostPath = urlparts[0]; -var mwRemoteVersion = '1.06'; +var mwRemoteVersion = '1.07'; var mwUseScriptLoader = true; // setup up request Params: diff --git a/js2/uploadPage.js b/js2/uploadPage.js index eba86800e9..b90db37ec5 100644 --- a/js2/uploadPage.js +++ b/js2/uploadPage.js @@ -3,10 +3,6 @@ * It controls the invocation of the mvUploader class based on local config. */ -js2AddOnloadHook( function() { - mwUploadHelper.init(); -} ); - var mwUploadFormTarget = '#mw-upload-form'; // Set up the upload form bindings once all DOM manipulation is done var mwUploadHelper = { @@ -128,7 +124,7 @@ var mwUploadHelper = { } } // Capitalise first letter and replace spaces by underscores - fname = fname.charAt( 0 ).toUpperCase().concat( fname.substring( 1, 10000 ) ).replace( / / g, '_' ); + fname = fname.charAt( 0 ).toUpperCase().concat( fname.substring( 1, 10000 ) ).replace(/ /g, '_' ); // Output result $j( '#wpDestFile' ).val( fname ); @@ -138,3 +134,8 @@ var mwUploadHelper = { } ); } } + + +js2AddOnloadHook( function() { + mwUploadHelper.init(); +} ); \ No newline at end of file -- 2.20.1