Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix system_killboard.js for new JSON format #536

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 70 additions & 10 deletions js/app/ui/system_killboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,25 @@ define([

let killData = killMailData[j];

let linkUrl = '//zkillboard.com/kill/' + killData.killID + '/';
let victimImageUrl = Init.url.ccpImageServer + 'Type/' + killData.victim.shipTypeID + '_64.png';
let killDate = getDateObjectByTimeString(killData.killTime);
let linkUrl = '//zkillboard.com/kill/' + killData.killmail_id + '/';
let victimImageUrl = Init.url.ccpImageServer + 'Type/' + killData.victim.ship_type_id + '_64.png';
let killDate = getDateObjectByTimeString(killData.killmail_time);
let killDateString = Util.convertDateToString(killDate);
let killLossValue = Util.formatPrice( killData.zkb.totalValue );

// check for ally
let victimAllyLogoUrl = '';
let displayAlly = 'none';
if(killData.victim.allianceID > 0){
victimAllyLogoUrl = Init.url.ccpImageServer + 'Alliance/' + killData.victim.allianceID + '_32.png';
if(killData.victim.alliance_id > 0){
victimAllyLogoUrl = Init.url.ccpImageServer + 'Alliance/' + killData.victim.alliance_id + '_32.png';
displayAlly = 'block';
}

// check for corp
let victimCorpLogoUrl = '';
let displayCorp = 'none';
if(killData.victim.corporationID > 0){
victimCorpLogoUrl = Init.url.ccpImageServer + 'Corporation/' + killData.victim.corporationID + '_32.png';
if(killData.victim.corporation_id > 0){
victimCorpLogoUrl = Init.url.ccpImageServer + 'Corporation/' + killData.victim.corporation_id + '_32.png';
displayCorp = 'inline';
}

Expand Down Expand Up @@ -342,8 +342,11 @@ define([
// loop kills and count kills by hour
for (let i = 0; i < kbData.length; i++) {
let killmailData = kbData[i];

let killDate = getDateObjectByTimeString(killmailData.killTime);
killmailData.victim.characterName = getPlayerNameByID(killmailData.victim.character_id);
killmailData.victim.corporationName = getCorpNameByID(killmailData.victim.corporation_id);
killmailData.victim.allianceName = getAllianceNameByID(killmailData.victim.alliance_id);

let killDate = getDateObjectByTimeString(killmailData.killmail_time);

// get time diff
let timeDiffMin = Math.round(( serverDate - killDate ) / 1000 / 60);
Expand Down Expand Up @@ -431,6 +434,63 @@ define([

return date;
};

/**
* Get PlayerName with CCP ESI API
* @param playerID
* @returns {String}
*/
let getPlayerNameByID = function(playerID){
let playerName;
$.ajax({
url: '//esi.tech.ccp.is/latest/characters/' + playerID + '/?datasource=tranquility',
type: "POST",
async: false, // Mode synchrone
dataType: "json",
complete: function(data){
playerName = data.responseJSON.name;
}
});
return playerName;
};

/**
* Get CorpName with CCP ESI API
* @param corpID
* @returns {String}
*/
let getCorpNameByID = function(corpID){
let corpName;
$.ajax({
url: '//esi.tech.ccp.is/latest/corporations/' + corpID + '/?datasource=tranquility',
type: "POST",
async: false, // Mode synchrone
dataType: "json",
complete: function(data){
corpName = data.responseJSON.corporation_name;
}
});
return corpName;
};

/**
* Get AllianceName with CCP ESI API
* @param allianceID
* @returns {String}
*/
let getAllianceNameByID = function(allianceID){
let allianceName;
$.ajax({
url: '//esi.tech.ccp.is/latest/alliances/' + allianceID + '/?datasource=tranquility',
type: "POST",
async: false, // Mode synchrone
dataType: "json",
complete: function(data){
allianceName = data.responseJSON.name;
}
});
return allianceName;
};

/**
* get module element
Expand Down Expand Up @@ -491,4 +551,4 @@ define([
}

};
});
});