forked from ddrdushy/FCC-Status
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed jshint issues except in Gruntfile.js
- Loading branch information
Showing
2 changed files
with
108 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,138 +1,155 @@ | ||
'use strict'; | ||
/*global $:false */ | ||
/*jshint quotmark: false */ | ||
/*jshint loopfunc: true */ | ||
/*jslint latedef:false*/ | ||
/*jslint browser:true */ | ||
/*jshint maxparams: 5 */ | ||
|
||
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 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>'; | ||
|
||
$(document).ready(function(){ | ||
var url='https://api.gitter.im/v1/rooms?access_token='+key; | ||
var roomId=""; | ||
var noOfUsers=0; | ||
|
||
$(document).ready(function () { | ||
"use strict"; | ||
|
||
var url = "https://api.gitter.im/v1/rooms?access_token=" + key; | ||
var roomId = ""; | ||
var noOfUsers = 0; | ||
$.ajax({ | ||
type:'GET', | ||
url:url, | ||
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++){ | ||
if(data[i].name=='kgisl/campsite'){ | ||
roomId=data[i].id; | ||
noOfUsers=data[i].userCount; | ||
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; | ||
error: function ( /* xhr, textStatus, errorThrown */ ) { | ||
points = 0; | ||
} | ||
}); | ||
var jsonData=[]; | ||
var jsonData = []; | ||
|
||
|
||
for(var i=0;i<noOfUsers;i+=30){ | ||
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, | ||
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); | ||
$.merge(jsonData, data); | ||
//alert(jsonData); | ||
}, | ||
error:function(/* xhr, textStatus, errorThrown */){ | ||
points=0; | ||
error: function ( /* xhr, textStatus, errorThrown */ ) { | ||
points = 0; | ||
} | ||
}); | ||
} | ||
getData(jsonData); | ||
}); | ||
|
||
function getData(jsonData){ | ||
|
||
//alert(json["array"].length | ||
var len=jsonData.length; | ||
var sum=0; | ||
for(var i=0;i<len;i++){ | ||
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); | ||
|
||
function browniePointsFetcher(uname) { | ||
"use strict"; | ||
|
||
arr.sort(function(a,b){ | ||
return a.points- b.points; | ||
}); | ||
|
||
arr.reverse(); | ||
var j=0; | ||
|
||
|
||
html+=arr.map(function (a) { | ||
j++; | ||
return '<tr><td>'+(j)+'</td>'+dataFormatter(a.avatar, a.name, a.uname, a.points)+'</tr>'; | ||
}).join(''); | ||
html+='</table>'; | ||
|
||
$("#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>'); | ||
|
||
} | ||
|
||
function browniePointsFetcher(uname){ | ||
var points=0; | ||
var url='https://www.freecodecamp.com/api/users/about?username='+uname.toLowerCase(); | ||
var points = 0; | ||
var url = 'https://www.freecodecamp.com/api/users/about?username=' + uname.toLowerCase(); | ||
$.ajax({ | ||
type:'GET', | ||
url:url, | ||
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 */){ | ||
error: function ( /* xhr, textStatus, errorThrown */ ) { | ||
points = 0; | ||
} | ||
}); | ||
return points; | ||
} | ||
|
||
|
||
function dataFormatter(image,name,uname,points){ | ||
var temp_html='<td>'; | ||
temp_html+='<img src='+image+' class="img-thumbnail" width="100px" ></img></td>'; | ||
temp_html+='<td>'; | ||
temp_html+='<h3>'+name+'</h3></td>'; | ||
temp_html+='<td>'; | ||
temp_html+='<h3><a href="http://freecodecamp.com/'+uname+'" target="_blank">'+uname+'</a></h3></td>'; | ||
temp_html+='<td>'; | ||
if(points===0){ | ||
temp_html+='<h3><span class="label label-warning">'+points+'</span></h3></td>'; | ||
}else{ | ||
temp_html+='<h3>'+points+'</h3></td>'; | ||
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; | ||
} | ||
|
||
|
||
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 + '%' | ||
}); | ||
} | ||
} | ||
$('.progress-bar').prop("hidden", true); | ||
|
||
|
||
arr.sort(function (a, b) { | ||
return a.points - b.points; | ||
}); | ||
|
||
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>'; | ||
|
||
$("#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>'); | ||
|
||
return temp_html; | ||
} | ||
|
||
|