TheDJ has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/173513

Change subject: Make the private modules of TMH pass jshint
......................................................................

Make the private modules of TMH pass jshint

Change-Id: I41cf1bf6a1a2406d2d4731492747bb9a6b8d9803
---
A .jshintignore
A .jshintrc
M resources/ext.tmh.transcodetable.js
M resources/mw.MediaWikiPlayerSupport.js
M resources/mw.PopUpThumbVideo.js
M resources/mw.TMHGalleryHook.js
6 files changed, 161 insertions(+), 115 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TimedMediaHandler 
refs/changes/13/173513/1

diff --git a/.jshintignore b/.jshintignore
new file mode 100644
index 0000000..a56a7ef
--- /dev/null
+++ b/.jshintignore
@@ -0,0 +1,2 @@
+node_modules
+
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..ef9af3d
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,39 @@
+{
+       /* Common */
+
+       // Enforcing
+       "camelcase": true,
+       "curly": true,
+       "eqeqeq": true,
+       "immed": true,
+       "latedef": true,
+       "newcap": true,
+       "noarg": true,
+       "noempty": true,
+       "nonew": true,
+       "quotmark": "single",
+       "trailing": true,
+       "undef": true,
+       "unused": true,
+       // Legacy
+       "onevar": true,
+
+       /* Local */
+
+       // Enforcing
+       "bitwise": true,
+       "es3": true,
+       // Relaxing
+       "laxbreak": true,
+       "smarttabs": true,
+       "multistr": true,
+       // Environment
+       "browser": true,
+       // Legacy
+       "nomen": true,
+
+       "predef": [
+               "mediaWiki",
+               "jQuery"
+       ]
+}
diff --git a/resources/ext.tmh.transcodetable.js 
b/resources/ext.tmh.transcodetable.js
index ed0e901..8539015 100644
--- a/resources/ext.tmh.transcodetable.js
+++ b/resources/ext.tmh.transcodetable.js
@@ -1,91 +1,95 @@
 /**
 * Javascript to support transcode table on image page
 */
-$( document ).ready( function () {
-       var errorPopup, $errorLink;
+( function ( mw, $ ) {
+       $( document ).ready( function () {
+               var errorPopup, $errorLink;
 
-       errorPopup = function () {
-               // pop up dialog
-               mw.addDialog( {
-                       'width': '640',
-                       'height': '480',
-                       'title': $(this).attr( 'title' ),
-                       'content': $('<textarea />')
-                               .css( {
-                                       'width':'99%',
-                                       'height':'99%'
-                               } )
-                               .text( $(this).attr('data-error') )
-               } )
-               .css( 'overflow', 'hidden' );
-               return false;
-       }
-
-       // Old version. Need to keep for a little while in case of cached pages.
-       $( '.mw-filepage-transcodestatus .errorlink' ).click( errorPopup );
-       // New version.
-       $errorLink = $( '.mw-filepage-transcodestatus 
.mw-tmh-pseudo-error-link' );
-       $errorLink.wrapInner( function () {
-               var $this = $( this );
-               return $( '<a />' ).attr( {
-                       href: '#',
-                       title: $this.text(),
-                       'data-error': $this.attr( 'data-error' )
-               } ).click( errorPopup );
-       } );
-
-       // Reset transcode action:
-       $( '.mw-filepage-transcodereset a' ).click( function () {
-               var tKey = $( this ).attr( 'data-transcodekey' );
-               var buttons = {};
-               buttons[ mw.msg( 'mwe-ok' ) ] = function () {
-                       var _thisDialog = this;
-
-                       // Only show cancel button while loading:
-                       var cancelBtn = {};
-                       cancelBtn[ mw.msg( 'mwe-cancel' ) ] = function () {
-                               $(this).dialog( 'close' );
-                       }
-                       $( _thisDialog ).dialog( 'option', 'buttons', cancelBtn 
);
-
-                       $( this ).loadingSpinner();
-
-                       var apiUrl =  mw.config.get( 'wgServer' ) + 
mw.config.get( 'wgScriptPath' ) + '/api.php';
-                       // Do an api post action:
-                       $.post( apiUrl, {
-                               'action' : 'transcodereset',
-                               'transcodekey' : tKey,
-                               'title' : mw.config.get('wgPageName'),
-                               'token' : mw.user.tokens.get('editToken'),
-                               'format' : 'json'
-                       }, function ( data ) {
-                               if( data && data['success'] ){
-                                       // refresh the page
-                                       window.location.reload();
-                               } else {
-                                       if( data.error && data.error.info ){
-                                               $( _thisDialog ).text( 
data.error.info );
-                                       } else {
-                                               $( _thisDialog ).text( mw.msg( 
'timedmedia-reset-error' ) );
-                                       }
-                                       var okBtn = {};
-                                       okBtn[ mw.msg('mwe-ok') ] = function() 
{ $(this).dialog( 'close' ); }
-                                       $( _thisDialog ).dialog( 'option', 
'buttons', okBtn );
-                               }
-                       })
+               errorPopup = function () {
+                       // pop up dialog
+                       mw.addDialog( {
+                               'width': '640',
+                               'height': '480',
+                               'title': $(this).attr( 'title' ),
+                               'content': $('<textarea />')
+                                       .css( {
+                                               'width':'99%',
+                                               'height':'99%'
+                                       } )
+                                       .text( $(this).attr('data-error') )
+                       } )
+                       .css( 'overflow', 'hidden' );
+                       return false;
                };
-               buttons[ mw.msg( 'mwe-cancel' ) ] = function () {
-                       $( this ).dialog( 'close' );
-               }
-               // pop up dialog
-               mw.addDialog( {
-                       'width': '400',
-                       'height': '200',
-                       'title': mw.msg( 'timedmedia-reset' ),
-                       'content': mw.msg( 'timedmedia-reset-confirm' ),
-                       'buttons': buttons
-               } )
-               .css( 'overflow', 'hidden' );
-               return false;
-       })
-})
+
+               // Old version. Need to keep for a little while in case of 
cached pages.
+               $( '.mw-filepage-transcodestatus .errorlink' ).click( 
errorPopup );
+               // New version.
+               $errorLink = $( '.mw-filepage-transcodestatus 
.mw-tmh-pseudo-error-link' );
+               $errorLink.wrapInner( function () {
+                       var $this = $( this );
+                       return $( '<a />' ).attr( {
+                               href: '#',
+                               title: $this.text(),
+                               'data-error': $this.attr( 'data-error' )
+                       } ).click( errorPopup );
+               } );
+
+               // Reset transcode action:
+               $( '.mw-filepage-transcodereset a' ).click( function () {
+                       var tKey = $( this ).attr( 'data-transcodekey' ),
+                       buttons = {};
+
+                       buttons[ mw.msg( 'mwe-ok' ) ] = function () {
+                               var apiUrl,
+                                       _thisDialog = this,
+                                       cancelBtn = {};
+
+                               // Only show cancel button while loading:
+                               cancelBtn[ mw.msg( 'mwe-cancel' ) ] = function 
() {
+                                       $(this).dialog( 'close' );
+                               };
+                               $( _thisDialog ).dialog( 'option', 'buttons', 
cancelBtn );
+
+                               $( this ).loadingSpinner();
+
+                               apiUrl =  mw.config.get( 'wgServer' ) + 
mw.config.get( 'wgScriptPath' ) + '/api.php';
+                               // Do an api post action:
+                               $.post( apiUrl, {
+                                       'action': 'transcodereset',
+                                       'transcodekey': tKey,
+                                       'title': mw.config.get('wgPageName'),
+                                       'token': 
mw.user.tokens.get('editToken'),
+                                       'format': 'json'
+                               }, function ( data ) {
+                                       if ( data && data.success ) {
+                                               // refresh the page
+                                               window.location.reload();
+                                       } else {
+                                               if ( data.error && 
data.error.info ) {
+                                                       $( _thisDialog ).text( 
data.error.info );
+                                               } else {
+                                                       $( _thisDialog ).text( 
mw.msg( 'timedmedia-reset-error' ) );
+                                               }
+                                               var okBtn = {};
+                                               okBtn[ mw.msg('mwe-ok') ] = 
function () { $(this).dialog( 'close' ); };
+                                               $( _thisDialog ).dialog( 
'option', 'buttons', okBtn );
+                                       }
+                               } );
+                       };
+                       buttons[ mw.msg( 'mwe-cancel' ) ] = function () {
+                               $( this ).dialog( 'close' );
+                       };
+                       // pop up dialog
+                       mw.addDialog( {
+                               'width': '400',
+                               'height': '200',
+                               'title': mw.msg( 'timedmedia-reset' ),
+                               'content': mw.msg( 'timedmedia-reset-confirm' ),
+                               'buttons': buttons
+                       } )
+                       .css( 'overflow', 'hidden' );
+                       return false;
+               } );
+       } );
+} )( mediaWiki, jQuery );
diff --git a/resources/mw.MediaWikiPlayerSupport.js 
b/resources/mw.MediaWikiPlayerSupport.js
index 727def4..c1ef613 100644
--- a/resources/mw.MediaWikiPlayerSupport.js
+++ b/resources/mw.MediaWikiPlayerSupport.js
@@ -54,7 +54,7 @@
                                var i, page, imageinfo;
                                if ( data.query.pages ) {
                                        for ( i in data.query.pages ) {
-                                               if ( i == '-1' ) {
+                                               if ( i === '-1' ) {
                                                        callback( false );
                                                        return ;
                                                }
@@ -84,14 +84,14 @@
                                );
 
                                // Set the duration
-                               if ( imageinfo.metadata[2].name == 'length' ) {
+                               if ( imageinfo.metadata[2].name === 'length' ) {
                                        embedPlayer.duration = 
imageinfo.metadata[2].value;
                                }
 
                                // Set the width height
                                // Make sure we have an accurate aspect ratio
-                               if ( imageinfo.height != 0 && imageinfo.width 
!= 0 ) {
-                                       embedPlayer.height = parseInt( 
embedPlayer.width * ( imageinfo.height / imageinfo.width ) );
+                               if ( imageinfo.height !== 0 && imageinfo.width 
!== 0 ) {
+                                       embedPlayer.height = parseInt( 
embedPlayer.width * ( imageinfo.height / imageinfo.width ), 10 );
                                }
 
                                // Update the css for the player interface
@@ -109,7 +109,7 @@
                * @param {String} resourceHTML Resource wiki text page contents
                */
                function doCreditLine( resourceHTML, articleUrl ) {
-                       var authUrl, $page, $author, $links, $date, $authorLink
+                       var authUrl, $page, $author, $authorText, $links, 
$date, $authorLink,
                        imgSize = { },
                        // Get the title string ( again a "Title" like js 
object could help out here. )
                        titleStr = embedPlayer.apiTitleKey.replace( /_/g, ' ' ),
@@ -139,7 +139,7 @@
                        $author = $page.find( '#fileinfotpl_aut' );
                        if ( $author.length ) {
                                // Get the real author sibling of 
fileinfotpl_aut
-                               $authorText = $author.next()
+                               $authorText = $author.next();
                                // Remove white space:
                                $authorText.find( 'br' ).remove();
 
@@ -155,7 +155,7 @@
                                }
                                $creditLine.append( $( '<br />' ),
                                        mw.msg( 
'mwe-embedplayer-credit-author', $authorText.html() )
-                               )
+                               );
                        }
 
                        // Look for date:
@@ -168,7 +168,7 @@
                                $date.find( 'br' ).remove();
                                $creditLine.append(  $( '<br />' ),
                                        mw.msg( 'mwe-embedplayer-credit-date', 
$date.html() )
-                               )
+                               );
                        }
 
                        // Build out the image and credit line
@@ -176,7 +176,7 @@
                                imgSize.height = imgSize.width = ( 
embedPlayer.controlBuilder.getOverlayWidth() < 250 ) ? 45 : 80;
                        } else {
                                imgSize.width = ( 
embedPlayer.controlBuilder.getOverlayWidth() < 250 ) ? 45 : 120;
-                               imgSize.height = parseInt( imgSize.width * ( 
embedPlayer.getHeight() / embedPlayer.getWidth() ) );
+                               imgSize.height = parseInt( imgSize.width * ( 
embedPlayer.getHeight() / embedPlayer.getWidth() ), 10 );
                        }
                        return $( '<div/>' ).addClass( 'creditline' )
                                .append(
@@ -193,13 +193,13 @@
                                .append(
                                        $creditLine
                                );
-               };
+               }
 
                /**
                 * Issues a request to populate the credits box
                 */
                function showCredits( $target, callback ) {
-                       var apiUrl, fileTitle, request, articleUrl = '';
+                       var apiUrl, fileTitle, request;
                        if ( $creditsCache ) {
                                $target.html( $creditsCache );
                                callback( true );
@@ -217,8 +217,7 @@
                                'maxage': 3600
                        };
                        mw.getJSON( apiUrl, request, function ( data ) {
-
-                               descUrl = apiUrl.replace( 'api.php', 
'index.php');
+                               var descUrl = apiUrl.replace( 'api.php', 
'index.php');
                                descUrl += '?title=' + encodeURIComponent( 
fileTitle );
                                if ( data && data.parse && data.parse.text && 
data.parse.text['*'] ) {
                                        // TODO improve provider 'concept' to 
support page title link
@@ -229,14 +228,14 @@
                                $target.html( $creditsCache );
                                callback( true );
                        } );
-               };
+               }
                /**
                 * Adds embedPlayer Bindings
                 */
 
                // Show credits when requested
                $( embedPlayer ).bindQueueCallback( 'showCredits', function ( 
$target, callback ) {
-                       if ( $target.data( 'playerId') != embedPlayer.id ) {
+                       if ( $target.data( 'playerId') !== embedPlayer.id ) {
                                // bad event trigger
                                return ;
                        }
@@ -246,7 +245,7 @@
 
                // Show credits on clip complete:
                $( embedPlayer ).bind( 'onEndedDone', function ( event, id ) {
-                       if ( embedPlayer.id != id ) {
+                       if ( embedPlayer.id !== id ) {
                                // possible event trigger error. ( skip )
                                return ;
                        }
@@ -281,10 +280,11 @@
                });
 
                $( embedPlayer ).bind( 'TimedText_BuildCCMenu', function ( 
event, $menu, id ) {
-                       var pageTitle,
+                       var _this,
+                               pageTitle,
                                addTextPage,
                                $li;
-                       if ( id != embedPlayer.id ) {
+                       if ( id !== embedPlayer.id ) {
                                _this = $( '#' + id )[0].timedText;
                                embedPlayer = _this.embedPlayer;
                        }
@@ -320,7 +320,7 @@
 
                $( embedPlayer ).bindQueueCallback( 'checkPlayerSourcesEvent', 
function ( callback ) {
                        // Only load source if none are available:
-                       if ( embedPlayer.mediaElement.sources.length == 0 ) {
+                       if ( embedPlayer.mediaElement.sources.length === 0 ) {
                                loadPlayerSources( callback );
                        } else {
                                // No source to load, issue callback directly
@@ -355,19 +355,19 @@
                });
 
                $( embedPlayer ).bind( 'getShareIframeSrc', function ( event, 
callback, id ) {
-                       if ( id != embedPlayer.id ) {
+                       if ( id !== embedPlayer.id ) {
                                embedPlayer = $( '#' + id )[0];
                        }
                        var iframeUrl = false;
                        // Do a special check for wikimediacommons provider as 
a known shared reop
-                       if ( embedPlayer['data-mwprovider'] == 
'wikimediacommons' ) {
+                       if ( embedPlayer['data-mwprovider'] === 
'wikimediacommons' ) {
                                iframeUrl = 
'//commons.wikimedia.org/wiki/File:' + decodeURIComponent( 
embedPlayer.apiTitleKey ).replace( /^(File:|Image:)/, '' );
                        } else {
                                // use the local wiki:
                                if ( mw.config.get( 'wgServer' ) && 
mw.config.get( 'wgArticlePath' ) ) {
                                        iframeUrl =  mw.config.get( 'wgServer' 
) +
                                                mw.config.get( 'wgArticlePath' 
).replace( /\$1/, 'File:' +
-                                                       decodeURIComponent( 
embedPlayer.apiTitleKey ).replace( /^(File:|Image:)/, '' ) )
+                                                       decodeURIComponent( 
embedPlayer.apiTitleKey ).replace( /^(File:|Image:)/, '' ) );
                                }
                        }
                        if ( iframeUrl ) {
diff --git a/resources/mw.PopUpThumbVideo.js b/resources/mw.PopUpThumbVideo.js
index 1217eee..6968f64 100644
--- a/resources/mw.PopUpThumbVideo.js
+++ b/resources/mw.PopUpThumbVideo.js
@@ -4,9 +4,10 @@
 ( function ( mw, $ ) {
        $( document ).ready( function () {
                $('.PopUpMediaTransform a').each( function () {
-                       var parent = $( this ).parent();
+                       var link, title,
+                               parent = $( this ).parent();
                        if ( parent.attr( 'videopayload' ) ) {
-                               $( this ).click( function ( event ) {
+                               $( this ).click( function ( /*event*/ ) {
                                        var thisref = this;
 
                                        mw.loader.using( 'mw.MwEmbedSupport', 
function () {
@@ -32,8 +33,8 @@
                                        return false;
                                } );
                        } else if ( parent.attr( 'data-videopayload' ) ) {
-                               var link = $( this ).attr( 'href' ),
-                                       title = mw.Title.newFromImg( { src: 
link } );
+                               link = $( this ).attr( 'href' );
+                               title = mw.Title.newFromImg( { src: link } );
                                if ( title && title.getPrefixedDb() !== 
mw.config.get( 'wgPageName' ) ) {
                                        $( this ).attr( 'href', title.getUrl() 
);
                                }
diff --git a/resources/mw.TMHGalleryHook.js b/resources/mw.TMHGalleryHook.js
index e4baf58..fd23690 100644
--- a/resources/mw.TMHGalleryHook.js
+++ b/resources/mw.TMHGalleryHook.js
@@ -1,7 +1,7 @@
 /**
 * Simple script to add pop-up video dialog link support for video thumbnails
 */
-( function( mw, $ ) {
+( function ( mw ) {
        // Hook to allow dynamically resizing videos in image galleries
        mw.hook( 'mediawiki.page.gallery.resize' ).add( function ( info ) {
                var $mwPlayerContainer,
@@ -42,5 +42,5 @@
                        info.$imageDiv.width( info.imgWidth );
                        $popUp.add( $popUp.find( 'img' ) ).width( info.imgWidth 
).height( info.imgHeight );
                }
-       });
-} )( mediaWiki, jQuery );
+       } );
+} )( mediaWiki );

-- 
To view, visit https://gerrit.wikimedia.org/r/173513
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I41cf1bf6a1a2406d2d4731492747bb9a6b8d9803
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TimedMediaHandler
Gerrit-Branch: master
Gerrit-Owner: TheDJ <hartman.w...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to