* partial fix of regEx... (might be worth reverting) fixing rex issues and testing...
authorMichael Dale <dale@users.mediawiki.org>
Thu, 12 Nov 2009 18:24:19 +0000 (18:24 +0000)
committerMichael Dale <dale@users.mediawiki.org>
Thu, 12 Nov 2009 18:24:19 +0000 (18:24 +0000)
js2/mwEmbed/libAddMedia/remoteSearchDriver.js
js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js
js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js
js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js
js2/mwEmbed/libAddMedia/simpleUploadForm.js
js2/mwEmbed/libEmbedVideo/embedVideo.js
js2/mwEmbed/libEmbedVideo/flowplayerEmbed.js
js2/mwEmbed/libSequencer/mvPlayList.js
js2/mwEmbed/libSequencer/mvSequencer.js
js2/mwEmbed/mv_embed.js

index 34f32cd..e9f5355 100644 (file)
@@ -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'      : '<span>' + gM( 'mwe-unknown_license' ) + '</span>',
@@ -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: 
index 7879615..7b43a6e 100644 (file)
@@ -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 '';
        },
index 27113c9..9bddd40 100644 (file)
@@ -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,
index 9590a2e..0b7a5f3 100644 (file)
@@ -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 ] );
        },
index bb442f6..d3501ea 100644 (file)
@@ -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
index b42a542..c6f7fa5 100644 (file)
@@ -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, '&amp;' )
-                       . replace( / < / g, '&lt;' )
-                       . replace( / > / g, '&gt;' );
+               return s.replace( /&/g, '&amp;' )
+                       . replace( /</g, '&lt;' )
+                       . replace( />/g, '&gt;' );
        },
        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 = '<li>' +
@@ -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, ' ' ) + " <br>";
+                                               title_msg += j.replace( /_/g, ' ' ) + ': ' + clip['meta'][j].replace( /_/g, ' ' ) + " <br>";
                                        }
                                        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 '<div class="ui-corner-all ' + thumb_class + '" src="' + my_thumb_src + '" ' +
@@ -1574,7 +1579,10 @@ embedVideo.prototype = {
                }
                if ( this.org_thum_src.indexOf( 't=' ) !== - 1 ) {
                        this.last_thumb_url = getURLParamReplace( this.org_thum_src,
-                               { 't' : seconds2npt( float_sec + parseInt( this.start_offset ) ) } );
+                               { 
+                                       't' : seconds2npt( float_sec + parseInt( this.start_offset ) ) 
+                               }
+                       );
                        if ( !this.thumbnail_updating ) {
                                this.updateThumbnail( this.last_thumb_url , false );
                                this.last_thumb_url = null;
@@ -1893,7 +1901,7 @@ embedVideo.prototype = {
                // Set up the click bindings:
                $target.find( "[rel='sel_source']" ).each( function() {
                        $j( this ).click( function() {
-                               var iparts = $j( this ).attr( 'id' ).replace( / sc_ / , '' ).split( '_' );
+                               var iparts = $j( this ).attr( 'id' ).replace(/sc_/ , '' ).split( '_' );
                                var source_id = iparts[0];
                                var default_player_id = iparts[1];
                                js_log( 'source id: ' +  source_id + ' player id: ' + default_player_id );
index f41109a..580cf0b 100644 (file)
@@ -1476,7 +1476,7 @@ extend( window.flashembed, {
                        if ( typeof _d != "undefined" ) {
                                _d = _d.replace( /^.*\s+(\S+\s+\S+$ )/, "$1" );
                                var _m = parseInt( _d.replace( /^(.*)\..*$/, "$1" ), 10 );
-                               var _r = / r / .test( _d ) ? parseInt( _d.replace( / ^ . * r( . * )$ / , "$1" ), 10 ) : 0;
+                               var _r = / r / .test( _d ) ? parseInt( _d.replace( /^.*r(.*)$/ , "$1" ), 10 ) : 0;
                                version = [_m, _r];
                        }
                        
index 3e568f8..80a15e8 100644 (file)
@@ -559,7 +559,7 @@ mvPlayList.prototype = {
                        js_log( 'no playhead so we can\'t get playhead pos' );
                        return 0;
                }
-               var track_len = $j( '#mv_seeker_' + this.id ).css( 'width' ).replace( / px / , '' );
+               var track_len = $j( '#mv_seeker_' + this.id ).css( 'width' ).replace( /px/ , '' );
                // assume the duration is static and present at .duration during playback
                var clip_perc = this.cur_clip.embed.duration / this.getDuration();
                var perc_offset = time_offset = 0;
@@ -1231,7 +1231,7 @@ mvClip.prototype = {
                                        js_log( "time is: " + time );
                                        this.img = this.img.replace( /t\=[^&]*/gi, "t=" + time );
                                        if ( this.img.indexOf( '&size=' ) != - 1 ) {
-                                               this.img = this.img.replace( / size = [ ^ &] * / gi, "size=" + size );
+                                               this.img = this.img.replace( /size=[^&]*/gi, "size=" + size );
                                        } else {
                                                this.img += '&size=' + size;
                                        }
index 1e5aeff..6180ad1 100644 (file)
@@ -808,7 +808,7 @@ mvSequencer.prototype = {
                } else {
                        // @@we need a api entry point to store a "clipboard"
                        if ( this_seq.clipboardEditToken && this_seq.plObj.interface_url ) {
-                               var req_url = this_seq.plObj.interface_url.replace( / api.php / , 'index.php' ) + '?action=ajax&rs=mv_seqtool_clipboard&rsargs[]=copy';
+                               var req_url = this_seq.plObj.interface_url.replace( /api.php/, 'index.php' ) + '?action=ajax&rs=mv_seqtool_clipboard&rsargs[]=copy';
                                $j.ajax( {
                                        type: "POST",
                                        url:req_url,
index 4fdf21f..0b13d7a 100644 (file)
@@ -161,27 +161,27 @@ lcCssPath( {
 // parseUri 1.2.2
 // (c) Steven Levithan <stevenlevithan.com>
 // 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*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,