From 54e8481ec23b943438a2c5ab89c89601d63b69cc Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Tue, 24 Dec 2024 10:33:55 +0100 Subject: [PATCH] chore: carried out code formatting and stability work --- .../[esx_addons]/ps-dispatch/ui/app.js | 62 ++++++++++++------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/server-data/resources/[esx_addons]/ps-dispatch/ui/app.js b/server-data/resources/[esx_addons]/ps-dispatch/ui/app.js index 4ac104cf..ddb05f8f 100644 --- a/server-data/resources/[esx_addons]/ps-dispatch/ui/app.js +++ b/server-data/resources/[esx_addons]/ps-dispatch/ui/app.js @@ -1,7 +1,8 @@ +/* eslint-disable no-unused-vars */ $(document).ready(() => { - window.addEventListener('message', function (event) { - let data = event.data; - if (data.update == 'newCall') { + window.addEventListener('message', function(event) { + const data = event.data; + if (data.update === 'newCall') { addNewCall(data.callID, data.timer, data.data, data.isPolice); } }); @@ -50,7 +51,7 @@ function timeAgo(dateParam) { } const date = - typeof dateParam === 'object' ? dateParam : new Date(dateParam); + typeof dateParam === 'object' ? dateParam : new Date(dateParam); const DAY_IN_MS = 86400000; const today = new Date(); const yesterday = new Date(today - DAY_IN_MS); @@ -62,17 +63,23 @@ function timeAgo(dateParam) { if (seconds < 5) { return 'Just Now'; - } else if (seconds < 60) { + } + else if (seconds < 60) { return `${seconds} Seconds ago`; - } else if (seconds < 90) { + } + else if (seconds < 90) { return 'About a minute ago'; - } else if (minutes < 60) { + } + else if (minutes < 60) { return `${minutes} Minutes ago`; - } else if (isToday) { + } + else if (isToday) { return getFormattedDate(date, 'Today'); - } else if (isYesterday) { + } + else if (isYesterday) { return getFormattedDate(date, 'Yesterday'); - } else if (isThisYear) { + } + else if (isThisYear) { return getFormattedDate(date, false, true); } @@ -84,7 +91,8 @@ function addNewCall(callID, timer, info, isPolice) { let DispatchItem; if (info['isDead']) { DispatchItem = `
#${callID}
${info.dispatchCode}
${info.dispatchMessage}
`; - } else { + } + else { DispatchItem = `
#${callID}
${info.dispatchCode}
${info.dispatchMessage}
`; } @@ -92,7 +100,7 @@ function addNewCall(callID, timer, info, isPolice) { if (info['time']) { DispatchItem += `
${timeAgo( - info['time'] + info['time'], )}
`; } @@ -126,9 +134,11 @@ function addNewCall(callID, timer, info, isPolice) { if (info['model'] && info['plate']) { DispatchItem += `
${info['model']}${info['plate']}
`; - } else if (info['plate']) { + } + else if (info['plate']) { DispatchItem += `
${info['plate']}
`; - } else if (info['model']) { + } + else if (info['model']) { DispatchItem += `
${info['model']}
`; } @@ -136,14 +146,16 @@ function addNewCall(callID, timer, info, isPolice) { DispatchItem += `
${info['firstColor']}
`; } if (info['automaticGunfire'] == true) { - DispatchItem += `
Automatic Gunfire
`; + DispatchItem += '
Automatic Gunfire
'; } if (info['name'] && info['number']) { DispatchItem += `
${info['name']}${info['number']}
`; - } else if (info['number']) { + } + else if (info['number']) { DispatchItem += `
${info['number']}
`; - } else if (info['name']) { + } + else if (info['name']) { DispatchItem += `
${info['name']}
`; } @@ -151,21 +163,27 @@ function addNewCall(callID, timer, info, isPolice) { DispatchItem += `
${info['information']}
`; } - DispatchItem += `
`; + DispatchItem += '
'; $('.dispatch-holder').prepend(DispatchItem); - var timer = 4000; + timer = 4000; if (prio == 1) { - timer = 12000; - } else if (prio == 2) { - timer = 9000; + if (prio == 1) { + timer = 12000; + } + else if (prio == 2) { + timer = 9000; + } } +} +function removeCall(callID, timer) { $(`.${callID}`).addClass('animate__backInRight'); setTimeout(() => { $(`.${callID}`).addClass('animate__backOutRight'); + setTimeout(() => { $(`.${callID}`).remove(); }, 1000);