Commit ca0c676 1 parent e942b6a commit ca0c676 Copy full SHA for ca0c676
File tree 3 files changed +31
-3
lines changed
3 files changed +31
-3
lines changed Original file line number Diff line number Diff line change 21
21
{ "message" : " Migrate faction stakeouts over to API V2." , "contributor" : " DeKleineKobini" },
22
22
{ "message" : " Migrate faction last action over to API V2." , "contributor" : " DeKleineKobini" },
23
23
{ "message" : " Make icons in the popup clickable to open their corresponding pages." , "contributor" : " Hashibee" },
24
- { "message" : " Show some more networth types in live networth." , "contributor" : " DeKleineKobini" }
24
+ { "message" : " Show some more networth types in live networth." , "contributor" : " DeKleineKobini" },
25
+ { "message" : " More accurate/useful end time for OC2 countdown in sidebar" , "contributor" : " Phoenix" }
25
26
],
26
27
"removed" : []
27
28
}
Original file line number Diff line number Diff line change 60
60
61
61
function buildTimeLeftElement ( ) {
62
62
const timeLeftElement = document . newElement ( { type : "span" , class : "countdown" } ) ;
63
+ const now = Date . now ( ) ;
64
+ let readyAt ;
65
+ // Torn's ready_at value corresponds to the planning finish time for currently joined members
66
+ // If the OC is partially filled it will not provide an accurate end time (i.e. when it will initiate)
67
+
68
+ // Count the missing members
69
+ let missingMembers = 0 ;
70
+ for ( const slot of userdata . organizedCrime . slots ) {
71
+ if ( slot . user_id === null ) {
72
+ missingMembers += 1 ;
73
+ }
74
+ }
75
+
76
+ // Add 24 hours for every missing member
77
+ // The end result is that this now provides the earliest projected end/initiation time
78
+ if ( missingMembers > 0 ) {
79
+ const missingTime = 24 * 60 * 60 * missingMembers ;
80
+ readyAt = Math . max ( ( userdata . organizedCrime . ready_at + missingTime ) * 1000 , now + missingTime * 1000 ) ;
81
+ } else {
82
+ readyAt = userdata . organizedCrime . ready_at * 1000 ;
83
+ }
63
84
64
- const readyAt = userdata . organizedCrime . ready_at * 1000 ;
65
- const timeLeft = readyAt - Date . now ( ) ;
85
+ const timeLeft = readyAt - now ;
66
86
67
87
if ( timeLeft <= TO_MILLIS . HOURS * 8 ) timeLeftElement . classList . add ( "short" ) ;
68
88
else if ( timeLeft <= TO_MILLIS . HOURS * 12 ) timeLeftElement . classList . add ( "medium" ) ;
Original file line number Diff line number Diff line change @@ -238,6 +238,13 @@ const TEAM = [
238
238
torn : 2303184 ,
239
239
color : "#6ACF65" ,
240
240
} ,
241
+ {
242
+ name : "Phoenix" ,
243
+ title : "Developer" ,
244
+ core : false ,
245
+ torn : 85185 ,
246
+ color : "#085185" ,
247
+ } ,
241
248
] ;
242
249
243
250
const CONTRIBUTORS = TEAM . filter ( ( { title, color } ) => title . includes ( "Developer" ) || color ) . reduce (
You can’t perform that action at this time.
0 commit comments