@@ -192,7 +192,7 @@ ExportChallenges_promise.then(res => { (window as any).ExportChallenges = res; }
192192ExportMissionTypes_promise . then ( res => { ( window as any ) . ExportMissionTypes = res ; } ) ;
193193ExportFactions_promise . then ( res => { ( window as any ) . ExportFactions = res ; } ) ;
194194
195- function formatExpiry ( expiry )
195+ function formatExpiry ( expiry : number ) : string
196196{
197197 expiry -= expiry % 1000 ; expiry += 1000 ; // normalise the ms so everything ticks at the same time
198198 const time = Date . now ( ) ;
@@ -204,7 +204,7 @@ function formatExpiry(expiry)
204204 return deltaToUnits ( delta ) . join ( " " ) ;
205205}
206206
207- function deltaToUnits ( delta )
207+ function deltaToUnits ( delta : number ) : string [ ]
208208{
209209 delta = Math . abs ( delta ) ;
210210
@@ -228,29 +228,29 @@ function deltaToUnits(delta)
228228 return units ;
229229}
230230
231- function formatActivation ( activation )
231+ function formatActivation ( activation : number ) : string
232232{
233233 return deltaToUnits ( Date . now ( ) - activation ) [ 0 ] ;
234234}
235235
236- function createExpiryBadge ( expiry )
236+ function createExpiryBadge ( expiry : number ) : HTMLSpanElement
237237{
238238 const span = document . createElement ( "span" ) ;
239- span . setAttribute ( "data-expiry" , expiry ) ;
239+ span . setAttribute ( "data-expiry" , expiry . toString ( ) ) ;
240240 span . className = "badge text-bg-secondary" ;
241241 span . textContent = formatExpiry ( expiry ) ;
242242 return span ;
243243}
244244
245- function setDatum ( name , value , expiry )
245+ function setDatum ( name : string , value : string , expiry : number ) : void
246246{
247247 const elm = document . getElementById ( name ) ;
248248 elm . querySelectorAll ( "[data-bs-toggle=tooltip]" ) . forEach ( x => window . bootstrap . Tooltip . getInstance ( x ) . dispose ( ) ) ;
249249 elm . textContent = value + " " ;
250250 elm . appendChild ( createExpiryBadge ( expiry ) ) ;
251251}
252252
253- function updateVallis ( )
253+ function updateVallis ( ) : void
254254{
255255 const EPOCH = new Date ( "November 10, 2018 08:13:48 UTC" ) . getTime ( ) ;
256256 const time = Date . now ( ) ;
@@ -466,7 +466,7 @@ function updateIncursions()
466466 setTimeout ( updateIncursions , window . incursions_expiry - Date . now ( ) ) ;
467467}
468468
469- function addTooltip ( elm , title )
469+ function addTooltip ( elm : HTMLElement , title : string ) : any
470470{
471471 elm . setAttribute ( "data-bs-toggle" , "tooltip" ) ;
472472 elm . setAttribute ( "data-bs-title" , title ) ;
@@ -871,7 +871,7 @@ const sortieModifiers = {
871871 "SORTIE_MODIFIER_BOW_ONLY" : "Bow Only" ,
872872} ;
873873
874- function setWorldStateExpiry ( expiry )
874+ function setWorldStateExpiry ( expiry : number ) : void
875875{
876876 if ( Date . now ( ) > expiry )
877877 {
@@ -890,8 +890,8 @@ async function updateSorties()
890890 await ExportMissionTypes_promise ;
891891
892892 const sortie = window . worldState . Sorties . find ( x => Date . now ( ) >= parseInt ( x . Activation . $date . $numberLong ) && Date . now ( ) < parseInt ( x . Expiry . $date . $numberLong ) ) ;
893- setWorldStateExpiry ( sortie . Expiry . $date . $numberLong ) ;
894- setDatum ( "sortie-header" , toTitleCase ( osdict [ "/Lotus/Language/Menu/SortieMissionName" ] ) , sortie . Expiry . $date . $numberLong ) ;
893+ setWorldStateExpiry ( parseInt ( sortie . Expiry . $date . $numberLong ) ) ;
894+ setDatum ( "sortie-header" , toTitleCase ( osdict [ "/Lotus/Language/Menu/SortieMissionName" ] ) , parseInt ( sortie . Expiry . $date . $numberLong ) ) ;
895895 document . getElementById ( "sortie-header" ) . innerHTML += " " ;
896896 document . getElementById ( "sortie-header" ) . appendChild ( createCompletionToggle ( sortie . _id . $oid ) ) ;
897897 const tbody = document . createElement ( "tbody" ) ;
@@ -915,8 +915,8 @@ async function updateSorties()
915915 window . last_sortie = sortie . _id . $oid ;
916916
917917 const litesortie = window . worldState . LiteSorties . find ( x => Date . now ( ) >= parseInt ( x . Activation . $date . $numberLong ) && Date . now ( ) < parseInt ( x . Expiry . $date . $numberLong ) ) ;
918- setWorldStateExpiry ( litesortie . Expiry . $date . $numberLong ) ;
919- setDatum ( "litesortie-header" , osdict [ "/Lotus/Language/WorldStateWindow/LiteSortieMissionName" ] , litesortie . Expiry . $date . $numberLong ) ;
918+ setWorldStateExpiry ( parseInt ( litesortie . Expiry . $date . $numberLong ) ) ;
919+ setDatum ( "litesortie-header" , osdict [ "/Lotus/Language/WorldStateWindow/LiteSortieMissionName" ] , parseInt ( litesortie . Expiry . $date . $numberLong ) ) ;
920920 document . getElementById ( "litesortie-header" ) . innerHTML += " " ;
921921 document . getElementById ( "litesortie-header" ) . appendChild ( createCompletionToggle ( litesortie . _id . $oid ) ) ;
922922 const mission_names = [ ] ;
@@ -945,8 +945,8 @@ function updateKinePage()
945945async function updateDarvosDeal ( )
946946{
947947 window . dailyDeal = window . worldState . DailyDeals . find ( x => Date . now ( ) >= parseInt ( x . Activation . $date . $numberLong ) && Date . now ( ) < parseInt ( x . Expiry . $date . $numberLong ) ) ;
948- setDatum ( "darvo-header" , "Darvo's Deal" , window . dailyDeal . Expiry . $date . $numberLong ) ;
949- setWorldStateExpiry ( window . dailyDeal . Expiry . $date . $numberLong ) ;
948+ setDatum ( "darvo-header" , "Darvo's Deal" , parseInt ( window . dailyDeal . Expiry . $date . $numberLong ) ) ;
949+ setWorldStateExpiry ( parseInt ( window . dailyDeal . Expiry . $date . $numberLong ) ) ;
950950 const item_data = await getItemDataPromise ( window . dailyDeal . StoreItem ) ;
951951 await dicts_promise ;
952952 document . getElementById ( "darvo-item" ) . textContent = dict [ item_data . name ] ;
@@ -976,8 +976,8 @@ async function updateBaro()
976976 document . getElementById ( "baro-soon" ) . classList . add ( "d-none" ) ;
977977 document . getElementById ( "baro-now" ) . classList . remove ( "d-none" ) ;
978978
979- setWorldStateExpiry ( window . worldState . VoidTraders [ 0 ] . Expiry . $date . $numberLong ) ;
980- setDatum ( "baro-header" , "Baro Ki'Teer" , window . worldState . VoidTraders [ 0 ] . Expiry . $date . $numberLong ) ;
979+ setWorldStateExpiry ( parseInt ( window . worldState . VoidTraders [ 0 ] . Expiry . $date . $numberLong ) ) ;
980+ setDatum ( "baro-header" , "Baro Ki'Teer" , parseInt ( window . worldState . VoidTraders [ 0 ] . Expiry . $date . $numberLong ) ) ;
981981
982982 for ( const item of window . worldState . VoidTraders [ 0 ] . Manifest )
983983 {
@@ -1044,8 +1044,8 @@ async function updateBaro()
10441044 document . getElementById ( "baro-soon" ) . classList . remove ( "d-none" ) ;
10451045 document . getElementById ( "baro-now" ) . classList . add ( "d-none" ) ;
10461046
1047- setWorldStateExpiry ( window . worldState . VoidTraders [ 0 ] . Activation . $date . $numberLong ) ;
1048- setDatum ( "baro-header" , "Baro Ki'Teer" , window . worldState . VoidTraders [ 0 ] . Activation . $date . $numberLong ) ;
1047+ setWorldStateExpiry ( parseInt ( window . worldState . VoidTraders [ 0 ] . Activation . $date . $numberLong ) ) ;
1048+ setDatum ( "baro-header" , "Baro Ki'Teer" , parseInt ( window . worldState . VoidTraders [ 0 ] . Activation . $date . $numberLong ) ) ;
10491049
10501050 window . last_baro_expiry = "69" ;
10511051 }
@@ -1091,7 +1091,7 @@ async function updateAlerts()
10911091 }
10921092 span . innerHTML += " (" + alert . MissionInfo . minEnemyLevel + "-" + alert . MissionInfo . maxEnemyLevel + ") @ " + dict [ ExportRegions [ alert . MissionInfo . location ] . name ] + ", " + dict [ ExportRegions [ alert . MissionInfo . location ] . systemName ] + " " ;
10931093 span . appendChild ( createExpiryBadge ( alert . Expiry . $date . $numberLong ) ) ;
1094- setWorldStateExpiry ( alert . Expiry . $date . $numberLong ) ;
1094+ setWorldStateExpiry ( parseInt ( alert . Expiry . $date . $numberLong ) ) ;
10951095 span . innerHTML += " " ;
10961096 span . appendChild ( createCompletionToggle ( alert . _id . $oid ) ) ;
10971097 block . appendChild ( span ) ;
@@ -1266,7 +1266,7 @@ function updateCircuit()
12661266}
12671267dict_promise . then ( updateCircuit ) ;
12681268
1269- function loadScriptPromise ( src )
1269+ function loadScriptPromise ( src : string ) : Promise < any >
12701270{
12711271 return new Promise ( ( resolve , reject ) =>
12721272 {
@@ -1279,7 +1279,7 @@ function loadScriptPromise(src)
12791279}
12801280
12811281const item_data_promises = { } ;
1282- function getItemDataPromise ( uniqueName )
1282+ function getItemDataPromise ( uniqueName : string ) : Promise < any >
12831283{
12841284 uniqueName = uniqueName . split ( "/Lotus/StoreItems/" ) . join ( "/Lotus/" ) ;
12851285 if ( ! item_data_promises [ uniqueName ] )
@@ -1289,7 +1289,7 @@ function getItemDataPromise(uniqueName)
12891289 return item_data_promises [ uniqueName ] ;
12901290}
12911291
1292- async function getItemNamePromise ( uniqueName )
1292+ async function getItemNamePromise ( uniqueName : string ) : Promise < string >
12931293{
12941294 try
12951295 {
@@ -1313,13 +1313,13 @@ async function getItemNamePromise(uniqueName)
13131313 }
13141314}
13151315
1316- function isOidMarkedAsCompleted ( oid )
1316+ function isOidMarkedAsCompleted ( oid : string ) : boolean
13171317{
13181318 const arr = JSON . parse ( localStorage . getItem ( "oids_completed" ) ?? "[]" ) ;
13191319 return arr . findIndex ( x => x == oid ) != - 1 ;
13201320}
13211321
1322- function toggleOidCompletion ( oid )
1322+ function toggleOidCompletion ( oid : string ) : void
13231323{
13241324 const arr = JSON . parse ( localStorage . getItem ( "oids_completed" ) ?? "[]" ) ;
13251325 const index = arr . findIndex ( x => x == oid ) ;
@@ -1334,12 +1334,12 @@ function toggleOidCompletion(oid)
13341334 localStorage . setItem ( "oids_completed" , JSON . stringify ( arr ) ) ;
13351335}
13361336
1337- function createCompletionToggle ( oid )
1337+ function createCompletionToggle ( oid : string ) : HTMLAnchorElement
13381338{
13391339 let what = "completed" ;
1340- if ( oid . substr ( 0 , 5 ) == "kahlb" )
1340+ if ( oid . substring ( 0 , 5 ) == "kahlb" )
13411341 {
1342- what += " (Bonus Objective #" + oid . substr ( 5 , 1 ) + ")" ;
1342+ what += " (Bonus Objective #" + oid . substring ( 5 , 6 ) + ")" ;
13431343 }
13441344
13451345 const a = document . createElement ( "a" ) ;
@@ -1442,7 +1442,7 @@ function updateInvasions()
14421442 } ) ;
14431443}
14441444
1445- function setFissuresExpiry ( expiry )
1445+ function setFissuresExpiry ( expiry : number ) : void
14461446{
14471447 if ( ! window . refresh_fissures_at || window . refresh_fissures_at > expiry )
14481448 {
@@ -1611,11 +1611,11 @@ setInterval(function()
16111611{
16121612 for ( const elm of document . querySelectorAll ( ".badge[data-expiry]" ) )
16131613 {
1614- elm . textContent = formatExpiry ( elm . getAttribute ( "data-expiry" ) ) ;
1614+ elm . textContent = formatExpiry ( parseInt ( elm . getAttribute ( "data-expiry" ) ) ) ;
16151615 }
16161616 for ( const elm of document . querySelectorAll ( ".badge[data-activation]" ) )
16171617 {
1618- elm . textContent = formatActivation ( elm . getAttribute ( "data-activation" ) ) ;
1618+ elm . textContent = formatActivation ( parseInt ( elm . getAttribute ( "data-activation" ) ) ) ;
16191619 }
16201620} , 100 ) ;
16211621
@@ -1647,7 +1647,7 @@ setInterval(function()
16471647 }
16481648} , 500 ) ;
16491649
1650- function refreshCollapseStatus ( elm )
1650+ function refreshCollapseStatus ( elm : HTMLElement ) : void
16511651{
16521652 const engaged = localStorage . getItem ( "live.collapse." + elm . getAttribute ( "data-collapse-toggle" ) ) ;
16531653 const span = document . createElement ( "span" ) ;
@@ -1684,7 +1684,7 @@ document.querySelectorAll<HTMLSpanElement>("[data-collapse-toggle]").forEach(elm
16841684 } ;
16851685} ) ;
16861686
1687- function sendNotification ( text )
1687+ function sendNotification ( text : string ) : void
16881688{
16891689 const toast = document . createElement ( "div" ) ;
16901690 toast . className = "toast align-items-center text-bg-primary border-0" ;
@@ -1707,7 +1707,7 @@ function sendNotification(text)
17071707 }
17081708}
17091709
1710- function refreshNotifStatus ( elm )
1710+ function refreshNotifStatus ( elm : HTMLElement ) : void
17111711{
17121712 const enabled = localStorage . getItem ( "live.notif." + elm . getAttribute ( "data-notif-toggle" ) ) ;
17131713 const span = document . createElement ( "span" ) ;
@@ -1743,4 +1743,4 @@ document.querySelectorAll<HTMLAnchorElement>("[data-notif-toggle]").forEach(elm
17431743 } ;
17441744} ) ;
17451745
1746- document . querySelectorAll ( ".vq-abbr" ) . forEach ( elm => addTooltip ( elm , "Voidplume Quills" ) ) ;
1746+ document . querySelectorAll < HTMLElement > ( ".vq-abbr" ) . forEach ( elm => addTooltip ( elm , "Voidplume Quills" ) ) ;
0 commit comments