From b68a36e89ed31342a7eb5b98bd05706bbf942ec5 Mon Sep 17 00:00:00 2001 From: raylu Date: Sun, 20 Oct 2013 18:45:06 -0700 Subject: clean up kill page --- web/static/js/kill.js | 145 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 102 insertions(+), 43 deletions(-) (limited to 'web/static/js/kill.js') diff --git a/web/static/js/kill.js b/web/static/js/kill.js index 57c0a3f..1ef53a4 100644 --- a/web/static/js/kill.js +++ b/web/static/js/kill.js @@ -1,51 +1,110 @@ window.addEvent('domready', function() { var kill_id = document.location.pathname.split('/').getLast(); ykill.api('/kill/' + kill_id, function(data) { - var kill = data.kill; - $('kill_time').appendText(kill['kill_time']); - $('solar_system').appendText(kill['solarSystemName'] + ' (' + kill['security'].toFixed(1) + ')'); - - var div = $('characters'); - data.characters.each(function(char) { - div.adopt(new Element('img', { - 'src': '//image.eveonline.com/Character/' + char['character_id'] + '_64.jpg', - 'alt': char['character_name'], - })); - div.appendText(char['character_name']); - div.adopt(new Element('img', { - 'src': '//image.eveonline.com/Corporation/' + char['corporation_id'] + '_64.png', - 'alt': char['corporation_name'], - })); - div.appendText(char['corporation_name']); - if (char['alliance_id']) { - div.adopt(new Element('img', { - 'src': '//image.eveonline.com/Alliance/' + char['alliance_id'] + '_64.png', - 'alt': char['alliance_name'], - })); - div.appendText(char['alliance_name']); - } - div.adopt(new Element('img', { - 'src': '//image.eveonline.com/Type/' + char['ship_type_id'] + '_32.png', - 'alt': char['ship_name'], - })); - if (!char['victim']) { - div.adopt(new Element('img', { - 'src': '//image.eveonline.com/Type/' + char['weapon_type_id'] + '_32.png', - 'alt': char['weapon_name'], - })); - } - div.appendText(char['damage']); - div.adopt(new Element('br')); + var table = $('victim'); + var kill = data['kill']; + var victim = data['victim']; + table.adopt( + new Element('tr').adopt( + new Element('td', {'html': 'time'}), + new Element('td', {'html': kill['kill_time']}) + ), + new Element('tr').adopt( + new Element('td', {'html': 'system'}), + new Element('td', {'html': kill['solarSystemName'] + ' (' + kill['security'].toFixed(1) + ')'}) + ), + new Element('tr').adopt( + new Element('td').grab( + ykill.portrait(victim['character_id'], victim['character_name'], 'character', '_64.jpg') + ), + new Element('td', {'html': victim['character_name']}) + ), + new Element('tr').adopt( + new Element('td').grab( + ykill.portrait(victim['corporation_id'], victim['corporation_name'], 'corporation', '_64.png') + ), + new Element('td', {'html': victim['corporation_name']}) + ) + ); + if (victim['alliance_id']) + table.grab(new Element('tr').adopt( + new Element('td').grab( + ykill.portrait(victim['alliance_id'], victim['alliance_name'], 'alliance', '_64.png') + ), + new Element('td', {'html': victim['alliance_name']}) + )); + if (victim['faction_id']) + table.grab(new Element('tr').adopt( + new Element('td').grab( + ykill.portrait(victim['faction_id'], victim['faction_name'], 'faction', '_64.png') + ), + new Element('td', {'html': victim['faction_name']}) + )); + table.grab(new Element('tr').adopt( + new Element('td').grab( + ykill.portrait(victim['ship_type_id'], victim['ship_name'], 'type', '_64.png') + ), + new Element('td', {'html': victim['ship_name']}) + )); + + var div = $('ship'); + div.setStyle('background-image', 'url(//image.eveonline.com/render/' + victim['ship_type_id'] + '_256.png)'); + + table = $('attackers'); + show_attacker(table, data['final_blow']); + data['attackers'].each(function(char) { + show_attacker(table, char); }); - div = $('items'); - data.items.each(function(item) { - div.adopt(new Element('img', { - 'src': '//image.eveonline.com/Type/' + item['type_id'] + '_32.png', - 'alt': item['item_name'], - })); - div.appendText(item['item_name'] + ' (' + item['dropped'] + ',' + item['destroyed'] + ')'); - div.adopt(new Element('br')); + table = $('items'); + data['items'].each(function(item) { + table.grab(new Element('tr').adopt( + new Element('td').grab( + new Element('img', { + 'src': '//image.eveonline.com/Type/' + item['type_id'] + '_32.png', + 'alt': item['item_name'], + }) + ), + new Element('td', {'html': item['item_name']}), + new Element('td', {'html': item['dropped'] || item['destroyed']}) + )); }); }); + + function show_attacker(table, char) { + var tr = new Element('tr'); + + var td = new Element('td').adopt( + ykill.portrait(char['character_id'], char['character_name'], 'character', '_32.jpg'), + ykill.portrait(char['corporation_id'], char['corporation_name'], 'corporation', '_32.png') + ); + if (char['alliance_id']) + td.grab(ykill.portrait(char['alliance_id'], char['alliance_name'], 'alliance', '_32.png')); + if (char['faction_id']) + td.grab(ykill.portrait(char['faction_id'], char['faction_name'], 'faction', '_32.png')); + tr.grab(td); + + td = new Element('td'); + td.appendText(char['character_name']); + td.grab(new Element('br')); + td.appendText(char['corporation_name']); + if (char['alliance_id']) { + td.grab(new Element('br')); + td.appendText(char['alliance_name']); + } + if (char['faction_id']) { + td.grab(new Element('br')); + td.appendText(char['faction_name']); + } + tr.grab(td); + + td = new Element('td').adopt( + ykill.portrait(char['ship_type_id'], char['ship_name'], 'type', '_32.png'), + ykill.portrait(char['weapon_type_id'], char['weapon_name'], 'type', '_32.png') + ); + tr.grab(td); + tr.grab(new Element('td').appendText(char['damage'])); + + table.grab(tr); + } }); -- cgit v1.2.3