Skip to content

Commit

Permalink
Changed indentation to 2; Resolved #7 and ddrdushy/FCC-Status/#15
Browse files Browse the repository at this point in the history
  • Loading branch information
kgashok committed May 30, 2016
1 parent 6e5e308 commit 9eb88f0
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 117 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
243 changes: 127 additions & 116 deletions src/js/gBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<table class="table" id="data"><tr><th>SNO</th><th>Avatar</th><th>Name</th><th>User Name</th><th>Points</th></tr>';
var html =
'<table class="table" id="data"><tr><th>SNO</th><th>Avatar</th><th>Name</th><th>User Name</th><th>Points</th></tr>';


$(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 = '<td>';
tempHtml += '<img src=' + image + ' class="img-thumbnail" width="100px" ></img></td>';
tempHtml += '<td>';
tempHtml += '<h3>' + name + '</h3></td>';
tempHtml += '<td>';
tempHtml += '<h3><a href="http://freecodecamp.com/' + uname + '" target="_blank">' + uname + '</a></h3></td>';
tempHtml += '<td>';
if (points === 0) {
tempHtml += '<h3><span class="label label-warning">' + points + '</span></h3></td>';
} else {
tempHtml += '<h3>' + points + '</h3></td>';
}

return tempHtml;
"use strict";

var tempHtml = '<td>';
tempHtml += '<img src=' + image +
' class="img-thumbnail" width="100px" ></img></td>';
tempHtml += '<td>';
tempHtml += '<h3>' + name + '</h3></td>';
tempHtml += '<td>';
tempHtml += '<h3><a href="http://freecodecamp.com/' + uname +
'" target="_blank">' + uname + '</a></h3></td>';
tempHtml += '<td>';
if (points === 0) {
tempHtml += '<h3><span class="label label-warning">' + points +
'</span></h3></td>';
} else {
tempHtml += '<h3>' + points + '</h3></td>';
}

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 '<tr><td>' + (j) + '</td>' + dataFormatter(a.avatar, a.name, a.uname, a.points) + '</tr>';
}).join('');
html += '</table>';
html += arr.map(function (a) {
j = j + 1;
return '<tr><td>' + (j) + '</td>' + dataFormatter(a.avatar, a
.name, a.uname, a.points) + '</tr>';
}).join('');
html += '</table>';

$("#data").html(html);
$("#data").html(html);

//var a = $("#data").html();
$("#campers").html('<h2><span class="label label-info">Total Campers:- ' + j + '</span></h2>');
$("#totalProblems").html('<h2><span class="label label-info">Total Problems:- ' + sum + '</span></h2>');
//var a = $("#data").html();
$("#campers").html(
'<h2><span class="label label-info">Total Campers:- ' + j +
'</span></h2>');
$("#totalProblems").html(
'<h2><span class="label label-info">Total Problems:- ' + sum +
'</span></h2>');

}


0 comments on commit 9eb88f0

Please sign in to comment.