hello guys i just basically saw some good website who alrdy combined 9 servers tables in 1 table including all votes from all server which is something perfect and i tried to do but i can't seem to work it out ! so
the links of tables i have are
https://ark-servers.net/api/?object=servers&element=voters&key=jwoy226r9qo29rxid0a9vg65pno4s9bsf29&month=current&format=json
https://ark-servers.net/api/?object=servers&element=voters&key=4knryax7ibqp789k3tzjjjbmkxkl5ns9dh&month=current&format=json
https://ark-servers.net/api/?object=servers&element=voters&key=7w41ryvms91repwbef222ccqsnoutiurray&month=current&format=json
And i basically want these 3 tables there to be all in 1 table combined with all counts
Lets say Target 1 Had on the first link 50 vote and on the second link 30 vote and the third 1 that makes it overall 81 Please someone help me solve that i would be appreciated!
this was the java code i used
the links of tables i have are
https://ark-servers.net/api/?object=servers&element=voters&key=jwoy226r9qo29rxid0a9vg65pno4s9bsf29&month=current&format=json
https://ark-servers.net/api/?object=servers&element=voters&key=4knryax7ibqp789k3tzjjjbmkxkl5ns9dh&month=current&format=json
https://ark-servers.net/api/?object=servers&element=voters&key=7w41ryvms91repwbef222ccqsnoutiurray&month=current&format=json
And i basically want these 3 tables there to be all in 1 table combined with all counts
Lets say Target 1 Had on the first link 50 vote and on the second link 30 vote and the third 1 that makes it overall 81 Please someone help me solve that i would be appreciated!
this was the java code i used
- Code:
<script>
var votingURLs = [
'https://ark-servers.net/api/?object=servers&element=voters&key=jwoy226r9qo29rxid0a9vg65pno4s9bsf29&month=current&format=json',
'https://ark-servers.net/api/?object=servers&element=voters&key=4knryax7ibqp789k3tzjjjbmkxkl5ns9dh&month=current&format=json',
'https://ark-servers.net/api/?object=servers&element=voters&key=7w41ryvms91repwbef222ccqsnoutiurray&month=current&format=json',
];
var votingLists = [];
var counter = 0;
var finalList = [];
var voters = [];
var votesOfVoters = [];
$(document).ready(function () {
$.each(votingURLs, function( index, value ) {
var data;
$.ajax({
dataType: "json",
url: value,
data: data,
success: function (data) {
console.log(data.voters);
votingLists[index] = data.voters;
checkCompleteness();
}
});
});
});
function checkCompleteness(){
counter++;
if(counter==(votingURLs.length)){
evalData();
}
}
function evalData(){
console.log("Start Evaluating");
finalList = votingLists[0];
$.each(votingLists, function(index, list){
if(index > 0){
$.each(list, function(index, value){
var name = value.nickname;
var found = false;
$.each(finalList, function(indexF, valueF){
if(name == valueF.nickname){
valueF.votes = parseInt(valueF.votes) + parseInt(value.votes);
found = true;
return false;
}
});
//If not found, add it to the list
if(!found){
finalList.push(value);
}
});
}
});
displayingList(finalList);
}
function displayingList(list){
console.log("Start Displaying");
list.sort(function(a,b) {
return parseInt(b.votes,10) - parseInt(a.votes,10);
});
$.each(list, function(index, value){
var row = '<tr> <td>' + value.nickname + '</td> <td> ' + value.votes + '</td> </tr>';
$('table[data="votingList"] tbody').append(row);
});
}
</script>