jenkins-bot has submitted this change and it was merged.

Change subject: Add npm entry point
......................................................................


Add npm entry point

Change-Id: If49cdfd2916a37659c8460c40242b16eef0d75fc
---
A .jshintignore
A .jshintrc
A Gruntfile.js
M apiExplorer.js
A package.json
5 files changed, 91 insertions(+), 16 deletions(-)

Approvals:
  Hashar: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/.jshintignore b/.jshintignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/.jshintignore
@@ -0,0 +1 @@
+node_modules
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..04c3a97
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,23 @@
+{
+       // Enforcing
+       "bitwise": true,
+       "eqeqeq": true,
+       "freeze": true,
+       "latedef": "nofunc",
+       "noarg": true,
+       "nonew": true,
+       "undef": true,
+       "unused": true,
+       "strict": false,
+
+       // Relaxing
+       "es5": false,
+
+       // Environment
+       "browser": true,
+       "jquery": true,
+
+       "globals": {
+               "mediaWiki": false
+       }
+}
diff --git a/Gruntfile.js b/Gruntfile.js
new file mode 100644
index 0000000..36b6671
--- /dev/null
+++ b/Gruntfile.js
@@ -0,0 +1,30 @@
+/*jshint node:true */
+module.exports = function ( grunt ) {
+       grunt.loadNpmTasks( 'grunt-contrib-jshint' );
+       grunt.loadNpmTasks( 'grunt-jsonlint' );
+       grunt.loadNpmTasks( 'grunt-banana-checker' );
+
+       grunt.initConfig( {
+               jshint: {
+                       options: {
+                               jshintrc: true
+                       },
+                       all: [
+                               '**/*.js',
+                               '!node_modules/**'
+                       ]
+               },
+               banana: {
+                       all: 'i18n/'
+               },
+               jsonlint: {
+                       all: [
+                               '**/*.json',
+                               '!node_modules/**'
+                       ]
+               }
+       } );
+
+       grunt.registerTask( 'test', [ 'jshint', 'jsonlint', 'banana' ] );
+       grunt.registerTask( 'default', 'test' );
+};
diff --git a/apiExplorer.js b/apiExplorer.js
index ee26d68..a71b9fa 100644
--- a/apiExplorer.js
+++ b/apiExplorer.js
@@ -6,9 +6,13 @@
  * for the same API.
  */
 
-$().log("== API Explorer ==");
+/*jshint -W083 */
 
-if(typeof ApiExplorer == "undefined"){
+( function ( $ ) {
+
+$().log("== API Explorer ==");
+var ApiExplorer;
+if(typeof ApiExplorer === "undefined"){
        ApiExplorer = function(){
                var self = this;
 
@@ -22,14 +26,16 @@
                        $('#apEx_loading').show();
 
                        // Make a request to the API to get the list of 
available modules, querymodules, and formats.
-                       Mediawiki.paraminfo('modules', 'paraminfo', 
function(result){
+                       mediaWiki.paraminfo('modules', 'paraminfo', 
function(result){
                                var params = 
result.paraminfo.modules[0].parameters;
                                for(var index in params){
                                        var param = params[index];
                                        if(param.type){
                                                var allTypes = [];
-                                               for(var typeIndex in 
param.type){
-                                                       var t = 
param.type[typeIndex];
+                                               var typeIndex;
+                                               var t;
+                                               for(typeIndex in param.type){
+                                                       t = 
param.type[typeIndex];
                                                        allTypes.push(t);
                                                }
                                                allTypes = allTypes.sort();
@@ -40,12 +46,12 @@
                                                        'querymodules': 
'querymodules',
                                                        'formatmodules': 
'formatmodules'
                                                };
-                                               if(typeof names[param.name] != 
'undefined'){
+                                               if(typeof names[param.name] !== 
'undefined'){
                                                        var name = param.name;
                                                        $('#apEx div.'+name+' 
h2.name').prepend( param.name ).data('module-name', param.name);
                                                        $('#apEx div.'+name+' 
div.description').html( param.description );
-                                                       for(var typeIndex in 
allTypes){
-                                                               var t = 
allTypes[typeIndex];
+                                                       for(typeIndex in 
allTypes){
+                                                               t = 
allTypes[typeIndex];
                                                                $('#apEx 
div.'+name+' dl').append("<dt class='collapsible collapsed'><h3 
data-param-name='"+t+"'>" + t + "<span class='toggleIcon'></span></h3></dt>");
                                                        }
 
@@ -62,7 +68,7 @@
 
                                                                        // Make 
call to API to get info for that dt... ONLY if the dd is still empty.
                                                                        var 
ddContent = $(e.currentTarget).find('dd').html();
-                                                                       
if(ddContent == "" || ddContent == null){
+                                                                       
if(ddContent === "" || ddContent === null){
                                                                                
// The dd (definition) for this dt (term) is not loaded yet.  Use the API to 
load it.
 
                                                                                
// TODO: Put a loading-indicator in the h3 and then remove when finished 
loading?
@@ -71,7 +77,7 @@
                                                                                
var dtName = $(e.currentTarget).find('h3').data('param-name');
                                                                                
$().log("Content is empty, loading info from API for " + paramName + '=' + 
dtName);
 
-                                                                               
Mediawiki.paraminfo(paramName, dtName, function(result){
+                                                                               
mediaWiki.paraminfo(paramName, dtName, function(result){
                                                                                
        $().log("Got info for "+ paramName + '=' + dtName);
                                                                                
        var modulesArray = result.paraminfo[paramName];
 
@@ -106,14 +112,15 @@
                 * isn't as simple/portable as it would be otherwise.
                 */
                this.objToHtml = function( obj ){
-                       var html = "";
-                       var html = "<ul>";
+                       var html;
+                       html = "";
+                       html = "<ul>";
 
                        // TODO: Customize this for better display of 
parameters, errors, etc. (they're too nested right now).
 
                        for(var key in obj){
                                var value = obj[key];
-                               if(typeof value == 'object'){
+                               if(typeof value === 'object'){
                                        value = self.objToHtml( value );
                                }
                                html += "<li><strong>"+key+"</strong>: " + 
value + "</li>";
@@ -122,9 +129,9 @@
                        return html;
                };
 
-               this.clicked_modules = function(e){ return self.dtClicked( e, 
'modules'); }
-               this.clicked_querymodules = function(e){ return self.dtClicked( 
e, 'querymodules'); }
-               this.clicked_formatmodules = function(e){ return 
self.dtClicked( e, 'formatmodules'); }
+               this.clicked_modules = function(e){ return self.dtClicked( e, 
'modules'); };
+               this.clicked_querymodules = function(e){ return self.dtClicked( 
e, 'querymodules'); };
+               this.clicked_formatmodules = function(e){ return 
self.dtClicked( e, 'formatmodules'); };
                this.dtClicked = function(e, paramName){
                        $().log("Got a click on " + paramName);
                        $().log(e);
@@ -136,3 +143,5 @@
        var apEx = new ApiExplorer();
        apEx.run();
 });
+
+}( jQuery ) );
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..ec97d7b
--- /dev/null
+++ b/package.json
@@ -0,0 +1,12 @@
+{
+  "scripts": {
+    "test": "grunt test"
+  },
+  "devDependencies": {
+    "grunt": "0.4.5",
+    "grunt-cli": "0.1.13",
+    "grunt-banana-checker": "0.4.0",
+    "grunt-contrib-jshint": "1.0.0",
+    "grunt-jsonlint": "1.0.7"
+  }
+}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If49cdfd2916a37659c8460c40242b16eef0d75fc
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/ApiExplorer
Gerrit-Branch: master
Gerrit-Owner: Paladox <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Paladox <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to