From 9eb88f052ed585dce504754be9c35686df41df8b Mon Sep 17 00:00:00 2001 From: kgashok Date: Tue, 31 May 2016 03:35:21 +0530 Subject: [PATCH] Changed indentation to 2; Resolved #7 and ddrdushy/FCC-Status/#15 --- Gruntfile.js | 2 +- src/js/gBot.js | 243 ++++++++++++++++++++++++++----------------------- 2 files changed, 128 insertions(+), 117 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index b8e6c50..2a672ce 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -6,7 +6,7 @@ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-contrib-jshint'); gruntConfig.jshint = { options: { bitwise: true, camelcase: true, curly: true, eqeqeq: true, forin: true, immed: true, - indent: 4, latedef: true, newcap: true, noarg: true, noempty: true, nonew: true, plusplus: true, + indent: 2, latedef: true, newcap: true, noarg: true, noempty: true, nonew: true, plusplus: true, quotmark: true, regexp: true, undef: true, unused: true, strict: true, trailing: true, maxparams: 3, maxdepth: 2, maxstatements: 50}, all: [ diff --git a/src/js/gBot.js b/src/js/gBot.js index 7f20afc..bdbfaeb 100644 --- a/src/js/gBot.js +++ b/src/js/gBot.js @@ -4,152 +4,163 @@ /*jslint latedef:false*/ /*jslint browser:true */ /*jshint maxparams: 5 */ +/*jshint indent: 2 */ var key = "ae28f23f134c4364ad45e7b7355cfa91c92038bb"; var arr = []; var points = 0; -var html = ''; +var html = + '
SNOAvatarNameUser NamePoints
'; $(document).ready(function () { - "use strict"; + "use strict"; + + var url = "https://api.gitter.im/v1/rooms?access_token=" + key; + var roomId = ""; + var noOfUsers = 0; + $.ajax({ + type: 'GET', + url: url, + //data:data, + async: false, + dataType: 'json', + success: function (data) { + //Do stuff with the JSON data + for (var i = 0; i < data.length; i = i + 1) { + if (data[i].name === 'kgisl/campsite') { + roomId = data[i].id; + noOfUsers = data[i].userCount; + break; + } + } + }, + error: function ( /* xhr, textStatus, errorThrown */ ) { + points = 0; + } + }); + var jsonData = []; - var url = "https://api.gitter.im/v1/rooms?access_token=" + key; - var roomId = ""; - var noOfUsers = 0; + + for (var i = 0; i < noOfUsers; i += 30) { $.ajax({ - type: 'GET', - url: url, - //data:data, - async: false, - dataType: 'json', - success: function (data) { - //Do stuff with the JSON data - for (var i = 0; i < data.length; i = i + 1) { - if (data[i].name === 'kgisl/campsite') { - roomId = data[i].id; - noOfUsers = data[i].userCount; - break; - } - } - }, - error: function ( /* xhr, textStatus, errorThrown */ ) { - points = 0; - } + type: 'GET', + url: 'https://api.gitter.im/v1/rooms/' + roomId + + '/users?access_token=' + key + '&skip=' + i, + //data:data, + async: false, + dataType: 'json', + success: function (data) { + $.merge(jsonData, data); + //alert(jsonData); + }, + error: function ( /* xhr, textStatus, errorThrown */ ) { + points = 0; + } }); - var jsonData = []; - - - for (var i = 0; i < noOfUsers; i += 30) { - $.ajax({ - type: 'GET', - url: 'https://api.gitter.im/v1/rooms/' + roomId + '/users?access_token=' + key + '&skip=' + i, - //data:data, - async: false, - dataType: 'json', - success: function (data) { - $.merge(jsonData, data); - //alert(jsonData); - }, - error: function ( /* xhr, textStatus, errorThrown */ ) { - points = 0; - } - }); - } - getData(jsonData); + } + getData(jsonData); }); function browniePointsFetcher(uname) { - "use strict"; - - var points = 0; - var url = 'https://www.freecodecamp.com/api/users/about?username=' + uname.toLowerCase(); - $.ajax({ - type: 'GET', - url: url, - //data:data, - async: false, - dataType: 'json', - success: function (data) { - //Do stuff with the JSON data - points = data.about.browniePoints; - }, - error: function ( /* xhr, textStatus, errorThrown */ ) { - points = 0; - } - }); - return points; + "use strict"; + + var points = 0; + var url = 'https://www.freecodecamp.com/api/users/about?username=' + + uname.toLowerCase(); + $.ajax({ + type: 'GET', + url: url, + //data:data, + async: false, + dataType: 'json', + success: function (data) { + //Do stuff with the JSON data + points = data.about.browniePoints; + }, + error: function ( /* xhr, textStatus, errorThrown */ ) { + points = 0; + } + }); + return points; } function dataFormatter(image, name, uname, points) { - "use strict"; - - var tempHtml = ''; - tempHtml += ''; - tempHtml += ''; - tempHtml += ''; - } else { - tempHtml += '

' + points + '

'; - } - - return tempHtml; + "use strict"; + + var tempHtml = ''; + tempHtml += ''; + tempHtml += ''; + tempHtml += ''; + } else { + tempHtml += '

' + points + '

'; + } + + return tempHtml; } function getData(jsonData) { - "use strict"; - - //alert(json["array"].length - var len = jsonData.length; - var sum = 0; - for (var i = 0; i < len; i = i + 1) { - if (jsonData[i].id !== '546fc9f1db8155e6700d6e8c' && - jsonData[i].id !== '5433c4b0163965c9bc209625' && - jsonData[i].id !== '570a6857187bb6f0eadec072') { - points = browniePointsFetcher(jsonData[i].username); - sum += points; - arr.push({ - avatar: jsonData[i].avatarUrlSmall, - name: jsonData[i].displayName, - uname: jsonData[i].username, - points: points - }); - - $('.progress-bar').css({ - width: (i / len) * 100 + '%' - }); - } + "use strict"; + + //alert(json["array"].length + var len = jsonData.length; + var sum = 0; + for (var i = 0; i < len; i = i + 1) { + if (jsonData[i].id !== '546fc9f1db8155e6700d6e8c' && + jsonData[i].id !== '5433c4b0163965c9bc209625' && + jsonData[i].id !== '570a6857187bb6f0eadec072') { + points = browniePointsFetcher(jsonData[i].username); + sum += points; + arr.push({ + avatar: jsonData[i].avatarUrlSmall, + name: jsonData[i].displayName, + uname: jsonData[i].username, + points: points + }); + + $('.progress-bar').css({ + width: (i / len) * 100 + '%' + }); } - $('.progress-bar').prop("hidden", true); + } + $('.progress-bar').prop("hidden", true); - arr.sort(function (a, b) { - return a.points - b.points; - }); + arr.sort(function (a, b) { + return a.points - b.points; + }); - arr.reverse(); - var j = 0; + arr.reverse(); + var j = 0; - html += arr.map(function (a) { - j = j + 1; - return '' + dataFormatter(a.avatar, a.name, a.uname, a.points) + ''; - }).join(''); - html += '
SNOAvatarNameUser NamePoints
'; - tempHtml += ''; - tempHtml += '

' + name + '

'; - tempHtml += '

' + uname + '

'; - if (points === 0) { - tempHtml += '

' + points + '

'; + tempHtml += ''; + tempHtml += '

' + name + '

'; + tempHtml += '

' + uname + '

'; + if (points === 0) { + tempHtml += '

' + points + + '

' + (j) + '
'; + html += arr.map(function (a) { + j = j + 1; + return '' + (j) + '' + dataFormatter(a.avatar, a + .name, a.uname, a.points) + ''; + }).join(''); + html += ''; - $("#data").html(html); + $("#data").html(html); - //var a = $("#data").html(); - $("#campers").html('

Total Campers:- ' + j + '

'); - $("#totalProblems").html('

Total Problems:- ' + sum + '

'); + //var a = $("#data").html(); + $("#campers").html( + '

Total Campers:- ' + j + + '

'); + $("#totalProblems").html( + '

Total Problems:- ' + sum + + '

'); } -