Skip to content

Commit

Permalink
Merge pull request #4 from pmitter/developer
Browse files Browse the repository at this point in the history
Fixed the top three ban stats in index page. v1.0 ready to release
  • Loading branch information
pmitter committed Feb 10, 2021
2 parents b04d795 + 9c42d0f commit 5fcfc8b
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 9 deletions.
15 changes: 8 additions & 7 deletions includes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ $.getJSON("./list.json",function(data){
var people_list ='';
var point=0;
var rows = (data.length)%3==0 ? Math.trunc(data.length/3) : Math.trunc(data.length/3)+1;
console.log(rows);
//console.log(rows);
for(let i=1;i<=rows;i++)
{
console.log("Row="+i);
//console.log("Row="+i);
people_list+='<div class="row">';
let count=1;
while(count<=3 && point<data.length)
{
people_list+='<div class="col-sm-4 mb-2" style="margin-top: 40px;">';
people_list+='<div id="card" class="card">';
//iMAGE
console.log("Image="+data[point].image);
//console.log("Image="+data[point].image);
people_list+='<img src="'+data[point].image+'" alt="John" style="width:100%">';
people_list+='<div class="container-fluid">';
people_list+='<br>';
Expand All @@ -24,7 +24,7 @@ $.getJSON("./list.json",function(data){
people_list+='<p id="title" class="title" style="font-size: 25px;"><i class="fas fa-times-circle" style="color: red;"></i> Banned from:</p>';
people_list+='<p align="center;">';
//List of banned websites
console.log("Length of Banned="+(data[point].banned).length);
//console.log("Length of Banned="+(data[point].banned).length);
for(let j=0;j<(data[point].banned).length;j++){
if(j==((data[point].banned).length-1))
{
Expand All @@ -51,16 +51,17 @@ $.getJSON("./list.json",function(data){
//without_logo+=without_logo.slice(0,-1);
without_logo=without_logo.slice(0,-7)+'</p>';
with_logo=with_logo.slice(0,-49)+'</p>';
console.log("With Logo ="+with_logo);
//console.log("With Logo ="+with_logo);
people_list+=without_logo;
people_list+=with_logo;
people_list+='</p>';
people_list+='<br>';
people_list+='</div>';
people_list+='</div>';
people_list+='</div>';

console.log("Count="+(count++)+" Point="+(point++));
count++;
point++;
//console.log("Count="+(count++)+" Point="+(point++));
}
people_list+='</div>';
}
Expand Down
63 changes: 61 additions & 2 deletions includes/top-three.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,69 @@
var obj = JSON.parse(localStorage.getItem('top-banned-list'));
console.log(obj[0].count);
//console.log("Obj= "+obj);

if(obj==null){
console.log("obj is null");
$.getJSON('list.json', function (data){
var bannedList = [];
for(let i=0;i<data.length;i++)
{
// Operation for banned list
for(let j=0;j<data[i].banned.length;j++)
{
if((bannedList.find(record => record.name === data[i].banned[j].name))!=undefined){
for(let k=0;k<bannedList.length;k++)
{
if(bannedList[k].name!= data[i].banned[j].name)
continue;
else{
bannedList[k].count+=1;
break;
}
}
}else{
bannedList.push({name:data[i].banned[j].name,logo:data[i].banned[j].logo,count:1});
}
}
}
//Sorting bannedList & availList

bannedList.sort(function (a,b){
return b.count - a.count;
})
console.table(bannedList);

obj = [{
name:bannedList[0].name,
count:bannedList[0].count
},
{
name:bannedList[1].name,
count:bannedList[1].count
},
{
name:bannedList[2].name,
count:bannedList[2].count
}
]

//console.log("OBJ ="+obj)
//console.log("End of the if")
var top_list='<div class="col-sm-4">'+'Banned from '+obj[0].name+':';
top_list+='<p><strong>'+obj[0].count+'</strong></p></div>';
top_list+='<div class="col-sm-4">'+'Banned from '+obj[1].name+':';
top_list+='<p><strong>'+obj[1].count+'</strong></p></div>';
top_list+='<div class="col-sm-4">'+'Banned from '+obj[2].name+':';
top_list+='<p><strong>'+obj[2].count+'</strong></p></div>';
$('#top-three').append(top_list);
})
}
else{
//console.log("Obj ="+obj);
var top_list='<div class="col-sm-4">'+'Banned from '+obj[0].name+':';
top_list+='<p><strong>'+obj[0].count+'</strong></p></div>';
top_list+='<div class="col-sm-4">'+'Banned from '+obj[1].name+':';
top_list+='<p><strong>'+obj[1].count+'</strong></p></div>';
top_list+='<div class="col-sm-4">'+'Banned from '+obj[2].name+':';
top_list+='<p><strong>'+obj[2].count+'</strong></p></div>';

$('#top-three').append(top_list);
}

0 comments on commit 5fcfc8b

Please sign in to comment.