From 9049c98d76674bd8e253beee327207a8e7a1b5e8 Mon Sep 17 00:00:00 2001 From: TheFantomas <117121911+TheFantomas@users.noreply.github.com> Date: Sun, 9 Jul 2023 17:00:36 +0200 Subject: [PATCH] formatting(all): Format with prettier and lua formatter --- .editorconfig | 10 + [core]/cron/server/main.lua | 10 +- [core]/es_extended/client/functions.lua | 108 ++- [core]/es_extended/config.lua | 84 +- [core]/es_extended/config.weapons.lua | 16 +- [core]/es_extended/html/css/app.css | 99 ++- [core]/es_extended/html/js/app.js | 62 +- [core]/es_extended/html/js/mustache.min.js | 348 +++++++- [core]/es_extended/html/js/wrapper.js | 49 +- [core]/es_extended/html/ui.html | 18 +- [core]/es_extended/locales/fr.lua | 2 +- [core]/es_extended/locales/nl.lua | 4 +- [core]/es_extended/locales/sl.lua | 4 +- [core]/es_extended/server/commands.lua | 14 +- [core]/es_extended/server/functions.lua | 4 +- [core]/es_extended/server/main.lua | 483 ++++++----- [core]/esx_context/index.html | 816 +++++++++--------- [core]/esx_identity/config.lua | 14 +- [core]/esx_identity/html/css/style.css | 208 ++--- [core]/esx_identity/html/index.html | 112 +-- [core]/esx_identity/html/js/script.js | 61 +- [core]/esx_loadingscreen/css/index.css | 132 +-- [core]/esx_loadingscreen/index.html | 39 +- [core]/esx_loadingscreen/js/index.js | 14 +- [core]/esx_menu_default/html/css/app.css | 116 +-- [core]/esx_menu_default/html/js/app.js | 728 ++++++++-------- .../esx_menu_default/html/js/mustache.min.js | 348 +++++++- [core]/esx_menu_default/html/ui.html | 33 +- [core]/esx_menu_dialog/html/css/app.css | 162 ++-- [core]/esx_menu_dialog/html/js/app.js | 305 ++++--- .../esx_menu_dialog/html/js/mustache.min.js | 348 +++++++- [core]/esx_menu_dialog/html/ui.html | 35 +- [core]/esx_menu_list/html/css/app.css | 58 +- [core]/esx_menu_list/html/js/app.js | 358 ++++---- [core]/esx_menu_list/html/js/mustache.min.js | 348 +++++++- [core]/esx_menu_list/html/ui.html | 20 +- [core]/esx_multicharacter/client/main.lua | 2 +- [core]/esx_multicharacter/html/css/main.css | 96 +-- [core]/esx_multicharacter/html/js/app.js | 118 ++- [core]/esx_multicharacter/html/ui.html | 47 +- [core]/esx_notify/nui/css/style.css | 88 +- [core]/esx_notify/nui/index.html | 27 +- [core]/esx_notify/nui/js/script.js | 86 +- [core]/esx_progressbar/nui/css/style.css | 12 +- [core]/esx_progressbar/nui/index.html | 157 ++-- [core]/esx_progressbar/nui/js/script.js | 96 +-- [core]/esx_textui/nui/css/style.css | 84 +- [core]/esx_textui/nui/index.html | 55 +- [core]/esx_textui/nui/js/script.js | 112 +-- 49 files changed, 3915 insertions(+), 2635 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..383d3ca5 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +trim_trailing_whitespace = true +max_line_length = 300 +indent_size = 4 +indent_style = space \ No newline at end of file diff --git a/[core]/cron/server/main.lua b/[core]/cron/server/main.lua index d82214a7..fb47a435 100644 --- a/[core]/cron/server/main.lua +++ b/[core]/cron/server/main.lua @@ -3,8 +3,8 @@ local LastTime = nil function RunAt(h, m, cb) Jobs[#Jobs + 1] = { - h = h, - m = m, + h = h, + m = m, cb = cb } end @@ -15,7 +15,11 @@ function GetTime() local h = tonumber(os.date('%H', timestamp)) local m = tonumber(os.date('%M', timestamp)) - return { d = d, h = h, m = m } + return { + d = d, + h = h, + m = m + } end function OnTime(d, h, m) diff --git a/[core]/es_extended/client/functions.lua b/[core]/es_extended/client/functions.lua index 47466708..7ba5dcc3 100644 --- a/[core]/es_extended/client/functions.lua +++ b/[core]/es_extended/client/functions.lua @@ -26,7 +26,7 @@ end function ESX.SearchInventory(items, count) if type(items) == 'string' then - items = {items} + items = { items } end local returnData = {} @@ -154,7 +154,7 @@ if GetResourceState("esx_context") ~= "missing" then end function ESX.RefreshContext(...) - exports["esx_context"]:Refresh(...) + exports["esx_context"]:Refresh(...) end else function ESX.OpenContext() @@ -203,7 +203,6 @@ function ESX.UI.Menu.Open(type, namespace, name, data, submit, cancel, change, c menu.change = change menu.close = function() - ESX.UI.Menu.RegisteredTypes[type].close(namespace, name) for i = 1, #ESX.UI.Menu.Opened, 1 do @@ -218,11 +217,9 @@ function ESX.UI.Menu.Open(type, namespace, name, data, submit, cancel, change, c if close then close() end - end menu.update = function(query, newData) - for i = 1, #menu.data.elements, 1 do local match = true @@ -238,7 +235,6 @@ function ESX.UI.Menu.Open(type, namespace, name, data, submit, cancel, change, c end end end - end menu.refresh = function() @@ -266,7 +262,6 @@ function ESX.UI.Menu.Open(type, namespace, name, data, submit, cancel, change, c break end end - end end end @@ -496,7 +491,6 @@ function ESX.Game.GetPlayers(onlyOtherPlayers, returnKeyValue, returnPeds) return players end - function ESX.Game.GetClosestObject(coords, modelFilter) return ESX.Game.GetClosestEntity(ESX.Game.GetObjects(), false, coords, modelFilter) end @@ -604,19 +598,19 @@ function ESX.Game.GetVehicleProperties(vehicle) local interiorColor = GetVehicleInteriorColour(vehicle) local customPrimaryColor = nil if hasCustomPrimaryColor then - customPrimaryColor = {GetVehicleCustomPrimaryColour(vehicle)} + customPrimaryColor = { GetVehicleCustomPrimaryColour(vehicle) } end local hasCustomXenonColor, customXenonColorR, customXenonColorG, customXenonColorB = GetVehicleXenonLightsCustomColor(vehicle) local customXenonColor = nil if hasCustomXenonColor then - customXenonColor = {customXenonColorR, customXenonColorG, customXenonColorB} + customXenonColor = { customXenonColorR, customXenonColorG, customXenonColorB } end local hasCustomSecondaryColor = GetIsVehicleSecondaryColourCustom(vehicle) local customSecondaryColor = nil if hasCustomSecondaryColor then - customSecondaryColor = {GetVehicleCustomSecondaryColour(vehicle)} + customSecondaryColor = { GetVehicleCustomSecondaryColour(vehicle) } end local extras = {} @@ -634,11 +628,11 @@ function ESX.Game.GetVehicleProperties(vehicle) local doorsBroken, windowsBroken, tyreBurst = {}, {}, {} local numWheels = tostring(GetVehicleNumberOfWheels(vehicle)) - local TyresIndex = { -- Wheel index list according to the number of vehicle wheels. - ['2'] = {0, 4}, -- Bike and cycle. - ['3'] = {0, 1, 4, 5}, -- Vehicle with 3 wheels (get for wheels because some 3 wheels vehicles have 2 wheels on front and one rear or the reverse). - ['4'] = {0, 1, 4, 5}, -- Vehicle with 4 wheels. - ['6'] = {0, 1, 2, 3, 4, 5} -- Vehicle with 6 wheels. + local TyresIndex = { -- Wheel index list according to the number of vehicle wheels. + ['2'] = { 0, 4 }, -- Bike and cycle. + ['3'] = { 0, 1, 4, 5 }, -- Vehicle with 3 wheels (get for wheels because some 3 wheels vehicles have 2 wheels on front and one rear or the reverse). + ['4'] = { 0, 1, 4, 5 }, -- Vehicle with 4 wheels. + ['6'] = { 0, 1, 2, 3, 4, 5 } -- Vehicle with 6 wheels. } if TyresIndex[numWheels] then @@ -647,7 +641,7 @@ function ESX.Game.GetVehicleProperties(vehicle) end end - for windowId = 0, 7 do -- 13 + for windowId = 0, 7 do -- 13 RollUpWindow(vehicle, windowId) --fix when you put the car away with the window down windowsBroken[tostring(windowId)] = not IsVehicleWindowIntact(vehicle, windowId) end @@ -690,8 +684,8 @@ function ESX.Game.GetVehicleProperties(vehicle) xenonColor = GetVehicleXenonLightsColor(vehicle), customXenonColor = customXenonColor, - neonEnabled = {IsVehicleNeonLightEnabled(vehicle, 0), IsVehicleNeonLightEnabled(vehicle, 1), - IsVehicleNeonLightEnabled(vehicle, 2), IsVehicleNeonLightEnabled(vehicle, 3)}, + neonEnabled = { IsVehicleNeonLightEnabled(vehicle, 0), IsVehicleNeonLightEnabled(vehicle, 1), + IsVehicleNeonLightEnabled(vehicle, 2), IsVehicleNeonLightEnabled(vehicle, 3) }, neonColor = table.pack(GetVehicleNeonLightsColour(vehicle)), extras = extras, @@ -723,7 +717,7 @@ function ESX.Game.GetVehicleProperties(vehicle) modXenon = IsToggleModOn(vehicle, 22), modFrontWheels = GetVehicleMod(vehicle, 23), - modCustomFrontWheels = GetVehicleModVariation(vehicle, 23), + modCustomFrontWheels = GetVehicleModVariation(vehicle, 23), modBackWheels = GetVehicleMod(vehicle, 24), modCustomBackWheels = GetVehicleModVariation(vehicle, 24), @@ -836,7 +830,7 @@ function ESX.Game.SetVehicleProperties(vehicle, props) end end - if props.driftTyresEnabled then + if props.driftTyresEnabled then SetDriftTyresEnabled(vehicle, true) end @@ -921,8 +915,8 @@ function ESX.Game.SetVehicleProperties(vehicle, props) if props.modFrontWheels ~= nil then SetVehicleMod(vehicle, 23, props.modFrontWheels, false) end - if props.modCustomFrontWheels ~= nil then - SetVehicleMod(vehicle, 23, props.modCustomFrontWheels, false) + if props.modCustomFrontWheels ~= nil then + SetVehicleMod(vehicle, 23, props.modCustomFrontWheels, false) end if props.modBackWheels ~= nil then SetVehicleMod(vehicle, 24, props.modBackWheels, false) @@ -1074,7 +1068,7 @@ function ESX.ShowInventory() local playerPed = ESX.PlayerData.ped local elements = { - {unselectable = true, icon = 'fas fa-box', title = 'Player Inventory'} + { unselectable = true, icon = 'fas fa-box', title = 'Player Inventory' } } local currentWeight = 0 @@ -1083,7 +1077,7 @@ function ESX.ShowInventory() local formattedMoney = TranslateCap('locale_currency', ESX.Math.GroupDigits(ESX.PlayerData.accounts[i].money)) local canDrop = ESX.PlayerData.accounts[i].name ~= 'bank' - elements[#elements+1] = { + elements[#elements + 1] = { icon = 'fas fa-money-bill-wave', title = ('%s: %s'):format(ESX.PlayerData.accounts[i].label, formattedMoney), count = ESX.PlayerData.accounts[i].money, @@ -1100,7 +1094,7 @@ function ESX.ShowInventory() if v.count > 0 then currentWeight = currentWeight + (v.weight * v.count) - elements[#elements+1] = { + elements[#elements + 1] = { icon = 'fas fa-box', title = ('%s x%s'):format(v.label, v.count), count = v.count, @@ -1119,7 +1113,7 @@ function ESX.ShowInventory() if HasPedGotWeapon(playerPed, weaponHash, false) then local ammo = GetAmmoInPedWeapon(playerPed, weaponHash) - elements[#elements+1] = { + elements[#elements + 1] = { icon = 'fas fa-gun', title = v.ammo and ('%s - %s %s'):format(v.label, ammo, v.ammo.label) or v.label, count = 1, @@ -1134,10 +1128,10 @@ function ESX.ShowInventory() end end - elements[#elements+1] = { + elements[#elements + 1] = { unselectable = true, icon = "fas fa-weight", - title = "Current Weight: "..currentWeight + title = "Current Weight: " .. currentWeight } ESX.CloseContext() @@ -1148,7 +1142,7 @@ function ESX.ShowInventory() local elements2 = {} if element.usable then - elements2[#elements2+1] = { + elements2[#elements2 + 1] = { icon = "fas fa-utensils", title = TranslateCap('use'), action = 'use', @@ -1159,7 +1153,7 @@ function ESX.ShowInventory() if element.canRemove then if player ~= -1 and distance <= 3.0 then - elements2[#elements2+1] = { + elements2[#elements2 + 1] = { icon = "fas fa-hands", title = TranslateCap('give'), action = 'give', @@ -1168,7 +1162,7 @@ function ESX.ShowInventory() } end - elements2[#elements2+1] = { + elements2[#elements2 + 1] = { icon = "fas fa-trash", title = TranslateCap('remove'), action = 'remove', @@ -1178,7 +1172,7 @@ function ESX.ShowInventory() end if element.type == 'item_weapon' and element.canGiveAmmo and element.ammo > 0 and player ~= -1 and distance <= 3.0 then - elements2[#elements2+1] = { + elements2[#elements2 + 1] = { icon = "fas fa-gun", title = TranslateCap('giveammo'), action = 'give_ammo', @@ -1187,7 +1181,7 @@ function ESX.ShowInventory() } end - elements2[#elements2+1] = { + elements2[#elements2 + 1] = { icon = "fas fa-arrow-left", title = TranslateCap('return'), action = 'return' @@ -1202,7 +1196,7 @@ function ESX.ShowInventory() if #playersNearby > 0 then local players = {} local elements3 = { - {unselectable = true, icon = "fas fa-users", title = "Nearby Players"} + { unselectable = true, icon = "fas fa-users", title = "Nearby Players" } } for _, playerNearby in ipairs(playersNearby) do @@ -1211,7 +1205,7 @@ function ESX.ShowInventory() ESX.TriggerServerCallback('esx:getPlayerNames', function(returnedPlayers) for playerId, playerName in pairs(returnedPlayers) do - elements3[#elements3+1] = { + elements3[#elements3 + 1] = { icon = "fas fa-user", title = playerName, playerId = playerId @@ -1232,9 +1226,9 @@ function ESX.ShowInventory() ESX.CloseContext() else local elementsG = { - {unselectable = true, icon = "fas fa-trash", title = element.title}, - {icon = "fas fa-tally", title = "Amount.", input = true, inputType = "number", inputPlaceholder = "Amount to give..", inputMin = 1, inputMax = 1000}, - {icon = "fas fa-check-double", title = "Confirm", val = "confirm"} + { unselectable = true, icon = "fas fa-trash", title = element.title }, + { icon = "fas fa-tally", title = "Amount.", input = true, inputType = "number", inputPlaceholder = "Amount to give..", inputMin = 1, inputMax = 1000 }, + { icon = "fas fa-check-double", title = "Confirm", val = "confirm" } } ESX.OpenContext("right", elementsG, function(menuG, _) @@ -1271,9 +1265,9 @@ function ESX.ShowInventory() TriggerServerEvent('esx:removeInventoryItem', type, item) else local elementsR = { - {unselectable = true, icon = "fas fa-trash", title = element.title}, - {icon = "fas fa-tally", title = "Amount.", input = true, inputType = "number", inputPlaceholder = "Amount to remove..", inputMin = 1, inputMax = 1000}, - {icon = "fas fa-check-double", title = "Confirm", val = "confirm"} + { unselectable = true, icon = "fas fa-trash", title = element.title }, + { icon = "fas fa-tally", title = "Amount.", input = true, inputType = "number", inputPlaceholder = "Amount to remove..", inputMin = 1, inputMax = 1000 }, + { icon = "fas fa-check-double", title = "Confirm", val = "confirm" } } ESX.OpenContext("right", elementsR, function(menuR, _) @@ -1306,9 +1300,9 @@ function ESX.ShowInventory() if closestPlayer ~= -1 and closestDistance < 3.0 then if pedAmmo > 0 then local elementsGA = { - {unselectable = true, icon = "fas fa-trash", title = element.title}, - {icon = "fas fa-tally", title = "Amount.", input = true, inputType = "number", inputPlaceholder = "Amount to give..", inputMin = 1, inputMax = 1000}, - {icon = "fas fa-check-double", title = "Confirm", val = "confirm"} + { unselectable = true, icon = "fas fa-trash", title = element.title }, + { icon = "fas fa-tally", title = "Amount.", input = true, inputType = "number", inputPlaceholder = "Amount to give..", inputMin = 1, inputMax = 1000 }, + { icon = "fas fa-check-double", title = "Confirm", val = "confirm" } } ESX.OpenContext("right", elementsGA, function(menuGA, _) @@ -1360,20 +1354,20 @@ end) function ESX.GetVehicleType(model) model = type(model) == 'string' and joaat(model) or model - if model == `submersible` or model == `submersible2` then + if model == `submersible` or model == `submersible2` then return 'submarine' - end + end - local vehicleType = GetVehicleClassFromName(model) - local types = { - [8] = "bike", - [11] = "trailer", - [13] = "bike", - [14] = "boat", - [15] = "heli", - [16] = "plane", - [21] = "train", - } + local vehicleType = GetVehicleClassFromName(model) + local types = { + [8] = "bike", + [11] = "trailer", + [13] = "bike", + [14] = "boat", + [15] = "heli", + [16] = "plane", + [21] = "train", + } return types[vehicleType] or "automobile" end diff --git a/[core]/es_extended/config.lua b/[core]/es_extended/config.lua index 6bafa027..a2bf5b6a 100644 --- a/[core]/es_extended/config.lua +++ b/[core]/es_extended/config.lua @@ -33,56 +33,56 @@ Config.AdminGroups = { } -Config.EnablePaycheck = true -- enable paycheck -Config.LogPaycheck = false -- Logs paychecks to a nominated Discord channel via webhook (default is false) -Config.EnableSocietyPayouts = false -- pay from the society account that the player is employed at? Requirement: esx_society -Config.MaxWeight = 24 -- the max inventory weight without backpack +Config.EnablePaycheck = true -- enable paycheck +Config.LogPaycheck = false -- Logs paychecks to a nominated Discord channel via webhook (default is false) +Config.EnableSocietyPayouts = false -- pay from the society account that the player is employed at? Requirement: esx_society +Config.MaxWeight = 24 -- the max inventory weight without backpack Config.PaycheckInterval = 7 * 60000 -- how often to recieve pay checks in milliseconds -Config.EnableDebug = false -- Use Debug options? -Config.EnableDefaultInventory = true -- Display the default Inventory ( F2 ) -Config.EnableWantedLevel = false -- Use Normal GTA wanted Level? -Config.EnablePVP = true -- Allow Player to player combat +Config.EnableDebug = false -- Use Debug options? +Config.EnableDefaultInventory = true -- Display the default Inventory ( F2 ) +Config.EnableWantedLevel = false -- Use Normal GTA wanted Level? +Config.EnablePVP = true -- Allow Player to player combat Config.Multichar = GetResourceState("esx_multicharacter") ~= "missing" -Config.Identity = true -- Select a characters identity data before they have loaded in (this happens by default with multichar) -Config.DistanceGive = 4.0 -- Max distance when giving items, weapons etc. +Config.Identity = true -- Select a characters identity data before they have loaded in (this happens by default with multichar) +Config.DistanceGive = 4.0 -- Max distance when giving items, weapons etc. -Config.AdminLogging = false -- Logs the usage of certain commands by those with group.admin ace permissions (default is false) +Config.AdminLogging = false -- Logs the usage of certain commands by those with group.admin ace permissions (default is false) -Config.DisableHealthRegeneration = false -- Player will no longer regenerate health -Config.DisableVehicleRewards = false -- Disables Player Recieving weapons from vehicles -Config.DisableNPCDrops = false -- stops NPCs from dropping weapons on death -Config.DisableDispatchServices = false -- Disable Dispatch services -Config.DisableScenarios = false -- Disable Scenarios -Config.DisableWeaponWheel = false -- Disables default weapon wheel -Config.DisableAimAssist = false -- disables AIM assist (mainly on controllers) -Config.DisableVehicleSeatShuff = false -- Disables vehicle seat shuff +Config.DisableHealthRegeneration = false -- Player will no longer regenerate health +Config.DisableVehicleRewards = false -- Disables Player Recieving weapons from vehicles +Config.DisableNPCDrops = false -- stops NPCs from dropping weapons on death +Config.DisableDispatchServices = false -- Disable Dispatch services +Config.DisableScenarios = false -- Disable Scenarios +Config.DisableWeaponWheel = false -- Disables default weapon wheel +Config.DisableAimAssist = false -- disables AIM assist (mainly on controllers) +Config.DisableVehicleSeatShuff = false -- Disables vehicle seat shuff Config.RemoveHudCommonents = { - [1] = false, --WANTED_STARS, - [2] = false, --WEAPON_ICON - [3] = false, --CASH - [4] = false, --MP_CASH - [5] = false, --MP_MESSAGE - [6] = false, --VEHICLE_NAME - [7] = false, -- AREA_NAME - [8] = false, -- VEHICLE_CLASS - [9] = false, --STREET_NAME - [10] = false, --HELP_TEXT - [11] = false, --FLOATING_HELP_TEXT_1 - [12] = false, --FLOATING_HELP_TEXT_2 - [13] = false, --CASH_CHANGE - [14] = false, --RETICLE - [15] = false, --SUBTITLE_TEXT - [16] = false, --RADIO_STATIONS - [17] = false, --SAVING_GAME, - [18] = false, --GAME_STREAM - [19] = false, --WEAPON_WHEEL - [20] = false, --WEAPON_WHEEL_STATS - [21] = false, --HUD_COMPONENTS - [22] = false, --HUD_WEAPONS + [1] = false, --WANTED_STARS, + [2] = false, --WEAPON_ICON + [3] = false, --CASH + [4] = false, --MP_CASH + [5] = false, --MP_MESSAGE + [6] = false, --VEHICLE_NAME + [7] = false, -- AREA_NAME + [8] = false, -- VEHICLE_CLASS + [9] = false, --STREET_NAME + [10] = false, --HELP_TEXT + [11] = false, --FLOATING_HELP_TEXT_1 + [12] = false, --FLOATING_HELP_TEXT_2 + [13] = false, --CASH_CHANGE + [14] = false, --RETICLE + [15] = false, --SUBTITLE_TEXT + [16] = false, --RADIO_STATIONS + [17] = false, --SAVING_GAME, + [18] = false, --GAME_STREAM + [19] = false, --WEAPON_WHEEL + [20] = false, --WEAPON_WHEEL_STATS + [21] = false, --HUD_COMPONENTS + [22] = false, --HUD_WEAPONS } -Config.SpawnVehMaxUpgrades = true -- admin vehicles spawn with max vehcle settings +Config.SpawnVehMaxUpgrades = true -- admin vehicles spawn with max vehcle settings Config.CustomAIPlates = '........' -- Custom plates for AI vehicles -- Pattern string format --1 will lead to a random number from 0-9. diff --git a/[core]/es_extended/config.weapons.lua b/[core]/es_extended/config.weapons.lua index cd9bc1ec..83bdd8d7 100644 --- a/[core]/es_extended/config.weapons.lua +++ b/[core]/es_extended/config.weapons.lua @@ -317,7 +317,7 @@ Config.Weapons = { { name = 'grip', label = TranslateCap('component_grip'), hash = `COMPONENT_AT_AR_AFGRIP` } } }, - { name = 'WEAPON_MUSKET', label = TranslateCap('weapon_musket'), tints = Config.DefaultWeaponTints, components = {}, ammo = { label = TranslateCap('ammo_rounds'), hash = `AMMO_SHOTGUN` } }, + { name = 'WEAPON_MUSKET', label = TranslateCap('weapon_musket'), tints = Config.DefaultWeaponTints, components = {}, ammo = { label = TranslateCap('ammo_rounds'), hash = `AMMO_SHOTGUN` } }, { name = 'WEAPON_PUMPSHOTGUN', label = TranslateCap('weapon_pumpshotgun'), @@ -937,14 +937,14 @@ Config.Weapons = { } }, -- Heavy / Launchers - { name = 'WEAPON_COMPACTLAUNCHER', label = TranslateCap('weapon_compactlauncher'), tints = Config.DefaultWeaponTints, components = {}, ammo = { label = TranslateCap('ammo_grenadelauncher'), hash = `AMMO_GRENADELAUNCHER` } }, + { name = 'WEAPON_COMPACTLAUNCHER', label = TranslateCap('weapon_compactlauncher'), tints = Config.DefaultWeaponTints, components = {}, ammo = { label = TranslateCap('ammo_grenadelauncher'), hash = `AMMO_GRENADELAUNCHER` } }, { name = 'WEAPON_FIREWORK', label = TranslateCap('weapon_firework'), components = {}, ammo = { label = TranslateCap('ammo_firework'), hash = `AMMO_FIREWORK` } }, - { name = 'WEAPON_GRENADELAUNCHER', label = TranslateCap('weapon_grenadelauncher'), tints = Config.DefaultWeaponTints, components = {}, ammo = { label = TranslateCap('ammo_grenadelauncher'), hash = `AMMO_GRENADELAUNCHER` } }, - { name = 'WEAPON_HOMINGLAUNCHER', label = TranslateCap('weapon_hominglauncher'), tints = Config.DefaultWeaponTints, components = {}, ammo = { label = TranslateCap('ammo_rockets'), hash = `AMMO_HOMINGLAUNCHER` } }, - { name = 'WEAPON_MINIGUN', label = TranslateCap('weapon_minigun'), tints = Config.DefaultWeaponTints, components = {}, ammo = { label = TranslateCap('ammo_rounds'), hash = `AMMO_MINIGUN` } }, - { name = 'WEAPON_RAILGUN', label = TranslateCap('weapon_railgun'), tints = Config.DefaultWeaponTints, components = {}, ammo = { label = TranslateCap('ammo_rounds'), hash = `AMMO_RAILGUN` } }, - { name = 'WEAPON_RPG', label = TranslateCap('weapon_rpg'), tints = Config.DefaultWeaponTints, components = {}, ammo = { label = TranslateCap('ammo_rockets'), hash = `AMMO_RPG` } }, - { name = 'WEAPON_RAYMINIGUN', label = TranslateCap('weapon_rayminigun'), tints = Config.DefaultWeaponTints, components = {}, ammo = { label = TranslateCap('ammo_rounds'), hash = `AMMO_MINIGUN` } }, + { name = 'WEAPON_GRENADELAUNCHER', label = TranslateCap('weapon_grenadelauncher'), tints = Config.DefaultWeaponTints, components = {}, ammo = { label = TranslateCap('ammo_grenadelauncher'), hash = `AMMO_GRENADELAUNCHER` } }, + { name = 'WEAPON_HOMINGLAUNCHER', label = TranslateCap('weapon_hominglauncher'), tints = Config.DefaultWeaponTints, components = {}, ammo = { label = TranslateCap('ammo_rockets'), hash = `AMMO_HOMINGLAUNCHER` } }, + { name = 'WEAPON_MINIGUN', label = TranslateCap('weapon_minigun'), tints = Config.DefaultWeaponTints, components = {}, ammo = { label = TranslateCap('ammo_rounds'), hash = `AMMO_MINIGUN` } }, + { name = 'WEAPON_RAILGUN', label = TranslateCap('weapon_railgun'), tints = Config.DefaultWeaponTints, components = {}, ammo = { label = TranslateCap('ammo_rounds'), hash = `AMMO_RAILGUN` } }, + { name = 'WEAPON_RPG', label = TranslateCap('weapon_rpg'), tints = Config.DefaultWeaponTints, components = {}, ammo = { label = TranslateCap('ammo_rockets'), hash = `AMMO_RPG` } }, + { name = 'WEAPON_RAYMINIGUN', label = TranslateCap('weapon_rayminigun'), tints = Config.DefaultWeaponTints, components = {}, ammo = { label = TranslateCap('ammo_rounds'), hash = `AMMO_MINIGUN` } }, -- Thrown { name = 'WEAPON_BALL', label = TranslateCap('weapon_ball'), components = {}, ammo = { label = TranslateCap('ammo_ball'), hash = `AMMO_BALL` } }, { name = 'WEAPON_BZGAS', label = TranslateCap('weapon_bzgas'), components = {}, ammo = { label = TranslateCap('ammo_bzgas'), hash = `AMMO_BZGAS` } }, diff --git a/[core]/es_extended/html/css/app.css b/[core]/es_extended/html/css/app.css index cfd2f67b..6d4b095c 100644 --- a/[core]/es_extended/html/css/app.css +++ b/[core]/es_extended/html/css/app.css @@ -1,76 +1,75 @@ @font-face { - font-family: "Pricedown"; - src: url("../fonts/pdown.ttf"); + font-family: "Pricedown"; + src: url("../fonts/pdown.ttf"); } @font-face { - font-family: "bankgothic"; - src: url("../fonts/bankgothic.ttf"); + font-family: "bankgothic"; + src: url("../fonts/bankgothic.ttf"); } html { - overflow: hidden; + overflow: hidden; } #inventory_notifications { - font-family: bankgothic; - position: absolute; - right: 40; - bottom: 40; - font-size: 2em; - font-weight: bold; - color: #fff; - text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, - 1px 1px 0 #000; + font-family: bankgothic; + position: absolute; + right: 40; + bottom: 40; + font-size: 2em; + font-weight: bold; + color: #fff; + text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000; } .menu { - font-family: "Open Sans", sans-serif; - min-width: 400px; - min-height: 250px; - color: #fff; - position: absolute; - left: 40; - top: 0; + font-family: "Open Sans", sans-serif; + min-width: 400px; + min-height: 250px; + color: #fff; + position: absolute; + left: 40; + top: 0; } .menu .head { - font-family: "Open Sans", sans-serif; - font-size: 28px; - padding: 10px; - background: #1a1a1a; - border-bottom: 3px solid #bc1635; - border-radius: 10px 10px 0 0; - -webkit-border-radius: 10px 10px 0 0; - -moz-border-radius: 10px 10px 0 0; - -o-border-radius: 10px 10px 0 0; - box-shadow: inset 0px 1px 0 rgba(255, 255, 255, 0.28); - -webkit-box-shadow: inset 0px 1px 0 rgba(255, 255, 255, 0.28); - -moz-box-shadow: inset 0px 1px 0 rgba(255, 255, 255, 0.28); - -o-box-shadow: inset 0px 1px 0 rgba(255, 255, 255, 0.28); - box-shadow: 1px 1px 10px 4px rgba(0, 0, 0, 0.4); + font-family: "Open Sans", sans-serif; + font-size: 28px; + padding: 10px; + background: #1a1a1a; + border-bottom: 3px solid #bc1635; + border-radius: 10px 10px 0 0; + -webkit-border-radius: 10px 10px 0 0; + -moz-border-radius: 10px 10px 0 0; + -o-border-radius: 10px 10px 0 0; + box-shadow: inset 0px 1px 0 rgba(255, 255, 255, 0.28); + -webkit-box-shadow: inset 0px 1px 0 rgba(255, 255, 255, 0.28); + -moz-box-shadow: inset 0px 1px 0 rgba(255, 255, 255, 0.28); + -o-box-shadow: inset 0px 1px 0 rgba(255, 255, 255, 0.28); + box-shadow: 1px 1px 10px 4px rgba(0, 0, 0, 0.4); } .menu .head span { - font-family: "Pricedown"; - font-size: 28px; - padding-left: 15px; - padding-top: 6px; + font-family: "Pricedown"; + font-size: 28px; + padding-left: 15px; + padding-top: 6px; } .menu .menu-items .menu-item { - font-family: "Open Sans", sans-serif; - font-size: 14px; - height: 40px; - display: block; - background-color: #f1f1f1; - box-shadow: inset 1px 0px 0px 1px #b8b8b8; - height: 32px; - line-height: 32px; - color: #3a3a3a; - text-align: center; + font-family: "Open Sans", sans-serif; + font-size: 14px; + height: 40px; + display: block; + background-color: #f1f1f1; + box-shadow: inset 1px 0px 0px 1px #b8b8b8; + height: 32px; + line-height: 32px; + color: #3a3a3a; + text-align: center; } .menu .menu-items .menu-item.selected { - background-color: #ccc; + background-color: #ccc; } diff --git a/[core]/es_extended/html/js/app.js b/[core]/es_extended/html/js/app.js index 029ecc00..4a95fe12 100644 --- a/[core]/es_extended/html/js/app.js +++ b/[core]/es_extended/html/js/app.js @@ -1,40 +1,40 @@ (() => { - ESX = {}; + ESX = {}; - ESX.inventoryNotification = function (add, label, count) { - let notif = ""; + ESX.inventoryNotification = function (add, label, count) { + let notif = ""; - if (add) { - notif += "+"; - } else { - notif += "-"; - } + if (add) { + notif += "+"; + } else { + notif += "-"; + } - if (count) { - notif += count + " " + label; - } else { - notif += " " + label; - } + if (count) { + notif += count + " " + label; + } else { + notif += " " + label; + } - let elem = $("
" + notif + "
"); - $("#inventory_notifications").append(elem); + let elem = $("
" + notif + "
"); + $("#inventory_notifications").append(elem); - $(elem) - .delay(3000) - .fadeOut(1000, function () { - elem.remove(); - }); - }; + $(elem) + .delay(3000) + .fadeOut(1000, function () { + elem.remove(); + }); + }; - window.onData = (data) => { - if (data.action === "inventoryNotification") { - ESX.inventoryNotification(data.add, data.item, data.count); - } - }; + window.onData = (data) => { + if (data.action === "inventoryNotification") { + ESX.inventoryNotification(data.add, data.item, data.count); + } + }; - window.onload = function (e) { - window.addEventListener("message", (event) => { - onData(event.data); - }); - }; + window.onload = function (e) { + window.addEventListener("message", (event) => { + onData(event.data); + }); + }; })(); diff --git a/[core]/es_extended/html/js/mustache.min.js b/[core]/es_extended/html/js/mustache.min.js index 520cfcb9..f3656597 100644 --- a/[core]/es_extended/html/js/mustache.min.js +++ b/[core]/es_extended/html/js/mustache.min.js @@ -1 +1,347 @@ -(function defineMustache(global,factory){if(typeof exports==="object"&&exports&&typeof exports.nodeName!=="string"){factory(exports)}else if(typeof define==="function"&&define.amd){define(["exports"],factory)}else{global.Mustache={};factory(global.Mustache)}})(this,function mustacheFactory(mustache){var objectToString=Object.prototype.toString;var isArray=Array.isArray||function isArrayPolyfill(object){return objectToString.call(object)==="[object Array]"};function isFunction(object){return typeof object==="function"}function typeStr(obj){return isArray(obj)?"array":typeof obj}function escapeRegExp(string){return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function hasProperty(obj,propName){return obj!=null&&typeof obj==="object"&&propName in obj}var regExpTest=RegExp.prototype.test;function testRegExp(re,string){return regExpTest.call(re,string)}var nonSpaceRe=/\S/;function isWhitespace(string){return!testRegExp(nonSpaceRe,string)}var entityMap={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function escapeHtml(string){return String(string).replace(/[&<>"'`=\/]/g,function fromEntityMap(s){return entityMap[s]})}var whiteRe=/\s*/;var spaceRe=/\s+/;var equalsRe=/\s*=/;var curlyRe=/\s*\}/;var tagRe=/#|\^|\/|>|\{|&|=|!/;function parseTemplate(template,tags){if(!template)return[];var sections=[];var tokens=[];var spaces=[];var hasTag=false;var nonSpace=false;function stripSpace(){if(hasTag&&!nonSpace){while(spaces.length)delete tokens[spaces.pop()]}else{spaces=[]}hasTag=false;nonSpace=false}var openingTagRe,closingTagRe,closingCurlyRe;function compileTags(tagsToCompile){if(typeof tagsToCompile==="string")tagsToCompile=tagsToCompile.split(spaceRe,2);if(!isArray(tagsToCompile)||tagsToCompile.length!==2)throw new Error("Invalid tags: "+tagsToCompile);openingTagRe=new RegExp(escapeRegExp(tagsToCompile[0])+"\\s*");closingTagRe=new RegExp("\\s*"+escapeRegExp(tagsToCompile[1]));closingCurlyRe=new RegExp("\\s*"+escapeRegExp("}"+tagsToCompile[1]))}compileTags(tags||mustache.tags);var scanner=new Scanner(template);var start,type,value,chr,token,openSection;while(!scanner.eos()){start=scanner.pos;value=scanner.scanUntil(openingTagRe);if(value){for(var i=0,valueLength=value.length;i0?sections[sections.length-1][4]:nestedTokens;break;default:collector.push(token)}}return nestedTokens}function Scanner(string){this.string=string;this.tail=string;this.pos=0}Scanner.prototype.eos=function eos(){return this.tail===""};Scanner.prototype.scan=function scan(re){var match=this.tail.match(re);if(!match||match.index!==0)return"";var string=match[0];this.tail=this.tail.substring(string.length);this.pos+=string.length;return string};Scanner.prototype.scanUntil=function scanUntil(re){var index=this.tail.search(re),match;switch(index){case-1:match=this.tail;this.tail="";break;case 0:match="";break;default:match=this.tail.substring(0,index);this.tail=this.tail.substring(index)}this.pos+=match.length;return match};function Context(view,parentContext){this.view=view;this.cache={".":this.view};this.parent=parentContext}Context.prototype.push=function push(view){return new Context(view,this)};Context.prototype.lookup=function lookup(name){var cache=this.cache;var value;if(cache.hasOwnProperty(name)){value=cache[name]}else{var context=this,names,index,lookupHit=false;while(context){if(name.indexOf(".")>0){value=context.view;names=name.split(".");index=0;while(value!=null&&index")value=this.renderPartial(token,context,partials,originalTemplate);else if(symbol==="&")value=this.unescapedValue(token,context);else if(symbol==="name")value=this.escapedValue(token,context);else if(symbol==="text")value=this.rawValue(token);if(value!==undefined)buffer+=value}return buffer};Writer.prototype.renderSection=function renderSection(token,context,partials,originalTemplate){var self=this;var buffer="";var value=context.lookup(token[1]);function subRender(template){return self.render(template,context,partials)}if(!value)return;if(isArray(value)){for(var j=0,valueLength=value.length;j": ">", '"': """, "'": "'", "/": "/", "`": "`", "=": "=" }; + function escapeHtml(string) { + return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap(s) { + return entityMap[s]; + }); + } + var whiteRe = /\s*/; + var spaceRe = /\s+/; + var equalsRe = /\s*=/; + var curlyRe = /\s*\}/; + var tagRe = /#|\^|\/|>|\{|&|=|!/; + function parseTemplate(template, tags) { + if (!template) return []; + var sections = []; + var tokens = []; + var spaces = []; + var hasTag = false; + var nonSpace = false; + function stripSpace() { + if (hasTag && !nonSpace) { + while (spaces.length) delete tokens[spaces.pop()]; + } else { + spaces = []; + } + hasTag = false; + nonSpace = false; + } + var openingTagRe, closingTagRe, closingCurlyRe; + function compileTags(tagsToCompile) { + if (typeof tagsToCompile === "string") tagsToCompile = tagsToCompile.split(spaceRe, 2); + if (!isArray(tagsToCompile) || tagsToCompile.length !== 2) throw new Error("Invalid tags: " + tagsToCompile); + openingTagRe = new RegExp(escapeRegExp(tagsToCompile[0]) + "\\s*"); + closingTagRe = new RegExp("\\s*" + escapeRegExp(tagsToCompile[1])); + closingCurlyRe = new RegExp("\\s*" + escapeRegExp("}" + tagsToCompile[1])); + } + compileTags(tags || mustache.tags); + var scanner = new Scanner(template); + var start, type, value, chr, token, openSection; + while (!scanner.eos()) { + start = scanner.pos; + value = scanner.scanUntil(openingTagRe); + if (value) { + for (var i = 0, valueLength = value.length; i < valueLength; ++i) { + chr = value.charAt(i); + if (isWhitespace(chr)) { + spaces.push(tokens.length); + } else { + nonSpace = true; + } + tokens.push(["text", chr, start, start + 1]); + start += 1; + if (chr === "\n") stripSpace(); + } + } + if (!scanner.scan(openingTagRe)) break; + hasTag = true; + type = scanner.scan(tagRe) || "name"; + scanner.scan(whiteRe); + if (type === "=") { + value = scanner.scanUntil(equalsRe); + scanner.scan(equalsRe); + scanner.scanUntil(closingTagRe); + } else if (type === "{") { + value = scanner.scanUntil(closingCurlyRe); + scanner.scan(curlyRe); + scanner.scanUntil(closingTagRe); + type = "&"; + } else { + value = scanner.scanUntil(closingTagRe); + } + if (!scanner.scan(closingTagRe)) throw new Error("Unclosed tag at " + scanner.pos); + token = [type, value, start, scanner.pos]; + tokens.push(token); + if (type === "#" || type === "^") { + sections.push(token); + } else if (type === "/") { + openSection = sections.pop(); + if (!openSection) throw new Error('Unopened section "' + value + '" at ' + start); + if (openSection[1] !== value) throw new Error('Unclosed section "' + openSection[1] + '" at ' + start); + } else if (type === "name" || type === "{" || type === "&") { + nonSpace = true; + } else if (type === "=") { + compileTags(value); + } + } + openSection = sections.pop(); + if (openSection) throw new Error('Unclosed section "' + openSection[1] + '" at ' + scanner.pos); + return nestTokens(squashTokens(tokens)); + } + function squashTokens(tokens) { + var squashedTokens = []; + var token, lastToken; + for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) { + token = tokens[i]; + if (token) { + if (token[0] === "text" && lastToken && lastToken[0] === "text") { + lastToken[1] += token[1]; + lastToken[3] = token[3]; + } else { + squashedTokens.push(token); + lastToken = token; + } + } + } + return squashedTokens; + } + function nestTokens(tokens) { + var nestedTokens = []; + var collector = nestedTokens; + var sections = []; + var token, section; + for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) { + token = tokens[i]; + switch (token[0]) { + case "#": + case "^": + collector.push(token); + sections.push(token); + collector = token[4] = []; + break; + case "/": + section = sections.pop(); + section[5] = token[2]; + collector = sections.length > 0 ? sections[sections.length - 1][4] : nestedTokens; + break; + default: + collector.push(token); + } + } + return nestedTokens; + } + function Scanner(string) { + this.string = string; + this.tail = string; + this.pos = 0; + } + Scanner.prototype.eos = function eos() { + return this.tail === ""; + }; + Scanner.prototype.scan = function scan(re) { + var match = this.tail.match(re); + if (!match || match.index !== 0) return ""; + var string = match[0]; + this.tail = this.tail.substring(string.length); + this.pos += string.length; + return string; + }; + Scanner.prototype.scanUntil = function scanUntil(re) { + var index = this.tail.search(re), + match; + switch (index) { + case -1: + match = this.tail; + this.tail = ""; + break; + case 0: + match = ""; + break; + default: + match = this.tail.substring(0, index); + this.tail = this.tail.substring(index); + } + this.pos += match.length; + return match; + }; + function Context(view, parentContext) { + this.view = view; + this.cache = { ".": this.view }; + this.parent = parentContext; + } + Context.prototype.push = function push(view) { + return new Context(view, this); + }; + Context.prototype.lookup = function lookup(name) { + var cache = this.cache; + var value; + if (cache.hasOwnProperty(name)) { + value = cache[name]; + } else { + var context = this, + names, + index, + lookupHit = false; + while (context) { + if (name.indexOf(".") > 0) { + value = context.view; + names = name.split("."); + index = 0; + while (value != null && index < names.length) { + if (index === names.length - 1) lookupHit = hasProperty(value, names[index]); + value = value[names[index++]]; + } + } else { + value = context.view[name]; + lookupHit = hasProperty(context.view, name); + } + if (lookupHit) break; + context = context.parent; + } + cache[name] = value; + } + if (isFunction(value)) value = value.call(this.view); + return value; + }; + function Writer() { + this.cache = {}; + } + Writer.prototype.clearCache = function clearCache() { + this.cache = {}; + }; + Writer.prototype.parse = function parse(template, tags) { + var cache = this.cache; + var tokens = cache[template]; + if (tokens == null) tokens = cache[template] = parseTemplate(template, tags); + return tokens; + }; + Writer.prototype.render = function render(template, view, partials) { + var tokens = this.parse(template); + var context = view instanceof Context ? view : new Context(view); + return this.renderTokens(tokens, context, partials, template); + }; + Writer.prototype.renderTokens = function renderTokens(tokens, context, partials, originalTemplate) { + var buffer = ""; + var token, symbol, value; + for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) { + value = undefined; + token = tokens[i]; + symbol = token[0]; + if (symbol === "#") value = this.renderSection(token, context, partials, originalTemplate); + else if (symbol === "^") value = this.renderInverted(token, context, partials, originalTemplate); + else if (symbol === ">") value = this.renderPartial(token, context, partials, originalTemplate); + else if (symbol === "&") value = this.unescapedValue(token, context); + else if (symbol === "name") value = this.escapedValue(token, context); + else if (symbol === "text") value = this.rawValue(token); + if (value !== undefined) buffer += value; + } + return buffer; + }; + Writer.prototype.renderSection = function renderSection(token, context, partials, originalTemplate) { + var self = this; + var buffer = ""; + var value = context.lookup(token[1]); + function subRender(template) { + return self.render(template, context, partials); + } + if (!value) return; + if (isArray(value)) { + for (var j = 0, valueLength = value.length; j < valueLength; ++j) { + buffer += this.renderTokens(token[4], context.push(value[j]), partials, originalTemplate); + } + } else if (typeof value === "object" || typeof value === "string" || typeof value === "number") { + buffer += this.renderTokens(token[4], context.push(value), partials, originalTemplate); + } else if (isFunction(value)) { + if (typeof originalTemplate !== "string") throw new Error("Cannot use higher-order sections without the original template"); + value = value.call(context.view, originalTemplate.slice(token[3], token[5]), subRender); + if (value != null) buffer += value; + } else { + buffer += this.renderTokens(token[4], context, partials, originalTemplate); + } + return buffer; + }; + Writer.prototype.renderInverted = function renderInverted(token, context, partials, originalTemplate) { + var value = context.lookup(token[1]); + if (!value || (isArray(value) && value.length === 0)) return this.renderTokens(token[4], context, partials, originalTemplate); + }; + Writer.prototype.renderPartial = function renderPartial(token, context, partials) { + if (!partials) return; + var value = isFunction(partials) ? partials(token[1]) : partials[token[1]]; + if (value != null) return this.renderTokens(this.parse(value), context, partials, value); + }; + Writer.prototype.unescapedValue = function unescapedValue(token, context) { + var value = context.lookup(token[1]); + if (value != null) return value; + }; + Writer.prototype.escapedValue = function escapedValue(token, context) { + var value = context.lookup(token[1]); + if (value != null) return mustache.escape(value); + }; + Writer.prototype.rawValue = function rawValue(token) { + return token[1]; + }; + mustache.name = "mustache.js"; + mustache.version = "2.3.0"; + mustache.tags = ["{{", "}}"]; + var defaultWriter = new Writer(); + mustache.clearCache = function clearCache() { + return defaultWriter.clearCache(); + }; + mustache.parse = function parse(template, tags) { + return defaultWriter.parse(template, tags); + }; + mustache.render = function render(template, view, partials) { + if (typeof template !== "string") { + throw new TypeError('Invalid template! Template should be a "string" ' + 'but "' + typeStr(template) + '" was given as the first ' + "argument for mustache#render(template, view, partials)"); + } + return defaultWriter.render(template, view, partials); + }; + mustache.to_html = function to_html(template, view, partials, send) { + var result = mustache.render(template, view, partials); + if (isFunction(send)) { + send(result); + } else { + return result; + } + }; + mustache.escape = escapeHtml; + mustache.Scanner = Scanner; + mustache.Context = Context; + mustache.Writer = Writer; + return mustache; +}); diff --git a/[core]/es_extended/html/js/wrapper.js b/[core]/es_extended/html/js/wrapper.js index e4c47650..ee20f261 100644 --- a/[core]/es_extended/html/js/wrapper.js +++ b/[core]/es_extended/html/js/wrapper.js @@ -1,35 +1,34 @@ (() => { - let ESXWrapper = {}; - ESXWrapper.MessageSize = 1024; - ESXWrapper.messageId = 0; + let ESXWrapper = {}; + ESXWrapper.MessageSize = 1024; + ESXWrapper.messageId = 0; - window.SendMessage = function (namespace, type, msg) { - ESXWrapper.messageId = - ESXWrapper.messageId < 65535 ? ESXWrapper.messageId + 1 : 0; - const str = JSON.stringify(msg); + window.SendMessage = function (namespace, type, msg) { + ESXWrapper.messageId = ESXWrapper.messageId < 65535 ? ESXWrapper.messageId + 1 : 0; + const str = JSON.stringify(msg); - for (let i = 0; i < str.length; i++) { - let count = 0; - let chunk = ""; + for (let i = 0; i < str.length; i++) { + let count = 0; + let chunk = ""; - while (count < ESXWrapper.MessageSize && i < str.length) { - chunk += str[i]; + while (count < ESXWrapper.MessageSize && i < str.length) { + chunk += str[i]; - count++; - i++; - } + count++; + i++; + } - i--; + i--; - const data = { - __type: type, - id: ESXWrapper.messageId, - chunk: chunk, - }; + const data = { + __type: type, + id: ESXWrapper.messageId, + chunk: chunk, + }; - if (i === str.length - 1) data.end = true; + if (i === str.length - 1) data.end = true; - $.post("http://" + namespace + "/__chunk", JSON.stringify(data)); - } - }; + $.post("http://" + namespace + "/__chunk", JSON.stringify(data)); + } + }; })(); diff --git a/[core]/es_extended/html/ui.html b/[core]/es_extended/html/ui.html index 86ad62be..bbc9c005 100644 --- a/[core]/es_extended/html/ui.html +++ b/[core]/es_extended/html/ui.html @@ -1,12 +1,12 @@ - - - - -
+ + + + +
- - - - + + + + diff --git a/[core]/es_extended/locales/fr.lua b/[core]/es_extended/locales/fr.lua index e3c3166e..bc5289d5 100644 --- a/[core]/es_extended/locales/fr.lua +++ b/[core]/es_extended/locales/fr.lua @@ -113,7 +113,7 @@ Locales["fr"] = { ["command_giveammo_weapon"] = "Nom de l'arme", ["command_giveammo_ammo"] = "Quantité de munitions", ["tpm_nowaypoint"] = "Aucun point n'est défini sur la carte", - ["tpm_success"] = "Vous avez bien été téléporté", + ["tpm_success"] = "Vous avez bien été téléporté", ["noclip_message"] = "Le mode noclip a été %s", ["enabled"] = "~g~activé~s~", diff --git a/[core]/es_extended/locales/nl.lua b/[core]/es_extended/locales/nl.lua index 9de0115e..af4b920f 100644 --- a/[core]/es_extended/locales/nl.lua +++ b/[core]/es_extended/locales/nl.lua @@ -111,11 +111,11 @@ Locales["nl"] = { ['command_giveammo_ammo'] = 'Ammo Hoeveelheid', ['tpm_nowaypoint'] = 'Geen waypoint gezet.', ['tpm_success'] = 'Successvol geteleporteerd', - + ['noclip_message'] = 'Noclip is %s', ['enabled'] = '~g~aangezet~s~', ['disabled'] = '~r~uitgezet~s~', - + -- Locale settings ["locale_digit_grouping_symbol"] = ",", ["locale_currency"] = "€%s", diff --git a/[core]/es_extended/locales/sl.lua b/[core]/es_extended/locales/sl.lua index 4a485fd3..0e5de612 100644 --- a/[core]/es_extended/locales/sl.lua +++ b/[core]/es_extended/locales/sl.lua @@ -111,11 +111,11 @@ Locales["sl"] = { ['command_giveammo_ammo'] = 'Kolicina streliva', ['tpm_nowaypoint'] = 'Ni nastavljene poti!.', ['tpm_success'] = 'Uspesno teleportiran', - + ['noclip_message'] = 'Noclip je bil %s', ['enabled'] = '~g~Vkljucen~s~', ['disabled'] = '~r~Izkljucen~s~', - + -- Locale settings ["locale_digit_grouping_symbol"] = ",", ["locale_currency"] = "€%s", diff --git a/[core]/es_extended/server/commands.lua b/[core]/es_extended/server/commands.lua index 7e160870..86c64b46 100644 --- a/[core]/es_extended/server/commands.lua +++ b/[core]/es_extended/server/commands.lua @@ -286,12 +286,12 @@ if not Config.OxInventory then if Config.AdminLogging then ESX.DiscordLogFields("UserActions", "Give Weapon Component /giveweaponcomponent Triggered!", "pink", { - { name = "Player", value = xPlayer.name, inline = true }, - { name = "ID", value = xPlayer.source, inline = true }, - { name = "Target", value = args.playerId.name, inline = true }, - { name = "Weapon", value = args.weaponName, inline = true }, - { name = "Component", value = args.componentName, inline = true }, - }) + { name = "Player", value = xPlayer.name, inline = true }, + { name = "ID", value = xPlayer.source, inline = true }, + { name = "Target", value = args.playerId.name, inline = true }, + { name = "Weapon", value = args.weaponName, inline = true }, + { name = "Component", value = args.componentName, inline = true }, + }) end end else @@ -552,6 +552,6 @@ ESX.RegisterCommand('players', "admin", function() for i = 1, #(xPlayers) do local xPlayer = xPlayers[i] print(('^1[^2ID: ^5%s^0 | ^2Name : ^5%s^0 | ^2Group : ^5%s^0 | ^2Identifier : ^5%s^1]^0\n'):format( - xPlayer.source, xPlayer.getName(), xPlayer.getGroup(), xPlayer.identifier)) + xPlayer.source, xPlayer.getName(), xPlayer.getGroup(), xPlayer.identifier)) end end, true) diff --git a/[core]/es_extended/server/functions.lua b/[core]/es_extended/server/functions.lua index 7e15b197..d70369a1 100644 --- a/[core]/es_extended/server/functions.lua +++ b/[core]/es_extended/server/functions.lua @@ -115,7 +115,7 @@ function ESX.RegisterCommand(name, group, cb, allowConsole, suggestion) newArgs[v.name] = string.sub(merge, lenght) end end - + --backwards compatibility if not v.validate and not v.type then error = nil @@ -403,7 +403,7 @@ function ESX.RefreshJobs() if not Jobs then -- Fallback data, if no jobs exist - ESX.Jobs['unemployed'] = {label = 'Unemployed', grades = {['0'] = {grade = 0, label = 'Unemployed', salary = 200, skin_male = {}, skin_female = {}}}} + ESX.Jobs['unemployed'] = { label = 'Unemployed', grades = { ['0'] = { grade = 0, label = 'Unemployed', salary = 200, skin_male = {}, skin_female = {} } } } else ESX.Jobs = Jobs end diff --git a/[core]/es_extended/server/main.lua b/[core]/es_extended/server/main.lua index 607b86a3..d1bc6e0f 100644 --- a/[core]/es_extended/server/main.lua +++ b/[core]/es_extended/server/main.lua @@ -52,11 +52,10 @@ function onPlayerJoined(playerId) ('there was an error loading your character!\nError code: identifier-active-ingame\n\nThis error is caused by a player on this server who has the same identifier as you have. Make sure you are not playing on the same Rockstar account.\n\nYour Rockstar identifier: %s'):format( identifier)) else - local result = MySQL.scalar.await('SELECT 1 FROM users WHERE identifier = ?', {identifier}) + local result = MySQL.scalar.await('SELECT 1 FROM users WHERE identifier = ?', { identifier }) if result then loadESXPlayer(identifier, playerId, false) else - createESXPlayer(identifier, playerId) end end @@ -80,12 +79,12 @@ function createESXPlayer(identifier, playerId, data) end if not Config.Multichar then - MySQL.prepare(newPlayer, {json.encode(accounts), identifier, defaultGroup}, function() + MySQL.prepare(newPlayer, { json.encode(accounts), identifier, defaultGroup }, function() loadESXPlayer(identifier, playerId, true) end) else MySQL.prepare(newPlayer, - {json.encode(accounts), identifier, defaultGroup, data.firstname, data.lastname, data.dateofbirth, data.sex, data.height}, function() + { json.encode(accounts), identifier, defaultGroup, data.firstname, data.lastname, data.dateofbirth, data.sex, data.height }, function() loadESXPlayer(identifier, playerId, true) end) end @@ -104,7 +103,7 @@ if not Config.Multichar then if not Core.DatabaseConnected then return deferrals.done('[ESX] OxMySQL Was Unable To Connect to your database. Please make sure it is turned on and correctly configured in your server.cfg') end - + if identifier then if ESX.GetPlayerFromIdentifier(identifier) then return deferrals.done( @@ -121,249 +120,248 @@ if not Config.Multichar then end function loadESXPlayer(identifier, playerId, isNew) - local userData = { - accounts = {}, - inventory = {}, - job = {}, - loadout = {}, - playerName = GetPlayerName(playerId), - weight = 0, - metadata = {} - } - local result = MySQL.prepare.await(loadPlayer, { identifier }) - local job, grade, jobObject, gradeObject = result.job, tostring(result.job_grade) - local foundAccounts, foundItems = {}, {} + local userData = { + accounts = {}, + inventory = {}, + job = {}, + loadout = {}, + playerName = GetPlayerName(playerId), + weight = 0, + metadata = {} + } + local result = MySQL.prepare.await(loadPlayer, { identifier }) + local job, grade, jobObject, gradeObject = result.job, tostring(result.job_grade) + local foundAccounts, foundItems = {}, {} - -- Accounts - if result.accounts and result.accounts ~= '' then - local accounts = json.decode(result.accounts) + -- Accounts + if result.accounts and result.accounts ~= '' then + local accounts = json.decode(result.accounts) - for account, money in pairs(accounts) do - foundAccounts[account] = money - end - end + for account, money in pairs(accounts) do + foundAccounts[account] = money + end + end - for account, data in pairs(Config.Accounts) do - if data.round == nil then - data.round = true - end - local index = #userData.accounts + 1 - userData.accounts[index] = { - name = account, - money = foundAccounts[account] or Config.StartingAccountMoney[account] or 0, - label = data.label, - round = data.round, - index = index - } - end + for account, data in pairs(Config.Accounts) do + if data.round == nil then + data.round = true + end + local index = #userData.accounts + 1 + userData.accounts[index] = { + name = account, + money = foundAccounts[account] or Config.StartingAccountMoney[account] or 0, + label = data.label, + round = data.round, + index = index + } + end - -- Job - if ESX.DoesJobExist(job, grade) then - jobObject, gradeObject = ESX.Jobs[job], ESX.Jobs[job].grades[grade] - else - print(('[^3WARNING^7] Ignoring invalid job for ^5%s^7 [job: ^5%s^7, grade: ^5%s^7]'):format(identifier, job, grade)) - job, grade = 'unemployed', '0' - jobObject, gradeObject = ESX.Jobs[job], ESX.Jobs[job].grades[grade] - end + -- Job + if ESX.DoesJobExist(job, grade) then + jobObject, gradeObject = ESX.Jobs[job], ESX.Jobs[job].grades[grade] + else + print(('[^3WARNING^7] Ignoring invalid job for ^5%s^7 [job: ^5%s^7, grade: ^5%s^7]'):format(identifier, job, grade)) + job, grade = 'unemployed', '0' + jobObject, gradeObject = ESX.Jobs[job], ESX.Jobs[job].grades[grade] + end - userData.job.id = jobObject.id - userData.job.name = jobObject.name - userData.job.label = jobObject.label + userData.job.id = jobObject.id + userData.job.name = jobObject.name + userData.job.label = jobObject.label - userData.job.grade = tonumber(grade) - userData.job.grade_name = gradeObject.name - userData.job.grade_label = gradeObject.label - userData.job.grade_salary = gradeObject.salary + userData.job.grade = tonumber(grade) + userData.job.grade_name = gradeObject.name + userData.job.grade_label = gradeObject.label + userData.job.grade_salary = gradeObject.salary - userData.job.skin_male = {} - userData.job.skin_female = {} + userData.job.skin_male = {} + userData.job.skin_female = {} - if gradeObject.skin_male then - userData.job.skin_male = json.decode(gradeObject.skin_male) - end - if gradeObject.skin_female then - userData.job.skin_female = json.decode(gradeObject.skin_female) - end + if gradeObject.skin_male then + userData.job.skin_male = json.decode(gradeObject.skin_male) + end + if gradeObject.skin_female then + userData.job.skin_female = json.decode(gradeObject.skin_female) + end - -- Inventory - if not Config.OxInventory then - if result.inventory and result.inventory ~= '' then - local inventory = json.decode(result.inventory) + -- Inventory + if not Config.OxInventory then + if result.inventory and result.inventory ~= '' then + local inventory = json.decode(result.inventory) - for name, count in pairs(inventory) do - local item = ESX.Items[name] + for name, count in pairs(inventory) do + local item = ESX.Items[name] - if item then - foundItems[name] = count - else - print(('[^3WARNING^7] Ignoring invalid item ^5"%s"^7 for ^5"%s^7"'):format(name, identifier)) - end - end - end + if item then + foundItems[name] = count + else + print(('[^3WARNING^7] Ignoring invalid item ^5"%s"^7 for ^5"%s^7"'):format(name, identifier)) + end + end + end - for name, item in pairs(ESX.Items) do - local count = foundItems[name] or 0 - if count > 0 then - userData.weight = userData.weight + (item.weight * count) - end + for name, item in pairs(ESX.Items) do + local count = foundItems[name] or 0 + if count > 0 then + userData.weight = userData.weight + (item.weight * count) + end - table.insert(userData.inventory, - { - name = name, - count = count, - label = item.label, - weight = item.weight, - usable = Core.UsableItemsCallbacks[name] ~= nil, - rare = item.rare, - canRemove = item.canRemove - }) - end + table.insert(userData.inventory, + { + name = name, + count = count, + label = item.label, + weight = item.weight, + usable = Core.UsableItemsCallbacks[name] ~= nil, + rare = item.rare, + canRemove = item.canRemove + }) + end - table.sort(userData.inventory, function(a, b) - return a.label < b.label - end) - else - if result.inventory and result.inventory ~= '' then - userData.inventory = json.decode(result.inventory) - else - userData.inventory = {} - end - end + table.sort(userData.inventory, function(a, b) + return a.label < b.label + end) + else + if result.inventory and result.inventory ~= '' then + userData.inventory = json.decode(result.inventory) + else + userData.inventory = {} + end + end - -- Group - if result.group then - if result.group == "superadmin" then - userData.group = "admin" - print("[^3WARNING^7] ^5Superadmin^7 detected, setting group to ^5admin^7") - else - userData.group = result.group - end - else - userData.group = 'user' - end + -- Group + if result.group then + if result.group == "superadmin" then + userData.group = "admin" + print("[^3WARNING^7] ^5Superadmin^7 detected, setting group to ^5admin^7") + else + userData.group = result.group + end + else + userData.group = 'user' + end - -- Loadout - if not Config.OxInventory then - if result.loadout and result.loadout ~= '' then - local loadout = json.decode(result.loadout) + -- Loadout + if not Config.OxInventory then + if result.loadout and result.loadout ~= '' then + local loadout = json.decode(result.loadout) - for name, weapon in pairs(loadout) do - local label = ESX.GetWeaponLabel(name) + for name, weapon in pairs(loadout) do + local label = ESX.GetWeaponLabel(name) - if label then - if not weapon.components then - weapon.components = {} - end - if not weapon.tintIndex then - weapon.tintIndex = 0 - end + if label then + if not weapon.components then + weapon.components = {} + end + if not weapon.tintIndex then + weapon.tintIndex = 0 + end - table.insert(userData.loadout, - { - name = name, - ammo = weapon.ammo, - label = label, - components = weapon.components, - tintIndex = weapon.tintIndex - }) - end - end - end - end + table.insert(userData.loadout, + { + name = name, + ammo = weapon.ammo, + label = label, + components = weapon.components, + tintIndex = weapon.tintIndex + }) + end + end + end + end - -- Position - userData.coords = json.decode(result.position) or Config.DefaultSpawns[math.random(#Config.DefaultSpawns)] + -- Position + userData.coords = json.decode(result.position) or Config.DefaultSpawns[math.random(#Config.DefaultSpawns)] - -- Skin - if result.skin and result.skin ~= '' then - userData.skin = json.decode(result.skin) - else - if userData.sex == 'f' then - userData.skin = { sex = 1 } - else - userData.skin = { sex = 0 } - end - end + -- Skin + if result.skin and result.skin ~= '' then + userData.skin = json.decode(result.skin) + else + if userData.sex == 'f' then + userData.skin = { sex = 1 } + else + userData.skin = { sex = 0 } + end + end - -- Identity - if result.firstname and result.firstname ~= '' then - userData.firstname = result.firstname - userData.lastname = result.lastname - userData.playerName = userData.firstname .. ' ' .. userData.lastname - if result.dateofbirth then - userData.dateofbirth = result.dateofbirth - end - if result.sex then - userData.sex = result.sex - end - if result.height then - userData.height = result.height - end - end + -- Identity + if result.firstname and result.firstname ~= '' then + userData.firstname = result.firstname + userData.lastname = result.lastname + userData.playerName = userData.firstname .. ' ' .. userData.lastname + if result.dateofbirth then + userData.dateofbirth = result.dateofbirth + end + if result.sex then + userData.sex = result.sex + end + if result.height then + userData.height = result.height + end + end - if result.metadata and result.metadata ~= '' then - local metadata = json.decode(result.metadata) - userData.metadata = metadata - end + if result.metadata and result.metadata ~= '' then + local metadata = json.decode(result.metadata) + userData.metadata = metadata + end - local xPlayer = CreateExtendedPlayer(playerId, identifier, userData.group, userData.accounts, userData.inventory, userData.weight, userData.job, userData.loadout, userData.playerName, userData.coords, userData.metadata) - ESX.Players[playerId] = xPlayer - Core.playersByIdentifier[identifier] = xPlayer + local xPlayer = CreateExtendedPlayer(playerId, identifier, userData.group, userData.accounts, userData.inventory, userData.weight, userData.job, userData.loadout, userData.playerName, userData.coords, userData.metadata) + ESX.Players[playerId] = xPlayer + Core.playersByIdentifier[identifier] = xPlayer - if userData.firstname then - xPlayer.set('firstName', userData.firstname) - xPlayer.set('lastName', userData.lastname) - if userData.dateofbirth then - xPlayer.set('dateofbirth', userData.dateofbirth) - end - if userData.sex then - xPlayer.set('sex', userData.sex) - end - if userData.height then - xPlayer.set('height', userData.height) - end - end + if userData.firstname then + xPlayer.set('firstName', userData.firstname) + xPlayer.set('lastName', userData.lastname) + if userData.dateofbirth then + xPlayer.set('dateofbirth', userData.dateofbirth) + end + if userData.sex then + xPlayer.set('sex', userData.sex) + end + if userData.height then + xPlayer.set('height', userData.height) + end + end - TriggerEvent('esx:playerLoaded', playerId, xPlayer, isNew) + TriggerEvent('esx:playerLoaded', playerId, xPlayer, isNew) - xPlayer.triggerEvent('esx:playerLoaded', - { - accounts = xPlayer.getAccounts(), - coords = userData.coords, - identifier = xPlayer.getIdentifier(), - inventory = xPlayer.getInventory(), - job = xPlayer.getJob(), - loadout = xPlayer.getLoadout(), - maxWeight = xPlayer.getMaxWeight(), - money = xPlayer.getMoney(), - sex = xPlayer.get("sex") or "m", - firstName = xPlayer.get("firstName") or "John", - lastName = xPlayer.get("lastName") or "Doe", - dateofbirth = xPlayer.get("dateofbirth") or "01/01/2000", - height = xPlayer.get("height") or 120, - dead = false, - metadata = xPlayer.getMeta() - }, isNew, - userData.skin) + xPlayer.triggerEvent('esx:playerLoaded', + { + accounts = xPlayer.getAccounts(), + coords = userData.coords, + identifier = xPlayer.getIdentifier(), + inventory = xPlayer.getInventory(), + job = xPlayer.getJob(), + loadout = xPlayer.getLoadout(), + maxWeight = xPlayer.getMaxWeight(), + money = xPlayer.getMoney(), + sex = xPlayer.get("sex") or "m", + firstName = xPlayer.get("firstName") or "John", + lastName = xPlayer.get("lastName") or "Doe", + dateofbirth = xPlayer.get("dateofbirth") or "01/01/2000", + height = xPlayer.get("height") or 120, + dead = false, + metadata = xPlayer.getMeta() + }, isNew, + userData.skin) - if not Config.OxInventory then - xPlayer.triggerEvent('esx:createMissingPickups', Core.Pickups) - else - exports.ox_inventory:setPlayerInventory(xPlayer, userData.inventory) + if not Config.OxInventory then + xPlayer.triggerEvent('esx:createMissingPickups', Core.Pickups) + else + exports.ox_inventory:setPlayerInventory(xPlayer, userData.inventory) - if isNew then - for account, money in pairs(Config.StartingAccountMoney) do - if account == 'money' or account == 'black_money' then - exports.ox_inventory:AddItem(playerId, account, money) - end - end - end - end - xPlayer.triggerEvent('esx:registerSuggestions', Core.RegisteredCommands) - print(('[^2INFO^0] Player ^5"%s"^0 has connected to the server. ID: ^5%s^7'):format(xPlayer.getName(), playerId)) + if isNew then + for account, money in pairs(Config.StartingAccountMoney) do + if account == 'money' or account == 'black_money' then + exports.ox_inventory:AddItem(playerId, account, money) + end + end + end + end + xPlayer.triggerEvent('esx:registerSuggestions', Core.RegisteredCommands) + print(('[^2INFO^0] Player ^5"%s"^0 has connected to the server. ID: ^5%s^7'):format(xPlayer.getName(), playerId)) end - AddEventHandler('chatMessage', function(playerId, _, message) local xPlayer = ESX.GetPlayerFromId(playerId) if message:sub(1, 1) == '/' and playerId > 0 then @@ -621,8 +619,16 @@ end ESX.RegisterServerCallback('esx:getPlayerData', function(source, cb) local xPlayer = ESX.GetPlayerFromId(source) - cb({identifier = xPlayer.identifier, accounts = xPlayer.getAccounts(), inventory = xPlayer.getInventory(), job = xPlayer.getJob(), - loadout = xPlayer.getLoadout(), money = xPlayer.getMoney(), position = xPlayer.getCoords(true), metadata = xPlayer.getMeta()}) + cb({ + identifier = xPlayer.identifier, + accounts = xPlayer.getAccounts(), + inventory = xPlayer.getInventory(), + job = xPlayer.getJob(), + loadout = xPlayer.getLoadout(), + money = xPlayer.getMoney(), + position = xPlayer.getCoords(true), + metadata = xPlayer.getMeta() + }) end) ESX.RegisterServerCallback('esx:isUserAdmin', function(source, cb) @@ -636,8 +642,16 @@ end) ESX.RegisterServerCallback('esx:getOtherPlayerData', function(_, cb, target) local xPlayer = ESX.GetPlayerFromId(target) - cb({identifier = xPlayer.identifier, accounts = xPlayer.getAccounts(), inventory = xPlayer.getInventory(), job = xPlayer.getJob(), - loadout = xPlayer.getLoadout(), money = xPlayer.getMoney(), position = xPlayer.getCoords(true), metadata = xPlayer.getMeta()}) + cb({ + identifier = xPlayer.identifier, + accounts = xPlayer.getAccounts(), + inventory = xPlayer.getInventory(), + job = xPlayer.getJob(), + loadout = xPlayer.getLoadout(), + money = xPlayer.getMoney(), + position = xPlayer.getCoords(true), + metadata = xPlayer.getMeta() + }) end) ESX.RegisterServerCallback('esx:getPlayerNames', function(source, cb, players) @@ -656,20 +670,20 @@ ESX.RegisterServerCallback('esx:getPlayerNames', function(source, cb, players) cb(players) end) -ESX.RegisterServerCallback("esx:spawnVehicle", function(source,cb,vehData) - local ped = GetPlayerPed(source) - ESX.OneSync.SpawnVehicle(vehData.model or `ADDER`, vehData.coords or GetEntityCoords(ped), vehData.coords.w or 0.0, vehData.props or {}, function(id) - if vehData.warp then +ESX.RegisterServerCallback("esx:spawnVehicle", function(source, cb, vehData) + local ped = GetPlayerPed(source) + ESX.OneSync.SpawnVehicle(vehData.model or `ADDER`, vehData.coords or GetEntityCoords(ped), vehData.coords.w or 0.0, vehData.props or {}, function(id) + if vehData.warp then local vehicle = NetworkGetEntityFromNetworkId(id) - local timeout = 0 - while GetVehiclePedIsIn(ped) ~= vehicle and timeout <= 15 do - Wait(0) - TaskWarpPedIntoVehicle(ped, vehicle, -1) - timeout += 1 - end - end - cb(id) - end) + local timeout = 0 + while GetVehiclePedIsIn(ped) ~= vehicle and timeout <= 15 do + Wait(0) + TaskWarpPedIntoVehicle(ped, vehicle, -1) + timeout += 1 + end + end + cb(id) + end) end) AddEventHandler('txAdmin:events:scheduledRestart', function(eventData) @@ -684,4 +698,3 @@ end) AddEventHandler('txAdmin:events:serverShuttingDown', function() Core.SavePlayers() end) - diff --git a/[core]/esx_context/index.html b/[core]/esx_context/index.html index cd967955..9e40e850 100644 --- a/[core]/esx_context/index.html +++ b/[core]/esx_context/index.html @@ -1,462 +1,452 @@ - - - - + + + + - - - ESX Context HUD + + + ESX Context HUD - - + /* Show the checkmark when checked */ + .container input:checked ~ .checkmark:after { + display: block; + } + + - -
-
- -
- Unselectable Item - Testing, testing a description here. + +
+
+ +
+ Unselectable Item + Testing, testing a description here. +
+
+
+ +
+ Disabled Item + Testing, testing a description here. +
+
+
+ +
+ Item + Testing, testing a description here. Generic words to force overflow. +
+
-
-
- -
- Disabled Item - Testing, testing a description here. -
-
-
- -
- Item - Testing, testing a description here. Generic words to force - overflow. -
-
-
- - + // Open([ + // { + // unselectable:true, + // icon:"fas fa-info-circle", + // title:"Unselectable Item (Header/Label?)", + // }, + // { + // icon:"fas fa-check", + // title:"Item A", + // description:"Some description here. Add some words to make the text overflow." + // }, + // { + // disabled:true, + // icon:"fas fa-times", + // title:"Disabled Item", + // description:"Some description here. Add some words to make the text overflow." + // }, + // { + // icon:"fas fa-check", + // title:"Item B", + // description:"Some description here. Add some words to make the text overflow." + // }, + // { + // input:true, + // icon:"fas fa-times", + // title:"Input Text", + // inputType:"text", + // inputPlaceholder:"Placeholder..." + // }, + // { + // input:true, + // icon:"", + // title:"Input Number", + // inputType:"number", + // inputPlaceholder:"Placeholder...", + // inputValue:0, + // inputMin:0, + // inputMax:50 + // }, + // { + // input:true, + // icon:"", + // title:"Input Radio", + // inputType:"radio", + // inputPlaceholder:"turbocharger", + // inputValue:"supercharger", + // inputValues:[ + // { + // value:"turbocharger", + // title:"Turbocharger" + // }, + // { + // value:"supercharger", + // title:"Supercharger" + // }, + // ] + // } + // ]) + + diff --git a/[core]/esx_identity/config.lua b/[core]/esx_identity/config.lua index 2c16096b..7e450c23 100644 --- a/[core]/esx_identity/config.lua +++ b/[core]/esx_identity/config.lua @@ -13,11 +13,11 @@ Config.UseDeferrals = false Config.DateFormat = 'DD/MM/YYYY' -- These values are for the second input validation in server/main.lua -Config.MaxNameLength = 20 -- Max Name Length. -Config.MinHeight = 120 -- 120 cm lowest height -Config.MaxHeight = 220 -- 220 cm max height. -Config.LowestYear = 1900 -- 112 years old is the oldest you can be. -Config.HighestYear = 2005 -- 18 years old is the youngest you can be. +Config.MaxNameLength = 20 -- Max Name Length. +Config.MinHeight = 120 -- 120 cm lowest height +Config.MaxHeight = 220 -- 220 cm max height. +Config.LowestYear = 1900 -- 112 years old is the oldest you can be. +Config.HighestYear = 2005 -- 18 years old is the youngest you can be. -Config.FullCharDelete = true -- Delete all reference to character. -Config.EnableDebugging = ESX.GetConfig().EnableDebug -- prints for debugging :) +Config.FullCharDelete = true -- Delete all reference to character. +Config.EnableDebugging = ESX.GetConfig().EnableDebug -- prints for debugging :) diff --git a/[core]/esx_identity/html/css/style.css b/[core]/esx_identity/html/css/style.css index 1a7fff35..45f2404a 100644 --- a/[core]/esx_identity/html/css/style.css +++ b/[core]/esx_identity/html/css/style.css @@ -1,153 +1,153 @@ @import url("https://fonts.googleapis.com/css2?family=Oswald&display=swap"); body { - font-family: sans-serif; - overflow: hidden; - background-color: transparent; + font-family: sans-serif; + overflow: hidden; + background-color: transparent; } .none { - display: none; + display: none; } .dialog { - width: 332px; - opacity: 0.95; - padding: 20px; - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - background-color: #152029; - border-radius: 10px; - box-shadow: 0 -5px 3px -3px #21303d, 0 5px 3px -3px #21303d; - border: none; - color: #ffffff; + width: 332px; + opacity: 0.95; + padding: 20px; + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + background-color: #152029; + border-radius: 10px; + box-shadow: 0 -5px 3px -3px #21303d, 0 5px 3px -3px #21303d; + border: none; + color: #ffffff; } .title { - font-family: "Oswald", sans-serif; - font-size: 22px; - text-align: center; - padding: 5px; - margin-bottom: 20px; + font-family: "Oswald", sans-serif; + font-size: 22px; + text-align: center; + padding: 5px; + margin-bottom: 20px; } input { - margin-bottom: 15px; - border: none; - border-bottom: 2px solid #58636c; - width: 100%; - outline: none; - padding: 10px; - padding-left: 0; - font-family: "Oswald", sans-serif; - color: #ffffff; - text-align: left; - background-color: #152029; + margin-bottom: 15px; + border: none; + border-bottom: 2px solid #58636c; + width: 100%; + outline: none; + padding: 10px; + padding-left: 0; + font-family: "Oswald", sans-serif; + color: #ffffff; + text-align: left; + background-color: #152029; } ::placeholder { - /* Chrome, Firefox, Opera, Safari 10.1+ */ - color: rgba(84, 97, 105, 255); - font-family: "Oswald", sans-serif; - font-weight: 200; - opacity: 1; - /* Firefox */ + /* Chrome, Firefox, Opera, Safari 10.1+ */ + color: rgba(84, 97, 105, 255); + font-family: "Oswald", sans-serif; + font-weight: 200; + opacity: 1; + /* Firefox */ } .radio-toolbar input[type="radio"] { - opacity: 0; - position: absolute; - width: 36%; + opacity: 0; + position: absolute; + width: 36%; } .radio-toolbar label { - display: inline-block; - margin-top: 5px; - background-color: rgba(15, 15, 15, 0.9); - padding: 10px 20px; - font-family: "Oswald", sans-serif; - font-weight: 500; - font-size: 16px; - color: #ffffff; - border: none; - border-radius: 5px; - width: 36%; + display: inline-block; + margin-top: 5px; + background-color: rgba(15, 15, 15, 0.9); + padding: 10px 20px; + font-family: "Oswald", sans-serif; + font-weight: 500; + font-size: 16px; + color: #ffffff; + border: none; + border-radius: 5px; + width: 36%; } -.radio-toolbar input[type="radio"]:checked+label { - width: 36%; - background-color: rgba(15, 15, 15, 0.9); - border: none; - border-bottom: 1px solid #93a3b6; - border-radius: 5px; - color: #ffffff; +.radio-toolbar input[type="radio"]:checked + label { + width: 36%; + background-color: rgba(15, 15, 15, 0.9); + border: none; + border-bottom: 1px solid #93a3b6; + border-radius: 5px; + color: #ffffff; } -.radio-toolbar input[type="radio"]:focus+label { - background-color: rgba(15, 15, 15, 0.9); - border: none; - border-bottom: 1px solid #93a3b6; - border-radius: 5px; - color: #ffffff; +.radio-toolbar input[type="radio"]:focus + label { + background-color: rgba(15, 15, 15, 0.9); + border: none; + border-bottom: 1px solid #93a3b6; + border-radius: 5px; + color: #ffffff; } .radio-toolbar label:hover { - background-color: rgba(28, 24, 24, 0.931); - width: 36%; - color: #ffffff; + background-color: rgba(28, 24, 24, 0.931); + width: 36%; + color: #ffffff; } button { - display: block; - margin-top: 35px; - /*padding: 10px;*/ - background-color: #4569c6; - outline: none; - border: 2px double rgba(40, 40, 40, 0.9); - color: #ffffff; - height: 30px; - width: 100%; + display: block; + margin-top: 35px; + /*padding: 10px;*/ + background-color: #4569c6; + outline: none; + border: 2px double rgba(40, 40, 40, 0.9); + color: #ffffff; + height: 30px; + width: 100%; } h1 { - display: block; - margin-top: 5px; - margin-right: 5px; - padding: 10px; - background-color: rgba(15, 15, 15, 0.9); - color: #ffffff; - width: 93%; - text-align: center; + display: block; + margin-top: 5px; + margin-right: 5px; + padding: 10px; + background-color: rgba(15, 15, 15, 0.9); + color: #ffffff; + width: 93%; + text-align: center; } .range-wrap { - position: relative; - margin: 0 auto 3rem; + position: relative; + margin: 0 auto 3rem; } .range { - width: 100%; + width: 100%; } .bubble { - background: rgba(15, 15, 15, 0.9); - color: #ffffff; - padding: 4px 12px; - position: absolute; - border-radius: 4px; - left: 50%; - transform: translateX(-50%); + background: rgba(15, 15, 15, 0.9); + color: #ffffff; + padding: 4px 12px; + position: absolute; + border-radius: 4px; + left: 50%; + transform: translateX(-50%); } .bubble::after { - content: ""; - position: absolute; - width: 2px; - height: 2px; - background: rgba(15, 15, 15, 0.9); - color: black; - top: -1px; - left: 50%; -} \ No newline at end of file + content: ""; + position: absolute; + width: 2px; + height: 2px; + background: rgba(15, 15, 15, 0.9); + color: black; + top: -1px; + left: 50%; +} diff --git a/[core]/esx_identity/html/index.html b/[core]/esx_identity/html/index.html index 1d5a9ad3..f1320ea7 100644 --- a/[core]/esx_identity/html/index.html +++ b/[core]/esx_identity/html/index.html @@ -1,77 +1,49 @@ + + + - - - + ESX Identity + - ESX Identity - + +
+
IDENTITY
+
+
First Name
+
+
Last Name
+
+
Date of Birth (MM/DD/YYYY)
+
+
Height
+
+
+
+ + - -
-
IDENTITY
- -
- First Name -
-
-
- Last Name -
-
-
- Date of Birth (MM/DD/YYYY) -
-
-
- Height -
-
-
-
- - - - - + + +
+
+ + +
+ If the submit button doesn't work, please ensure that you've entered the fields correctly. +
-
- - -
- If the submit button doesn't work, please ensure that you've entered - the fields correctly. -
-
- - - - - \ No newline at end of file + + + + diff --git a/[core]/esx_identity/html/js/script.js b/[core]/esx_identity/html/js/script.js index bca1d09b..75cd203f 100644 --- a/[core]/esx_identity/html/js/script.js +++ b/[core]/esx_identity/html/js/script.js @@ -1,46 +1,39 @@ window.addEventListener("message", (event) => { - if (event.data.type === "enableui") { - document.body.classList[event.data.enable ? "remove" : "add"]("none"); - } + if (event.data.type === "enableui") { + document.body.classList[event.data.enable ? "remove" : "add"]("none"); + } }); document.querySelector("#register").addEventListener("submit", (event) => { - event.preventDefault(); + event.preventDefault(); - const dofVal = document.querySelector("#dateofbirth").value; - if (!dofVal) return; + const dofVal = document.querySelector("#dateofbirth").value; + if (!dofVal) return; - const dateCheck = new Date(dofVal); + const dateCheck = new Date(dofVal); - const year = new Intl.DateTimeFormat("en", { year: "numeric" }).format( - dateCheck - ); - const month = new Intl.DateTimeFormat("en", { month: "2-digit" }).format( - dateCheck - ); - const day = new Intl.DateTimeFormat("en", { day: "2-digit" }).format( - dateCheck - ); + const year = new Intl.DateTimeFormat("en", { year: "numeric" }).format(dateCheck); + const month = new Intl.DateTimeFormat("en", { month: "2-digit" }).format(dateCheck); + const day = new Intl.DateTimeFormat("en", { day: "2-digit" }).format(dateCheck); - const formattedDate = `${day}/${month}/${year}`; - fetch("http://esx_identity/register", { - method: "POST", - body: JSON.stringify({ - firstname: document.querySelector("#firstname").value, - lastname: document.querySelector("#lastname").value, - dateofbirth: formattedDate, - sex: document.querySelector("input[type='radio'][name='sex']:checked") - .value, - height: document.querySelector("#height").value, - }), - }); + const formattedDate = `${day}/${month}/${year}`; + fetch("http://esx_identity/register", { + method: "POST", + body: JSON.stringify({ + firstname: document.querySelector("#firstname").value, + lastname: document.querySelector("#lastname").value, + dateofbirth: formattedDate, + sex: document.querySelector("input[type='radio'][name='sex']:checked").value, + height: document.querySelector("#height").value, + }), + }); - document.querySelector("#register").reset(); + document.querySelector("#register").reset(); }); document.addEventListener("DOMContentLoaded", () => { - fetch("http://esx_identity/ready", { - method: "POST", - body: JSON.stringify({}), - }); -}); \ No newline at end of file + fetch("http://esx_identity/ready", { + method: "POST", + body: JSON.stringify({}), + }); +}); diff --git a/[core]/esx_loadingscreen/css/index.css b/[core]/esx_loadingscreen/css/index.css index 6cb39671..474a89b8 100644 --- a/[core]/esx_loadingscreen/css/index.css +++ b/[core]/esx_loadingscreen/css/index.css @@ -14,104 +14,104 @@ html, body { - margin: 0; - padding: 0; - font-family: "Quicksand", sans-serif; - overflow: hidden; + margin: 0; + padding: 0; + font-family: "Quicksand", sans-serif; + overflow: hidden; } #esx_intro { - z-index: 2; + z-index: 2; } #esx_loop { - z-index: 1; + z-index: 1; } #loading_txt { - bottom: 5%; - left: 50%; - margin-left: -80px; - position: absolute; - z-index: 999; + bottom: 5%; + left: 50%; + margin-left: -80px; + position: absolute; + z-index: 999; - -webkit-animation: fadein 5s; - -moz-animation: fadein 5s; - -ms-animation: fadein 5s; - -o-animation: fadein 5s; - animation: fadein 5s; + -webkit-animation: fadein 5s; + -moz-animation: fadein 5s; + -ms-animation: fadein 5s; + -o-animation: fadein 5s; + animation: fadein 5s; } p { - color: white; - font-size: 32px; + color: white; + font-size: 32px; } .text_thing:after { - content: " ."; - animation: dots 2s steps(5, end) infinite; + content: " ."; + animation: dots 2s steps(5, end) infinite; } @keyframes dots { - 0%, - 20% { - color: rgba(0, 0, 0, 0); - text-shadow: 0.25em 0 0 rgba(0, 0, 0, 0), 0.5em 0 0 rgba(0, 0, 0, 0); - } - 40% { - color: white; - text-shadow: 0.25em 0 0 rgba(0, 0, 0, 0), 0.5em 0 0 rgba(0, 0, 0, 0); - } - 60% { - text-shadow: 0.25em 0 0 white, 0.5em 0 0 rgba(0, 0, 0, 0); - } - 80%, - 100% { - text-shadow: 0.25em 0 0 white, 0.5em 0 0 white; - } + 0%, + 20% { + color: rgba(0, 0, 0, 0); + text-shadow: 0.25em 0 0 rgba(0, 0, 0, 0), 0.5em 0 0 rgba(0, 0, 0, 0); + } + 40% { + color: white; + text-shadow: 0.25em 0 0 rgba(0, 0, 0, 0), 0.5em 0 0 rgba(0, 0, 0, 0); + } + 60% { + text-shadow: 0.25em 0 0 white, 0.5em 0 0 rgba(0, 0, 0, 0); + } + 80%, + 100% { + text-shadow: 0.25em 0 0 white, 0.5em 0 0 white; + } } @keyframes fadein { - from { - opacity: 0; - } - to { - opacity: 1; - } + from { + opacity: 0; + } + to { + opacity: 1; + } } @-moz-keyframes fadein { - from { - opacity: 0; - } - to { - opacity: 1; - } + from { + opacity: 0; + } + to { + opacity: 1; + } } @-webkit-keyframes fadein { - from { - opacity: 0; - } - to { - opacity: 1; - } + from { + opacity: 0; + } + to { + opacity: 1; + } } @-ms-keyframes fadein { - from { - opacity: 0; - } - to { - opacity: 1; - } + from { + opacity: 0; + } + to { + opacity: 1; + } } @-o-keyframes fadein { - from { - opacity: 0; - } - to { - opacity: 1; - } + from { + opacity: 0; + } + to { + opacity: 1; + } } diff --git a/[core]/esx_loadingscreen/index.html b/[core]/esx_loadingscreen/index.html index 212b9e7e..590de522 100644 --- a/[core]/esx_loadingscreen/index.html +++ b/[core]/esx_loadingscreen/index.html @@ -1,25 +1,22 @@ - - - - - + + + + + - -
-
-

Loading

-
+ +
+
+

Loading

+
- - -
- + + +
+ diff --git a/[core]/esx_loadingscreen/js/index.js b/[core]/esx_loadingscreen/js/index.js index e2312b4a..c77c76ca 100644 --- a/[core]/esx_loadingscreen/js/index.js +++ b/[core]/esx_loadingscreen/js/index.js @@ -11,12 +11,12 @@ // This copyright should appear in every part of the project code document.addEventListener("DOMContentLoaded", () => { - const introTag = document.getElementById("esx_intro"); - const loopTag = document.getElementById("esx_loop"); + const introTag = document.getElementById("esx_intro"); + const loopTag = document.getElementById("esx_loop"); - introTag.onended = () => { - introTag.style.display = "none"; - loopTag.loop = true; // true - loopTag.play(); - }; + introTag.onended = () => { + introTag.style.display = "none"; + loopTag.loop = true; // true + loopTag.play(); + }; }); diff --git a/[core]/esx_menu_default/html/css/app.css b/[core]/esx_menu_default/html/css/app.css index e7f07e2b..4658b79d 100644 --- a/[core]/esx_menu_default/html/css/app.css +++ b/[core]/esx_menu_default/html/css/app.css @@ -1,110 +1,110 @@ @import url("https://fonts.googleapis.com/css2?family=Poppins:wght@500;600&display=swap"); ::-webkit-scrollbar { - display: none; + display: none; } .menu { - font-family: "Poppins", sans-serif; - min-width: 350px; - color: #fff; - position: absolute; - background: rgba(33, 33, 33, 0); - text-align: center; + font-family: "Poppins", sans-serif; + min-width: 350px; + color: #fff; + position: absolute; + background: rgba(33, 33, 33, 0); + text-align: center; } .head { - display: block; - overflow: hidden; - padding-bottom: 3px; - text-align: center; - margin-bottom: 5px; - white-space: nowrap; - background: rgba(10, 10, 10, 0.9); + display: block; + overflow: hidden; + padding-bottom: 3px; + text-align: center; + margin-bottom: 5px; + white-space: nowrap; + background: rgba(10, 10, 10, 0.9); } .menu .head { - text-align: center; - height: 28px; - color: #ffffff; - font-weight: 700; - font-size: 20px; + text-align: center; + height: 28px; + color: #ffffff; + font-weight: 700; + font-size: 20px; } .menu .menu-items { - max-height: 450px; - overflow-y: auto; - font-weight: 550; + max-height: 450px; + overflow-y: auto; + font-weight: 550; } .menu-items { - margin-bottom: 2px; + margin-bottom: 2px; } .menu .menu-items .menu-item { - display: block; - padding: 7px; - font-size: 13px; - height: 16px; - text-indent: 5px; - margin-top: 5px; - background: rgba(40, 40, 40, 0.8); - color: rgb(202, 202, 202); - border-radius: 5px; - margin-bottom: 6px; + display: block; + padding: 7px; + font-size: 13px; + height: 16px; + text-indent: 5px; + margin-top: 5px; + background: rgba(40, 40, 40, 0.8); + color: rgb(202, 202, 202); + border-radius: 5px; + margin-bottom: 6px; } .menu .menu-items .menu-item.selected { - border: 1px solid rgba(55, 55, 55, 0.9); - background: rgba(20, 20, 20, 0.9); - color: rgba(243, 243, 243); - letter-spacing: 0.2px; - font-weight: 500; + border: 1px solid rgba(55, 55, 55, 0.9); + background: rgba(20, 20, 20, 0.9); + color: rgba(243, 243, 243); + letter-spacing: 0.2px; + font-weight: 500; } .menu.align-left { - left: 0; - top: 50%; + left: 0; + top: 50%; } .menu.align-top-left { - left: 3rem; - top: 0; + left: 3rem; + top: 0; } .menu.align-top { - left: 50%; - top: 0; + left: 50%; + top: 0; } .menu.align-top-right { - right: 3rem; - top: 0; + right: 3rem; + top: 0; } .menu.align-right { - right: 0; - top: 50%; + right: 0; + top: 50%; } .menu.align-bottom-right { - right: 3rem; - bottom: 0; + right: 3rem; + bottom: 0; } .menu.align-bottom { - left: 50%; - bottom: 0; - transform: translate(0, -50%); + left: 50%; + bottom: 0; + transform: translate(0, -50%); } .menu.align-bottom-left { - left: 3rem; - bottom: 0; + left: 3rem; + bottom: 0; } .menu.align-center { - left: 50%; - top: 35%; - transform: translate(-50%, 50%); + left: 50%; + top: 35%; + transform: translate(-50%, 50%); } diff --git a/[core]/esx_menu_default/html/js/app.js b/[core]/esx_menu_default/html/js/app.js index 24db7603..36b960d1 100644 --- a/[core]/esx_menu_default/html/js/app.js +++ b/[core]/esx_menu_default/html/js/app.js @@ -1,378 +1,366 @@ (function () { - let MenuTpl = - '" + - "
"; - window.ESX_MENU = {}; - ESX_MENU.ResourceName = "esx_menu_default"; - ESX_MENU.opened = {}; - ESX_MENU.focus = []; - ESX_MENU.pos = {}; + let MenuTpl = + '" + + ""; + window.ESX_MENU = {}; + ESX_MENU.ResourceName = "esx_menu_default"; + ESX_MENU.opened = {}; + ESX_MENU.focus = []; + ESX_MENU.pos = {}; - ESX_MENU.open = function (namespace, name, data) { - if (typeof ESX_MENU.opened[namespace] === "undefined") { - ESX_MENU.opened[namespace] = {}; - } - - if (typeof ESX_MENU.opened[namespace][name] != "undefined") { - ESX_MENU.close(namespace, name); - } - - if (typeof ESX_MENU.pos[namespace] === "undefined") { - ESX_MENU.pos[namespace] = {}; - } - - for (let i = 0; i < data.elements.length; i++) { - if (typeof data.elements[i].type === "undefined") { - data.elements[i].type = "default"; - } - } - - data._index = ESX_MENU.focus.length; - data._namespace = namespace; - data._name = name; - - for (let i = 0; i < data.elements.length; i++) { - data.elements[i]._namespace = namespace; - data.elements[i]._name = name; - } - - ESX_MENU.opened[namespace][name] = data; - ESX_MENU.pos[namespace][name] = 0; - - for (let i = 0; i < data.elements.length; i++) { - if (data.elements[i].selected) { - ESX_MENU.pos[namespace][name] = i; - } else { - data.elements[i].selected = false; - } - } - - ESX_MENU.focus.push({ - namespace: namespace, - name: name, - }); - - ESX_MENU.render(); - $("#menu_" + namespace + "_" + name) - .find(".menu-item.selected")[0] - .scrollIntoView(); - }; - - ESX_MENU.close = function (namespace, name) { - delete ESX_MENU.opened[namespace][name]; - - for (let i = 0; i < ESX_MENU.focus.length; i++) { - if ( - ESX_MENU.focus[i].namespace === namespace && - ESX_MENU.focus[i].name === name - ) { - ESX_MENU.focus.splice(i, 1); - break; - } - } - - ESX_MENU.render(); - }; - - ESX_MENU.render = function () { - let menuContainer = document.getElementById("menus"); - let focused = ESX_MENU.getFocused(); - menuContainer.innerHTML = ""; - $(menuContainer).hide(); - - for (let namespace in ESX_MENU.opened) { - for (let name in ESX_MENU.opened[namespace]) { - let menuData = ESX_MENU.opened[namespace][name]; - let view = JSON.parse(JSON.stringify(menuData)); - - for (let i = 0; i < menuData.elements.length; i++) { - let element = view.elements[i]; - - switch (element.type) { - case "default": - break; - - case "slider": { - element.isSlider = true; - element.sliderLabel = - typeof element.options === "undefined" - ? element.value - : element.options[element.value]; - - break; - } - - default: - break; - } - - if (i === ESX_MENU.pos[namespace][name]) { - element.selected = true; - } + ESX_MENU.open = function (namespace, name, data) { + if (typeof ESX_MENU.opened[namespace] === "undefined") { + ESX_MENU.opened[namespace] = {}; } - let menu = $(Mustache.render(MenuTpl, view))[0]; - $(menu).hide(); - menuContainer.appendChild(menu); - } - } - - if (typeof focused != "undefined") { - $("#menu_" + focused.namespace + "_" + focused.name).show(); - } - - $(menuContainer).show(); - }; - - ESX_MENU.submit = function (namespace, name, data) { - $.post( - "http://" + ESX_MENU.ResourceName + "/menu_submit", - JSON.stringify({ - _namespace: namespace, - _name: name, - current: data, - elements: ESX_MENU.opened[namespace][name].elements, - }) - ); - }; - - ESX_MENU.cancel = function (namespace, name) { - $.post( - "http://" + ESX_MENU.ResourceName + "/menu_cancel", - JSON.stringify({ - _namespace: namespace, - _name: name, - }) - ); - }; - - ESX_MENU.change = function (namespace, name, data) { - $.post( - "http://" + ESX_MENU.ResourceName + "/menu_change", - JSON.stringify({ - _namespace: namespace, - _name: name, - current: data, - elements: ESX_MENU.opened[namespace][name].elements, - }) - ); - }; - - ESX_MENU.getFocused = function () { - return ESX_MENU.focus[ESX_MENU.focus.length - 1]; - }; - - window.onData = (data) => { - switch (data.action) { - case "openMenu": { - ESX_MENU.open(data.namespace, data.name, data.data); - break; - } - - case "closeMenu": { - ESX_MENU.close(data.namespace, data.name); - break; - } - - case "controlPressed": { - switch (data.control) { - case "ENTER": { - let focused = ESX_MENU.getFocused(); - - if (typeof focused != "undefined") { - let menu = ESX_MENU.opened[focused.namespace][focused.name]; - let pos = ESX_MENU.pos[focused.namespace][focused.name]; - let elem = menu.elements[pos]; - - if (menu.elements.length > 0) { - ESX_MENU.submit(focused.namespace, focused.name, elem); - } - } - - break; - } - - case "BACKSPACE": { - let focused = ESX_MENU.getFocused(); - - if (typeof focused != "undefined") { - ESX_MENU.cancel(focused.namespace, focused.name); - } - - break; - } - - case "TOP": { - let focused = ESX_MENU.getFocused(); - - if (typeof focused != "undefined") { - let menu = ESX_MENU.opened[focused.namespace][focused.name]; - let pos = ESX_MENU.pos[focused.namespace][focused.name]; - - if (pos > 0) { - ESX_MENU.pos[focused.namespace][focused.name]--; - } else { - ESX_MENU.pos[focused.namespace][focused.name] = - menu.elements.length - 1; - } - - let elem = - menu.elements[ESX_MENU.pos[focused.namespace][focused.name]]; - - for (let i = 0; i < menu.elements.length; i++) { - if (i === ESX_MENU.pos[focused.namespace][focused.name]) { - menu.elements[i].selected = true; - } else { - menu.elements[i].selected = false; - } - } - - ESX_MENU.change(focused.namespace, focused.name, elem); - ESX_MENU.render(); - - $("#menu_" + focused.namespace + "_" + focused.name) - .find(".menu-item.selected")[0] - .scrollIntoView(); - } - - break; - } - - case "DOWN": { - let focused = ESX_MENU.getFocused(); - - if (typeof focused != "undefined") { - let menu = ESX_MENU.opened[focused.namespace][focused.name]; - let pos = ESX_MENU.pos[focused.namespace][focused.name]; - let length = menu.elements.length; - - if (pos < length - 1) { - ESX_MENU.pos[focused.namespace][focused.name]++; - } else { - ESX_MENU.pos[focused.namespace][focused.name] = 0; - } - - let elem = - menu.elements[ESX_MENU.pos[focused.namespace][focused.name]]; - - for (let i = 0; i < menu.elements.length; i++) { - if (i === ESX_MENU.pos[focused.namespace][focused.name]) { - menu.elements[i].selected = true; - } else { - menu.elements[i].selected = false; - } - } - - ESX_MENU.change(focused.namespace, focused.name, elem); - ESX_MENU.render(); - - $("#menu_" + focused.namespace + "_" + focused.name) - .find(".menu-item.selected")[0] - .scrollIntoView(); - } - - break; - } - - case "LEFT": { - let focused = ESX_MENU.getFocused(); - - if (typeof focused != "undefined") { - let menu = ESX_MENU.opened[focused.namespace][focused.name]; - let pos = ESX_MENU.pos[focused.namespace][focused.name]; - let elem = menu.elements[pos]; - - switch (elem.type) { - case "default": - break; - - case "slider": { - let min = typeof elem.min === "undefined" ? 0 : elem.min; - - if (elem.value > min) { - elem.value--; - ESX_MENU.change(focused.namespace, focused.name, elem); - } - - ESX_MENU.render(); - break; - } - - default: - break; - } - - $("#menu_" + focused.namespace + "_" + focused.name) - .find(".menu-item.selected")[0] - .scrollIntoView(); - } - - break; - } - - case "RIGHT": { - let focused = ESX_MENU.getFocused(); - - if (typeof focused != "undefined") { - let menu = ESX_MENU.opened[focused.namespace][focused.name]; - let pos = ESX_MENU.pos[focused.namespace][focused.name]; - let elem = menu.elements[pos]; - - switch (elem.type) { - case "default": - break; - - case "slider": { - if ( - typeof elem.options != "undefined" && - elem.value < elem.options.length - 1 - ) { - elem.value++; - ESX_MENU.change(focused.namespace, focused.name, elem); - } - - if (typeof elem.max != "undefined" && elem.value < elem.max) { - elem.value++; - ESX_MENU.change(focused.namespace, focused.name, elem); - } - - ESX_MENU.render(); - break; - } - - default: - break; - } - - $("#menu_" + focused.namespace + "_" + focused.name) - .find(".menu-item.selected")[0] - .scrollIntoView(); - } - - break; - } - - default: - break; + if (typeof ESX_MENU.opened[namespace][name] != "undefined") { + ESX_MENU.close(namespace, name); } - break; - } - } - }; + if (typeof ESX_MENU.pos[namespace] === "undefined") { + ESX_MENU.pos[namespace] = {}; + } - window.onload = function (e) { - window.addEventListener("message", (event) => { - onData(event.data); - }); - }; + for (let i = 0; i < data.elements.length; i++) { + if (typeof data.elements[i].type === "undefined") { + data.elements[i].type = "default"; + } + } + + data._index = ESX_MENU.focus.length; + data._namespace = namespace; + data._name = name; + + for (let i = 0; i < data.elements.length; i++) { + data.elements[i]._namespace = namespace; + data.elements[i]._name = name; + } + + ESX_MENU.opened[namespace][name] = data; + ESX_MENU.pos[namespace][name] = 0; + + for (let i = 0; i < data.elements.length; i++) { + if (data.elements[i].selected) { + ESX_MENU.pos[namespace][name] = i; + } else { + data.elements[i].selected = false; + } + } + + ESX_MENU.focus.push({ + namespace: namespace, + name: name, + }); + + ESX_MENU.render(); + $("#menu_" + namespace + "_" + name) + .find(".menu-item.selected")[0] + .scrollIntoView(); + }; + + ESX_MENU.close = function (namespace, name) { + delete ESX_MENU.opened[namespace][name]; + + for (let i = 0; i < ESX_MENU.focus.length; i++) { + if (ESX_MENU.focus[i].namespace === namespace && ESX_MENU.focus[i].name === name) { + ESX_MENU.focus.splice(i, 1); + break; + } + } + + ESX_MENU.render(); + }; + + ESX_MENU.render = function () { + let menuContainer = document.getElementById("menus"); + let focused = ESX_MENU.getFocused(); + menuContainer.innerHTML = ""; + $(menuContainer).hide(); + + for (let namespace in ESX_MENU.opened) { + for (let name in ESX_MENU.opened[namespace]) { + let menuData = ESX_MENU.opened[namespace][name]; + let view = JSON.parse(JSON.stringify(menuData)); + + for (let i = 0; i < menuData.elements.length; i++) { + let element = view.elements[i]; + + switch (element.type) { + case "default": + break; + + case "slider": { + element.isSlider = true; + element.sliderLabel = typeof element.options === "undefined" ? element.value : element.options[element.value]; + + break; + } + + default: + break; + } + + if (i === ESX_MENU.pos[namespace][name]) { + element.selected = true; + } + } + + let menu = $(Mustache.render(MenuTpl, view))[0]; + $(menu).hide(); + menuContainer.appendChild(menu); + } + } + + if (typeof focused != "undefined") { + $("#menu_" + focused.namespace + "_" + focused.name).show(); + } + + $(menuContainer).show(); + }; + + ESX_MENU.submit = function (namespace, name, data) { + $.post( + "http://" + ESX_MENU.ResourceName + "/menu_submit", + JSON.stringify({ + _namespace: namespace, + _name: name, + current: data, + elements: ESX_MENU.opened[namespace][name].elements, + }) + ); + }; + + ESX_MENU.cancel = function (namespace, name) { + $.post( + "http://" + ESX_MENU.ResourceName + "/menu_cancel", + JSON.stringify({ + _namespace: namespace, + _name: name, + }) + ); + }; + + ESX_MENU.change = function (namespace, name, data) { + $.post( + "http://" + ESX_MENU.ResourceName + "/menu_change", + JSON.stringify({ + _namespace: namespace, + _name: name, + current: data, + elements: ESX_MENU.opened[namespace][name].elements, + }) + ); + }; + + ESX_MENU.getFocused = function () { + return ESX_MENU.focus[ESX_MENU.focus.length - 1]; + }; + + window.onData = (data) => { + switch (data.action) { + case "openMenu": { + ESX_MENU.open(data.namespace, data.name, data.data); + break; + } + + case "closeMenu": { + ESX_MENU.close(data.namespace, data.name); + break; + } + + case "controlPressed": { + switch (data.control) { + case "ENTER": { + let focused = ESX_MENU.getFocused(); + + if (typeof focused != "undefined") { + let menu = ESX_MENU.opened[focused.namespace][focused.name]; + let pos = ESX_MENU.pos[focused.namespace][focused.name]; + let elem = menu.elements[pos]; + + if (menu.elements.length > 0) { + ESX_MENU.submit(focused.namespace, focused.name, elem); + } + } + + break; + } + + case "BACKSPACE": { + let focused = ESX_MENU.getFocused(); + + if (typeof focused != "undefined") { + ESX_MENU.cancel(focused.namespace, focused.name); + } + + break; + } + + case "TOP": { + let focused = ESX_MENU.getFocused(); + + if (typeof focused != "undefined") { + let menu = ESX_MENU.opened[focused.namespace][focused.name]; + let pos = ESX_MENU.pos[focused.namespace][focused.name]; + + if (pos > 0) { + ESX_MENU.pos[focused.namespace][focused.name]--; + } else { + ESX_MENU.pos[focused.namespace][focused.name] = menu.elements.length - 1; + } + + let elem = menu.elements[ESX_MENU.pos[focused.namespace][focused.name]]; + + for (let i = 0; i < menu.elements.length; i++) { + if (i === ESX_MENU.pos[focused.namespace][focused.name]) { + menu.elements[i].selected = true; + } else { + menu.elements[i].selected = false; + } + } + + ESX_MENU.change(focused.namespace, focused.name, elem); + ESX_MENU.render(); + + $("#menu_" + focused.namespace + "_" + focused.name) + .find(".menu-item.selected")[0] + .scrollIntoView(); + } + + break; + } + + case "DOWN": { + let focused = ESX_MENU.getFocused(); + + if (typeof focused != "undefined") { + let menu = ESX_MENU.opened[focused.namespace][focused.name]; + let pos = ESX_MENU.pos[focused.namespace][focused.name]; + let length = menu.elements.length; + + if (pos < length - 1) { + ESX_MENU.pos[focused.namespace][focused.name]++; + } else { + ESX_MENU.pos[focused.namespace][focused.name] = 0; + } + + let elem = menu.elements[ESX_MENU.pos[focused.namespace][focused.name]]; + + for (let i = 0; i < menu.elements.length; i++) { + if (i === ESX_MENU.pos[focused.namespace][focused.name]) { + menu.elements[i].selected = true; + } else { + menu.elements[i].selected = false; + } + } + + ESX_MENU.change(focused.namespace, focused.name, elem); + ESX_MENU.render(); + + $("#menu_" + focused.namespace + "_" + focused.name) + .find(".menu-item.selected")[0] + .scrollIntoView(); + } + + break; + } + + case "LEFT": { + let focused = ESX_MENU.getFocused(); + + if (typeof focused != "undefined") { + let menu = ESX_MENU.opened[focused.namespace][focused.name]; + let pos = ESX_MENU.pos[focused.namespace][focused.name]; + let elem = menu.elements[pos]; + + switch (elem.type) { + case "default": + break; + + case "slider": { + let min = typeof elem.min === "undefined" ? 0 : elem.min; + + if (elem.value > min) { + elem.value--; + ESX_MENU.change(focused.namespace, focused.name, elem); + } + + ESX_MENU.render(); + break; + } + + default: + break; + } + + $("#menu_" + focused.namespace + "_" + focused.name) + .find(".menu-item.selected")[0] + .scrollIntoView(); + } + + break; + } + + case "RIGHT": { + let focused = ESX_MENU.getFocused(); + + if (typeof focused != "undefined") { + let menu = ESX_MENU.opened[focused.namespace][focused.name]; + let pos = ESX_MENU.pos[focused.namespace][focused.name]; + let elem = menu.elements[pos]; + + switch (elem.type) { + case "default": + break; + + case "slider": { + if (typeof elem.options != "undefined" && elem.value < elem.options.length - 1) { + elem.value++; + ESX_MENU.change(focused.namespace, focused.name, elem); + } + + if (typeof elem.max != "undefined" && elem.value < elem.max) { + elem.value++; + ESX_MENU.change(focused.namespace, focused.name, elem); + } + + ESX_MENU.render(); + break; + } + + default: + break; + } + + $("#menu_" + focused.namespace + "_" + focused.name) + .find(".menu-item.selected")[0] + .scrollIntoView(); + } + + break; + } + + default: + break; + } + + break; + } + } + }; + + window.onload = function (e) { + window.addEventListener("message", (event) => { + onData(event.data); + }); + }; })(); diff --git a/[core]/esx_menu_default/html/js/mustache.min.js b/[core]/esx_menu_default/html/js/mustache.min.js index 520cfcb9..f3656597 100644 --- a/[core]/esx_menu_default/html/js/mustache.min.js +++ b/[core]/esx_menu_default/html/js/mustache.min.js @@ -1 +1,347 @@ -(function defineMustache(global,factory){if(typeof exports==="object"&&exports&&typeof exports.nodeName!=="string"){factory(exports)}else if(typeof define==="function"&&define.amd){define(["exports"],factory)}else{global.Mustache={};factory(global.Mustache)}})(this,function mustacheFactory(mustache){var objectToString=Object.prototype.toString;var isArray=Array.isArray||function isArrayPolyfill(object){return objectToString.call(object)==="[object Array]"};function isFunction(object){return typeof object==="function"}function typeStr(obj){return isArray(obj)?"array":typeof obj}function escapeRegExp(string){return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function hasProperty(obj,propName){return obj!=null&&typeof obj==="object"&&propName in obj}var regExpTest=RegExp.prototype.test;function testRegExp(re,string){return regExpTest.call(re,string)}var nonSpaceRe=/\S/;function isWhitespace(string){return!testRegExp(nonSpaceRe,string)}var entityMap={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function escapeHtml(string){return String(string).replace(/[&<>"'`=\/]/g,function fromEntityMap(s){return entityMap[s]})}var whiteRe=/\s*/;var spaceRe=/\s+/;var equalsRe=/\s*=/;var curlyRe=/\s*\}/;var tagRe=/#|\^|\/|>|\{|&|=|!/;function parseTemplate(template,tags){if(!template)return[];var sections=[];var tokens=[];var spaces=[];var hasTag=false;var nonSpace=false;function stripSpace(){if(hasTag&&!nonSpace){while(spaces.length)delete tokens[spaces.pop()]}else{spaces=[]}hasTag=false;nonSpace=false}var openingTagRe,closingTagRe,closingCurlyRe;function compileTags(tagsToCompile){if(typeof tagsToCompile==="string")tagsToCompile=tagsToCompile.split(spaceRe,2);if(!isArray(tagsToCompile)||tagsToCompile.length!==2)throw new Error("Invalid tags: "+tagsToCompile);openingTagRe=new RegExp(escapeRegExp(tagsToCompile[0])+"\\s*");closingTagRe=new RegExp("\\s*"+escapeRegExp(tagsToCompile[1]));closingCurlyRe=new RegExp("\\s*"+escapeRegExp("}"+tagsToCompile[1]))}compileTags(tags||mustache.tags);var scanner=new Scanner(template);var start,type,value,chr,token,openSection;while(!scanner.eos()){start=scanner.pos;value=scanner.scanUntil(openingTagRe);if(value){for(var i=0,valueLength=value.length;i0?sections[sections.length-1][4]:nestedTokens;break;default:collector.push(token)}}return nestedTokens}function Scanner(string){this.string=string;this.tail=string;this.pos=0}Scanner.prototype.eos=function eos(){return this.tail===""};Scanner.prototype.scan=function scan(re){var match=this.tail.match(re);if(!match||match.index!==0)return"";var string=match[0];this.tail=this.tail.substring(string.length);this.pos+=string.length;return string};Scanner.prototype.scanUntil=function scanUntil(re){var index=this.tail.search(re),match;switch(index){case-1:match=this.tail;this.tail="";break;case 0:match="";break;default:match=this.tail.substring(0,index);this.tail=this.tail.substring(index)}this.pos+=match.length;return match};function Context(view,parentContext){this.view=view;this.cache={".":this.view};this.parent=parentContext}Context.prototype.push=function push(view){return new Context(view,this)};Context.prototype.lookup=function lookup(name){var cache=this.cache;var value;if(cache.hasOwnProperty(name)){value=cache[name]}else{var context=this,names,index,lookupHit=false;while(context){if(name.indexOf(".")>0){value=context.view;names=name.split(".");index=0;while(value!=null&&index")value=this.renderPartial(token,context,partials,originalTemplate);else if(symbol==="&")value=this.unescapedValue(token,context);else if(symbol==="name")value=this.escapedValue(token,context);else if(symbol==="text")value=this.rawValue(token);if(value!==undefined)buffer+=value}return buffer};Writer.prototype.renderSection=function renderSection(token,context,partials,originalTemplate){var self=this;var buffer="";var value=context.lookup(token[1]);function subRender(template){return self.render(template,context,partials)}if(!value)return;if(isArray(value)){for(var j=0,valueLength=value.length;j": ">", '"': """, "'": "'", "/": "/", "`": "`", "=": "=" }; + function escapeHtml(string) { + return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap(s) { + return entityMap[s]; + }); + } + var whiteRe = /\s*/; + var spaceRe = /\s+/; + var equalsRe = /\s*=/; + var curlyRe = /\s*\}/; + var tagRe = /#|\^|\/|>|\{|&|=|!/; + function parseTemplate(template, tags) { + if (!template) return []; + var sections = []; + var tokens = []; + var spaces = []; + var hasTag = false; + var nonSpace = false; + function stripSpace() { + if (hasTag && !nonSpace) { + while (spaces.length) delete tokens[spaces.pop()]; + } else { + spaces = []; + } + hasTag = false; + nonSpace = false; + } + var openingTagRe, closingTagRe, closingCurlyRe; + function compileTags(tagsToCompile) { + if (typeof tagsToCompile === "string") tagsToCompile = tagsToCompile.split(spaceRe, 2); + if (!isArray(tagsToCompile) || tagsToCompile.length !== 2) throw new Error("Invalid tags: " + tagsToCompile); + openingTagRe = new RegExp(escapeRegExp(tagsToCompile[0]) + "\\s*"); + closingTagRe = new RegExp("\\s*" + escapeRegExp(tagsToCompile[1])); + closingCurlyRe = new RegExp("\\s*" + escapeRegExp("}" + tagsToCompile[1])); + } + compileTags(tags || mustache.tags); + var scanner = new Scanner(template); + var start, type, value, chr, token, openSection; + while (!scanner.eos()) { + start = scanner.pos; + value = scanner.scanUntil(openingTagRe); + if (value) { + for (var i = 0, valueLength = value.length; i < valueLength; ++i) { + chr = value.charAt(i); + if (isWhitespace(chr)) { + spaces.push(tokens.length); + } else { + nonSpace = true; + } + tokens.push(["text", chr, start, start + 1]); + start += 1; + if (chr === "\n") stripSpace(); + } + } + if (!scanner.scan(openingTagRe)) break; + hasTag = true; + type = scanner.scan(tagRe) || "name"; + scanner.scan(whiteRe); + if (type === "=") { + value = scanner.scanUntil(equalsRe); + scanner.scan(equalsRe); + scanner.scanUntil(closingTagRe); + } else if (type === "{") { + value = scanner.scanUntil(closingCurlyRe); + scanner.scan(curlyRe); + scanner.scanUntil(closingTagRe); + type = "&"; + } else { + value = scanner.scanUntil(closingTagRe); + } + if (!scanner.scan(closingTagRe)) throw new Error("Unclosed tag at " + scanner.pos); + token = [type, value, start, scanner.pos]; + tokens.push(token); + if (type === "#" || type === "^") { + sections.push(token); + } else if (type === "/") { + openSection = sections.pop(); + if (!openSection) throw new Error('Unopened section "' + value + '" at ' + start); + if (openSection[1] !== value) throw new Error('Unclosed section "' + openSection[1] + '" at ' + start); + } else if (type === "name" || type === "{" || type === "&") { + nonSpace = true; + } else if (type === "=") { + compileTags(value); + } + } + openSection = sections.pop(); + if (openSection) throw new Error('Unclosed section "' + openSection[1] + '" at ' + scanner.pos); + return nestTokens(squashTokens(tokens)); + } + function squashTokens(tokens) { + var squashedTokens = []; + var token, lastToken; + for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) { + token = tokens[i]; + if (token) { + if (token[0] === "text" && lastToken && lastToken[0] === "text") { + lastToken[1] += token[1]; + lastToken[3] = token[3]; + } else { + squashedTokens.push(token); + lastToken = token; + } + } + } + return squashedTokens; + } + function nestTokens(tokens) { + var nestedTokens = []; + var collector = nestedTokens; + var sections = []; + var token, section; + for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) { + token = tokens[i]; + switch (token[0]) { + case "#": + case "^": + collector.push(token); + sections.push(token); + collector = token[4] = []; + break; + case "/": + section = sections.pop(); + section[5] = token[2]; + collector = sections.length > 0 ? sections[sections.length - 1][4] : nestedTokens; + break; + default: + collector.push(token); + } + } + return nestedTokens; + } + function Scanner(string) { + this.string = string; + this.tail = string; + this.pos = 0; + } + Scanner.prototype.eos = function eos() { + return this.tail === ""; + }; + Scanner.prototype.scan = function scan(re) { + var match = this.tail.match(re); + if (!match || match.index !== 0) return ""; + var string = match[0]; + this.tail = this.tail.substring(string.length); + this.pos += string.length; + return string; + }; + Scanner.prototype.scanUntil = function scanUntil(re) { + var index = this.tail.search(re), + match; + switch (index) { + case -1: + match = this.tail; + this.tail = ""; + break; + case 0: + match = ""; + break; + default: + match = this.tail.substring(0, index); + this.tail = this.tail.substring(index); + } + this.pos += match.length; + return match; + }; + function Context(view, parentContext) { + this.view = view; + this.cache = { ".": this.view }; + this.parent = parentContext; + } + Context.prototype.push = function push(view) { + return new Context(view, this); + }; + Context.prototype.lookup = function lookup(name) { + var cache = this.cache; + var value; + if (cache.hasOwnProperty(name)) { + value = cache[name]; + } else { + var context = this, + names, + index, + lookupHit = false; + while (context) { + if (name.indexOf(".") > 0) { + value = context.view; + names = name.split("."); + index = 0; + while (value != null && index < names.length) { + if (index === names.length - 1) lookupHit = hasProperty(value, names[index]); + value = value[names[index++]]; + } + } else { + value = context.view[name]; + lookupHit = hasProperty(context.view, name); + } + if (lookupHit) break; + context = context.parent; + } + cache[name] = value; + } + if (isFunction(value)) value = value.call(this.view); + return value; + }; + function Writer() { + this.cache = {}; + } + Writer.prototype.clearCache = function clearCache() { + this.cache = {}; + }; + Writer.prototype.parse = function parse(template, tags) { + var cache = this.cache; + var tokens = cache[template]; + if (tokens == null) tokens = cache[template] = parseTemplate(template, tags); + return tokens; + }; + Writer.prototype.render = function render(template, view, partials) { + var tokens = this.parse(template); + var context = view instanceof Context ? view : new Context(view); + return this.renderTokens(tokens, context, partials, template); + }; + Writer.prototype.renderTokens = function renderTokens(tokens, context, partials, originalTemplate) { + var buffer = ""; + var token, symbol, value; + for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) { + value = undefined; + token = tokens[i]; + symbol = token[0]; + if (symbol === "#") value = this.renderSection(token, context, partials, originalTemplate); + else if (symbol === "^") value = this.renderInverted(token, context, partials, originalTemplate); + else if (symbol === ">") value = this.renderPartial(token, context, partials, originalTemplate); + else if (symbol === "&") value = this.unescapedValue(token, context); + else if (symbol === "name") value = this.escapedValue(token, context); + else if (symbol === "text") value = this.rawValue(token); + if (value !== undefined) buffer += value; + } + return buffer; + }; + Writer.prototype.renderSection = function renderSection(token, context, partials, originalTemplate) { + var self = this; + var buffer = ""; + var value = context.lookup(token[1]); + function subRender(template) { + return self.render(template, context, partials); + } + if (!value) return; + if (isArray(value)) { + for (var j = 0, valueLength = value.length; j < valueLength; ++j) { + buffer += this.renderTokens(token[4], context.push(value[j]), partials, originalTemplate); + } + } else if (typeof value === "object" || typeof value === "string" || typeof value === "number") { + buffer += this.renderTokens(token[4], context.push(value), partials, originalTemplate); + } else if (isFunction(value)) { + if (typeof originalTemplate !== "string") throw new Error("Cannot use higher-order sections without the original template"); + value = value.call(context.view, originalTemplate.slice(token[3], token[5]), subRender); + if (value != null) buffer += value; + } else { + buffer += this.renderTokens(token[4], context, partials, originalTemplate); + } + return buffer; + }; + Writer.prototype.renderInverted = function renderInverted(token, context, partials, originalTemplate) { + var value = context.lookup(token[1]); + if (!value || (isArray(value) && value.length === 0)) return this.renderTokens(token[4], context, partials, originalTemplate); + }; + Writer.prototype.renderPartial = function renderPartial(token, context, partials) { + if (!partials) return; + var value = isFunction(partials) ? partials(token[1]) : partials[token[1]]; + if (value != null) return this.renderTokens(this.parse(value), context, partials, value); + }; + Writer.prototype.unescapedValue = function unescapedValue(token, context) { + var value = context.lookup(token[1]); + if (value != null) return value; + }; + Writer.prototype.escapedValue = function escapedValue(token, context) { + var value = context.lookup(token[1]); + if (value != null) return mustache.escape(value); + }; + Writer.prototype.rawValue = function rawValue(token) { + return token[1]; + }; + mustache.name = "mustache.js"; + mustache.version = "2.3.0"; + mustache.tags = ["{{", "}}"]; + var defaultWriter = new Writer(); + mustache.clearCache = function clearCache() { + return defaultWriter.clearCache(); + }; + mustache.parse = function parse(template, tags) { + return defaultWriter.parse(template, tags); + }; + mustache.render = function render(template, view, partials) { + if (typeof template !== "string") { + throw new TypeError('Invalid template! Template should be a "string" ' + 'but "' + typeStr(template) + '" was given as the first ' + "argument for mustache#render(template, view, partials)"); + } + return defaultWriter.render(template, view, partials); + }; + mustache.to_html = function to_html(template, view, partials, send) { + var result = mustache.render(template, view, partials); + if (isFunction(send)) { + send(result); + } else { + return result; + } + }; + mustache.escape = escapeHtml; + mustache.Scanner = Scanner; + mustache.Context = Context; + mustache.Writer = Writer; + return mustache; +}); diff --git a/[core]/esx_menu_default/html/ui.html b/[core]/esx_menu_default/html/ui.html index 5c090697..2cb88e7c 100644 --- a/[core]/esx_menu_default/html/ui.html +++ b/[core]/esx_menu_default/html/ui.html @@ -1,25 +1,16 @@ - - - - - - + + + + + + - - + + - - - - + + + + diff --git a/[core]/esx_menu_dialog/html/css/app.css b/[core]/esx_menu_dialog/html/css/app.css index c2f590c4..20b39923 100644 --- a/[core]/esx_menu_dialog/html/css/app.css +++ b/[core]/esx_menu_dialog/html/css/app.css @@ -1,132 +1,132 @@ @import url("https://fonts.googleapis.com/css?family=Montserrat&display=swap"); #controls { - font-family: montserrat; - font-size: 3em; - color: #fff; - position: absolute; - bottom: 40; - right: 40; + font-family: montserrat; + font-size: 3em; + color: #fff; + position: absolute; + bottom: 40; + right: 40; } .controls { - display: none; + display: none; } .dialog { - font-family: montserrat; - background: rgba(33, 33, 33, 0.8); - color: #fff; - position: absolute; - border-top-left-radius: 5px; - border-top-right-radius: 5px; - overflow: hidden; - top: 50%; - left: 50%; - width: 600px; - height: 152px; - transform: translate(-50%, -50%); + font-family: montserrat; + background: rgba(33, 33, 33, 0.8); + color: #fff; + position: absolute; + border-top-left-radius: 5px; + border-top-right-radius: 5px; + overflow: hidden; + top: 50%; + left: 50%; + width: 600px; + height: 152px; + transform: translate(-50%, -50%); } .head { - display: flex; - flex-basis: 100%; - align-items: center; - color: #fff; + display: flex; + flex-basis: 100%; + align-items: center; + color: #fff; } .dialog.big { - height: 200px; + height: 200px; } .dialog .head { - background: rgba(25, 25, 25, 0.9); - text-align: center; - height: 40px; + background: rgba(25, 25, 25, 0.9); + text-align: center; + height: 40px; } .dialog .head span::before { - content: ""; - display: inline-block; - height: 100%; - vertical-align: middle; + content: ""; + display: inline-block; + height: 100%; + vertical-align: middle; } .dialog input[type="text"] { - width: 60%; - height: 32px; - outline: 0; - background: none; - text-align: center; - margin-top: 26px; - margin-left: 125px; - font-size: large; - transition: all 0.2s ease-in-out; - color: white; - border: 0.5px solid #ffffff3b; - border-radius: 0px; + width: 60%; + height: 32px; + outline: 0; + background: none; + text-align: center; + margin-top: 26px; + margin-left: 125px; + font-size: large; + transition: all 0.2s ease-in-out; + color: white; + border: 0.5px solid #ffffff3b; + border-radius: 0px; } .dialog input[type="text"]:active, .dialog input[type="text"]:hover { - color: white; + color: white; } .dialog textarea { - width: 100%; - height: 128px; + width: 100%; + height: 128px; } .dialog button[name="submit"] { - width: 17.6%; - height: 32px; - margin-left: 160px; - font-weight: 300; - color: rgb(37, 34, 53); - border-radius: 10px; - text-transform: uppercase; - background: rgb(50, 79, 208); - outline: 0; - border: none; - transition: all 0.2s ease-in-out; + width: 17.6%; + height: 32px; + margin-left: 160px; + font-weight: 300; + color: rgb(37, 34, 53); + border-radius: 10px; + text-transform: uppercase; + background: rgb(50, 79, 208); + outline: 0; + border: none; + transition: all 0.2s ease-in-out; } .dialog button { - z-index: 9999; - transform: translate(-0%, 50%); + z-index: 9999; + transform: translate(-0%, 50%); } .dialog button[name="cancel"] { - width: 17.6%; - height: 32px; - margin-left: 60px; - border: none; - text-transform: uppercase; - font-weight: 200; - border-radius: 10px; - color: rgb(53, 34, 34); - outline: 0; - background: #c74545; - transition: all 0.2s ease-in-out; + width: 17.6%; + height: 32px; + margin-left: 60px; + border: none; + text-transform: uppercase; + font-weight: 200; + border-radius: 10px; + color: rgb(53, 34, 34); + outline: 0; + background: #c74545; + transition: all 0.2s ease-in-out; } .dialog button[name="cancel"]:hover { - letter-spacing: 1px; - color: #ffffff; - width: 17.6%; + letter-spacing: 1px; + color: #ffffff; + width: 17.6%; } .dialog button[name="submit"]:hover { - letter-spacing: 1px; - color: white; - width: 17.6%; + letter-spacing: 1px; + color: white; + width: 17.6%; } .head::before, .head::after { - content: ""; - flex-grow: 1; - background: #00e1ff; - height: 2px; - margin: 0px 3px; + content: ""; + flex-grow: 1; + background: #00e1ff; + height: 2px; + margin: 0px 3px; } diff --git a/[core]/esx_menu_dialog/html/js/app.js b/[core]/esx_menu_dialog/html/js/app.js index bcbd97fc..9cbdf2ba 100644 --- a/[core]/esx_menu_dialog/html/js/app.js +++ b/[core]/esx_menu_dialog/html/js/app.js @@ -1,184 +1,181 @@ (function () { - let MenuTpl = - '