kill.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. window.addEvent('domready', function() {
  2. var kill_id = document.location.pathname.split('/').getLast();
  3. ykill.api('/kill/' + kill_id, function(data) {
  4. var kill = data['kill'];
  5. var victim = data['victim'];
  6. document.title += ' - ' + victim['character_name'] + ' - ' + victim['ship_name'];
  7. var table = $('victim');
  8. table.adopt(
  9. new Element('tr').adopt(
  10. new Element('td', {'html': 'time'}),
  11. new Element('td', {'html': kill['kill_time']})
  12. ),
  13. new Element('tr').adopt(
  14. new Element('td', {'html': 'system'}),
  15. new Element('td', {'html': ykill.format_system(kill['system_name'], kill['security'], kill['security_status'])})
  16. ),
  17. new Element('tr').adopt(
  18. new Element('td').grab(
  19. ykill.portrait(victim['character_id'], victim['character_name'], 'character', '_64.jpg')
  20. ),
  21. new Element('td', {'html': victim['character_name']})
  22. ),
  23. new Element('tr').adopt(
  24. new Element('td').grab(
  25. ykill.portrait(victim['corporation_id'], victim['corporation_name'], 'corporation', '_64.png')
  26. ),
  27. new Element('td', {'html': victim['corporation_name']})
  28. )
  29. );
  30. if (victim['alliance_id'])
  31. table.grab(new Element('tr').adopt(
  32. new Element('td').grab(
  33. ykill.portrait(victim['alliance_id'], victim['alliance_name'], 'alliance', '_64.png')
  34. ),
  35. new Element('td', {'html': victim['alliance_name']})
  36. ));
  37. if (victim['faction_id'])
  38. table.grab(new Element('tr').adopt(
  39. new Element('td').grab(
  40. ykill.portrait(victim['faction_id'], victim['faction_name'], 'alliance', '_64.png')
  41. ),
  42. new Element('td', {'html': victim['faction_name']})
  43. ));
  44. table.grab(
  45. new Element('tr').adopt(
  46. new Element('td', {'html': 'cost'}),
  47. new Element('td', {'html': ykill.format_isk(kill['cost'])})
  48. )
  49. );
  50. var items = data['items'];
  51. var div = $('ship');
  52. div.setStyle('background-image', 'url(//image.eveonline.com/render/' + victim['ship_type_id'] + '_256.png)');
  53. Object.each(data['slots'], function(num, slot) {
  54. var divs = $(slot).getChildren();
  55. for (var i = 0; i < num; i++)
  56. divs[i].addClass('avail');
  57. if (!items[slot])
  58. return;
  59. items[slot].each(function(item) {
  60. var div = $('slot_' + item['flag']);
  61. var bg_img = div.getStyle('background-image');
  62. if (bg_img == 'none')
  63. set_item(div, item);
  64. else {
  65. var charge_div = $('charge_' + item['flag']);
  66. if (item['capacity']) {
  67. charge_div.setStyle('background-image', bg_img);
  68. charge_div.grab(div.getChildren()[0]);
  69. set_item(div, item);
  70. } else {
  71. set_item(charge_div, item);
  72. }
  73. }
  74. });
  75. });
  76. table = $('attackers');
  77. table.grab(new Element('tr').grab(
  78. new Element('td', {'class': 'attacker_type', 'colspan': 4, 'html': 'final blow'})
  79. ));
  80. show_attacker(table, data['final_blow']);
  81. if (data['attackers'].length) {
  82. table.grab(new Element('tr').grab(
  83. new Element('td', {'class': 'attacker_type', 'colspan': 4, 'html': 'attackers'})
  84. ));
  85. data['attackers'].each(function(char) {
  86. show_attacker(table, char);
  87. });
  88. }
  89. table = $('items');
  90. table.adopt(
  91. new Element('tr').grab(
  92. new Element('td', {'html': 'ship', 'colspan': 4, 'class': 'slot'})
  93. ),
  94. new Element('tr').adopt(
  95. new Element('td').grab(
  96. ykill.portrait(victim['ship_type_id'], victim['ship_name'], 'type', '_32.png')
  97. ),
  98. new Element('td', {'html': victim['ship_name']}),
  99. new Element('td'),
  100. new Element('td', {'html': ykill.format_isk(victim['ship_cost'])})
  101. )
  102. );
  103. var slots = [
  104. 'subsystem', 'high', 'medium', 'low', 'rig', 'drone bay',
  105. 'cargo', 'special hold', 'ship hangar', 'fleet hangar', 'implant', '???'
  106. ];
  107. slots.each(function(slot) {
  108. if (!items[slot])
  109. return;
  110. table.grab(new Element('tr').grab(
  111. new Element('td', {'html': slot, 'colspan': 4, 'class': 'slot'})
  112. ));
  113. if (slot == 'high') {
  114. var highs = {'dropped': {}, 'destroyed': {}};
  115. items[slot].each(function(item) {
  116. var d = item['dropped'] ? 'dropped' : 'destroyed';
  117. var count = item[d];
  118. if (highs[d][item['type_id']])
  119. highs[d][item['type_id']][d] += item[d];
  120. else
  121. highs[d][item['type_id']] = item;
  122. });
  123. items[slot] = [];
  124. Object.each(highs, function(item_class) {
  125. Object.each(item_class, function(item) {
  126. items[slot].push(item);
  127. });
  128. });
  129. }
  130. items[slot].each(function(item) {
  131. var type_id = item['type_id'];
  132. var item_name = item['item_name'];
  133. var item_class = item['dropped'] ? 'dropped' : 'destroyed';
  134. var count = item[item_class];
  135. var cost = item['cost'] * count;
  136. if (item['singleton'] == 2) {
  137. item_name += ' (copy)';
  138. cost /= 1000;
  139. }
  140. if (item['type_id'] == 33329 && item['flag'] == 89) // Genolution 'Auroral' AU-79 in implant slot
  141. cost = 'n/a';
  142. else
  143. cost = ykill.format_isk(cost);
  144. table.grab(new Element('tr').adopt(
  145. new Element('td').grab(
  146. new Element('img', {
  147. 'src': '//image.eveonline.com/Type/' + type_id + '_32.png',
  148. 'alt': item['item_name'],
  149. })
  150. ),
  151. new Element('td', {'html': item_name}),
  152. new Element('td', {'html': count, 'class': item_class}),
  153. new Element('td', {'html': cost})
  154. ));
  155. });
  156. });
  157. });
  158. function set_item(div, item) {
  159. div.setStyle('background-image', 'url(//image.eveonline.com/type/' + item['type_id'] + '_32.png)');
  160. div.grab(new Element('div', {'class': 'tooltip', 'html': item['item_name']}));
  161. }
  162. function show_attacker(table, char) {
  163. var tr = new Element('tr');
  164. var td = new Element('td');
  165. td.grab(ykill.portrait(char['character_id'], char['character_name'], 'character', '_32.jpg'));
  166. if (char['alliance_id'])
  167. td.grab(ykill.portrait(char['alliance_id'], char['alliance_name'], 'alliance', '_32.png'));
  168. else if (char['faction_id'])
  169. td.grab(ykill.portrait(char['faction_id'], char['faction_name'], 'alliance', '_32.png'));
  170. else
  171. td.grab(ykill.portrait(char['corporation_id'], char['corporation_name'], 'corporation', '_32.png'));
  172. tr.grab(td);
  173. td = new Element('td');
  174. td.appendText(char['character_name']);
  175. td.grab(new Element('br'));
  176. td.appendText(char['corporation_name']);
  177. if (char['alliance_id']) {
  178. td.grab(new Element('br'));
  179. td.appendText(char['alliance_name']);
  180. }
  181. if (char['faction_id']) {
  182. td.grab(new Element('br'));
  183. td.appendText(char['faction_name']);
  184. }
  185. tr.grab(td);
  186. td = new Element('td').adopt(
  187. ykill.portrait(char['ship_type_id'], char['ship_name'], 'type', '_32.png'),
  188. ykill.portrait(char['weapon_type_id'], char['weapon_name'], 'type', '_32.png')
  189. );
  190. tr.grab(td);
  191. tr.grab(new Element('td').appendText(char['damage'].toLocaleString()));
  192. table.grab(tr);
  193. }
  194. });