-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathspaitable.js
585 lines (565 loc) · 17 KB
/
spaitable.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
$(function() {
$.PACKAGED_VOLUMES = {
"Abaddon": 50000,
"Abaddon Kador Edition": 50000,
"Abaddon Tash-Murkon Edition": 50000,
"Absolution": 15000,
"Adrestia": 10000,
"Aeon": 1300000,
"Algos": 5000,
"Aliastra Catalyst": 5000,
"Amarr Media Shuttle": 500,
"Amarr Police Frigate": 2500,
"Amarr Shuttle": 500,
"Anathema": 2500,
"Anshar": 1300000,
"Apocalypse": 50000,
"Apocalypse Blood Raider Edition": 50000,
"Apocalypse Imperial Issue": 50000,
"Apocalypse Kador Edition": 50000,
"Apocalypse Navy Issue": 50000,
"Apocalypse Tash-Murkon Edition": 50000,
"Apotheosis": 500,
"Arazu": 10000,
"Arbitrator": 10000,
"Archon": 1300000,
"Ares": 2500,
"Ark": 1300000,
"Armageddon": 50000,
"Armageddon Imperial Issue": 50000,
"Armageddon Navy Issue": 50000,
"Ashimmu": 10000,
"Astarte": 15000,
"Astero": 2500,
"Atron": 2500,
"Augoror": 10000,
"Augoror Navy Issue": 10000,
"Avatar": 10000000,
"Badger": 20000,
"Bantam": 2500,
"Barghest": 50000,
"Basilisk": 10000,
"Bellicose": 10000,
"Bestower": 20000,
"Bestower Tash-Murkon Edition": 20000,
"Bhaalgorn": 50000,
"Bifrost": 5000,
"Blackbird": 10000,
"Blade": 2500,
"Bowhead": 1300000,
"Breacher": 2500,
"Broadsword": 10000,
"Brutix": 15000,
"Brutix Navy Issue": 15000,
"Brutix Serpentis Edition": 15000,
"Burst": 2500,
"Bustard": 20000,
"Buzzard": 2500,
"Caldari Media Shuttle": 500,
"Caldari Navy Hookbill": 2500,
"Caldari Shuttle": 500,
"Cambion": 2500,
"Capsule": 500,
"Capsule - Genolution 'Auroral' 197-variant": 500,
"Caracal": 10000,
"Caracal Navy Issue": 10000,
"Caracal Nugoeihuvi Edition": 10000,
"Caracal Wiyrkomi Edition": 10000,
"Catalyst": 5000,
"Catalyst Serpentis Edition": 5000,
"Celestis": 10000,
"Cerberus": 10000,
"Chameleon": 10000,
"Charon": 1300000,
"Cheetah": 2500,
"Chimera": 1300000,
"Chremoas": 2500,
"Civilian Amarr Shuttle": 500,
"Civilian Caldari Shuttle": 500,
"Civilian Gallente Shuttle": 500,
"Civilian Minmatar Shuttle": 500,
"Claw": 2500,
"Claymore": 15000,
"Cockroach": 2500,
"Coercer": 5000,
"Coercer Blood Raiders Edition": 5000,
"Concord Army Battleship": 50000,
"Concord Army Frigate": 2500,
"Concord Police Battleship": 50000,
"Concord Police Cruiser": 10000,
"Concord Police Frigate": 2500,
"Concord Special Ops Battleship": 50000,
"Concord Special Ops Frigate": 2500,
"Concord SWAT Battleship": 50000,
"Concord SWAT Frigate": 2500,
"Condor": 2500,
"Confessor": 5000,
"Corax": 5000,
"Cormorant": 5000,
"Cormorant Guristas Edition": 5000,
"Council Diplomatic Shuttle": 500,
"Covetor": 3750,
"Crane": 20000,
"Crow": 2500,
"Crucifier": 2500,
"Crucifier Navy Issue": 2500,
"Cruor": 2500,
"Crusader": 2500,
"Curse": 10000,
"Cyclone": 15000,
"Cyclone Thukker Tribe Edition": 15000,
"Cynabal": 10000,
"Dagger": 2500,
"Damnation": 15000,
"Daredevil": 2500,
"Deacon": 2500,
"Deimos": 10000,
"Devoter": 10000,
"Devourer": 2500,
"Dominix": 50000,
"Dominix Navy Issue": 50000,
"Dominix Quafe Edition": 50000,
"Dragoon": 5000,
"Drake": 15000,
"Drake Navy Issue": 15000,
"Dramiel": 2500,
"Eagle": 10000,
"Echelon": 2500,
"Echo": 2500,
"Endurance": 2500,
"Enyo": 2500,
"Eos": 15000,
"Epithal": 20000,
"Erebus": 10000000,
"Erinye": 2500,
"Eris": 5000,
"Etana": 10000,
"Executioner": 2500,
"Exequror": 10000,
"Exequror Navy Issue": 10000,
"Falcon": 10000,
"Federation Navy Comet": 2500,
"Fenrir": 1300000,
"Ferox": 15000,
"Ferox Guristas Edition": 15000,
"Fiend": 10000,
"Flycatcher": 5000,
"Freki": 2500,
"Fury": 2500,
"Gallente Media Shuttle": 500,
"Gallente Police Ship": 2500,
"Gallente Shuttle": 500,
"Garmur": 2500,
"Gatherer": 2500,
"Gila": 10000,
"Gnosis": 15000,
"Gold Magnate": 2500,
"Golem": 50000,
"Golem Guristas Edition": 50000,
"Golem Kaalakiota Edition": 50000,
"Golem Nugoeihuvi Edition": 50000,
"Goru's Shuttle": 500,
"Griffin": 2500,
"Griffin Navy Issue": 2500,
"Guardian": 10000,
"Guardian-Vexor": 10000,
"Guristas Shuttle": 500,
"Harbinger": 15000,
"Harbinger Navy Issue": 15000,
"Harpy": 2500,
"Hawk": 2500,
"Hecate": 5000,
"Hel": 1300000,
"Helios": 2500,
"Hematos": 2500,
"Heretic": 5000,
"Heron": 2500,
"Hoarder": 20000,
"Hound": 2500,
"Huginn": 10000,
"Hulk": 3750,
"Hurricane": 15000,
"Hurricane Fleet Issue": 15000,
"Hyena": 2500,
"Hyperion": 50000,
"Hyperion Aliastra Edition": 50000,
"Hyperion Inner Zone Shipping Edition": 50000,
"Ibis": 2500,
"Imicus": 2500,
"Immolator": 2500,
"Immovable Enigma": 2500,
"Imp": 2500,
"Impairor": 2500,
"Impel": 20000,
"Imperial Navy Slicer": 2500,
"Incursus": 2500,
"Incursus Aliastra Edition": 2500,
"Incursus Inner Zone Shipping Edition": 2500,
"Inner Zone Shipping Catalyst": 5000,
"Inner Zone Shipping Imicus": 2500,
"Inquisitor": 2500,
"Intaki Syndicate Catalyst": 5000,
"InterBus Catalyst": 5000,
"InterBus Shuttle": 500,
"Ishkur": 2500,
"Ishtar": 10000,
"Iteron Inner Zone Shipping Edition": 20000,
"Iteron Mark V": 20000,
"Jackdaw": 5000,
"Jaguar": 2500,
"Keres": 2500,
"Kestrel": 2500,
"Khanid Navy Frigate": 2500,
"Kirin": 2500,
"Kishar": 2500,
"Kitsune": 2500,
"Kronos": 50000,
"Kronos Inner Zone Shipping Edition": 50000,
"Kronos Police Edition": 50000,
"Kronos Quafe Edition": 50000,
"Kryos": 20000,
"Lachesis": 10000,
"Legion": 5000,
"Leopard": 500,
"Leviathan": 10000000,
"Loki": 5000,
"Lynx": 2500,
"Machariel": 50000,
"Mackinaw": 3750,
"Mackinaw ORE Development Edition": 3750,
"Maelstrom": 50000,
"Maelstrom Krusual Edition": 50000,
"Maelstrom Nefantar Edition": 50000,
"Magnate": 2500,
"Magus": 5000,
"Malediction": 2500,
"Malice": 2500,
"Maller": 10000,
"Mammoth": 20000,
"Mammoth Nefantar Edition": 20000,
"Manticore": 2500,
"Mastodon": 20000,
"Maulus": 2500,
"Maulus Navy Issue": 2500,
"Medusa": 2500,
"Megathron": 50000,
"Megathron Federate Issue": 50000,
"Megathron Inner Zone Shipping Edition": 50000,
"Megathron Navy Issue": 50000,
"Megathron Police Edition": 50000,
"Megathron Quafe Edition": 50000,
"Merlin": 2500,
"Merlin Nugoeihuvi Edition": 2500,
"Merlin Wiyrkomi Edition": 2500,
"Miasmos": 20000,
"Miasmos Amastris Edition": 20000,
"Miasmos Quafe Ultra Edition": 20000,
"Miasmos Quafe Ultramarine Edition": 20000,
"Mimir": 10000,
"Minmatar Media Shuttle": 500,
"Minmatar Peacekeeper Ship": 2500,
"Minmatar Shuttle": 500,
"Moa": 10000,
"Moracha": 10000,
"Mordus Frigate": 2500,
"Moros": 1300000,
"Moros Interbus Edition": 1300000,
"Muninn": 10000,
"Myrmidon": 15000,
"Naga": 15000,
"Naglfar": 1300000,
"Naglfar Justice Edition": 1300000,
"Nation": 1300000,
"Navitas": 2500,
"Nefantar Thrasher": 5000,
"Nemesis": 2500,
"Nereus": 20000,
"Nestor": 50000,
"Nidhoggur": 1300000,
"Nighthawk": 15000,
"Nightmare": 50000,
"Noctis": 20000,
"Nomad": 1300000,
"Nyx": 1300000,
"Obelisk": 1300000,
"Occator": 20000,
"Omen": 10000,
"Omen Kador Edition": 10000,
"Omen Navy Issue": 10000,
"Omen Tash-Murkon Edition": 10000,
"Oneiros": 10000,
"Onyx": 10000,
"Opux Dragoon Yacht": 10000,
"Opux Luxury Yacht": 10000,
"Oracle": 15000,
"Orca": 500000,
"Orca ORE Development Edition": 500000,
"Orthrus": 10000,
"Osprey": 10000,
"Osprey Navy Issue": 10000,
"Paladin": 50000,
"Paladin Blood Raider Edition": 50000,
"Paladin Kador Edition": 50000,
"Paladin Tash-Murkon Edition": 50000,
"Panther": 50000,
"Phantasm": 10000,
"Phobos": 10000,
"Phoenix": 1300000,
"Phoenix Wiyrkomi Edition": 1300000,
"Pilgrim": 10000,
"Polaris Centurion Frigate": 2500,
"Polaris Centurion TEST": 2500,
"Polaris Enigma Frigate": 2500,
"Polaris Inspector Frigate": 2500,
"Polaris Legatus Frigate": 2500,
"Police Pursuit Comet": 2500,
"Pontifex": 5000,
"Primae": 20000,
"Probe": 2500,
"Procurer": 3750,
"Prophecy": 15000,
"Prophecy Blood Raiders Edition": 15000,
"Prorator": 20000,
"Prospect": 2500,
"Proteus": 5000,
"Providence": 1300000,
"Prowler": 20000,
"Punisher": 2500,
"Punisher Kador Edition": 2500,
"Punisher Tash-Murkon Edition": 2500,
"Purifier": 2500,
"Quafe Catalyst": 5000,
"Ragnarok": 10000000,
"Rapier": 10000,
"Raptor": 2500,
"Rattlesnake": 50000,
"Rattlesnake Victory Edition": 50000,
"Raven": 50000,
"Raven Guristas Edition": 50000,
"Raven Kaalakiota Edition": 50000,
"Raven Navy Issue": 50000,
"Raven Nugoeihuvi Edition": 50000,
"Raven State Issue": 50000,
"Reaper": 2500,
"Redeemer": 50000,
"Republic Fleet Firetail": 2500,
"Retribution": 2500,
"Retriever": 3750,
"Revelation": 1300000,
"Revelation Sarum Edition": 1300000,
"Revenant": 1300000,
"Rhea": 1300000,
"Rifter": 2500,
"Rifter Krusual Edition": 2500,
"Rifter Nefantar Edition": 2500,
"Rokh": 50000,
"Rokh Nugoeihuvi Edition": 50000,
"Rokh Wiyrkomi Edition": 50000,
"Rook": 10000,
"Rorqual": 1300000,
"Rorqual ORE Development Edition": 1300000,
"Rupture": 10000,
"Sabre": 5000,
"Sacrilege": 10000,
"Sarum Magnate": 2500,
"Scalpel": 2500,
"Scimitar": 10000,
"Scorpion": 50000,
"Scorpion Ishukone Watch": 50000,
"Scorpion Navy Issue": 50000,
"Scythe": 10000,
"Scythe Fleet Issue": 10000,
"Sentinel": 2500,
"Sigil": 20000,
"Silver Magnate": 2500,
"Sin": 50000,
"Skiff": 3750,
"Slasher": 2500,
"Sleipnir": 15000,
"SOCT 1": 2500,
"SOCT 2": 2500,
"Stabber": 10000,
"Stabber Fleet Issue": 10000,
"Stabber Krusual Edition": 10000,
"Stabber Nefantar Edition": 10000,
"Stiletto": 2500,
"Stork": 5000,
"Stratios": 10000,
"Stratios Emergency Responder": 10000,
"Succubus": 2500,
"Sukuuvestaa Heron": 2500,
"Svipul": 5000,
"Swordspine": 2500,
"Taipan": 2500,
"Talos": 15000,
"Talwar": 5000,
"Taranis": 2500,
"Tash-Murkon Magnate": 2500,
"Tayra": 20000,
"Tayra Wiyrkomi Edition": 20000,
"Tempest": 50000,
"Tempest Fleet Issue": 50000,
"Tempest Justice Edition": 50000,
"Tempest Krusual Edition": 50000,
"Tempest Nefantar Edition": 50000,
"Tempest Tribal Issue": 50000,
"Tengu": 5000,
"Thalia": 2500,
"Thanatos": 1300000,
"Thorax": 10000,
"Thorax Aliastra Edition": 10000,
"Thorax Inner Zone Shipping Edition": 10000,
"Thrasher": 5000,
"Thrasher Thukker Tribe Edition": 5000,
"Tormentor": 2500,
"Tornado": 15000,
"Tristan": 2500,
"Tristan Quafe Edition": 2500,
"Typhoon": 50000,
"Typhoon Fleet Issue": 50000,
"Utu": 2500,
"Vagabond": 10000,
"Vangel": 10000,
"Vargur": 50000,
"Vargur Justice Edition": 50000,
"Vargur Krusual Edition": 50000,
"Vargur Nefantar Edition": 50000,
"Velator": 2500,
"Vengeance": 2500,
"Venture": 2500,
"Vexor": 10000,
"Vexor Navy Issue": 10000,
"Vexor Quafe Edition": 10000,
"Vherokior Probe": 2500,
"Viator": 20000,
"Victorieux Luxury Yacht": 10000,
"Vigil": 2500,
"Vigil Fleet Issue": 2500,
"Vigilant": 10000,
"Vindicator": 50000,
"Violator": 2500,
"Vulture": 15000,
"Whiptail": 2500,
"Widow": 50000,
"Wolf": 2500,
"Worm": 2500,
"Wreathe": 20000,
"Wyvern": 1300000,
"Zealot": 10000,
"Zephyr": 500
};
$.COLLAT_AMOUNT = 0.02;
$.C4C_COST = 400;
$.JITA_COST = 300;
$.LOCAL_FADE_COST = 100;
// Put the commas back when we click on something else
$.formatNumber = function (str) {
var x = str.split('.');
var x1 = x[0]; x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
};
// Decimal points, but nothing else for simple copy-pasting
$.formatNumberToString = function (num) {
return $.formatNumber(num.toFixed(2).toString());
};
$.shipmentVolume = function() {
var rawVolume = $('th :nth-child(5)').text();
return parseFloat(rawVolume.substr(0, rawVolume.length - 2).replace(/[^\d\.]/g,''));
}
//Check for packageable ships
$.isPackageableShips = function() {
return $('.line-item-row').is(function(i, v) {
return $.itemIsPackable($(v).children(":nth-child(2)").text().trim());
});
};
$.itemIsPackable = function(name) {
return $.PACKAGED_VOLUMES.hasOwnProperty(name);
};
//Calculate packaged ship volumes and update the results
$.computePackagedVolumes = function() {
var totalunPackagedVolume = 0.0;
var totalPackagedVolume = 0.0;
$('.line-item-row').each(function(i, v) {
var shipName = $(v).children(":nth-child(2)").text().trim();
if($.itemIsPackable(shipName)) {
var quantity = parseFloat($(v).children(":nth-child(1)").text().replace(/,/g,""));
var unPackagedVolume = parseFloat($(v).children(":nth-child(3)").text().replace(/,/g,""));
var packagedVolume = $.PACKAGED_VOLUMES[shipName];
totalunPackagedVolume += unPackagedVolume * quantity;
totalPackagedVolume += packagedVolume * quantity;
var sellAmount = parseFloat($(v).children(":nth-child(4)").children(":nth-child(1)").text().replace(/,/g,""));
var buyAmount = parseFloat($(v).children(":nth-child(4)").children(":nth-child(3)").text().replace(/,/g,""));
var iskDensitySell = sellAmount/packagedVolume;
var iskDensityBuy = buyAmount/packagedVolume;
//Replace volume
$(v).children(":nth-child(3)").text($.formatNumberToString(packagedVolume));
//Replace density
$(v).children(":nth-child(6)").html($.formatNumberToString(iskDensitySell) + "<br/>" + $.formatNumberToString(iskDensityBuy));
}
});
//Update total volume
var totalVolume = $.shipmentVolume() - totalunPackagedVolume + totalPackagedVolume;
$('th :nth-child(5)').html($.formatNumberToString(totalVolume) + "m<sup>3</sup>");
//Update the warning
$('#ships-warning h4').text("PACKAGED SHIPS");
//Hide the button
$('#package-toggle').hide();
//Recompute the costs
$.computeShippingCosts();
};
// Compute shipping costs based on the volume and pricing currently in the results
$.computeShippingCosts = function() {
var sellValue = parseFloat($('th .nowrap:nth-child(1)').html().replace(/,/g,''));
var buyValue = parseFloat($('th :nth-child(3)').html().replace(/,/g,''));
var volume = $.shipmentVolume();
var sellCollat = sellValue * $.COLLAT_AMOUNT;
var buyCollat = buyValue * $.COLLAT_AMOUNT;
$('#c4cNoCollatReward').text($.formatNumberToString(volume * $.C4C_COST));
$('#c4cSellReward').text($.formatNumberToString(volume * $.C4C_COST + sellCollat));
$('#c4cBuyReward').text($.formatNumberToString(volume * $.C4C_COST + buyCollat));
$('#jitaNoCollatReward').text($.formatNumberToString(volume * $.JITA_COST));
$('#jitaSellReward').text($.formatNumberToString(volume * $.JITA_COST + sellCollat));
$('#jitaBuyReward').text($.formatNumberToString(volume * $.JITA_COST + buyCollat));
$('#localFadeNoCollatReward').text($.formatNumberToString(volume * $.LOCAL_FADE_COST));
$('#localFadeSellReward').text($.formatNumberToString(volume * $.LOCAL_FADE_COST + sellCollat));
$('#localFadeBuyReward').text($.formatNumberToString(volume * $.LOCAL_FADE_COST + buyCollat));
$('.sellAmount').each(function(i, val){
$(val).text($.formatNumberToString(sellValue));
});
$('.buyAmount').each(function(i, val){
$(val).text($.formatNumberToString(buyValue));
});
}
$('.copyable').click(function() {
$(this).text(parseFloat($(this).text().replace(/,/g,'')));
var range, selection;
if (window.getSelection && document.createRange) {
selection = window.getSelection();
range = document.createRange();
range.selectNodeContents(this);
selection.removeAllRanges();
selection.addRange(range);
} else if (document.selection && document.body.createTextRange) {
range = document.body.createTextRange();
range.moveToElementText(this);
range.select();
}
var currentElement = this;
$('.copyable').each(function(i, v){
if(v != currentElement) {
$(v).text($.formatNumber($(this).text()));
}
});
});
$('#package-toggle').click($.computePackagedVolumes);
// Once everything is set up, we need to actually compute it.
$.computeShippingCosts();
if($.isPackageableShips()) {
$('#package-toggle').show();
$('#ships-warning').show();
}
});