* 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
} 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 );
}
};
},
// @@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];
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];
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;
}
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];
}
}
// 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'];
} 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 += '<tr>' +
'<td colspan="2"><b>' + gM( 'mwe-other_properties' ) + '</b></td>' +
// 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;
}
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];
},
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 ) {
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( ':' );
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 {
},
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( '<div class="ui-widget ui-widget-content ui-corner-all" style="position:absolute;z-index:10;' +
'top:' + ( loc.top ) + 'px;' +
- 'left:' + ( parseInt( loc.left ) + parseInt( this.width ) + 10 ) + 'px;' +
+ 'left:' + ( parseInt( loc.left ) + parseInt( this.width ) + 10) + 'px;' +
'height:' + theight + 'px;width:400px;' +
'display:none;" ' +
'id="metaBox_' + this.id + '">' +
mv_get_loading_img() +
'</div>' );
- }
- // 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:
// @@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';
}
},
// 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 ) {
$.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;
}
/* 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
}
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 +
$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 ) {
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 );
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 {
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"
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:
if ( !mwAddMediaConfig )
var mwAddMediaConfig = { };
-var mvTimedTextEdit = { };
+var mvTimeTextEdit = { };
loadGM( {
"mwe-upload-subs-file" : "Upload subtitle",
*
* @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
function lcCssPath( cssSet ) {
for ( var i in cssSet ) {
- mvCssPaths[i] = mv_embed_path + cssSet[i];
+ mvCssPaths[i] = cssSet[i];
}
}
lcCssPath( {
'$j.Jcrop' : 'libClipEdit/Jcrop/css/jquery.Jcrop.css',
'$j.fn.ColorPicker' : 'libClipEdit/colorpicker/css/colorpicker.css'
-} )
-
-
-// parseUri 1.2.2
-// (c) Steven Levithan <stevenlevithan.com>
-// 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/';
// @@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:
*
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;
}
$.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 ) {
}
return false;
}
-
+
+ /**
+ * Utility Functions
+ *
+ * parseUri 1.2.2
+ * (c) Steven Levithan <stevenlevithan.com>
+ * 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 )
// 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] ] );
}
}
}
}
// 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 {
// 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 );
}
}
*/
// 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 {
// 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",
}
// 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
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 ) {
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;
}
// 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 {
// 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;
}
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 {
/*
- * 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:
* 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 = {
}
}
// 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 );
} );
}
}
+
+
+js2AddOnloadHook( function() {
+ mwUploadHelper.init();
+} );
\ No newline at end of file