From: Michael Dale Date: Thu, 12 Nov 2009 18:24:19 +0000 (+0000) Subject: * partial fix of regEx... (might be worth reverting) fixing rex issues and testing... X-Git-Tag: 1.31.0-rc.0~38837 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=commitdiff_plain;h=4575fcbd4953d848d559383eae0409a7ceb1fec4;p=lhc%2Fweb%2Fwiklou.git * partial fix of regEx... (might be worth reverting) fixing rex issues and testing things in /example_usage --- diff --git a/js2/mwEmbed/libAddMedia/remoteSearchDriver.js b/js2/mwEmbed/libAddMedia/remoteSearchDriver.js index 34f32cd496..e9f5355310 100644 --- a/js2/mwEmbed/libAddMedia/remoteSearchDriver.js +++ b/js2/mwEmbed/libAddMedia/remoteSearchDriver.js @@ -422,7 +422,7 @@ remoteSearchDriver.prototype = { return this.getLicenceFromKey( jL , license_url ); } }; - // could not find it return mwe-unknown_license + // Could not find it return mwe-unknown_license return { 'title' : gM( 'mwe-unknown_license' ), 'img_html' : '' + gM( 'mwe-unknown_license' ) + '', @@ -677,12 +677,12 @@ remoteSearchDriver.prototype = { _this.addResourceEditLoader(); // @@note: we have most of what we need in resultData imageinfo cp.sObj.addByTitle( wTitle, function( rObj ) { - // redraw ( with added result if new ) + // Redraw ( with added result if new ) _this.drawOutputResults(); - // pull up resource editor: + // Pull up resource editor: _this.resourceEdit( rObj, $j( '#res_upload__' + rObj.id ).get( 0 ) ); } ); - // return false to close progress window: + // Return false to close progress window: return false; } } ); @@ -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]; @@ -1336,7 +1336,7 @@ remoteSearchDriver.prototype = { var _this = this; // Update base target_resource_title: - rObj.target_resource_title = rObj.titleKey.replace( / File: | Image: / , '' ) + rObj.target_resource_title = rObj.titleKey.replace( /File:|Image:/ , '' ) // check if local repository // or if import mode if just "linking" (we should already have the 'url' @@ -1373,7 +1373,7 @@ remoteSearchDriver.prototype = { // @@todo maybe update poster too? rObj.local_poster = imagePage['imageinfo'][0].thumburl; // update the title: - rObj.target_resource_title = imagePage.title.replace( / File: | Image: / , '' ); + rObj.target_resource_title = imagePage.title.replace(/File:|Image:/ , '' ); cir_callback( rObj ); } else { // close the dialog and display the import interface: diff --git a/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js b/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js index 787961532a..7b43a6e643 100644 --- a/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js +++ b/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js @@ -98,7 +98,7 @@ baseRemoteSearch.prototype = { if ( node != null && attr_name == null ) { if ( node.childNodes[0] != null ) { // trim and strip html: - tag_val = $j.trim( node.firstChild.nodeValue ).replace( / ( < ( [ ^ > ] + ) > ) / ig, "" ); + tag_val = $j.trim( node.firstChild.nodeValue ).replace(/(<([^>]+)>)/ig,""); } } if ( node != null && attr_name != null ) { @@ -108,7 +108,7 @@ baseRemoteSearch.prototype = { var attr_vals = { }; for ( var j in attr_name ) { if ( $j( node ).attr( attr_name[j] ).length != 0 ) - attr_vals[ attr_name[j] ] = $j.trim( $j( node ).attr( attr_name[j] ) ).replace( / ( < ( [ ^ > ] + ) > ) / ig, "" ); + attr_vals[ attr_name[j] ] = $j.trim( $j(node).attr( attr_name[j]) ).replace(/(<([^>]+)>)/ig,""); } tag_val = attr_vals ; } @@ -186,7 +186,7 @@ baseRemoteSearch.prototype = { getInlineDescWiki:function( rObj ) { // return striped html & trim white space if ( rObj.desc ) - return $j.trim( rObj.desc.replace( / ( < ( [ ^ > ] + ) > ) / ig, "" ) ); + return $j.trim( rObj.desc.replace(/(<([^>]+)>)/ig,"") ); // no desc avaliable: return ''; }, diff --git a/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js b/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js index 27113c96a6..9bddd4081b 100644 --- a/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js +++ b/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js @@ -185,7 +185,7 @@ mediaWikiSearch.prototype = { 'id' : page_id, 'titleKey' : page.title, 'link' : page.imageinfo[0].descriptionurl, - 'title' : page.title.replace( / File: | .jpg | .png | .svg | .ogg | .ogv | .oga / ig, '' ), + 'title' : page.title.replace(/File:.jpg|.png|.svg|.ogg|.ogv|.oga/ig, ''), 'poster' : page.imageinfo[0].thumburl, 'thumbwidth' : page.imageinfo[0].thumbwidth, 'thumbheight': page.imageinfo[0].thumbheight, diff --git a/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js b/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js index 9590a2e0db..0b7a5f3c96 100644 --- a/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js +++ b/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js @@ -69,10 +69,10 @@ metavidSearch.prototype = { } ); }, getTitleKey:function( rObj ) { - return rObj['stream_name'] + '_part_' + rObj['start_time'].replace( / : / g, '.' ) + '_to_' + rObj['end_time'].replace( / : / g, '.' ) + '.ogv'; + return rObj['stream_name'] + '_part_' + rObj['start_time'].replace(/:/ g, '.' ) + '_to_' + rObj['end_time'].replace(/:/g, '.' ) + '.ogv'; }, getTitle:function( rObj ) { - var sn = rObj['stream_name'].replace( / _ / g, ' ' ); + var sn = rObj['stream_name'].replace( /_/ g, ' ' ); sn = sn.charAt( 0 ).toUpperCase() + sn.substr( 1 ); return gM( 'mwe-stream_title', [ sn, rObj.start_time, rObj.end_time ] ); }, diff --git a/js2/mwEmbed/libAddMedia/simpleUploadForm.js b/js2/mwEmbed/libAddMedia/simpleUploadForm.js index bb442f63ed..d3501eab03 100644 --- a/js2/mwEmbed/libAddMedia/simpleUploadForm.js +++ b/js2/mwEmbed/libAddMedia/simpleUploadForm.js @@ -110,7 +110,7 @@ var default_form_options = { } else { fname = path.substring( backslash + 1, 10000 ); } - 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 ); // do destination check diff --git a/js2/mwEmbed/libEmbedVideo/embedVideo.js b/js2/mwEmbed/libEmbedVideo/embedVideo.js index b42a5423ab..c6f7fa57e2 100644 --- a/js2/mwEmbed/libEmbedVideo/embedVideo.js +++ b/js2/mwEmbed/libEmbedVideo/embedVideo.js @@ -376,7 +376,9 @@ mediaSource.prototype = { if ( !npt2seconds( end_ntp ) ) end_ntp = this.end_ntp; - this.src = getURLParamReplace( this.src, { 't': start_ntp + '/' + end_ntp } ); + this.src = getURLParamReplace( this.src, { + 't': start_ntp + '/' + end_ntp + }); // update the duration this.parseURLDuration(); @@ -820,9 +822,9 @@ embedVideo.prototype = { if ( typeof s != 'String' ) { s = s.toString(); } - return s.replace( / & / g, '&' ) - . replace( / < / g, '<' ) - . replace( / > / g, '>' ); + return s.replace( /&/g, '&' ) + . replace( //g, '>' ); }, hq : function ( s ) { return '"' + this.hx( s ) + '"'; @@ -1198,7 +1200,7 @@ embedVideo.prototype = { local_poster = page['imageinfo'][0].thumburl; } var descriptionurl = page['imageinfo'][0].descriptionurl; - var title_str = page.title.replace( / File: | .ogv$ | .oga$ | .ogg$ / gi, "" ); + var title_str = page.title.replace( /File:|.ogv$|.oga$|.ogg$/gi, "" ); // only link to other videos: if ( descriptionurl.match( /\.ogg$|\.ogv$|\.oga$/gi ) != null) { var liout = '
  • ' + @@ -1418,7 +1420,7 @@ embedVideo.prototype = { var clip = this.anno_data_cache[link_id]; var title_msg = ''; for ( var j in clip['meta'] ) { - title_msg += j.replace( / _ / g, ' ' ) + ': ' + clip['meta'][j].replace( / _ / g, ' ' ) + "
    "; + title_msg += j.replace( /_/g, ' ' ) + ': ' + clip['meta'][j].replace( /_/g, ' ' ) + "
    "; } var time_req = clip.time_req; if ( link_type == 'current' ) // if current start from end of current clip play to end of current meta: @@ -1552,7 +1554,10 @@ embedVideo.prototype = { // check if our thumbnail has a time attribute: if ( my_thumb_src.indexOf( 't=' ) !== - 1 ) { var time_ntp = seconds2npt ( options.time + parseInt( this.start_offset ) ); - my_thumb_src = getURLParamReplace( my_thumb_src, { 't':time_ntp, 'size': options.size } ); + my_thumb_src = getURLParamReplace( my_thumb_src, { + 't':time_ntp, + 'size': options.size + }); } var thumb_class = ( typeof options['thumb_class'] != 'undefined' ) ? options['thumb_class'] : ''; return '
    // MIT License -function parseUri ( str ) { +function parseUri (str) { var o = parseUri.options, - m = o.parser[o.strictMode ? "strict" : "loose"].exec( str ), - uri = { }, + m = o.parser[o.strictMode ? "strict" : "loose"].exec(str), + uri = {}, i = 14; - while ( i-- ) uri[o.key[i]] = m[i] || ""; + 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; - } ); + 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"], + key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"], q: { name: "queryKey", - parser: / ( ? : ^ | & )( [ ^ &= ] * ) = ? ( [ ^ &] * ) / g + parser: /(?:^|&)([^&=]*)=?([^&]*)/g }, parser: { strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,