Amire80 has uploaded a new change for review.

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


Change subject: Remove unused code and reduce JSHint warnings
......................................................................

Remove unused code and reduce JSHint warnings

Change-Id: I2d71df4e9b252bbe4139be3afdf65ce076b21f49
---
M SpecialApiSandbox.php
M modules/ext.apiSandbox.js
2 files changed, 32 insertions(+), 36 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ApiSandbox 
refs/changes/04/52804/1

diff --git a/SpecialApiSandbox.php b/SpecialApiSandbox.php
index e82677a..3685688 100644
--- a/SpecialApiSandbox.php
+++ b/SpecialApiSandbox.php
@@ -81,8 +81,6 @@
                        $this->getQueryModules( 'meta' )
                );
 
-               #$s = '<div id="api-sandbox-buttons"></div>';
-               #$s .= '<div id="api-sandbox-examples" style="display: 
none;"></div>';
                $s = '
 <table class="api-sandbox-options">
        <tbody>
diff --git a/modules/ext.apiSandbox.js b/modules/ext.apiSandbox.js
index 1478558..df2f837 100644
--- a/modules/ext.apiSandbox.js
+++ b/modules/ext.apiSandbox.js
@@ -15,7 +15,7 @@
 
        // get the first element in a list that is "scrollable"
        // depends on browser and skin (i.e. body or html)
-       function getScrollableElement( /* selectors, .. */ ) {
+       function getScrollableElement( /* selectors, ... */ ) {
                var i, argLen, el, $el, canScroll;
                for ( i = 0, argLen = arguments.length; i < argLen; i += 1 ) {
                        el = arguments[i];
@@ -34,6 +34,28 @@
                return [];
        }
 
+       function updateGenerator( callback ) {
+               var generator = $( '#param-generator' ).val();
+               if ( generator === '' ) {
+                       $generatorBox.hide();
+               } else {
+                       $generatorBox.show();
+                       getParamInfo(
+                               { querymodules: generator },
+                               function () { showLoading( $generatorContainer 
); },
+                               function () {
+                                       generatorRequest = new UiBuilder( 
$generatorContainer, paramInfo.querymodules[generator], 'g' );
+                                       if ( typeof callback === 'function' ) {
+                                               callback();
+                                       }
+                               },
+                               function () {
+                                       showLoadError( $generatorContainer, 
'apisb-request-error' );
+                               }
+                       );
+               }
+       }
+
        /**
         * Displays a spinner and a "Loading..."
         * @param $element {jQuery} Container for the loading message
@@ -41,9 +63,8 @@
        function showLoading( $element ) {
                $element.html(
                        mw.html.element( 'img',
-                               { src: mw.config.get( 'stylepath' ) + 
'/common/images/spinner.gif', alt: '' } )
-                       + mw.html.escape( mw.msg( 'apisb-loading' )
-                       )
+                               { src: mw.config.get( 'stylepath' ) + 
'/common/images/spinner.gif', alt: '' } ) +
+                       mw.html.escape( mw.msg( 'apisb-loading' ) )
                );
        }
 
@@ -229,7 +250,7 @@
                }
 
                function applyRemainingFieldParameters( obj, blacklist ) {
-                       var pieces, key, value, $el, splitted, j, nodeName;
+                       var key, value, $el, nodeName;
                        // Set the remaining fields
                        for ( key in obj ) {
                                if( obj.hasOwnProperty( key ) && 
blacklist.indexOf( key ) === -1 ) {
@@ -349,7 +370,7 @@
                                mainRequest.setHelp( $help );
                                $submit.button( 'option', 'disabled', false );
                                updateExamples( info );
-                               if ( typeof callback == 'function' ) {
+                               if ( typeof callback === 'function' ) {
                                        callback();
                                }
                        },
@@ -407,7 +428,7 @@
                $help.text( '' );
                updateQueryInfo( a, q, callback );
                $generatorBox.hide();
-               if ( q == '' && callIfEmpty && typeof callback == 'function' ) {
+               if ( q === '' && callIfEmpty && typeof callback === 'function' 
) {
                        callback();
                }
        }
@@ -480,7 +501,7 @@
                                        .append( mw.html.element( 'th', { 
'class': 'api-sandbox-params-value' }, mw.msg( 'apisb-params-input' ) ) )
                                        .append( mw.html.element( 'th', {}, 
mw.msg( 'apisb-params-desc' ) ) )
                                .end();
-                       $tbody = $table.find( '> tbody' )
+                       $tbody = $table.find( '> tbody' );
                        for ( i = 0, length = this.params.length; i < length; i 
+= 1 ) {
                                param = this.params[i];
                                name = this.prefix + param.name;
@@ -626,10 +647,9 @@
                }
        }; // end of UiBuilder.prototype
 
-       /** When the dom is ready.. **/
+       /** When the dom is ready... **/
 
        $( function () {
-
                $( '#api-sandbox-content' ).show();
 
                // init page elements
@@ -692,7 +712,7 @@
                                        key: nsId,
                                        value: nsName
                                } );
-                       }               
+                       }
                } );
 
                // load stuff we need from the beginning
@@ -714,28 +734,6 @@
 
                $action.change( function() { updateUI(); } );
                $query.change( function() { updateUI(); } );
-
-               function updateGenerator( callback ) {
-                       var generator = $( '#param-generator' ).val();
-                       if ( generator === '' ) {
-                               $generatorBox.hide();
-                       } else {
-                               $generatorBox.show();
-                               getParamInfo(
-                                       { querymodules: generator },
-                                       function () { showLoading( 
$generatorContainer ); },
-                                       function () {
-                                               generatorRequest = new 
UiBuilder( $generatorContainer, paramInfo.querymodules[generator], 'g' );
-                                               if ( typeof callback == 
'function' ) {
-                                                       callback();
-                                               }
-                                       },
-                                       function () {
-                                               showLoadError( 
$generatorContainer, 'apisb-request-error' );
-                                       }
-                               );
-                       }
-               }
 
                $( '#param-generator' ).live( 'change', updateGenerator );
 
@@ -783,7 +781,7 @@
                                params += generatorRequest.getRequestData();
                        }
                        var historyEntry = '#' + url + params;
-                       if ( window.location.hash != historyEntry ) {
+                       if ( window.location.hash !== historyEntry ) {
                                history.pushState( null, '', historyEntry );
                        }
                        url = mw.util.wikiScript( 'api' ) + '?' + url;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2d71df4e9b252bbe4139be3afdf65ce076b21f49
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ApiSandbox
Gerrit-Branch: master
Gerrit-Owner: Amire80 <amir.ahar...@mail.huji.ac.il>

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

Reply via email to