2929 </portal >
3030
3131 <template >
32- <div class =" relative" >
33- <div id =" map" class =" w-map h-max -mt-12 max-w-full relative" ></div >
34- <pre class =" bg-opacity-70 bg-white coordinate-attr absolute bottom-0 left-0 cursor-pointer z-1k" @click =" copyText($event, clickedCoords)" v-if =" clickedCoords" >{{ clickedCoords }}</pre >
32+ <div class =" -mt-12" id =" map-wrapper" >
33+ <div class =" relative" >
34+ <div id =" map" class =" w-map max-w-full relative h-max" ></div >
35+ <pre class =" bg-opacity-70 bg-white coordinate-attr absolute bottom-0 left-0 cursor-pointer z-1k" @click =" copyText($event, clickedCoords)" v-if =" clickedCoords" >{{ clickedCoords }}</pre >
36+ </div >
37+ <div v-if =" afkPeople" class =" w-map-right pt-4" >
38+ <h3 class =" mb-2" >{{ t('map.afk_title') }}</h3 >
39+ <pre v-html =" afkPeople" class =" text-sm" >{{ afkPeople }}</pre >
40+ </div >
3541 </div >
3642 </template >
3743
@@ -89,7 +95,7 @@ export default {
8995 trackedPlayer: window .location .hash .substr (1 ),
9096 firstRefresh: true ,
9197 clickedCoords: ' ' ,
92- afkMap : {}
98+ afkPeople : ' '
9399 };
94100 },
95101 methods: {
@@ -191,9 +197,10 @@ export default {
191197
192198 return ret;
193199 },
194- getIcon (player , isDriving , isPassenger , isInvisible ) {
200+ getIcon (player , isDriving , isPassenger , isInvisible , isDead ) {
195201 let size = {
196202 circle: 17 ,
203+ skull: 17 ,
197204 circle_red: 12 ,
198205 circle_green: 13
199206 };
@@ -205,7 +212,14 @@ export default {
205212 }
206213 );
207214
208- if (isInvisible) {
215+ if (isDead) {
216+ icon = new L.Icon (
217+ {
218+ iconUrl: ' /images/skull.png' ,
219+ iconSize: [size .skull , size .skull ]
220+ }
221+ );
222+ } else if (isInvisible) {
209223 icon = new L.Icon (
210224 {
211225 iconUrl: ' /images/circle_green.png' ,
@@ -270,6 +284,7 @@ export default {
270284 });
271285
272286 let validIds = [];
287+ let afkList = [];
273288 $ .each (data, function (_ , player ) {
274289 if (! player .character ) {
275290 return ;
@@ -281,34 +296,19 @@ export default {
281296 isDriving = ' vehicle' in player && player .vehicle && player .vehicle .driving ,
282297 isPassenger = ' vehicle' in player && player .vehicle && ! player .vehicle .driving ,
283298 isInvisible = ' invisible' in player && player .invisible ,
299+ isDead = player .character && ' dead' in player .character && player .character .dead ,
284300 speed = ' vehicle' in player && player .vehicle && ' speed' in player .vehicle ? player .vehicle .speed : null ,
285- icon = _this .getIcon (player, isDriving, isPassenger, isInvisible),
301+ icon = _this .getIcon (player, isDriving, isPassenger, isInvisible, isDead ),
286302 vehicle = _this .getVehicleType (player .vehicle );
287303
288- const roundedCoords = {
289- x: player .coords .x .toFixed (1 ),
290- y: player .coords .y .toFixed (1 ),
291- },
292- now = Math .round ((new Date ()).getTime () / 1000 );
293-
294- if (! (id in _this .afkMap )) {
295- _this .afkMap [id] = {
296- coords: roundedCoords,
297- lastChange: now,
298- };
299- } else if (_this .afkMap [id].coords .x !== roundedCoords .x || _this .afkMap [id].coords .y !== roundedCoords .y ) {
300- _this .afkMap [id].coords = roundedCoords;
301- _this .afkMap [id].lastChange = now;
302- }
303-
304- const afkTime = now - _this .afkMap [id].lastChange ;
305-
306304 if (printPlayerInfo && printPlayerInfo === player .character .id ) {
307305 printPlayerInfo = null ;
308- console .info (' Player debug' , {
309- afkTime: afkTime,
310- player: player
311- });
306+ console .info (' Player debug' , player);
307+ }
308+
309+ if (isNaN (coords .lat ) || isNaN (coords .lng )) {
310+ console .debug (' NaN Coords' , coords, player);
311+ return ;
312312 }
313313
314314 validIds .push (id);
@@ -344,6 +344,10 @@ export default {
344344 attributes .push (' invisible' );
345345 markers[id].options .forceZIndex = 101 ;
346346 }
347+ if (isDead) {
348+ attributes .push (' dead' );
349+ markers[id].options .forceZIndex = 101 ;
350+ }
347351 if (isDriving) {
348352 attributes .push (' driving (' + (vehicle .type === ' car' ? ' car/bike' : vehicle .type ) + ' )' );
349353 markers[id].options .forceZIndex = 100 ;
@@ -356,23 +360,32 @@ export default {
356360 }
357361 extra += ' <br><i>Is ' + attributes .shift () + (attributes .length > 0 ? ' and ' + attributes .join (' , ' ) : ' ' ) + ' </i>' ;
358362
359- if (afkTime > 300 ) {
360- extra += ' <br><i>Hasn\' t moved in ' + _this .formatSeconds (afkTime) + ' </i>' ;
363+ if (player .afk > 300 ) {
364+ extra += ' <br><i>Hasn\' t moved in ' + _this .formatSeconds (player .afk ) + ' </i>' ;
365+ }
366+ if (player .afk > 15 * 60 ) {
367+ afkList .push (` <tr>
368+ <td class="pr-2"><a class="text-indigo-600 dark:text-indigo-400" target="_blank" href="/players/` + player .steamIdentifier + ` ">` + player .character .fullName + ` </a></td>
369+ <td class="pr-2">hasn't moved in ` + _this .formatSeconds (player .afk ) + ` </td>
370+ <td><a class="text-indigo-600 dark:text-indigo-400 track-cid" href="#" data-trackid="` + id + ` ">[Track]</a></td>
371+ </tr>` .replace (/ \r ? \n (\s {4} )? / gm , ' ' ));
361372 }
362373
363374 if (_this .trackedPlayer === id) {
364- extra += ' <br><br><a href="#" class="track-cid" data-trackid="stop"" >' + _this .t (' map.stop_track' ) + ' </a>' ;
375+ extra += ' <br><br><a href="#" class="track-cid" data-trackid="stop">' + _this .t (' map.stop_track' ) + ' </a>' ;
365376
366377 _this .map .setView (coords, _this .firstRefresh ? 6 : _this .map .getZoom (), {
367378 duration: 0.1
368379 });
369380 } else {
370- extra += ' <br><br><a href="#" class="track-cid" data-trackid="' + id + ' "" >' + _this .t (' map.track' ) + ' </a>' ;
381+ extra += ' <br><br><a href="#" class="track-cid" data-trackid="' + id + ' ">' + _this .t (' map.track' ) + ' </a>' ;
371382 }
372383
373- markers[id]._popup .setContent (player .character .fullName + ' (<a href="/players/' + player .steamIdentifier + ' ">#' + player .character .id + ' </a>)' + extra);
384+ markers[id]._popup .setContent (player .character .fullName + ' <sup> ' + player . source + ' </sup> (<a href="/players/' + player .steamIdentifier + ' " target="_blank ">#' + player .character .id + ' </a>)' + extra);
374385 });
375386
387+ this .afkPeople = afkList .length > 0 ? ' <table>' + afkList .join (" \n " ) + ' </table>' : ' ' ;
388+
376389 $ .each (markers, function (id , marker ) {
377390 if (! validIds .includes (id)) {
378391 _this .map .removeLayer (marker);
@@ -477,9 +490,11 @@ export default {
477490 console .info (' Clicked coordinates' , map);
478491 });
479492
480- $ (' #map' ).on (' click' , ' .track-cid' , function (e ) {
493+ $ (' #map-wrapper ' ).on (' click' , ' .track-cid' , function (e ) {
481494 e .preventDefault ();
482495
496+ console .log (this );
497+
483498 const track = $ (this ).data (' trackid' );
484499 if (track === ' stop' ) {
485500 _this .trackedPlayer = null ;
0 commit comments