diff options
-rw-r--r-- | db/queries.py | 36 | ||||
-rw-r--r-- | web/static/css/kill.ccss | 12 | ||||
-rw-r--r-- | web/static/js/kill.js | 35 |
3 files changed, 72 insertions, 11 deletions
diff --git a/db/queries.py b/db/queries.py index 436f041..6984f26 100644 --- a/db/queries.py +++ b/db/queries.py @@ -76,13 +76,47 @@ def kill(kill_id): else: attackers.append(char) - items = db.query(c, ''' + item_rows = db.query(c, ''' SELECT type_id, flag, dropped, destroyed, singleton, typeName AS item_name FROM items JOIN eve.invTypes ON type_id = typeID WHERE kill_id = ? ORDER BY flag ASC ''', kill_id) + items = {} + for item in item_rows: + flag = item['flag'] + if 125 <= flag <= 132: + slot = 'subsystem' + elif 27 <= flag <= 34: + slot = 'high' + elif 19 <= flag <= 26: + slot = 'medium' + elif 11 <= flag <= 18: + slot = 'low' + elif 92 <= flag <= 99: + slot = 'rig' + elif flag == 87: + slot = 'drone bay' + elif flag == 5: + slot = 'cargo' + elif 133 <= flag <= 143: + slot = 'special hold' + elif flag == 89: + slot = 'implant' + else: + slot = '???' + + if slot not in items: + items[slot] = {'dropped': {}, 'destroyed': {}} + if item['dropped']: + d = 'dropped' + else: + d = 'destroyed' + item_key = '{},{}'.format(item['type_id'], item['singleton']) + if item_key not in items[slot][d]: + items[slot][d][item_key] = [0, item['item_name']] + items[slot][d][item_key][0] += item[d] return { 'kill': kill, 'victim': victim, diff --git a/web/static/css/kill.ccss b/web/static/css/kill.ccss index e53ea0e..2ea2e38 100644 --- a/web/static/css/kill.ccss +++ b/web/static/css/kill.ccss @@ -25,3 +25,15 @@ table#attackers: white-space: normal &:nth-child(3): width: 50px + +table#items: + .slot: + background-color: #222 + tr:nth-child(odd): + background-color: #181818 + td:nth-child(3): + text-align: right + .dropped: + background-color: #050 + .destroyed: + color: #a00 diff --git a/web/static/js/kill.js b/web/static/js/kill.js index 1ef53a4..8fe142a 100644 --- a/web/static/js/kill.js +++ b/web/static/js/kill.js @@ -57,17 +57,32 @@ window.addEvent('domready', function() { }); 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']}) + var items = data['items']; + var slots = ['subsystem', 'high', 'medium', 'low', 'rig', 'drone bay', 'cargo', 'special hold', 'implant', '???']; + slots.each(function(slot) { + if (!items[slot]) + return; + table.grab(new Element('tr').grab( + new Element('td', {'html': slot, 'colspan': 3, 'class': 'slot'}) )); + var slot_items = items[slot]; + ['dropped', 'destroyed'].each(function(item_class) { + Object.each(slot_items[item_class], function(item, item_ids) { + var type_id = item_ids.split(',', 2)[0] + var item_name = item[1]; + var count = item[0]; + table.grab(new Element('tr').adopt( + new Element('td').grab( + new Element('img', { + 'src': '//image.eveonline.com/Type/' + type_id + '_32.png', + 'alt': item_name, + }) + ), + new Element('td', {'html': item_name}), + new Element('td', {'html': count, 'class': item_class}) + )); + }); + }); }); }); |