From 8b5f5b2b378890030a354e951ddd2f80b6cbb069 Mon Sep 17 00:00:00 2001 From: David Malchin Date: Fri, 22 Jul 2022 12:14:02 +0300 Subject: [PATCH] Fix styling, docs, and a possible bug (#762) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🎨 Fix spacing and indentation * 🎨 Use single quotes over backticks * 📝 Fix docs * 🐛 Make replace function clear and extend locales correctly * Revert "🎨 Use single quotes over backticks" * Update config.lua --- config.lua | 2 +- html/js/app.js | 1 - html/js/config.js | 4 ++-- shared/locale.lua | 11 +++++------ shared/main.lua | 40 ++++++++++++++++++++-------------------- 5 files changed, 28 insertions(+), 30 deletions(-) diff --git a/config.lua b/config.lua index 781b3db..70db402 100644 --- a/config.lua +++ b/config.lua @@ -6,7 +6,7 @@ QBConfig.UpdateInterval = 5 -- how often to update player data in minutes QBConfig.StatusInterval = 5000 -- how often to check hunger/thirst status in milliseconds QBConfig.Money = {} -QBConfig.Money.MoneyTypes = { ['cash'] = 500, ['bank'] = 5000, ['crypto'] = 0 } -- ['type'] = startamount - Add or remove money types for your server (for ex. ['blackmoney'] = 0), remember once added it will not be removed from the database! +QBConfig.Money.MoneyTypes = { cash = 500, bank = 5000, crypto = 0 } -- type = startamount - Add or remove money types for your server (for ex. blackmoney = 0), remember once added it will not be removed from the database! QBConfig.Money.DontAllowMinus = { 'cash', 'crypto' } -- Money that is not allowed going in minus QBConfig.Money.PayCheckTimeOut = 10 -- The time in minutes that it will give the paycheck QBConfig.Money.PayCheckSociety = false -- If true paycheck will come from the society account that the player is employed at, requires qb-management diff --git a/html/js/app.js b/html/js/app.js index 50ff2fb..d13562e 100644 --- a/html/js/app.js +++ b/html/js/app.js @@ -8,7 +8,6 @@ import { } from "./config.js"; const { useQuasar } = Quasar; - const { onMounted, onUnmounted } = Vue; const app = Vue.createApp({ diff --git a/html/js/config.js b/html/js/config.js index d21352a..32fa978 100644 --- a/html/js/config.js +++ b/html/js/config.js @@ -13,13 +13,13 @@ export const DEV_MODE = false; * Will hold config statically outside of Vue state * @property {Record} VariantDefinitions * @property {Record} NotificationStyling - * */ + **/ export let NOTIFY_CONFIG = null; /** * Pure function taking a notification type and returning an object * with style details - * @param variant {string} + * @param {string} variant * @returns NotiVariantData **/ export const determineStyleFromVariant = (variant) => { diff --git a/shared/locale.lua b/shared/locale.lua index 6b9510b..c24376c 100644 --- a/shared/locale.lua +++ b/shared/locale.lua @@ -44,7 +44,7 @@ end --- internally for initial population of phrases field. --- @param phrases table - Table of phrase definitions --- @param prefix string | nil - Optional prefix used for recursive calls ---- @return void +--- @return nil function Locale:extend(phrases, prefix) for key, phrase in pairs(phrases) do local prefixKey = prefix and ('%s.%s'):format(prefix, key) or key @@ -57,10 +57,9 @@ function Locale:extend(phrases, prefix) end end - --- Clear locale instance phrases --- Might be useful for memory management of large phrase maps. ---- @return void +--- @return nil function Locale:clear() self.phrases = {} end @@ -69,8 +68,8 @@ end --- @param phrases table function Locale:replace(phrases) phrases = phrases or {} - self.clear() - self.extend(phrases) + self:clear() + self:extend(phrases) end --- Gets & Sets a locale depending on if an argument is passed @@ -85,7 +84,7 @@ end --- Primary translation method for a phrase of given key --- @param key string - The phrase key to target ---- @param subs table +--- @param subs table | nil --- @return string function Locale:t(key, subs) local phrase, result diff --git a/shared/main.lua b/shared/main.lua index 2319bc9..3eb8f61 100644 --- a/shared/main.lua +++ b/shared/main.lua @@ -3,9 +3,9 @@ QBShared = QBShared or {} local StringCharset = {} local NumberCharset = {} -for i = 48, 57 do NumberCharset[#NumberCharset+1] = string.char(i) end -for i = 65, 90 do StringCharset[#StringCharset+1] = string.char(i) end -for i = 97, 122 do StringCharset[#StringCharset+1] = string.char(i) end +for i = 48, 57 do NumberCharset[#NumberCharset + 1] = string.char(i) end +for i = 65, 90 do StringCharset[#StringCharset + 1] = string.char(i) end +for i = 97, 122 do StringCharset[#StringCharset + 1] = string.char(i) end function QBShared.RandomStr(length) if length <= 0 then return '' end @@ -22,16 +22,16 @@ function QBShared.SplitStr(str, delimiter) local from = 1 local delim_from, delim_to = string.find(str, delimiter, from) while delim_from do - result[#result+1] = string.sub(str, from, delim_from - 1) + result[#result + 1] = string.sub(str, from, delim_from - 1) from = delim_to + 1 delim_from, delim_to = string.find(str, delimiter, from) end - result[#result+1] = string.sub(str, from) + result[#result + 1] = string.sub(str, from) return result end function QBShared.Trim(value) - if not value then return nil end + if not value then return nil end return (string.gsub(value, '^%s*(.-)%s*$', '%1')) end @@ -42,24 +42,24 @@ function QBShared.Round(value, numDecimalPlaces) end function QBShared.ChangeVehicleExtra(vehicle, extra, enable) - if DoesExtraExist(vehicle, extra) then - if enable then - SetVehicleExtra(vehicle, extra, false) - if not IsVehicleExtraTurnedOn(vehicle, extra) then - QBShared.ChangeVehicleExtra(vehicle, extra, enable) - end - else - SetVehicleExtra(vehicle, extra, true) - if IsVehicleExtraTurnedOn(vehicle, extra) then - QBShared.ChangeVehicleExtra(vehicle, extra, enable) - end - end - end + if DoesExtraExist(vehicle, extra) then + if enable then + SetVehicleExtra(vehicle, extra, false) + if not IsVehicleExtraTurnedOn(vehicle, extra) then + QBShared.ChangeVehicleExtra(vehicle, extra, enable) + end + else + SetVehicleExtra(vehicle, extra, true) + if IsVehicleExtraTurnedOn(vehicle, extra) then + QBShared.ChangeVehicleExtra(vehicle, extra, enable) + end + end + end end function QBShared.SetDefaultVehicleExtras(vehicle, config) -- Clear Extras - for i = 1,20 do + for i = 1, 20 do if DoesExtraExist(vehicle, i) then SetVehicleExtra(vehicle, i, 1) end