5
5
// ` used whenever interpolation is required
6
6
'use strict' ;
7
7
// config stuff ( can be overridden in a script block or js file of your choice )
8
- var eveui_user_agent = eveui_user_agent || 'For source website, see referrer. For library, see https://github.com/quiescens/eve-ui/ r:' + `0.9.3` ;
8
+ var eveui_user_agent = eveui_user_agent || 'For source website, see referrer. For library, see https://github.com/quiescens/eve-ui/ r:' + `0.9.4` ;
9
+ var eveui_accept_language = eveui_accept_language ;
9
10
var eveui_preload_initial = eveui_preload_initial || 50 ;
10
11
var eveui_preload_interval = eveui_preload_interval || 10 ;
11
12
var eveui_mode = eveui_mode || 'multi_window' ; // expand_all, expand, multi_window, modal
@@ -14,9 +15,11 @@ var eveui_fit_selector = eveui_fit_selector || '[href^="fitting:"],[data-dna]';
14
15
var eveui_item_selector = eveui_item_selector || '[href^="item:"],[data-itemid]' ;
15
16
var eveui_char_selector = eveui_char_selector || '[href^="char:"],[data-charid]' ;
16
17
var eveui_corp_selector = eveui_corp_selector || '[href^="corp:"],[data-corpid]' ;
17
- var eveui_use_osmium = eveui_use_osmium || false ;
18
+ var eveui_esi_endpoint = eveui_esi_endpoint || function ( path ) {
19
+ return 'https://esi.evetech.net' + path ;
20
+ } ;
18
21
var eveui_urlify = eveui_urlify || function ( dna ) {
19
- return 'https://o.smium.org/loadout/dna/ ' + encodeURI ( dna ) ;
22
+ return 'fitting: ' + encodeURI ( dna ) ;
20
23
} ;
21
24
var eveui_imageserver = eveui_imageserver || function ( image_ref ) {
22
25
if ( image_ref . startsWith ( 'Character' ) ) {
@@ -259,29 +262,26 @@ var eveui;
259
262
}
260
263
let request_timestamp = performance . now ( ) ;
261
264
// get item ids that match input
262
- $ . ajax ( {
263
- url : `https://esi.tech.ccp.is/ v1/search/`,
265
+ ajax ( {
266
+ url : eveui_esi_endpoint ( `/ v1/search/`) ,
264
267
cache : true ,
265
268
data : {
266
- user_agent : eveui_user_agent ,
267
269
search : $ ( this ) . val ( ) ,
268
270
categories : 'inventorytype'
269
271
}
270
272
} ) . done ( function ( data ) {
271
273
if ( typeof ( data . inventorytype ) === 'undefined' ) {
272
274
return ;
273
275
}
274
- let arg = {
275
- user_agent : eveui_user_agent ,
276
- ids : data . inventorytype . slice ( 0 , 50 )
277
- } ;
278
276
// get names for required item ids
279
- $ . ajax ( {
280
- url : `https://esi.tech.ccp.is/ v1/universe/names/`,
277
+ ajax ( {
278
+ url : eveui_esi_endpoint ( `/ v1/universe/names/`) ,
281
279
cache : true ,
282
280
method : 'POST' ,
283
281
contentType : 'application/json' ,
284
- data : JSON . stringify ( arg )
282
+ data : JSON . stringify ( {
283
+ ids : data . inventorytype . slice ( 0 , 50 )
284
+ } )
285
285
} ) . done ( function ( data ) {
286
286
if ( request_timestamp > itemselect_lastupdate ) {
287
287
itemselect_lastupdate = request_timestamp ;
@@ -367,12 +367,10 @@ var eveui;
367
367
mark ( 'event handlers set' ) ;
368
368
function eve_version_query ( ) {
369
369
mark ( 'eve version request' ) ;
370
- $ . ajax ( `https://esi.tech.ccp.is/v1/status/` , {
370
+ ajax ( {
371
+ url : eveui_esi_endpoint ( `/v1/status/` ) ,
371
372
dataType : 'json' ,
372
373
cache : true ,
373
- data : {
374
- user_agent : eveui_user_agent
375
- }
376
374
} ) . done ( function ( data ) {
377
375
eve_version = data . server_version ;
378
376
mark ( 'eve version response ' + eve_version ) ;
@@ -541,7 +539,7 @@ var eveui;
541
539
}
542
540
return html ;
543
541
}
544
- let html = `<span class="float_right"><eveui type="osmium" key="${ dna } " /></span><table class="eveui_fit_table"><thead><tr class="eveui_fit_header" data-eveui-itemid="${ ship_id } "><td colspan="2"><img src="${ eveui_imageserver ( 'Type/' + ship_id + '_32' ) } " class="eveui_icon eveui_ship_icon" /><td><div class="eveui_rowcontent"><span class="eveui_startcopy" />[<a target="_blank" href="${ eveui_urlify ( dna ) } ">${ ship . name } , ${ eveui_name || ship . name } </a>]<br/></div><td class="eveui_right whitespace_nowrap nocopy" colspan="2">${ eveui_allow_edit ? '<span class="eveui_icon eveui_edit_icon" />' : '' } <span class="eveui_icon eveui_copy_icon" /><span data-itemid="${ ship_id } " class="eveui_icon eveui_info_icon" /><span class="eveui_icon eveui_edit" /><span class="eveui_icon eveui_edit" /><span class="eveui_icon eveui_more_icon eveui_edit" /></thead><tbody class="whitespace_nowrap">${ item_rows ( high_slots , ship . hiSlots ) } <tr><td class="eveui_line_spacer"> ${ item_rows ( med_slots , ship . medSlots ) } <tr><td class="eveui_line_spacer"> ${ item_rows ( low_slots , ship . lowSlots ) } <tr><td class="eveui_line_spacer"> ${ item_rows ( rig_slots , ship . rigSlots ) } <tr><td class="eveui_line_spacer"> ${ item_rows ( subsystem_slots , ship . maxSubSystems ) } <tr><td class="eveui_line_spacer"> ${ item_rows ( other_slots ) } </tbody></table><span class="eveui_endcopy" />` ;
542
+ let html = `<table class="eveui_fit_table"><thead><tr class="eveui_fit_header" data-eveui-itemid="${ ship_id } "><td colspan="2"><img src="${ eveui_imageserver ( 'Type/' + ship_id + '_32' ) } " class="eveui_icon eveui_ship_icon" /><td><div class="eveui_rowcontent"><span class="eveui_startcopy" />[<a target="_blank" href="${ eveui_urlify ( dna ) } ">${ ship . name } , ${ eveui_name || ship . name } </a>]<br/></div><td class="eveui_right whitespace_nowrap nocopy" colspan="2">${ eveui_allow_edit ? '<span class="eveui_icon eveui_edit_icon" />' : '' } <span class="eveui_icon eveui_copy_icon" /><span data-itemid="${ ship_id } " class="eveui_icon eveui_info_icon" /><span class="eveui_icon eveui_edit" /><span class="eveui_icon eveui_edit" /><span class="eveui_icon eveui_more_icon eveui_edit" /></thead><tbody class="whitespace_nowrap">${ item_rows ( high_slots , ship . hiSlots ) } <tr><td class="eveui_line_spacer"> ${ item_rows ( med_slots , ship . medSlots ) } <tr><td class="eveui_line_spacer"> ${ item_rows ( low_slots , ship . lowSlots ) } <tr><td class="eveui_line_spacer"> ${ item_rows ( rig_slots , ship . rigSlots ) } <tr><td class="eveui_line_spacer"> ${ item_rows ( subsystem_slots , ship . maxSubSystems ) } <tr><td class="eveui_line_spacer"> ${ item_rows ( other_slots ) } </tbody></table><span class="eveui_endcopy" />` ;
545
543
return html ;
546
544
}
547
545
eveui . format_fit = format_fit ;
@@ -654,13 +652,6 @@ var eveui;
654
652
return eveui_window ;
655
653
}
656
654
eveui . corp_window = corp_window ;
657
- function format_fitstats ( dna ) {
658
- let html = '' ;
659
- let osmium_stats = eveui . cache [ 'osmium:' + dna ] ;
660
- html = `<span class="eveui_fit_stats">Defense<br /><span class="eveui_indent">${ Math . floor ( osmium_stats . ship . ehpAndResonances . ehp . avg ) } EHP<table><tr><td><td>em<td>th<td>ki<td>ex<tr><td>s<td>${ Math . round ( 100 - osmium_stats . ship . ehpAndResonances . shield . resonance . em * 100 ) } <td>${ Math . round ( 100 - osmium_stats . ship . ehpAndResonances . shield . resonance . thermal * 100 ) } <td>${ Math . round ( 100 - osmium_stats . ship . ehpAndResonances . shield . resonance . kinetic * 100 ) } <td>${ Math . round ( 100 - osmium_stats . ship . ehpAndResonances . shield . resonance . explosive * 100 ) } <tr><td>a<td>${ Math . round ( 100 - osmium_stats . ship . ehpAndResonances . armor . resonance . em * 100 ) } <td>${ Math . round ( 100 - osmium_stats . ship . ehpAndResonances . armor . resonance . thermal * 100 ) } <td>${ Math . round ( 100 - osmium_stats . ship . ehpAndResonances . armor . resonance . kinetic * 100 ) } <td>${ Math . round ( 100 - osmium_stats . ship . ehpAndResonances . armor . resonance . explosive * 100 ) } <tr><td>h<td>${ Math . round ( 100 - osmium_stats . ship . ehpAndResonances . hull . resonance . em * 100 ) } <td>${ Math . round ( 100 - osmium_stats . ship . ehpAndResonances . hull . resonance . thermal * 100 ) } <td>${ Math . round ( 100 - osmium_stats . ship . ehpAndResonances . hull . resonance . kinetic * 100 ) } <td>${ Math . round ( 100 - osmium_stats . ship . ehpAndResonances . hull . resonance . explosive * 100 ) } </table></span><hr />Offense<br /><span class="eveui_indent">${ Math . round ( osmium_stats . ship . damage . total . dps ) } Total DPS<br />(${ Math . round ( osmium_stats . ship . damage . drones . dps ) } Drone DPS)<br /></span><hr />Capacitor<br /><span class="eveui_indent">Δ${ ( osmium_stats . ship . capacitor . delta * - 1000 ) . toFixed ( 2 ) } /s<br /></span></span>` ;
661
- return html ;
662
- }
663
- eveui . format_fitstats = format_fitstats ;
664
655
function expand ( ) {
665
656
// expands anything that has been marked for expansion, or all applicable if we are set to expand_all mode
666
657
autoexpand ( ) ;
@@ -710,18 +701,6 @@ var eveui;
710
701
}
711
702
eveui . expand = expand ;
712
703
function autoexpand ( ) {
713
- // expands elements that require expansion even when not in expand mode
714
- $ ( 'eveui[type=osmium]' ) . filter ( ':not([state])' ) . each ( function ( ) {
715
- let selected_element = $ ( this ) ;
716
- let dna = selected_element . attr ( 'key' ) ;
717
- if ( eveui_use_osmium ) {
718
- selected_element . attr ( 'state' , 'loading' ) ;
719
- cache_request ( 'osmium:' + dna ) . done ( function ( ) {
720
- selected_element . html ( format_fitstats ( dna ) ) ;
721
- selected_element . attr ( 'state' , 'done' ) ;
722
- } ) ;
723
- }
724
- } ) ;
725
704
// generic expansion of simple expressions
726
705
$ ( 'eveui:not([type])' ) . filter ( ':not([state])' ) . each ( function ( ) {
727
706
let selected_element = $ ( this ) ;
@@ -773,6 +752,18 @@ var eveui;
773
752
} ) ;
774
753
return value ;
775
754
}
755
+ function ajax ( settings ) {
756
+ let my_settings = {
757
+ headers : {
758
+ 'Accept-Language' : eveui_accept_language ,
759
+ } ,
760
+ data : {
761
+ user_agent : eveui_user_agent ,
762
+ } ,
763
+ } ;
764
+ $ . extend ( true , my_settings , settings ) ;
765
+ return $ . ajax ( my_settings ) ;
766
+ }
776
767
function cache_items ( dna ) {
777
768
// caches all items required to process the specified fit
778
769
let pending = [ ] ;
@@ -791,16 +782,8 @@ var eveui;
791
782
let url ;
792
783
let jsonp = false ;
793
784
let custom_cache = key . startsWith ( '/v3/universe/types' )
794
- || key . startsWith ( '/v1/dogma/attributes' )
795
- || key . startsWith ( 'osmium' ) ;
796
- if ( key . startsWith ( 'osmium:' ) ) {
797
- jsonp = true ;
798
- let dna = key . split ( ':' , 2 ) [ 1 ] ;
799
- url = `https://o.smium.org/api/json/loadout/dna/attributes/loc:ship,a:ehpAndResonances,a:damage,a:outgoing,a:capacitor,a:tank?input=${ encodeURI ( dna ) } ` ;
800
- }
801
- else {
802
- url = 'https://esi.tech.ccp.is' + key + '/' ;
803
- }
785
+ || key . startsWith ( '/v1/dogma/attributes' ) ;
786
+ url = eveui_esi_endpoint ( key + '/' ) ;
804
787
let dataType = jsonp ? 'jsonp' : 'json' ;
805
788
if ( typeof ( eveui . cache [ key ] ) === 'object' ) {
806
789
if ( typeof ( eveui . cache [ key ] . promise ) === 'function' ) {
@@ -816,10 +799,8 @@ var eveui;
816
799
return $ . Deferred ( ) . reject ( ) ;
817
800
}
818
801
requests_pending ++ ;
819
- return eveui . cache [ key ] = $ . ajax ( url , {
820
- data : {
821
- user_agent : eveui_user_agent ,
822
- } ,
802
+ return eveui . cache [ key ] = ajax ( {
803
+ url : url ,
823
804
dataType : dataType ,
824
805
cache : ! custom_cache ,
825
806
} ) . done ( function ( data ) {
0 commit comments