From 426cda1b939a2328c1cccbdf942fb4db23b6ef3a Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Sun, 28 Jul 2024 12:23:23 +0200 Subject: [PATCH 01/23] fix fixed textui bug --- .../esx_mechanicjob/client/main.lua | 50 ++++++++----------- .../[esx_addons]/esx_mechanicjob/config.lua | 7 --- .../esx_mechanicjob/locales/en.lua | 1 - .../esx_mechanicjob/locales/it.lua | 1 - 4 files changed, 21 insertions(+), 38 deletions(-) diff --git a/server-data/resources/[esx_addons]/esx_mechanicjob/client/main.lua b/server-data/resources/[esx_addons]/esx_mechanicjob/client/main.lua index 6d1f7e64f..6ef416b97 100644 --- a/server-data/resources/[esx_addons]/esx_mechanicjob/client/main.lua +++ b/server-data/resources/[esx_addons]/esx_mechanicjob/client/main.lua @@ -176,7 +176,6 @@ function OpenMobileMechanicActionsMenu() { icon = "fas fa-gear", title = TranslateCap("clean"), value = "clean_vehicle" }, { icon = "fas fa-gear", title = TranslateCap("imp_veh"), value = "del_vehicle" }, { icon = "fas fa-gear", title = TranslateCap("tow"), value = "dep_vehicle" }, - { icon = "fas fa-gear", title = TranslateCap("place_objects"), value = "object_spawner" }, } ESX.OpenContext("right", elements, function(_, element) @@ -371,37 +370,11 @@ function OpenMobileMechanicActionsMenu() else ESX.ShowNotification(TranslateCap("imp_flatbed")) end - elseif element.value == "object_spawner" then - local playerPed = PlayerPedId() if IsPedSittingInAnyVehicle(playerPed) then ESX.ShowNotification(TranslateCap("inside_vehicle")) return end - - local elements2 = { - { unselectable = true, icon = "fas fa-object", title = TranslateCap("objects") }, - { icon = "fas fa-object", title = TranslateCap("roadcone"), value = "prop_roadcone02a" }, - { icon = "fas fa-object", title = TranslateCap("toolbox"), value = "prop_toolchest_01" }, - } - - ESX.OpenContext("right", elements2, function(_, elementObj) - local model = elementObj.value - local coords = GetEntityCoords(playerPed) - local forward = GetEntityForwardVector(playerPed) - local x, y, z = table.unpack(coords + forward * 1.0) - - if model == "prop_roadcone02a" then - z = z - 2.0 - elseif model == "prop_toolchest_01" then - z = z - 2.0 - end - - ESX.Game.SpawnObject(model, { x = x, y = y, z = z }, function(obj) - SetEntityHeading(obj, GetEntityHeading(playerPed)) - PlaceObjectOnGroundProperly(obj) - end) - end) end end) end @@ -590,7 +563,27 @@ AddEventHandler("esx_mechanicjob:hasEnteredMarker", function(zone) CurrentActionData = { vehicle = vehicle } end end - ESX.TextUI(CurrentActionMsg) + + if zone ~= "VehicleSpawnPoint" then + ESX.TextUI(CurrentActionMsg) + end +end) + +AddEventHandler("esx_mechanicjob:hasExitedMarker", function(zone) + if zone == "VehicleDelivery" then + NPCTargetDeleterZone = false + end + CurrentAction = nil + ESX.CloseContext() + ESX.HideUI() +end) + +AddEventHandler("esx_mechanicjob:hasExitedEntityZone", function(entity) + if CurrentAction == "remove_entity" then + CurrentAction = nil + end + ESX.CloseContext() + ESX.HideUI() end) -- Pop NPC mission vehicle when inside area @@ -758,5 +751,4 @@ RegisterKeyMapping("mechanicMenu", "Open Mechanic Menu", "keyboard", Config.Cont RegisterKeyMapping("mechanicjob", "Togggle NPC Job", "keyboard", Config.Controls.toggleNPCJob) AddEventHandler("esx:onPlayerDeath", function() end) - AddEventHandler("esx:onPlayerSpawn", function() end) diff --git a/server-data/resources/[esx_addons]/esx_mechanicjob/config.lua b/server-data/resources/[esx_addons]/esx_mechanicjob/config.lua index 78dde6a07..6fc49929b 100644 --- a/server-data/resources/[esx_addons]/esx_mechanicjob/config.lua +++ b/server-data/resources/[esx_addons]/esx_mechanicjob/config.lua @@ -36,13 +36,6 @@ Config.Zones = { Type = 21, }, - Garage = { - Pos = vector3(-97.5, 6496.1, 31.4), - Size = { x = 1.0, y = 1.0, z = 1.0 }, - Color = { r = 50, g = 200, b = 50 }, - Type = 21, - }, - VehicleSpawnPoint = { Pos = vector3(-366.354, -110.766, 37.696), Size = { x = 1.5, y = 1.5, z = 1.0 }, diff --git a/server-data/resources/[esx_addons]/esx_mechanicjob/locales/en.lua b/server-data/resources/[esx_addons]/esx_mechanicjob/locales/en.lua index 11f4d57a3..331a0bf17 100644 --- a/server-data/resources/[esx_addons]/esx_mechanicjob/locales/en.lua +++ b/server-data/resources/[esx_addons]/esx_mechanicjob/locales/en.lua @@ -22,7 +22,6 @@ Locales["en"] = { ["repair"] = "repair", ["clean"] = "clean", ["imp_veh"] = "impound", - ["place_objects"] = "place Objects", ["invoice_amount"] = "invoice Amount", ["amount_invalid"] = "invalid amount", ["no_players_nearby"] = "there is no nearby player", diff --git a/server-data/resources/[esx_addons]/esx_mechanicjob/locales/it.lua b/server-data/resources/[esx_addons]/esx_mechanicjob/locales/it.lua index a9219587b..862f35114 100644 --- a/server-data/resources/[esx_addons]/esx_mechanicjob/locales/it.lua +++ b/server-data/resources/[esx_addons]/esx_mechanicjob/locales/it.lua @@ -22,7 +22,6 @@ Locales["it"] = { ["repair"] = "riparazione", ["clean"] = "pulito", ["imp_veh"] = "sequestrato", - ["place_objects"] = "posiziona oggetti", ["invoice_amount"] = "importo fattura", ["amount_invalid"] = "importo non valido", ["no_players_nearby"] = "nessun giocatore nelle vicinanze", From 2a47144bd5d34e2bd52af9dd49925bc030bc4524 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 29 Jul 2024 00:17:34 +0200 Subject: [PATCH 02/23] refactor: Improved code style respecting ESLint rules --- .../bpt_dmvschool/html/debounce.min.js | 14 +- .../bpt_dmvschool/html/questions.js | 125 +++++++++--------- .../bpt_dmvschool/html/questions_it.js | 125 +++++++++--------- .../bpt_dmvschool/html/scripts.js | 81 ++++++------ 4 files changed, 183 insertions(+), 162 deletions(-) diff --git a/server-data/resources/[bpt_addons]/bpt_dmvschool/html/debounce.min.js b/server-data/resources/[bpt_addons]/bpt_dmvschool/html/debounce.min.js index 9b70688f1..35c4eb298 100644 --- a/server-data/resources/[bpt_addons]/bpt_dmvschool/html/debounce.min.js +++ b/server-data/resources/[bpt_addons]/bpt_dmvschool/html/debounce.min.js @@ -6,4 +6,16 @@ * Dual licensed under the MIT and GPL licenses. * http://benalman.com/about/license/ */ -(function (b, c) { var $ = b.jQuery || b.Cowboy || (b.Cowboy = {}), a; $.throttle = a = function (e, f, j, i) { var h, d = 0; if (typeof f !== "boolean") { i = j; j = f; f = c } function g() { var o = this, m = +new Date() - d, n = arguments; function l() { d = +new Date(); j.apply(o, n) } function k() { h = c } if (i && !h) { l() } h && clearTimeout(h); if (i === c && m > e) { l() } else { if (f !== true) { h = setTimeout(i ? k : l, i === c ? e - m : e) } } } if ($.guid) { g.guid = j.guid = j.guid || $.guid++ } return g }; $.debounce = function (d, e, f) { return f === c ? a(d, e, false) : a(d, f, e !== false) } })(this); \ No newline at end of file +(function(b, c) { + // eslint-disable-next-line prefer-const + let $ = b.jQuery || b.Cowboy || (b.Cowboy = {}), a; $.throttle = a = function(e, f, j, i) { + // eslint-disable-next-line max-statements-per-line + let h, d = 0; if (typeof f !== 'boolean') { i = j; j = f; f = c; } function g() { + // eslint-disable-next-line prefer-const, max-statements-per-line + let o = this, m = +new Date() - d, n = arguments; function l() { d = +new Date(); j.apply(o, n); } function k() { h = c; } if (i && !h) { l(); } h && clearTimeout(h); if (i === c && m > e) { l(); } + else if (f !== true) { h = setTimeout(i ? k : l, i === c ? e - m : e); } + // eslint-disable-next-line max-statements-per-line + } if ($.guid) { g.guid = j.guid = j.guid || $.guid++; } return g; + // eslint-disable-next-line max-statements-per-line + }; $.debounce = function(d, e, f) { return f === c ? a(d, e, false) : a(d, f, e !== false); }; +})(this); \ No newline at end of file diff --git a/server-data/resources/[bpt_addons]/bpt_dmvschool/html/questions.js b/server-data/resources/[bpt_addons]/bpt_dmvschool/html/questions.js index faff7195e..b9bcbea2e 100644 --- a/server-data/resources/[bpt_addons]/bpt_dmvschool/html/questions.js +++ b/server-data/resources/[bpt_addons]/bpt_dmvschool/html/questions.js @@ -1,91 +1,92 @@ -var tableauQuestion = [ +// eslint-disable-next-line no-unused-vars +const tableauQuestion = [ { - question: "If you're going 80 km/h, and you're approaching a residential area you must:", - propositionA: "You accelerate", - propositionB: "You keep your speed, if you do not pass other vehicles", - propositionC: "You slow down", - propositionD: "You keep your speed", - reponse: "C" + question: 'If you\'re going 80 km/h, and you\'re approaching a residential area you must:', + propositionA: 'You accelerate', + propositionB: 'You keep your speed, if you do not pass other vehicles', + propositionC: 'You slow down', + propositionD: 'You keep your speed', + reponse: 'C', }, { - question: "If you're turning right at a traffic light, but see a pedestrian crossing what do you do:", - propositionA: "You pass the pedestrian", - propositionB: "You check that there is no other vehicles around", - propositionC: "You wait until the pedestrian has crossed", - propositionD: "You shoot the pedestrian and continue to drive", - reponse: "C" + question: 'If you\'re turning right at a traffic light, but see a pedestrian crossing what do you do:', + propositionA: 'You pass the pedestrian', + propositionB: 'You check that there is no other vehicles around', + propositionC: 'You wait until the pedestrian has crossed', + propositionD: 'You shoot the pedestrian and continue to drive', + reponse: 'C', }, { - question: "Without any prior indication, the speed in a residential area is: __ km/h", - propositionA: "30 km/h", - propositionB: "50 km/h", - propositionC: "40 km/h", - propositionD: "60 km/h", - reponse: "B" + question: 'Without any prior indication, the speed in a residential area is: __ km/h', + propositionA: '30 km/h', + propositionB: '50 km/h', + propositionC: '40 km/h', + propositionD: '60 km/h', + reponse: 'B', }, { - question: "Before every lane change you must:", - propositionA: "Check your mirrors", - propositionB: "Check your blind spots", - propositionC: "Signal your intentions", - propositionD: "All of the above", - reponse: "D" + question: 'Before every lane change you must:', + propositionA: 'Check your mirrors', + propositionB: 'Check your blind spots', + propositionC: 'Signal your intentions', + propositionD: 'All of the above', + reponse: 'D', }, { - question: "What blood alcohol level is classified as driving while intoxicated?", - propositionA: "0.05%", - propositionB: "0.18%", - propositionC: "0.08%", - propositionD: "0.06%", - reponse: "C" + question: 'What blood alcohol level is classified as driving while intoxicated?', + propositionA: '0.05%', + propositionB: '0.18%', + propositionC: '0.08%', + propositionD: '0.06%', + reponse: 'C', }, { - question: "When can you continue to drive at a traffic light?", - propositionA: "When it is green", - propositionB: "When there is nobody in the intersection", - propositionC: "You are in a school zone", - propositionD: "When it is green and / or red and you're turning right", - reponse: "D" + question: 'When can you continue to drive at a traffic light?', + propositionA: 'When it is green', + propositionB: 'When there is nobody in the intersection', + propositionC: 'You are in a school zone', + propositionD: 'When it is green and / or red and you\'re turning right', + reponse: 'D', }, { - question: "A pedestrian has a do not cross signal, what do you do?", - propositionA: "You let them pass", - propositionB: "You observe before continuing", - propositionC: "You wave to tell them to cross", - propositionD: "You continue because your traffic light is green", - reponse: "D" + question: 'A pedestrian has a do not cross signal, what do you do?', + propositionA: 'You let them pass', + propositionB: 'You observe before continuing', + propositionC: 'You wave to tell them to cross', + propositionD: 'You continue because your traffic light is green', + reponse: 'D', }, { - question: "What is allowed when passing another vehicle", - propositionA: "You follow it closely to pass it faster", - propositionB: "You pass it without leaving the roadway", - propositionC: "You drive on the opposite side of the road to pass", - propositionD: "You exceed the speed limit to pass them", - reponse: "C" + question: 'What is allowed when passing another vehicle', + propositionA: 'You follow it closely to pass it faster', + propositionB: 'You pass it without leaving the roadway', + propositionC: 'You drive on the opposite side of the road to pass', + propositionD: 'You exceed the speed limit to pass them', + reponse: 'C', }, { - question: "You are driving on a highway which indicates a maximum speed of 120 km/h. But most trafficers drive at 125 km/h, so you should not drive faster than:", - propositionA: "120 km/h", - propositionB: "125 km/h", - propositionC: "130 km/h", - propositionD: "110 km/h", - reponse: "A" + question: 'You are driving on a highway which indicates a maximum speed of 120 km/h. But most trafficers drive at 125 km/h, so you should not drive faster than:', + propositionA: '120 km/h', + propositionB: '125 km/h', + propositionC: '130 km/h', + propositionD: '110 km/h', + reponse: 'A', }, { - question: "When you are overtaken by another vehicle it is important NOT to:", - propositionA: "Slow Down", - propositionB: "Check your mirrors", - propositionC: "Watch other drivers", - propositionD: "Increase your speed", - reponse: "D" + question: 'When you are overtaken by another vehicle it is important NOT to:', + propositionA: 'Slow Down', + propositionB: 'Check your mirrors', + propositionC: 'Watch other drivers', + propositionD: 'Increase your speed', + reponse: 'D', }, -] \ No newline at end of file +]; \ No newline at end of file diff --git a/server-data/resources/[bpt_addons]/bpt_dmvschool/html/questions_it.js b/server-data/resources/[bpt_addons]/bpt_dmvschool/html/questions_it.js index 05681796e..d5c0953b9 100644 --- a/server-data/resources/[bpt_addons]/bpt_dmvschool/html/questions_it.js +++ b/server-data/resources/[bpt_addons]/bpt_dmvschool/html/questions_it.js @@ -1,91 +1,92 @@ -var tableauQuestion = [ +// eslint-disable-next-line no-unused-vars +const tableauQuestion = [ { - question: "Se stai andando a 80 km/h, e ti stai avvicinando a una zona residenziale devi::", - propositionA: "Accellerare", - propositionB: "Mantieni la velocità, se non sorpassi altri veicoli", - propositionC: "Rallenti", - propositionD: "Mantieni la velocità", - reponse: "C" + question: 'Se stai andando a 80 km/h, e ti stai avvicinando a una zona residenziale devi::', + propositionA: 'Accellerare', + propositionB: 'Mantieni la velocità, se non sorpassi altri veicoli', + propositionC: 'Rallenti', + propositionD: 'Mantieni la velocità', + reponse: 'C', }, { - question: "Se al semaforo stai svoltando a destra, ma vedi un pedone cosa fai:", - propositionA: "Superi il pedone", - propositionB: "Controlli che non ci siano altri veicoli in giro", - propositionC: "Aspetti che il pedone abbia attraversato", - propositionD: "Spari al pedone e continui a guidare", - reponse: "C" + question: 'Se al semaforo stai svoltando a destra, ma vedi un pedone cosa fai:', + propositionA: 'Superi il pedone', + propositionB: 'Controlli che non ci siano altri veicoli in giro', + propositionC: 'Aspetti che il pedone abbia attraversato', + propositionD: 'Spari al pedone e continui a guidare', + reponse: 'C', }, { - question: "Senza alcuna indicazione preventiva, la velocità in una zona residenziale è: __ km/h", - propositionA: "30 km/h", - propositionB: "50 km/h", - propositionC: "40 km/h", - propositionD: "60 km/h", - reponse: "B" + question: 'Senza alcuna indicazione preventiva, la velocità in una zona residenziale è: __ km/h', + propositionA: '30 km/h', + propositionB: '50 km/h', + propositionC: '40 km/h', + propositionD: '60 km/h', + reponse: 'B', }, { - question: "Prima di ogni cambio si corsia devi:", - propositionA: "Controllare gli specchietti", - propositionB: "Controllare i punti ciechi", - propositionC: "Segnalare le tue intenzioni", - propositionD: "Tutte le risposte sono esatte", - reponse: "D" + question: 'Prima di ogni cambio si corsia devi:', + propositionA: 'Controllare gli specchietti', + propositionB: 'Controllare i punti ciechi', + propositionC: 'Segnalare le tue intenzioni', + propositionD: 'Tutte le risposte sono esatte', + reponse: 'D', }, { - question: "Quale livello di alcol nel sangue è classificato come guida in stato di ebbrezza?", - propositionA: "0.05%", - propositionB: "0.18%", - propositionC: "0.08%", - propositionD: "0.06%", - reponse: "C" + question: 'Quale livello di alcol nel sangue è classificato come guida in stato di ebbrezza?', + propositionA: '0.05%', + propositionB: '0.18%', + propositionC: '0.08%', + propositionD: '0.06%', + reponse: 'C', }, { - question: "Quando puoi continuare a guidare a un semaforo?", - propositionA: "Quando è verde", - propositionB: "Quando non c'è nessuno all'incrocio", - propositionC: "Quando sei in una zona scolastca", - propositionD: "Quando è verde e/o rosso e stai girando a destra", - reponse: "D" + question: 'Quando puoi continuare a guidare a un semaforo?', + propositionA: 'Quando è verde', + propositionB: 'Quando non c\'è nessuno all\'incrocio', + propositionC: 'Quando sei in una zona scolastca', + propositionD: 'Quando è verde e/o rosso e stai girando a destra', + reponse: 'D', }, { - question: "Un pedone ha un segnale di non attraversare, cosa fai?", - propositionA: "Li lasci passare", - propositionB: "Osservi prima di continuare", - propositionC: "Fai la mano per dire loro di attraversare", - propositionD: "Continui perchè il tuo semaforo è verde", - reponse: "D" + question: 'Un pedone ha un segnale di non attraversare, cosa fai?', + propositionA: 'Li lasci passare', + propositionB: 'Osservi prima di continuare', + propositionC: 'Fai la mano per dire loro di attraversare', + propositionD: 'Continui perchè il tuo semaforo è verde', + reponse: 'D', }, { - question: "Cosa è consentito quando si supera un'altro veicolo", - propositionA: "Lo segui da vicino per superarlo velocemente", - propositionB: "Lo passi senza lasciare la carreggiata", - propositionC: "Si guida sul lato opposto della strada per passare", - propositionD: "Si supera il limite di velocità per superarli", - reponse: "C" + question: 'Cosa è consentito quando si supera un\'altro veicolo', + propositionA: 'Lo segui da vicino per superarlo velocemente', + propositionB: 'Lo passi senza lasciare la carreggiata', + propositionC: 'Si guida sul lato opposto della strada per passare', + propositionD: 'Si supera il limite di velocità per superarli', + reponse: 'C', }, { - question: "Stai guidando su un'autostrada che indica una velocità massima di 120 km/h. Ma la maggior parte dei trafficanti guida a 125 km/h, quindi non dovresti guidare più veloce di:", - propositionA: "120 km/h", - propositionB: "125 km/h", - propositionC: "130 km/h", - propositionD: "110 km/h", - reponse: "A" + question: 'Stai guidando su un\'autostrada che indica una velocità massima di 120 km/h. Ma la maggior parte dei trafficanti guida a 125 km/h, quindi non dovresti guidare più veloce di:', + propositionA: '120 km/h', + propositionB: '125 km/h', + propositionC: '130 km/h', + propositionD: '110 km/h', + reponse: 'A', }, { - question: "Quando vieni sorpassato da un altro veicolo è importane NON:", - propositionA: "Rallentare", - propositionB: "Controllare gli specchietti", - propositionC: "Guardare gli altri automobilisti", - propositionD: "Aumentare la tua velocità", - reponse: "D" + question: 'Quando vieni sorpassato da un altro veicolo è importane NON:', + propositionA: 'Rallentare', + propositionB: 'Controllare gli specchietti', + propositionC: 'Guardare gli altri automobilisti', + propositionD: 'Aumentare la tua velocità', + reponse: 'D', }, -] \ No newline at end of file +]; \ No newline at end of file diff --git a/server-data/resources/[bpt_addons]/bpt_dmvschool/html/scripts.js b/server-data/resources/[bpt_addons]/bpt_dmvschool/html/scripts.js index 551f3bfb2..0bc20543a 100644 --- a/server-data/resources/[bpt_addons]/bpt_dmvschool/html/scripts.js +++ b/server-data/resources/[bpt_addons]/bpt_dmvschool/html/scripts.js @@ -1,16 +1,21 @@ // question variables -var questionNumber = 1; -var userAnswer = []; -var goodAnswer = []; -var questionUsed = []; -var nbQuestionToAnswer = 10; // don't forget to change the progress bar max value in html -var nbAnswerNeeded = 5; // out of nbQuestionToAnswer -var nbPossibleQuestions = 10; // number of questions in database questions.js -var lastClick = 0; +let questionNumber = 1; +let userAnswer = []; +let goodAnswer = []; +let questionUsed = []; +// eslint-disable-next-line no-inline-comments +const nbQuestionToAnswer = 10; // don't forget to change the progress bar max value in html +// eslint-disable-next-line no-inline-comments +const nbAnswerNeeded = 5; // out of nbQuestionToAnswer +// eslint-disable-next-line no-inline-comments +const nbPossibleQuestions = 10; // number of questions in database questions.js +// eslint-disable-next-line no-unused-vars +const lastClick = 0; function getRandomQuestion() { - var random = Math.floor(Math.random() * nbPossibleQuestions); + let random = Math.floor(Math.random() * nbPossibleQuestions); + // eslint-disable-next-line no-constant-condition while (true) { if (questionUsed.indexOf(random) === -1) { break; @@ -26,45 +31,45 @@ function getRandomQuestion() { // Partial Functions function closeMain() { - $(".home").css("display", "none"); + $('.home').css('display', 'none'); } function openMain() { - $(".home").css("display", "block"); + $('.home').css('display', 'block'); } function closeAll() { - $(".body").css("display", "none"); + $('.body').css('display', 'none'); } function openQuestionnaire() { - $(".questionnaire-container").css("display", "block"); - var randomQuestion = getRandomQuestion(); - - $("#questionNumero").html("Question: " + questionNumber); - $("#question").html(tableauQuestion[randomQuestion].question); - $(".answerA").html(tableauQuestion[randomQuestion].propositionA); - $(".answerB").html(tableauQuestion[randomQuestion].propositionB); - $(".answerC").html(tableauQuestion[randomQuestion].propositionC); - $(".answerD").html(tableauQuestion[randomQuestion].propositionD); + $('.questionnaire-container').css('display', 'block'); + const randomQuestion = getRandomQuestion(); + + $('#questionNumero').html('Question: ' + questionNumber); + $('#question').html(tableauQuestion[randomQuestion].question); + $('.answerA').html(tableauQuestion[randomQuestion].propositionA); + $('.answerB').html(tableauQuestion[randomQuestion].propositionB); + $('.answerC').html(tableauQuestion[randomQuestion].propositionC); + $('.answerD').html(tableauQuestion[randomQuestion].propositionD); $('input[name=question]').attr('checked', false); goodAnswer.push(tableauQuestion[randomQuestion].reponse); - $(".questionnaire-container .progression").val(questionNumber - 1); + $('.questionnaire-container .progression').val(questionNumber - 1); } function openResultGood() { - $(".resultGood").css("display", "block"); + $('.resultGood').css('display', 'block'); } function openResultBad() { - $(".resultBad").css("display", "block"); + $('.resultBad').css('display', 'block'); } function openContainer() { - $(".question-container").css("display", "block"); + $('.question-container').css('display', 'block'); } function closeContainer() { - $(".question-container").css("display", "none"); + $('.question-container').css('display', 'none'); } // Listen for NUI Events -window.addEventListener('message', function (event) { - var item = event.data; +window.addEventListener('message', function(event) { + const item = event.data; // Open & Close main window if (item.openQuestion == true) { @@ -78,18 +83,18 @@ window.addEventListener('message', function (event) { } // Open sub-windows / partials - if (item.openSection == "question") { + if (item.openSection == 'question') { closeAll(); openQuestionnaire(); } }); // Handle Button Presses -$(".btnQuestion").click(function () { +$('.btnQuestion').click(function() { $.post('http://bpt_dmvschool/question', JSON.stringify({})); }); -$(".btnClose").click(function () { +$('.btnClose').click(function() { $.post('http://bpt_dmvschool/close', JSON.stringify({})); userAnswer = []; goodAnswer = []; @@ -97,7 +102,7 @@ $(".btnClose").click(function () { questionNumber = 1; }); -$(".btnKick").click(function () { +$('.btnKick').click(function() { $.post('http://bpt_dmvschool/kick', JSON.stringify({})); userAnswer = []; goodAnswer = []; @@ -106,19 +111,20 @@ $(".btnKick").click(function () { }); // Handle Form Submits -$("#question-form").submit(function (e) { +$('#question-form').submit(function(e) { e.preventDefault(); if (questionNumber != nbQuestionToAnswer) { - //question 1 to 9: pushing answer in array + // question 1 to 9: pushing answer in array closeAll(); userAnswer.push($('input[name="question"]:checked').val()); questionNumber++; openQuestionnaire(); - } else { + } + else { // question 10: comparing arrays and sending number of good answers userAnswer.push($('input[name="question"]:checked').val()); - var nbGoodAnswer = 0; + let nbGoodAnswer = 0; for (i = 0; i < nbQuestionToAnswer; i++) { if (userAnswer[i] == goodAnswer[i]) { nbGoodAnswer++; @@ -128,7 +134,8 @@ $("#question-form").submit(function (e) { closeAll(); if (nbGoodAnswer >= nbAnswerNeeded) { openResultGood(); - } else { + } + else { openResultBad(); } } From 95e71d74f40f69e189f367a5ad228bcf06322699 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 29 Jul 2024 09:59:44 +0200 Subject: [PATCH 03/23] =?UTF-8?q?chore:=20[esx]\esx=5Ftextui\fxmanifest.lu?= =?UTF-8?q?a=20=F0=9F=8E=A8=20Run=20formatter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server-data/resources/[esx]/esx_textui/fxmanifest.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server-data/resources/[esx]/esx_textui/fxmanifest.lua b/server-data/resources/[esx]/esx_textui/fxmanifest.lua index 9d140ea7a..21afa470d 100644 --- a/server-data/resources/[esx]/esx_textui/fxmanifest.lua +++ b/server-data/resources/[esx]/esx_textui/fxmanifest.lua @@ -11,7 +11,7 @@ shared_script("@es_extended/imports.lua") ui_page("nui/index.html") files({ - "nui/index.html", - "nui/js/*.js", - "nui/css/*.css", + "nui/index.html", + "nui/js/*.js", + "nui/css/*.css", }) From 98ee9fd18cb17eab0f32f816bf8658e2c56f681b Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 29 Jul 2024 10:21:43 +0200 Subject: [PATCH 04/23] =?UTF-8?q?chore:=20[esx]\mythic=5Fnotify\fxmanifest?= =?UTF-8?q?.lua=20=F0=9F=8E=A8=20Run=20formatter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/[esx]/mythic_notify/fxmanifest.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server-data/resources/[esx]/mythic_notify/fxmanifest.lua b/server-data/resources/[esx]/mythic_notify/fxmanifest.lua index 5458c9a6c..0473d8237 100644 --- a/server-data/resources/[esx]/mythic_notify/fxmanifest.lua +++ b/server-data/resources/[esx]/mythic_notify/fxmanifest.lua @@ -5,21 +5,21 @@ name("Mythic Framework Notification System") version("1.0.1") ui_page({ - "html/ui.html", + "html/ui.html", }) files({ - "html/ui.html", - "html/js/app.js", - "html/css/style.css", + "html/ui.html", + "html/js/app.js", + "html/css/style.css", }) client_scripts({ - "client/main.lua", + "client/main.lua", }) exports({ - "SendAlert", - "SendUniqueAlert", - "PersistentAlert", + "SendAlert", + "SendUniqueAlert", + "PersistentAlert", }) From 9760b6a4b11430c3449e4cccd3240d251ce15664 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 29 Jul 2024 10:21:58 +0200 Subject: [PATCH 05/23] refactor: Improved code style respecting ESLint rules --- .../[esx]/mythic_notify/html/js/app.js | 162 +++++++++--------- 1 file changed, 83 insertions(+), 79 deletions(-) diff --git a/server-data/resources/[esx]/mythic_notify/html/js/app.js b/server-data/resources/[esx]/mythic_notify/html/js/app.js index be5afbaa0..6aef2e72c 100644 --- a/server-data/resources/[esx]/mythic_notify/html/js/app.js +++ b/server-data/resources/[esx]/mythic_notify/html/js/app.js @@ -1,93 +1,97 @@ -var notifs = {} +const notifs = {}; -window.addEventListener('message', function (event) { - ShowNotif(event.data); +window.addEventListener('message', function(event) { + ShowNotif(event.data); }); function CreateNotification(data) { - let $notification = $(document.createElement('div')); - $notification.addClass('notification').addClass(data.type); - $notification.html(data.text); - $notification.fadeIn(); - if (data.style !== undefined) { - Object.keys(data.style).forEach(function (css) { - $notification.css(css, data.style[css]) - }); - } + const $notification = $(document.createElement('div')); + $notification.addClass('notification').addClass(data.type); + $notification.html(data.text); + $notification.fadeIn(); + if (data.style !== undefined) { + Object.keys(data.style).forEach(function(css) { + $notification.css(css, data.style[css]); + }); + } - return $notification; + return $notification; } function UpdateNotification(data) { - let $notification = $(notifs[data.id]) - $notification.addClass('notification').addClass(data.type); - $notification.html(data.text); + const $notification = $(notifs[data.id]); + $notification.addClass('notification').addClass(data.type); + $notification.html(data.text); - if (data.style !== undefined) { - Object.keys(data.style).forEach(function (css) { - $notification.css(css, data.style[css]) - }); - } + if (data.style !== undefined) { + Object.keys(data.style).forEach(function(css) { + $notification.css(css, data.style[css]); + }); + } } function ShowNotif(data) { - if (data.persist != null) { - if (data.persist.toUpperCase() == 'START') { - if (notifs[data.id] === undefined) { - let $notification = CreateNotification(data); - $('.notif-container').append($notification); - notifs[data.id] = { - notif: $notification - }; - } else { - UpdateNotification(data); - } - } else if (data.persist.toUpperCase() == 'END') { - if (notifs[data.id] != null) { - let $notification = $(notifs[data.id].notif); - $.when($notification.fadeOut()).done(function () { - $notification.remove(); - delete notifs[data.id]; - }); - } - } - } else { - if (data.id != null) { - if (notifs[data.id] === undefined) { - let $notification = CreateNotification(data); - $('.notif-container').append($notification); - notifs[data.id] = { - notif: $notification, - timer: setTimeout(function () { - let $notification = notifs[data.id].notif; - $.when($notification.fadeOut()).done(function () { - $notification.remove(); - clearTimeout(notifs[data.id].timer); - delete notifs[data.id]; - }); - }, data.length != null ? data.length : 2500) - }; - } else { - clearTimeout(notifs[data.id].timer); - UpdateNotification(data); + if (data.persist != null) { + if (data.persist.toUpperCase() == 'START') { + if (notifs[data.id] === undefined) { + const $notification = CreateNotification(data); + $('.notif-container').append($notification); + notifs[data.id] = { + notif: $notification, + }; + } + else { + UpdateNotification(data); + } + } + else if (data.persist.toUpperCase() == 'END') { + if (notifs[data.id] != null) { + const $notification = $(notifs[data.id].notif); + $.when($notification.fadeOut()).done(function() { + $notification.remove(); + delete notifs[data.id]; + }); + } + } + } + else if (data.id != null) { + if (notifs[data.id] === undefined) { + const $notification = CreateNotification(data); + $('.notif-container').append($notification); + notifs[data.id] = { + notif: $notification, + timer: setTimeout(function() { + // eslint-disable-next-line no-shadow + const $notification = notifs[data.id].notif; + $.when($notification.fadeOut()).done(function() { + $notification.remove(); + clearTimeout(notifs[data.id].timer); + delete notifs[data.id]; + }); + }, data.length != null ? data.length : 2500), + }; + } + else { + clearTimeout(notifs[data.id].timer); + UpdateNotification(data); - notifs[data.id].timer = setTimeout(function () { - let $notification = notifs[data.id].notif; - $.when($notification.fadeOut()).done(function () { - $notification.remove(); - clearTimeout(notifs[data.id].timer); - delete notifs[data.id]; - }); - }, data.length != null ? data.length : 2500) - } - } else { - let $notification = CreateNotification(data); - $('.notif-container').append($notification); - setTimeout(function () { - $.when($notification.fadeOut()).done(function () { - $notification.remove() - }); - }, data.length != null ? data.length : 2500); - } - } + notifs[data.id].timer = setTimeout(function() { + const $notification = notifs[data.id].notif; + $.when($notification.fadeOut()).done(function() { + $notification.remove(); + clearTimeout(notifs[data.id].timer); + delete notifs[data.id]; + }); + }, data.length != null ? data.length : 2500); + } + } + else { + const $notification = CreateNotification(data); + $('.notif-container').append($notification); + setTimeout(function() { + $.when($notification.fadeOut()).done(function() { + $notification.remove(); + }); + }, data.length != null ? data.length : 2500); + } } \ No newline at end of file From ed77b19953937c62fd1d251fe4e1e09af314e93b Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 29 Jul 2024 10:30:40 +0200 Subject: [PATCH 06/23] fix: [bpt_addons]\bpt_addonaccount\server\main.lua corrected typo --- .../resources/[bpt_addons]/bpt_addonaccount/server/main.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server-data/resources/[bpt_addons]/bpt_addonaccount/server/main.lua b/server-data/resources/[bpt_addons]/bpt_addonaccount/server/main.lua index 449ddeb42..a4f3b24ba 100644 --- a/server-data/resources/[bpt_addons]/bpt_addonaccount/server/main.lua +++ b/server-data/resources/[bpt_addons]/bpt_addonaccount/server/main.lua @@ -101,7 +101,7 @@ AddEventHandler("esx:playerLoaded", function(_, xPlayer) addonAccounts[#addonAccounts + 1] = account end - xPlayer.set('addonAccounts', addonAccounts) + xPlayer.set("addonAccounts", addonAccounts) end) RegisterNetEvent("bpt_addonaccount:refreshAccounts") @@ -139,6 +139,6 @@ AddEventHandler("bpt_addonaccount:refreshAccounts", function() end end) -exports("getAccount", GetSharedAccount) +exports("getAccount", GetAccount) exports("getSharedAccount", GetSharedAccount) \ No newline at end of file From 407a23389ef046ec8b59dd86001556ecd89f04a5 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 29 Jul 2024 10:39:03 +0200 Subject: [PATCH 07/23] refactor: Improved code style respecting ESLint rules --- .../[bpt_addons]/bpt_hud/html-map/script.js | 32 +++++++------ .../[bpt_addons]/bpt_hud/html/style.js | 46 +++++++++---------- 2 files changed, 40 insertions(+), 38 deletions(-) diff --git a/server-data/resources/[bpt_addons]/bpt_hud/html-map/script.js b/server-data/resources/[bpt_addons]/bpt_hud/html-map/script.js index 746ef0108..ab2561fea 100644 --- a/server-data/resources/[bpt_addons]/bpt_hud/html-map/script.js +++ b/server-data/resources/[bpt_addons]/bpt_hud/html-map/script.js @@ -1,18 +1,20 @@ -$(document).ready(function () { - window.addEventListener("message", function (event) { - let data = event.data; +$(document).ready(function() { + window.addEventListener('message', function(event) { + const data = event.data; - if (data.mapoutline == true) { - $(".outline").show(); - } else if (data.mapoutline == false) { - $(".outline").hide(); - } + if (data.mapoutline == true) { + $('.outline').show(); + } + else if (data.mapoutline == false) { + $('.outline').hide(); + } - if (data.mapfoil == true) { - $(".mapfoil").hide(); - } else if (data.mapfoil == false) { - $(".mapfoil").show(); - } + if (data.mapfoil == true) { + $('.mapfoil').hide(); + } + else if (data.mapfoil == false) { + $('.mapfoil').show(); + } - }) -}) + }); +}); diff --git a/server-data/resources/[bpt_addons]/bpt_hud/html/style.js b/server-data/resources/[bpt_addons]/bpt_hud/html/style.js index efaee6d8d..a49f8cc26 100644 --- a/server-data/resources/[bpt_addons]/bpt_hud/html/style.js +++ b/server-data/resources/[bpt_addons]/bpt_hud/html/style.js @@ -1,40 +1,40 @@ -$(document).ready(function () { - window.addEventListener('message', function (event) { - var data = event.data; +$(document).ready(function() { + window.addEventListener('message', function(event) { + const data = event.data; if (data.show == false) { - if (data.posi == "bottom") { - $("body").show(); + if (data.posi == 'bottom') { + $('body').show(); soMany = 50 - data.health; - document.querySelectorAll('.wave')[0].style.setProperty("--top", `${soMany}%`); + document.querySelectorAll('.wave')[0].style.setProperty('--top', `${soMany}%`); - armorJS = 50 - data.armor - document.querySelectorAll('.wave2')[0].style.setProperty("--top", `${armorJS}%`); + armorJS = 50 - data.armor; + document.querySelectorAll('.wave2')[0].style.setProperty('--top', `${armorJS}%`); - foodJS = 50 - data.food - document.querySelectorAll('.wave3')[0].style.setProperty("--top", `${foodJS}%`); + foodJS = 50 - data.food; + document.querySelectorAll('.wave3')[0].style.setProperty('--top', `${foodJS}%`); - waterJS = 50 - data.thirst - document.querySelectorAll('.wave4')[0].style.setProperty("--top", `${waterJS}%`); + waterJS = 50 - data.thirst; + document.querySelectorAll('.wave4')[0].style.setProperty('--top', `${waterJS}%`); } else { - $(".main").css("top", "15vh"); - $(".main").css("right", "5vw"); - $("body").show(); + $('.main').css('top', '15vh'); + $('.main').css('right', '5vw'); + $('body').show(); soMany = 50 - data.health; - document.querySelectorAll('.wave')[0].style.setProperty("--top", `${soMany}%`); + document.querySelectorAll('.wave')[0].style.setProperty('--top', `${soMany}%`); - armorJS = 50 - data.armor - document.querySelectorAll('.wave2')[0].style.setProperty("--top", `${armorJS}%`); + armorJS = 50 - data.armor; + document.querySelectorAll('.wave2')[0].style.setProperty('--top', `${armorJS}%`); - foodJS = 50 - data.food - document.querySelectorAll('.wave3')[0].style.setProperty("--top", `${foodJS}%`); + foodJS = 50 - data.food; + document.querySelectorAll('.wave3')[0].style.setProperty('--top', `${foodJS}%`); - waterJS = 50 - data.thirst - document.querySelectorAll('.wave4')[0].style.setProperty("--top", `${waterJS}%`); + waterJS = 50 - data.thirst; + document.querySelectorAll('.wave4')[0].style.setProperty('--top', `${waterJS}%`); } } else { - $("body").hide(); + $('body').hide(); } }); }); \ No newline at end of file From 343b76e41f9e5fc8d3c71dad756b352b5a33dbc5 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 29 Jul 2024 11:20:31 +0200 Subject: [PATCH 08/23] refactor: Improved code style respecting ESLint rules --- .../bpt_idcard/html/assets/js/init.js | 139 +++-- .../bpt_idcard/html/assets/js/materialize.js | 572 ++++++++++-------- 2 files changed, 378 insertions(+), 333 deletions(-) diff --git a/server-data/resources/[bpt_addons]/bpt_idcard/html/assets/js/init.js b/server-data/resources/[bpt_addons]/bpt_idcard/html/assets/js/init.js index e4b9baecd..a449d3d21 100644 --- a/server-data/resources/[bpt_addons]/bpt_idcard/html/assets/js/init.js +++ b/server-data/resources/[bpt_addons]/bpt_idcard/html/assets/js/init.js @@ -1,75 +1,84 @@ -$(document).ready(function () { - // LUA listener - window.addEventListener('message', function (event) { - if (event.data.action == 'open') { - var type = event.data.type; - var userData = event.data.array['user'][0]; - var licenseData = event.data.array['licenses']; - var sex = userData.sex; +$(document).ready(function() { + // LUA listener + window.addEventListener('message', function(event) { + if (event.data.action == 'open') { + const type = event.data.type; + const userData = event.data.array['user'][0]; + const licenseData = event.data.array['licenses']; + const sex = userData.sex; - if (type == 'driver' || type == null) { - $('img').show(); - $('#name').css('color', '#282828'); + if (type == 'driver' || type == null) { + $('img').show(); + $('#name').css('color', '#282828'); - if (sex.toLowerCase() == 'm') { - $('img').attr('src', 'assets/images/male.png'); - $('#sex').text('male'); - } else { - $('img').attr('src', 'assets/images/female.png'); - $('#sex').text('female'); - } + if (sex.toLowerCase() == 'm') { + $('img').attr('src', 'assets/images/male.png'); + $('#sex').text('male'); + } + else { + $('img').attr('src', 'assets/images/female.png'); + $('#sex').text('female'); + } - $('#name').text(userData.firstname + ' ' + userData.lastname); - $('#dob').text(userData.dateofbirth); - $('#height').text(userData.height); - $('#signature').text(userData.firstname + ' ' + userData.lastname); + $('#name').text(userData.firstname + ' ' + userData.lastname); + $('#dob').text(userData.dateofbirth); + $('#height').text(userData.height); + $('#signature').text(userData.firstname + ' ' + userData.lastname); - if (type == 'driver') { - if (licenseData != null) { - Object.keys(licenseData).forEach(function (key) { - var type = licenseData[key].type; + if (type == 'driver') { + if (licenseData != null) { + Object.keys(licenseData).forEach(function(key) { + // eslint-disable-next-line no-shadow + let type = licenseData[key].type; - if (type == 'drive_bike') { - type = 'bike'; - } else if (type == 'drive_truck') { - type = 'truck'; - } else if (type == 'drive') { - type = 'car'; - } + if (type == 'drive_bike') { + type = 'bike'; + } + else if (type == 'drive_truck') { + type = 'truck'; + } + else if (type == 'drive') { + type = 'car'; + } - if (type == 'bike') { - $('#licenses').append('

' + 'Bike' + '

'); - } else if (type == 'truck') { - $('#licenses').append('

' + 'Truck' + '

'); - } else if (type == 'car') { - $('#licenses').append('

' + 'Car' + '

'); - } - }); - } + if (type == 'bike') { + $('#licenses').append('

' + 'Bike' + '

'); + } + else if (type == 'truck') { + $('#licenses').append('

' + 'Truck' + '

'); + } + else if (type == 'car') { + $('#licenses').append('

' + 'Car' + '

'); + } + }); + } - $('#id-card').css('background', 'url(assets/images/license.png)'); - } else { - $('#id-card').css('background', 'url(assets/images/idcard.png)'); - } - } else if (type == 'weapon') { - $('img').hide(); - $('#name').css('color', '#d9d9d9'); - $('#name').text(userData.firstname + ' ' + userData.lastname); - $('#dob').text(userData.dateofbirth); - $('#signature').text(userData.firstname + ' ' + userData.lastname); + $('#id-card').css('background', 'url(assets/images/license.png)'); + } + else { + $('#id-card').css('background', 'url(assets/images/idcard.png)'); + } + } + else if (type == 'weapon') { + $('img').hide(); + $('#name').css('color', '#d9d9d9'); + $('#name').text(userData.firstname + ' ' + userData.lastname); + $('#dob').text(userData.dateofbirth); + $('#signature').text(userData.firstname + ' ' + userData.lastname); - $('#id-card').css('background', 'url(assets/images/firearm.png)'); - } + $('#id-card').css('background', 'url(assets/images/firearm.png)'); + } - $('#id-card').show(); - } else if (event.data.action == 'close') { - $('#name').text(''); - $('#dob').text(''); - $('#height').text(''); - $('#signature').text(''); - $('#sex').text(''); - $('#id-card').hide(); - $('#licenses').html(''); - } - }); + $('#id-card').show(); + } + else if (event.data.action == 'close') { + $('#name').text(''); + $('#dob').text(''); + $('#height').text(''); + $('#signature').text(''); + $('#sex').text(''); + $('#id-card').hide(); + $('#licenses').html(''); + } + }); }); \ No newline at end of file diff --git a/server-data/resources/[bpt_addons]/bpt_idcard/html/assets/js/materialize.js b/server-data/resources/[bpt_addons]/bpt_idcard/html/assets/js/materialize.js index 3037f362b..79f6d7c12 100644 --- a/server-data/resources/[bpt_addons]/bpt_idcard/html/assets/js/materialize.js +++ b/server-data/resources/[bpt_addons]/bpt_idcard/html/assets/js/materialize.js @@ -1,276 +1,312 @@ -/*! +/* ! * Materialize v1.0.0-beta (http://materializecss.com) * Copyright 2014-2017 Materialize * MIT License (https://raw.githubusercontent.com/Dogfalo/materialize/master/LICENSE) */ -var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -/*! cash-dom 1.3.5, https://github.com/kenwheeler/cash @license MIT */ -(function (factory) { - window.cash = factory(); -})(function () { - var doc = document, - win = window, - ArrayProto = Array.prototype, - slice = ArrayProto.slice, - filter = ArrayProto.filter, - push = ArrayProto.push; - - var noop = function () { }, - isFunction = function (item) { - // @see https://crbug.com/568448 - return typeof item === typeof noop && item.call; - }, - isString = function (item) { - return typeof item === typeof ""; - }; - - var idMatch = /^#[\w-]*$/, - classMatch = /^\.[\w-]*$/, - htmlMatch = /<.+>/, - singlet = /^\w+$/; - - function find(selector, context) { - context = context || doc; - var elems = classMatch.test(selector) ? context.getElementsByClassName(selector.slice(1)) : singlet.test(selector) ? context.getElementsByTagName(selector) : context.querySelectorAll(selector); - return elems; - } - - var frag; - function parseHTML(str) { - if (!frag) { - frag = doc.implementation.createHTMLDocument(null); - var base = frag.createElement("base"); - base.href = doc.location.href; - frag.head.appendChild(base); - } - - frag.body.innerHTML = str; - - return frag.body.childNodes; - } - - function onReady(fn) { - if (doc.readyState !== "loading") { - fn(); - } else { - doc.addEventListener("DOMContentLoaded", fn); - } - } - - function Init(selector, context) { - if (!selector) { - return this; - } - - // If already a cash collection, don't do any further processing - if (selector.cash && selector !== win) { - return selector; - } - - var elems = selector, - i = 0, - length; - - if (isString(selector)) { - elems = idMatch.test(selector) ? - // If an ID use the faster getElementById check - doc.getElementById(selector.slice(1)) : htmlMatch.test(selector) ? - // If HTML, parse it into real elements - parseHTML(selector) : - // else use `find` - find(selector, context); - - // If function, use as shortcut for DOM ready - } else if (isFunction(selector)) { - onReady(selector); return this; - } - - if (!elems) { - return this; - } - - // If a single DOM element is passed in or received via ID, return the single element - if (elems.nodeType || elems === win) { - this[0] = elems; - this.length = 1; - } else { - // Treat like an array and loop through each item. - length = this.length = elems.length; - for (; i < length; i++) { - this[i] = elems[i]; - } - } - - return this; - } - - function cash(selector, context) { - return new Init(selector, context); - } - - var fn = cash.fn = cash.prototype = Init.prototype = { // jshint ignore:line - cash: true, - length: 0, - push: push, - splice: ArrayProto.splice, - map: ArrayProto.map, - init: Init - }; - - Object.defineProperty(fn, "constructor", { value: cash }); - - cash.parseHTML = parseHTML; - cash.noop = noop; - cash.isFunction = isFunction; - cash.isString = isString; - - cash.extend = fn.extend = function (target) { - target = target || {}; - - var args = slice.call(arguments), - length = args.length, - i = 1; - - if (args.length === 1) { - target = this; - i = 0; - } - - for (; i < length; i++) { - if (!args[i]) { - continue; - } - for (var key in args[i]) { - if (args[i].hasOwnProperty(key)) { - target[key] = args[i][key]; - } - } - } - - return target; - }; - - function each(collection, callback) { - var l = collection.length, - i = 0; - - for (; i < l; i++) { - if (callback.call(collection[i], collection[i], i, collection) === false) { - break; - } - } - } - - function matches(el, selector) { - var m = el && (el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector || el.oMatchesSelector); - return !!m && m.call(el, selector); - } - - function getCompareFunction(selector) { - return ( - /* Use browser's `matches` function if string */ - isString(selector) ? matches : - /* Match a cash element */ - selector.cash ? function (el) { - return selector.is(el); - } : - /* Direct comparison */ - function (el, selector) { - return el === selector; - } - ); - } - - function unique(collection) { - return cash(slice.call(collection).filter(function (item, index, self) { - return self.indexOf(item) === index; - })); - } - - cash.extend({ - merge: function (first, second) { - var len = +second.length, - i = first.length, - j = 0; - - for (; j < len; i++, j++) { - first[i] = second[j]; - } - - first.length = i; - return first; - }, - - each: each, - matches: matches, - unique: unique, - isArray: Array.isArray, - isNumeric: function (n) { - return !isNaN(parseFloat(n)) && isFinite(n); - } - - }); - - var uid = cash.uid = "_cash" + Date.now(); - - function getDataCache(node) { - return node[uid] = node[uid] || {}; - } - - function setData(node, key, value) { - return getDataCache(node)[key] = value; - } - - function getData(node, key) { - var c = getDataCache(node); - if (c[key] === undefined) { - c[key] = node.dataset ? node.dataset[key] : cash(node).attr("data-" + key); - } - return c[key]; - } - - function removeData(node, key) { - var c = getDataCache(node); - if (c) { - delete c[key]; - } else if (node.dataset) { - delete node.dataset[key]; - } else { - cash(node).removeAttr("data-" + name); - } - } - - fn.extend({ - data: function (name, value) { - if (isString(name)) { - return value === undefined ? getData(this[0], name) : this.each(function (v) { - return setData(v, name, value); - }); - } - - for (var key in name) { - this.data(key, name[key]); - } - - return this; - }, - - removeData: function (key) { - return this.each(function (v) { - return removeData(v, key); - }); - } +// eslint-disable-next-line max-statements-per-line +const _get = function get(object, property, receiver) { + // eslint-disable-next-line max-statements-per-line + if (object === null) object = Function.prototype; const desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { + // eslint-disable-next-line max-statements-per-line + const parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } + else { return get(parent, property, receiver); } + } + else if ('value' in desc) { return desc.value; } + // eslint-disable-next-line max-statements-per-line + else { const getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } +}; - }); +// eslint-disable-next-line max-statements-per-line +const _createClass = function() { function defineProperties(target, props) { for (let i = 0; i < props.length; i++) { const descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function(Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +// eslint-disable-next-line max-statements-per-line +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called'); } return call && (typeof call === 'object' || typeof call === 'function') ? call : self; } + +// eslint-disable-next-line max-statements-per-line +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +// eslint-disable-next-line max-statements-per-line +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +/* ! cash-dom 1.3.5, https://github.com/kenwheeler/cash @license MIT */ +(function(factory) { + window.cash = factory(); +})(function() { + // eslint-disable-next-line prefer-const + const doc = document, + // eslint-disable-next-line prefer-const + win = window, + // eslint-disable-next-line prefer-const + ArrayProto = Array.prototype, + // eslint-disable-next-line prefer-const + slice = ArrayProto.slice, + // eslint-disable-next-line prefer-const + filter = ArrayProto.filter, + push = ArrayProto.push; + + // eslint-disable-next-line prefer-const, no-empty-function + const noop = function() { }, + // eslint-disable-next-line prefer-const + isFunction = function(item) { + // @see https://crbug.com/568448 + return typeof item === typeof noop && item.call; + }, + isString = function(item) { + return typeof item === typeof ''; + }; + + // eslint-disable-next-line prefer-const + const idMatch = /^#[\w-]*$/, + // eslint-disable-next-line prefer-const + classMatch = /^\.[\w-]*$/, + // eslint-disable-next-line prefer-const + htmlMatch = /<.+>/, + singlet = /^\w+$/; + + function find(selector, context) { + context = context || doc; + const elems = classMatch.test(selector) ? context.getElementsByClassName(selector.slice(1)) : singlet.test(selector) ? context.getElementsByTagName(selector) : context.querySelectorAll(selector); + return elems; + } + + let frag; + function parseHTML(str) { + if (!frag) { + frag = doc.implementation.createHTMLDocument(null); + const base = frag.createElement('base'); + base.href = doc.location.href; + frag.head.appendChild(base); + } + + frag.body.innerHTML = str; + + return frag.body.childNodes; + } + + function onReady(fn) { + if (doc.readyState !== 'loading') { + fn(); + } + else { + doc.addEventListener('DOMContentLoaded', fn); + } + } + + function Init(selector, context) { + if (!selector) { + return this; + } + + // If already a cash collection, don't do any further processing + if (selector.cash && selector !== win) { + return selector; + } + + let elems = selector, + i = 0, + length; + + if (isString(selector)) { + elems = idMatch.test(selector) ? + // If an ID use the faster getElementById check + doc.getElementById(selector.slice(1)) : htmlMatch.test(selector) ? + // If HTML, parse it into real elements + parseHTML(selector) : + // else use `find` + find(selector, context); + + // If function, use as shortcut for DOM ready + } + else if (isFunction(selector)) { + onReady(selector); return this; + } + + if (!elems) { + return this; + } + + // If a single DOM element is passed in or received via ID, return the single element + if (elems.nodeType || elems === win) { + this[0] = elems; + this.length = 1; + } + else { + // Treat like an array and loop through each item. + length = this.length = elems.length; + for (; i < length; i++) { + this[i] = elems[i]; + } + } + + return this; + } + + function cash(selector, context) { + return new Init(selector, context); + } + + // eslint-disable-next-line no-inline-comments + const fn = cash.fn = cash.prototype = Init.prototype = { // jshint ignore:line + cash: true, + length: 0, + push: push, + splice: ArrayProto.splice, + map: ArrayProto.map, + init: Init, + }; + + Object.defineProperty(fn, 'constructor', { value: cash }); + + cash.parseHTML = parseHTML; + cash.noop = noop; + cash.isFunction = isFunction; + cash.isString = isString; + + cash.extend = fn.extend = function(target) { + target = target || {}; + + // eslint-disable-next-line prefer-const + let args = slice.call(arguments), + // eslint-disable-next-line prefer-const + length = args.length, + i = 1; + + if (args.length === 1) { + target = this; + i = 0; + } + + for (; i < length; i++) { + if (!args[i]) { + continue; + } + for (const key in args[i]) { + if (Object.prototype.hasOwnProperty.call(args[i], key)) { + target[key] = args[i][key]; + } + } + } + + return target; + }; + + function each(collection, callback) { + // eslint-disable-next-line prefer-const + let l = collection.length, + i = 0; + + for (; i < l; i++) { + if (callback.call(collection[i], collection[i], i, collection) === false) { + break; + } + } + } + + function matches(el, selector) { + const m = el && (el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector || el.oMatchesSelector); + return !!m && m.call(el, selector); + } + + function getCompareFunction(selector) { + return ( + /* Use browser's `matches` function if string */ + isString(selector) ? matches : + /* Match a cash element */ + selector.cash ? function(el) { + return selector.is(el); + } : + /* Direct comparison */ + // eslint-disable-next-line no-shadow + function(el, selector) { + return el === selector; + } + ); + } + + function unique(collection) { + return cash(slice.call(collection).filter(function(item, index, self) { + return self.indexOf(item) === index; + })); + } + + cash.extend({ + merge: function(first, second) { + // eslint-disable-next-line prefer-const + let len = +second.length, + i = first.length, + j = 0; + + for (; j < len; i++, j++) { + first[i] = second[j]; + } + + first.length = i; + return first; + }, + + each: each, + matches: matches, + unique: unique, + isArray: Array.isArray, + isNumeric: function(n) { + return !isNaN(parseFloat(n)) && isFinite(n); + }, + + }); + + const uid = cash.uid = '_cash' + Date.now(); + + function getDataCache(node) { + return node[uid] = node[uid] || {}; + } + + function setData(node, key, value) { + return getDataCache(node)[key] = value; + } + + function getData(node, key) { + const c = getDataCache(node); + if (c[key] === undefined) { + c[key] = node.dataset ? node.dataset[key] : cash(node).attr('data-' + key); + } + return c[key]; + } + + function removeData(node, key) { + const c = getDataCache(node); + if (c) { + delete c[key]; + } + else if (node.dataset) { + delete node.dataset[key]; + } + else { + cash(node).removeAttr('data-' + name); + } + } + + fn.extend({ + data: function(name, value) { + if (isString(name)) { + return value === undefined ? getData(this[0], name) : this.each(function(v) { + return setData(v, name, value); + }); + } + + for (const key in name) { + this.data(key, name[key]); + } + + return this; + }, + + removeData: function(key) { + return this.each(function(v) { + return removeData(v, key); + }); + }, + + }); var notWhiteMatch = /\S+/g; From 6e3ee589ec277aef2ebf817e58aa2df7faea8267 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 29 Jul 2024 11:21:12 +0200 Subject: [PATCH 09/23] feat: eslint.config.js rules --- eslint.config.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 eslint.config.js diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 000000000..d42dfae53 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,50 @@ +const js = require('@eslint/js'); + +module.exports = [ + js.configs.recommended, + { + languageOptions: { + ecmaVersion: 'latest', + }, + rules: { + 'arrow-spacing': ['warn', { 'before': true, 'after': true }], + 'brace-style': ['error', 'stroustrup', { 'allowSingleLine': true }], + 'comma-dangle': ['error', 'always-multiline'], + 'comma-spacing': 'error', + 'comma-style': 'error', + 'curly': ['error', 'multi-line', 'consistent'], + 'dot-location': ['error', 'property'], + 'handle-callback-err': 'off', + 'indent': ['error', 'tab'], + 'keyword-spacing': 'error', + 'max-nested-callbacks': ['error', { 'max': 4 }], + 'max-statements-per-line': ['error', { 'max': 2 }], + 'no-console': 'off', + 'no-empty-function': 'error', + 'no-floating-decimal': 'error', + 'no-inline-comments': 'error', + 'no-lonely-if': 'error', + 'no-multi-spaces': 'error', + 'no-multiple-empty-lines': ['error', { 'max': 2, 'maxEOF': 1, 'maxBOF': 0 }], + 'no-shadow': ['error', { 'allow': ['err', 'resolve', 'reject'] }], + 'no-trailing-spaces': ['error'], + 'no-var': 'error', + 'no-undef': 'off', + 'object-curly-spacing': ['error', 'always'], + 'prefer-const': 'error', + 'quotes': ['error', 'single'], + 'semi': ['error', 'always'], + 'space-before-blocks': 'error', + 'space-before-function-paren': ['error', { + 'anonymous': 'never', + 'named': 'never', + 'asyncArrow': 'always', + }], + 'space-in-parens': 'error', + 'space-infix-ops': 'error', + 'space-unary-ops': 'error', + 'spaced-comment': 'error', + 'yoda': 'error', + }, + }, +]; \ No newline at end of file From 8c32ffe9bcf2de2281245487320881e65df328d1 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 29 Jul 2024 11:27:19 +0200 Subject: [PATCH 10/23] refactor: Improved code style respecting ESLint rules --- .../[esx]/esx_identity/html/js/script.js | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/server-data/resources/[esx]/esx_identity/html/js/script.js b/server-data/resources/[esx]/esx_identity/html/js/script.js index 75cd203f7..46153278e 100644 --- a/server-data/resources/[esx]/esx_identity/html/js/script.js +++ b/server-data/resources/[esx]/esx_identity/html/js/script.js @@ -1,39 +1,39 @@ -window.addEventListener("message", (event) => { - if (event.data.type === "enableui") { - document.body.classList[event.data.enable ? "remove" : "add"]("none"); - } +window.addEventListener('message', (event) => { + if (event.data.type === 'enableui') { + document.body.classList[event.data.enable ? 'remove' : 'add']('none'); + } }); -document.querySelector("#register").addEventListener("submit", (event) => { - event.preventDefault(); +document.querySelector('#register').addEventListener('submit', (event) => { + 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({}), - }); +document.addEventListener('DOMContentLoaded', () => { + fetch('http://esx_identity/ready', { + method: 'POST', + body: JSON.stringify({}), + }); }); From 025de8722fb54d67f0e821f1a740e741a2e2b460 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 29 Jul 2024 18:20:17 +0200 Subject: [PATCH 11/23] feat: bpt_carshowroom --- .../bpt_carshowroom/client/main.lua | 376 ++++++++++++++++++ .../[bpt_addons]/bpt_carshowroom/config.lua | 36 ++ .../bpt_carshowroom/fxmanifest.lua | 15 + .../bpt_carshowroom/locales/it.lua | 10 + 4 files changed, 437 insertions(+) create mode 100644 server-data/resources/[bpt_addons]/bpt_carshowroom/client/main.lua create mode 100644 server-data/resources/[bpt_addons]/bpt_carshowroom/config.lua create mode 100644 server-data/resources/[bpt_addons]/bpt_carshowroom/fxmanifest.lua create mode 100644 server-data/resources/[bpt_addons]/bpt_carshowroom/locales/it.lua diff --git a/server-data/resources/[bpt_addons]/bpt_carshowroom/client/main.lua b/server-data/resources/[bpt_addons]/bpt_carshowroom/client/main.lua new file mode 100644 index 000000000..b7236f8f1 --- /dev/null +++ b/server-data/resources/[bpt_addons]/bpt_carshowroom/client/main.lua @@ -0,0 +1,376 @@ +local Keys = { + ["ESC"] = 322, + ["F1"] = 288, + ["F2"] = 289, + ["F3"] = 170, + ["F5"] = 166, + ["F6"] = 167, + ["F7"] = 168, + ["F8"] = 169, + ["F9"] = 56, + ["F10"] = 57, + ["~"] = 243, + ["1"] = 157, + ["2"] = 158, + ["3"] = 160, + ["4"] = 164, + ["5"] = 165, + ["6"] = 159, + ["7"] = 161, + ["8"] = 162, + ["9"] = 163, + ["-"] = 84, + ["="] = 83, + ["BACKSPACE"] = 177, + ["TAB"] = 37, + ["Q"] = 44, + ["W"] = 32, + ["E"] = 38, + ["R"] = 45, + ["T"] = 245, + ["Y"] = 246, + ["U"] = 303, + ["P"] = 199, + ["["] = 39, + ["]"] = 40, + ["ENTER"] = 18, + ["CAPS"] = 137, + ["A"] = 34, + ["S"] = 8, + ["D"] = 9, + ["F"] = 23, + ["G"] = 47, + ["H"] = 74, + ["K"] = 311, + ["L"] = 182, + ["LEFTSHIFT"] = 21, + ["Z"] = 20, + ["X"] = 73, + ["C"] = 26, + ["V"] = 0, + ["B"] = 29, + ["N"] = 249, + ["M"] = 244, + [","] = 82, + ["."] = 81, + ["LEFTCTRL"] = 36, + ["LEFTALT"] = 19, + ["SPACE"] = 22, + ["RIGHTCTRL"] = 70, + ["HOME"] = 213, + ["PAGEUP"] = 10, + ["PAGEDOWN"] = 11, + ["DELETE"] = 178, + ["LEFT"] = 174, + ["RIGHT"] = 175, + ["TOP"] = 27, + ["DOWN"] = 173, +} + +--- action functions +local CurrentAction = nil +local CurrentActionMsg = "" +local CurrentActionData = {} +local HasAlreadyEnteredMarker = false +local LastZone = nil + +--- bpt_vehicleshop funtions +local IsInShopMenu = false +local Categories = {} +local Vehicles = {} +local LastVehicles = {} +local CurrentVehicleData = nil + +--- esx +local PlayerData = {} +local GUI = {} +GUI.Time = 0 + +Citizen.CreateThread(function() + ESX = exports["es_extended"]:getSharedObject() + + ESX.TriggerServerCallback("esx_vehicleshop:getCategories", function(categories) + Categories = categories + end) + + ESX.TriggerServerCallback("esx_vehicleshop:getVehicles", function(vehicles) + Vehicles = vehicles + end) +end) + +function DeleteKatalogVehicles() + while #LastVehicles > 0 do + local vehicle = LastVehicles[1] + ESX.Game.DeleteVehicle(vehicle) + table.remove(LastVehicles, 1) + end +end + +----markers +AddEventHandler("bpt_bilpriser:hasEnteredMarker", function(zone) + if zone == "Katalog" then + CurrentAction = "cars_menu" + CurrentActionMsg = TranslateCap("press_e") + CurrentActionData = {} + end + + if zone == "GoDownFrom" then + CurrentAction = "go_down_from" + CurrentActionMsg = TranslateCap("press_e_to_enter") + CurrentActionData = {} + end + + if zone == "GoUpFrom" then + CurrentAction = "goTranslateCapp_from" + CurrentActionMsg = TranslateCap("press_e_to_exit") + CurrentActionData = {} + end +end) + +AddEventHandler("bpt_bilpriser:hasExitedMarker", function(zone) + if not IsInShopMenu then + ESX.UI.Menu.CloseAll() + end + + CurrentAction = nil +end) + +function OpenShopMenu() + IsInShopMenu = true + + ESX.UI.Menu.CloseAll() + + local playerPed = GetPlayerPed(-1) + + FreezeEntityPosition(playerPed, true) + SetEntityVisible(playerPed, false) + SetEntityCoords(playerPed, Config.Zones.ShopInside.Pos.x, Config.Zones.ShopInside.Pos.y, Config.Zones.ShopInside.Pos.z) + + local vehiclesByCategory = {} + local elements = {} + local firstVehicleData = nil + + for i = 1, #Categories, 1 do + vehiclesByCategory[Categories[i].name] = {} + end + + for i = 1, #Vehicles, 1 do + table.insert(vehiclesByCategory[Vehicles[i].category], Vehicles[i]) + end + + for i = 1, #Categories, 1 do + local category = Categories[i] + local categoryVehicles = vehiclesByCategory[category.name] + local options = {} + + for j = 1, #categoryVehicles, 1 do + local vehicle = categoryVehicles[j] + + if i == 1 and j == 1 then + firstVehicleData = vehicle + end + + table.insert(options, vehicle.name .. " ") + end + + table.insert(elements, { + name = category.name, + label = category.label, + value = 0, + type = "slider", + max = #Categories[i], + options = options, + }) + end + + ESX.UI.Menu.Open("default", GetCurrentResourceName(), "vehicle_shop", { + title = "Bilbroschyr", + align = "top-left", + elements = elements, + }, function(data, menu) + local vehicleData = vehiclesByCategory[data.current.name][data.current.value + 1] + + ESX.UI.Menu.Open("default", GetCurrentResourceName(), "shop_confirm", { + title = vehicleData.name, + align = "top-left", + elements = { + { label = "" .. vehicleData.name .. TranslateCap("costs") .. vehicleData.price * Config.Price .. TranslateCap("currency"), value = "yes" }, + { label = TranslateCap("back"), value = "no" }, + }, + }, function(data2, menu2) + if data2.current.value == "yes" then + sendNotification(TranslateCap("contact_dealer") .. vehicleData.price * Config.Price .. TranslateCap("currency"), "warning", 5000) + end + + if data2.current.value == "no" then + menu2.close() + end + end, function(data2, menu2) + menu2.close() + end) + end, function(data, menu) + menu.close() + + DoScreenFadeOut(1000) + Citizen.Wait(1000) + DoScreenFadeIn(1000) + + DeleteKatalogVehicles() + + local playerPed = GetPlayerPed(-1) + + CurrentAction = "shop_menu" + CurrentActionMsg = "shop menu" + CurrentActionData = {} + + FreezeEntityPosition(playerPed, false) + + SetEntityCoords(playerPed, Config.Zones.Katalog.Pos.x, Config.Zones.Katalog.Pos.y, Config.Zones.Katalog.Pos.z) + SetEntityVisible(playerPed, true) + + IsInShopMenu = false + end, function(data, menu) + local vehicleData = vehiclesByCategory[data.current.name][data.current.value + 1] + local playerPed = GetPlayerPed(-1) + + DeleteKatalogVehicles() + + ESX.Game.SpawnLocalVehicle( + vehicleData.model, + { + x = Config.Zones.ShopInside.Pos.x, + y = Config.Zones.ShopInside.Pos.y, + z = Config.Zones.ShopInside.Pos.z, + }, + Config.Zones.ShopInside.Heading, + function(vehicle) + table.insert(LastVehicles, vehicle) + TaskWarpPedIntoVehicle(playerPed, vehicle, -1) + FreezeEntityPosition(vehicle, true) + end + ) + end) + + DeleteKatalogVehicles() + + ESX.Game.SpawnLocalVehicle( + firstVehicleData.model, + { + x = Config.Zones.ShopInside.Pos.x, + y = Config.Zones.ShopInside.Pos.y, + z = Config.Zones.ShopInside.Pos.z, + }, + Config.Zones.ShopInside.Heading, + function(vehicle) + table.insert(LastVehicles, vehicle) + TaskWarpPedIntoVehicle(playerPed, vehicle, -1) + FreezeEntityPosition(vehicle, true) + end + ) +end + +--keycontrols +Citizen.CreateThread(function() + while true do + Citizen.Wait(0) + + if CurrentAction ~= nil then + SetTextComponentFormat("STRING") + AddTextComponentString(CurrentActionMsg) + DisplayHelpTextFromStringLabel(0, 0, 1, -1) + + if IsControlPressed(0, Keys["E"]) and (GetGameTimer() - GUI.Time) > 300 then + if CurrentAction == "cars_menu" then + OpenShopMenu() + end + + if CurrentAction == "go_down_from" then + local playerPed = GetPlayerPed(-1) + DoScreenFadeOut(3000) + Wait(3000) + DoScreenFadeIn(3000) + SetEntityCoords(playerPed, Config.Zones.GoUpFrom.Pos.x, Config.Zones.GoUpFrom.Pos.y, Config.Zones.GoUpFrom.Pos.z) + end + + if CurrentAction == "goTranslateCapp_from" then + local playerPed = GetPlayerPed(-1) + DoScreenFadeOut(3000) + Wait(3000) + DoScreenFadeIn(3000) + SetEntityCoords(playerPed, Config.Zones.GoDownFrom.Pos.x, Config.Zones.GoDownFrom.Pos.y, Config.Zones.GoDownFrom.Pos.z) + end + + CurrentAction = nil + GUI.Time = GetGameTimer() + end + end + end +end) + +-- Display markers +Citizen.CreateThread(function() + while true do + Wait(0) + + local coords = GetEntityCoords(GetPlayerPed(-1)) + + for k, v in pairs(Config.Zones) do + if v.Type ~= -1 and GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.DrawDistance then + DrawMarker(v.Type, v.Pos.x, v.Pos.y, v.Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, v.Size.x, v.Size.y, v.Size.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false) + end + end + end +end) + +-- Enter / Exit marker events +Citizen.CreateThread(function() + while true do + Wait(0) + + local coords = GetEntityCoords(GetPlayerPed(-1)) + local isInMarker = false + local currentZone = nil + + for k, v in pairs(Config.Zones) do + if GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < v.Size.x then + isInMarker = true + currentZone = k + end + end + + if (isInMarker and not HasAlreadyEnteredMarker) or (isInMarker and LastZone ~= currentZone) then + HasAlreadyEnteredMarker = true + LastZone = currentZone + TriggerEvent("bpt_bilpriser:hasEnteredMarker", currentZone) + end + + if not isInMarker and HasAlreadyEnteredMarker then + HasAlreadyEnteredMarker = false + TriggerEvent("bpt_bilpriser:hasExitedMarker", LastZone) + end + end +end) + +---- FUNCTIONS ---- +function Notify(text) + SetNotificationTextEntry("STRING") + AddTextComponentString(text) + DrawNotification(false, false) +end + +function DisplayHelpText(str) + SetTextComponentFormat("STRING") + AddTextComponentString(str) + DisplayHelpTextFromStringLabel(0, 0, 1, -1) +end + +--notification +function sendNotification(message, messageType, messageTimeout) + TriggerEvent("pNotify:SendNotification", { + text = message, + type = messageType, + queue = "katalog", + timeout = messageTimeout, + layout = "bottomCenter", + }) +end diff --git a/server-data/resources/[bpt_addons]/bpt_carshowroom/config.lua b/server-data/resources/[bpt_addons]/bpt_carshowroom/config.lua new file mode 100644 index 000000000..a875bd53c --- /dev/null +++ b/server-data/resources/[bpt_addons]/bpt_carshowroom/config.lua @@ -0,0 +1,36 @@ +Config = {} +Config.DrawDistance = 100.0 +Config.MarkerColor = { r = 255, g = 255, b = 255 } +Config.Locale = "it" +--this is how much the price shows from the purchase price +-- exapmle the cardealer boughts it for 2000 if 2 then it says 4000 +Config.Price = 2 -- this is times how much it should show + +Config.Zones = { + + ShopInside = { + Pos = { x = 228.26, y = -986.57, z = -99.96 }, + Size = { x = 1.5, y = 1.5, z = 1.0 }, + Heading = 177.28, + Type = -1, + }, + + Katalog = { + Pos = { x = 228.18, y = -995.48, z = -99.96 }, + Size = { x = 1.5, y = 1.5, z = 1.0 }, + Heading = 177.28, + Type = 27, + }, + + GoDownFrom = { + Pos = { x = -50.03, y = -1089.18, z = 25.48 }, + Size = { x = 1.5, y = 1.5, z = 1.0 }, + Type = 27, + }, + + GoUpFrom = { + Pos = { x = 240.98, y = -1004.85, z = -99.98 }, + Size = { x = 1.5, y = 1.5, z = 1.0 }, + Type = 27, + }, +} diff --git a/server-data/resources/[bpt_addons]/bpt_carshowroom/fxmanifest.lua b/server-data/resources/[bpt_addons]/bpt_carshowroom/fxmanifest.lua new file mode 100644 index 000000000..703f703ce --- /dev/null +++ b/server-data/resources/[bpt_addons]/bpt_carshowroom/fxmanifest.lua @@ -0,0 +1,15 @@ +fx_version("adamant") +game("gta5") + +description("esx_carshowroom") +lua54("yes") +version("1.0.1") + +shared_script("@es_extended/imports.lua") + +client_scripts({ + "@es_extended/locale.lua", + "locales/*.lua", + "config.lua", + "client/main.lua", +}) diff --git a/server-data/resources/[bpt_addons]/bpt_carshowroom/locales/it.lua b/server-data/resources/[bpt_addons]/bpt_carshowroom/locales/it.lua new file mode 100644 index 000000000..928c96a1d --- /dev/null +++ b/server-data/resources/[bpt_addons]/bpt_carshowroom/locales/it.lua @@ -0,0 +1,10 @@ +Locales["it"] = { + -- Everything + ["press_e"] = "Premi ~INPUT_CONTEXT~ per accedere al menu", + ["costs"] = " Costo: ", + ["currency"] = " $", + ["back"] = "Indietro", + ["contact_dealer"] = "Contatta il venditore per l'acquisto: ", + ["press_e_to_enter"] = "Premi ~INPUT_CONTEXT~ per salire ", + ["press_e_to_exit"] = "Premi ~INPUT_CONTEXT~ per scendere ", +} From 103ea3695f8bc421a3ccc9876e06b76056b2b329 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 29 Jul 2024 18:34:28 +0200 Subject: [PATCH 12/23] refactor: Improved code style respecting ESLint rules --- .../bpt_status/html/scripts/app.js | 100 +++++++++--------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/server-data/resources/[bpt_addons]/bpt_status/html/scripts/app.js b/server-data/resources/[bpt_addons]/bpt_status/html/scripts/app.js index f90962bdc..2f9e54581 100644 --- a/server-data/resources/[bpt_addons]/bpt_status/html/scripts/app.js +++ b/server-data/resources/[bpt_addons]/bpt_status/html/scripts/app.js @@ -1,51 +1,51 @@ -(function () { - let status = []; - - let renderStatus = function () { - document.getElementById("status_list").innerHTML = ""; - - for (let i = 0; i < status.length; i++) { - if (!status[i].visible) { - continue; - } - - const statusVal = document.createElement("div"); - statusVal.style.width = status[i].percent + "%"; - statusVal.style.backgroundColor = status[i].color; - statusVal.classList.add("status_val"); - - const statusInner = document.createElement("div"); - statusInner.classList.add("status_inner"); - statusInner.style.border = "1px solid " + status[i].color; - statusInner.appendChild(statusVal); - - const statusDiv = document.createElement("div"); - statusDiv.classList.add("status"); - statusDiv.appendChild(statusInner); - - document.getElementById("status_list").appendChild(statusDiv); - } - }; - - window.onData = function (data) { - if (data.update) { - status.length = 0; - - for (let i = 0; i < data.status.length; i++) { - status.push(data.status[i]); - } - - renderStatus(); - } - - if (data.setDisplay) { - document.getElementById("status_list").style.opacity = data.display; - } - }; - - window.onload = function () { - window.addEventListener("message", function (event) { - onData(event.data); - }); - }; +(function() { + const status = []; + + const renderStatus = function() { + document.getElementById('status_list').innerHTML = ''; + + for (let i = 0; i < status.length; i++) { + if (!status[i].visible) { + continue; + } + + const statusVal = document.createElement('div'); + statusVal.style.width = status[i].percent + '%'; + statusVal.style.backgroundColor = status[i].color; + statusVal.classList.add('status_val'); + + const statusInner = document.createElement('div'); + statusInner.classList.add('status_inner'); + statusInner.style.border = '1px solid ' + status[i].color; + statusInner.appendChild(statusVal); + + const statusDiv = document.createElement('div'); + statusDiv.classList.add('status'); + statusDiv.appendChild(statusInner); + + document.getElementById('status_list').appendChild(statusDiv); + } + }; + + window.onData = function(data) { + if (data.update) { + status.length = 0; + + for (let i = 0; i < data.status.length; i++) { + status.push(data.status[i]); + } + + renderStatus(); + } + + if (data.setDisplay) { + document.getElementById('status_list').style.opacity = data.display; + } + }; + + window.onload = function() { + window.addEventListener('message', function(event) { + onData(event.data); + }); + }; })(); \ No newline at end of file From d36e15f52809a4e6a41b85e228d9c06af59c34ec Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 29 Jul 2024 19:46:23 +0200 Subject: [PATCH 13/23] refactor: Improved code style respecting ESLint rules --- .../[bpt_addons]/bpt_loadscreen/js/config.js | 156 +++++++++-------- .../bpt_loadscreen/js/music-controls.js | 66 +++---- .../bpt_loadscreen/js/music-handler.js | 164 +++++++++--------- .../bpt_loadscreen/js/scriptnav.js | 140 ++++++--------- .../bpt_loadscreen/js/server-name-changer.js | 120 ++++++------- 5 files changed, 313 insertions(+), 333 deletions(-) diff --git a/server-data/resources/[bpt_addons]/bpt_loadscreen/js/config.js b/server-data/resources/[bpt_addons]/bpt_loadscreen/js/config.js index a1493a4d5..57ad75182 100644 --- a/server-data/resources/[bpt_addons]/bpt_loadscreen/js/config.js +++ b/server-data/resources/[bpt_addons]/bpt_loadscreen/js/config.js @@ -1,101 +1,107 @@ -var config = +// eslint-disable-next-line no-unused-vars +const config = { - // Base - BASE: { + // Base + BASE: { - color: { - background: "linear-gradient(45deg, rgba(0,0,0,1) 0%, rgba(85,85,85,1) 100%)", - servername: + color: { + background: 'linear-gradient(45deg, rgba(0,0,0,1) 0%, rgba(85,85,85,1) 100%)', + servername: [ - "rgba(250,250,250,1)", // main color - "rgba(66,66,66,1)" // change color + // eslint-disable-next-line no-inline-comments + 'rgba(250,250,250,1)', // main color + // eslint-disable-next-line no-inline-comments + 'rgba(66,66,66,1)', // change color ], - cursor_dot: "rgba(255,255,255,1)", - cursor_ring: "rgba(255,255,255,1)", - logs: "rgba(255, 255, 255, 0.46)", - music_text: "rgba(117,117,117,1)", - music_icons: "rgba(255,255,255,1)", - nav_icon: "rgba(255,255,255,1)", - nav_background: + cursor_dot: 'rgba(255,255,255,1)', + cursor_ring: 'rgba(255,255,255,1)', + logs: 'rgba(255, 255, 255, 0.46)', + music_text: 'rgba(117,117,117,1)', + music_icons: 'rgba(255,255,255,1)', + nav_icon: 'rgba(255,255,255,1)', + nav_background: [ - "rgba(9,9,12,1)", // front - "rgba(20,21,26,0.6)" // back + // eslint-disable-next-line no-inline-comments + 'rgba(9,9,12,1)', // front + // eslint-disable-next-line no-inline-comments + 'rgba(20,21,26,0.6)', // back ], - nav_underline: "rgba(117,117,117,1)", - nav_text: + nav_underline: 'rgba(117,117,117,1)', + nav_text: [ - "rgba(255,255,255,0.6)", // normal - "rgba(255,255,255,1)" // highlight + // eslint-disable-next-line no-inline-comments + 'rgba(255,255,255,0.6)', // normal + // eslint-disable-next-line no-inline-comments + 'rgba(255,255,255,1)', // highlight ], - loadingbar_background: + loadingbar_background: [ - "rgba(66,66,66,1)", // Pre-Map - "rgba(88,88,88,1)", // Map - "rgba(110,110,110,1)", // Post-Map - "rgba(132,132,132,1)" // Session + // eslint-disable-next-line no-inline-comments + 'rgba(66,66,66,1)', // Pre-Map + // eslint-disable-next-line no-inline-comments + 'rgba(88,88,88,1)', // Map + // eslint-disable-next-line no-inline-comments + 'rgba(110,110,110,1)', // Post-Map + // eslint-disable-next-line no-inline-comments + 'rgba(132,132,132,1)', // Session ], - loadingbar_text: + loadingbar_text: [ - "rgba(66,66,66,1)", // Pre-Map - "rgba(88,88,88,1)", // Map - "rgba(110,110,110,1)", // Post-Map - "rgba(132,132,132,1)" // Session + // eslint-disable-next-line no-inline-comments + 'rgba(66,66,66,1)', // Pre-Map + // eslint-disable-next-line no-inline-comments + 'rgba(88,88,88,1)', // Map + // eslint-disable-next-line no-inline-comments + 'rgba(110,110,110,1)', // Post-Map + // eslint-disable-next-line no-inline-comments + 'rgba(132,132,132,1)', // Session ], - waves: + waves: [ - "rgba(66,66,66,0.7)", // back - "rgba(88,88,88,0.5)", - "rgba(110,110,110,0.3)", - "rgba(132,132,132,1)" // front + // eslint-disable-next-line no-inline-comments + 'rgba(66,66,66,0.7)', // back + 'rgba(88,88,88,0.5)', + 'rgba(110,110,110,0.3)', + // eslint-disable-next-line no-inline-comments + 'rgba(132,132,132,1)', // front ], - } + }, - }, + }, - NAV: { - enable: true, - list: - { - GitHub: - [ - "GitHub", - "https://github.com/bitpredator/empiretown" - ], - } - }, - - // Server Name - SVN: { - enable: true, - phrases: + // Server Name + SVN: { + enable: true, + phrases: [ - 'EMPIRETOWN', - 'EMP', - 'BPT-CORE', - 'BPT-FRAMEWORK', + 'EMPIRETOWN', + 'EMP', + 'BPT-CORE', + 'BPT-FRAMEWORK', ], - chars: 'EMPIRETOWN EMP BPT-CORE BPT-FRAMEWORK', - changeTime: 15, - changePhrasesTime: 30, - }, + chars: 'EMPIRETOWN EMP BPT-CORE BPT-FRAMEWORK', + changeTime: 15, + changePhrasesTime: 30, + }, - // Logs - LOG: { - enable: false, - }, + // Logs + LOG: { + enable: false, + }, - // Music - MUSIC: { - enable: true, - music: // YT ID + // Music + MUSIC: { + enable: true, + // eslint-disable-next-line no-inline-comments + music: // YT ID [ - "RLr59M_Zvlg" + 'RLr59M_Zvlg', ], - Volume: 20, - TextPrefix: "EMP:" - } -} \ No newline at end of file + Volume: 20, + TextPrefix: 'EMP:', + }, +}; \ No newline at end of file diff --git a/server-data/resources/[bpt_addons]/bpt_loadscreen/js/music-controls.js b/server-data/resources/[bpt_addons]/bpt_loadscreen/js/music-controls.js index c4db97160..8e053ce3c 100644 --- a/server-data/resources/[bpt_addons]/bpt_loadscreen/js/music-controls.js +++ b/server-data/resources/[bpt_addons]/bpt_loadscreen/js/music-controls.js @@ -1,57 +1,59 @@ -var container = document.getElementById("music-info"); -var slider = document.getElementById("volumeSlider"); -var np = document.getElementById("now-playing"); -var playButton = document.getElementById("play-button") +const container = document.getElementById('music-info'); +const slider = document.getElementById('volumeSlider'); +const np = document.getElementById('now-playing'); +const playButton = document.getElementById('play-button'); -var playing = false; +let playing = false; if (config.MUSIC.enable) { - InitControls(); - setInterval(UpdateMusicInfo, 1000); + InitControls(); + setInterval(UpdateMusicInfo, 1000); } else { - container.style.display = "none"; + container.style.display = 'none'; } function InitControls() { - slider.value = config.MUSIC.Volume - slider.addEventListener("input", UpdateVolume, false); + slider.value = config.MUSIC.Volume; + slider.addEventListener('input', UpdateVolume, false); } function UpdateVolume() { - setVolume((slider.value - 1)); + setVolume((slider.value - 1)); } function UpdateMusicInfo() { - if (title.length != 0) { - np.innerHTML = config.MUSIC.TextPrefix + "『 " + title + " 』"; - } - else { - np.innerHTML = config.MUSIC.TextPrefix + "n.a."; - } + if (title.length != 0) { + np.innerHTML = config.MUSIC.TextPrefix + '『 ' + title + ' 』'; + } + else { + np.innerHTML = config.MUSIC.TextPrefix + 'n.a.'; + } } +// eslint-disable-next-line no-unused-vars function OnPlayClick() { - if (playing) { - playing = false; - pause(); + if (playing) { + playing = false; + pause(); - playButton.classList.remove("icon-pause2") - playButton.classList.add("icon-play3") + playButton.classList.remove('icon-pause2'); + playButton.classList.add('icon-play3'); - } - else { - playing = true; - resume(); + } + else { + playing = true; + resume(); - playButton.classList.remove("icon-play3") - playButton.classList.add("icon-pause2") - } + playButton.classList.remove('icon-play3'); + playButton.classList.add('icon-pause2'); + } } +// eslint-disable-next-line no-unused-vars function OnSkipClick() { - if (playing) { - skip(); - } + if (playing) { + skip(); + } } \ No newline at end of file diff --git a/server-data/resources/[bpt_addons]/bpt_loadscreen/js/music-handler.js b/server-data/resources/[bpt_addons]/bpt_loadscreen/js/music-handler.js index 9f51629c8..29faaf2a6 100644 --- a/server-data/resources/[bpt_addons]/bpt_loadscreen/js/music-handler.js +++ b/server-data/resources/[bpt_addons]/bpt_loadscreen/js/music-handler.js @@ -1,122 +1,130 @@ -var player; +let player; -var lib = +const lib = { - rand: function (min, max) { - return min + Math.floor(Math.random() * max); - }, + rand: function(min, max) { + return min + Math.floor(Math.random() * max); + }, - fadeInOut: function (duration, elementId, min, max) { - var halfDuration = duration / 2; + fadeInOut: function(duration, elementId, min, max) { + const halfDuration = duration / 2; - setTimeout(function () { - var element = document.getElementById(elementId); - element.style.opacity = min; + setTimeout(function() { + const element = document.getElementById(elementId); + element.style.opacity = min; - setTimeout(function () { - element.style.opacity = max; + setTimeout(function() { + element.style.opacity = max; - }, halfDuration); + }, halfDuration); - }, halfDuration); - }, -} + }, halfDuration); + }, +}; if (config.MUSIC.enable) { - var tag = document.createElement('script'); - tag.src = "https://www.youtube.com/iframe_api"; + const tag = document.createElement('script'); + tag.src = 'https://www.youtube.com/iframe_api'; - var ytScript = document.getElementsByTagName('script')[0]; - ytScript.parentNode.insertBefore(tag, ytScript); + const ytScript = document.getElementsByTagName('script')[0]; + ytScript.parentNode.insertBefore(tag, ytScript); - var musicIndex = lib.rand(0, config.MUSIC.music.length); - var title = "n.a."; + // eslint-disable-next-line no-var + var musicIndex = lib.rand(0, config.MUSIC.music.length); + // eslint-disable-next-line no-var, no-unused-vars + var title = 'n.a.'; } +// eslint-disable-next-line no-unused-vars function onYouTubeIframeAPIReady() { - var videoId = config.MUSIC.music[musicIndex]; - - player = new YT.Player('player', { - width: '1', - height: '', - playerVars: { - 'autoplay': 0, - 'controls': 0, - 'disablekb': 1, - 'enablejsapi': 1, - }, - events: { - 'onReady': onPlayerReady, - 'onStateChange': onPlayerStateChange, - 'onError': onPlayerError - } - }); + + player = new YT.Player('player', { + width: '1', + height: '', + playerVars: { + 'autoplay': 0, + 'controls': 0, + 'disablekb': 1, + 'enablejsapi': 1, + }, + events: { + 'onReady': onPlayerReady, + 'onStateChange': onPlayerStateChange, + 'onError': onPlayerError, + }, + }); } function onPlayerReady(event) { - title = event.target.getVideoData().title; - player.setVolume(config.MUSIC.Volume); + title = event.target.getVideoData().title; + player.setVolume(config.MUSIC.Volume); } function onPlayerStateChange(event) { - if (event.data == YT.PlayerState.PLAYING) { - title = event.target.getVideoData().title; - } - - if (event.data == YT.PlayerState.ENDED) { - musicIndex++; - play(); - } + if (event.data == YT.PlayerState.PLAYING) { + title = event.target.getVideoData().title; + } + + if (event.data == YT.PlayerState.ENDED) { + musicIndex++; + play(); + } } function onPlayerError(event) { - var videoId = config.MUSIC.music[musicIndex]; - - switch (event.data) { - case 2: - console.log("Invalid video url!"); - break; - case 5: - console.log("HTML 5 player error!"); - case 100: - console.log("Video not found!"); - case 101: - case 150: - console.log("Video embedding not allowed. [" + videoId + "]"); - break; - default: - console.log("Looks like you got an error bud.") - } - skip(); + const videoId = config.MUSIC.music[musicIndex]; + + switch (event.data) { + case 2: + console.log('Invalid video url!'); + break; + case 5: + console.log('HTML 5 player error!'); + // eslint-disable-next-line no-fallthrough + case 100: + console.log('Video not found!'); + // eslint-disable-next-line no-fallthrough + case 101: + case 150: + console.log('Video embedding not allowed. [' + videoId + ']'); + break; + default: + console.log('Looks like you got an error bud.'); + } + skip(); } function skip() { - musicIndex++; - play(); + musicIndex++; + play(); } function play() { - title = "n.a."; + title = 'n.a.'; - var idx = musicIndex % config.MUSIC.music.length; - var videoId = config.MUSIC.music[idx]; + const idx = musicIndex % config.MUSIC.music.length; + const videoId = config.MUSIC.music[idx]; - player.loadVideoById(videoId, 0, "tiny"); - player.playVideo(); + player.loadVideoById(videoId, 0, 'tiny'); + player.playVideo(); } +// eslint-disable-next-line no-unused-vars function resume() { - player.playVideo(); + player.playVideo(); } +// eslint-disable-next-line no-unused-vars function pause() { - player.pauseVideo(); + player.pauseVideo(); } +// eslint-disable-next-line no-unused-vars function stop() { - player.stopVideo(); + player.stopVideo(); } +// eslint-disable-next-line no-unused-vars function setVolume(volume) { - player.setVolume(volume) + player.setVolume(volume); } \ No newline at end of file diff --git a/server-data/resources/[bpt_addons]/bpt_loadscreen/js/scriptnav.js b/server-data/resources/[bpt_addons]/bpt_loadscreen/js/scriptnav.js index 64307eb13..850303d46 100644 --- a/server-data/resources/[bpt_addons]/bpt_loadscreen/js/scriptnav.js +++ b/server-data/resources/[bpt_addons]/bpt_loadscreen/js/scriptnav.js @@ -1,92 +1,52 @@ -(function ($) { - "use strict"; - - $(window).mousemove(function (e) { - $(".cursor1").css({ - left: e.pageX, - top: e.pageY - }) - }) - - document.getElementsByTagName("body")[0].addEventListener("mousemove", function (n) { - t.style.left = n.clientX + "px", - t.style.top = n.clientY + "px", - e.style.left = n.clientX + "px", - e.style.top = n.clientY + "px", - i.style.left = n.clientX + "px", - i.style.top = n.clientY + "px" - }); - var t = document.getElementById("cursor"), - e = document.getElementById("cursor2"), - i = document.getElementById("cursor3"); - function n(t) { - e.classList.add("hover"), i.classList.add("hover") - } - function s(t) { - e.classList.remove("hover"), i.classList.remove("hover") - } - s(); - for (var r = document.querySelectorAll(".hover-target"), a = r.length - 1; a >= 0; a--) { - o(r[a]) - } - function o(t) { - t.addEventListener("mouseover", n), t.addEventListener("mouseout", s) - } - - - function navlist() { - if (config.NAV.enable) { - const el = document.querySelector('.nav__list'); - - let output = ''; - - for (let i = 0; i < Object.keys(config.NAV.list).length; i++) { - output += ``; - } - - el.innerHTML = output; - } - else { - const nav = document.querySelector('.nav-but-wrap'); - - nav.style.display = "none"; - } - - } - - - var app = function () { - var body = undefined; - var menu = undefined; - var menuItems = undefined; - var init = function init() { - body = document.querySelector('body'); - menu = document.querySelector('.menu-icon'); - menuItems = document.querySelectorAll('.nav__list-item'); - applyListeners(); - navlist(); - }; - var applyListeners = function applyListeners() { - menu.addEventListener('click', function () { - return toggleClass(body, 'nav-active'); - }); - }; - var toggleClass = function toggleClass(element, stringClass) { - if (element.classList.contains(stringClass)) element.classList.remove(stringClass); else element.classList.add(stringClass); - }; - init(); - }(); - - - $("#switch").on('click', function () { - if ($("body").hasClass("light")) { - $("body").removeClass("light"); - $("#switch").removeClass("switched"); - } - else { - $("body").addClass("light"); - $("#switch").addClass("switched"); - } - }); +(function($) { + 'use strict'; + + $(window).mousemove(function(e) { + $('.cursor1').css({ + left: e.pageX, + top: e.pageY, + }); + }); + + // eslint-disable-next-line no-shadow + document.getElementsByTagName('body')[0].addEventListener('mousemove', function(n) { + t.style.left = n.clientX + 'px', + t.style.top = n.clientY + 'px', + e.style.left = n.clientX + 'px', + e.style.top = n.clientY + 'px', + i.style.left = n.clientX + 'px', + i.style.top = n.clientY + 'px'; + }); + // eslint-disable-next-line no-var + var t = document.getElementById('cursor'), + e = document.getElementById('cursor2'), + i = document.getElementById('cursor3'); + // eslint-disable-next-line no-unused-vars + function n(_t) { + e.classList.add('hover'), i.classList.add('hover'); + } + // eslint-disable-next-line no-unused-vars + function s(_t) { + e.classList.remove('hover'), i.classList.remove('hover'); + } + s(); + for (let r = document.querySelectorAll('.hover-target'), a = r.length - 1; a >= 0; a--) { + o(r[a]); + } + // eslint-disable-next-line no-shadow + function o(t) { + t.addEventListener('mouseover', n), t.addEventListener('mouseout', s); + } + + $('#switch').on('click', function() { + if ($('body').hasClass('light')) { + $('body').removeClass('light'); + $('#switch').removeClass('switched'); + } + else { + $('body').addClass('light'); + $('#switch').addClass('switched'); + } + }); })(jQuery); \ No newline at end of file diff --git a/server-data/resources/[bpt_addons]/bpt_loadscreen/js/server-name-changer.js b/server-data/resources/[bpt_addons]/bpt_loadscreen/js/server-name-changer.js index fba15b748..ea486a3af 100644 --- a/server-data/resources/[bpt_addons]/bpt_loadscreen/js/server-name-changer.js +++ b/server-data/resources/[bpt_addons]/bpt_loadscreen/js/server-name-changer.js @@ -1,74 +1,78 @@ class TextScramble { - constructor(el) { - this.el = el; - this.chars = config.SVN.chars; - this.update = this.update.bind(this); - } + constructor(el) { + this.el = el; + this.chars = config.SVN.chars; + this.update = this.update.bind(this); + } - setText(newText) { - const oldText = this.el.innerText; - const length = Math.max(oldText.length, newText.length); - const promise = new Promise(resolve => this.resolve = resolve); - this.queue = []; - for (let i = 0; i < length; i++) { - const from = oldText[i] || ''; - const to = newText[i] || ''; - const start = Math.floor(Math.random() * config.SVN.changePhrasesTime); - const end = start + Math.floor(Math.random() * config.SVN.changePhrasesTime); - this.queue.push({ from, to, start, end }); - } - cancelAnimationFrame(this.frameRequest); - this.frame = 0; - this.update(); - return promise; - } + setText(newText) { + const oldText = this.el.innerText; + const length = Math.max(oldText.length, newText.length); + const promise = new Promise(resolve => this.resolve = resolve); + this.queue = []; + for (let i = 0; i < length; i++) { + const from = oldText[i] || ''; + const to = newText[i] || ''; + const start = Math.floor(Math.random() * config.SVN.changePhrasesTime); + const end = start + Math.floor(Math.random() * config.SVN.changePhrasesTime); + this.queue.push({ from, to, start, end }); + } + cancelAnimationFrame(this.frameRequest); + this.frame = 0; + this.update(); + return promise; + } - update() { - let output = ''; - let complete = 0; - for (let i = 0, n = this.queue.length; i < n; i++) { - let { from, to, start, end, char } = this.queue[i]; - if (this.frame >= end) { - complete++; - output += to; - } else if (this.frame >= start) { - if (!char || Math.random() < 0.28) { - char = this.randomChar(); - this.queue[i].char = char; - } - output += `${char}`; - } else { - output += from; - } - } - this.el.innerHTML = output; - if (complete === this.queue.length) { - this.resolve(); - } else { - this.frameRequest = requestAnimationFrame(this.update); - this.frame++; - } - } + update() { + let output = ''; + let complete = 0; + for (let i = 0, n = this.queue.length; i < n; i++) { + // eslint-disable-next-line prefer-const + let { from, to, start, end, char } = this.queue[i]; + if (this.frame >= end) { + complete++; + output += to; + } + else if (this.frame >= start) { + if (!char || Math.random() < 0.28) { + char = this.randomChar(); + this.queue[i].char = char; + } + output += `${char}`; + } + else { + output += from; + } + } + this.el.innerHTML = output; + if (complete === this.queue.length) { + this.resolve(); + } + else { + this.frameRequest = requestAnimationFrame(this.update); + this.frame++; + } + } - randomChar() { - return this.chars[Math.floor(Math.random() * this.chars.length)]; - } + randomChar() { + return this.chars[Math.floor(Math.random() * this.chars.length)]; + } } const el = document.querySelector('.text'); const fx = new TextScramble(el); -el.style.color = config.SVN.color1 +el.style.color = config.SVN.color1; let counter = 0; const next = () => { - if (config.SVN.enable) { - fx.setText(config.SVN.phrases[counter]).then(() => { - setTimeout(next, Math.floor((Math.random() * (config.SVN.changeTime * 100) * 2.33) + config.SVN.changeTime * 100)); - }); - counter = (counter + 1) % config.SVN.phrases.length; - } + if (config.SVN.enable) { + fx.setText(config.SVN.phrases[counter]).then(() => { + setTimeout(next, Math.floor((Math.random() * (config.SVN.changeTime * 100) * 2.33) + config.SVN.changeTime * 100)); + }); + counter = (counter + 1) % config.SVN.phrases.length; + } }; next(); \ No newline at end of file From b65959182b8bee52ca5640c456993c2c333e02ff Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 29 Jul 2024 20:06:12 +0200 Subject: [PATCH 14/23] refactor: Improved code style respecting ESLint rules --- .../bpt_loadscreen/js/color-change.js | 82 ++-- .../bpt_loadscreen/js/loadingbar.js | 355 +++++++++--------- 2 files changed, 224 insertions(+), 213 deletions(-) diff --git a/server-data/resources/[bpt_addons]/bpt_loadscreen/js/color-change.js b/server-data/resources/[bpt_addons]/bpt_loadscreen/js/color-change.js index 1edeb6e85..7a0dfd085 100644 --- a/server-data/resources/[bpt_addons]/bpt_loadscreen/js/color-change.js +++ b/server-data/resources/[bpt_addons]/bpt_loadscreen/js/color-change.js @@ -1,60 +1,60 @@ function updateColors() { - // color background - document.documentElement.style.setProperty("--header-color", config.BASE.color.background); + // color background + document.documentElement.style.setProperty('--header-color', config.BASE.color.background); - // color servername - const servername = Object.values(config.BASE.color.servername); + // color servername + const servername = Object.values(config.BASE.color.servername); - document.documentElement.style.setProperty("--text-color", servername[0]); - document.documentElement.style.setProperty("--dud-color", servername[1]) + document.documentElement.style.setProperty('--text-color', servername[0]); + document.documentElement.style.setProperty('--dud-color', servername[1]); - // cursor - document.documentElement.style.setProperty("--cursor-dot", config.BASE.color.cursor_dot); - document.documentElement.style.setProperty("--cursor-ring", config.BASE.color.cursor_ring); + // cursor + document.documentElement.style.setProperty('--cursor-dot', config.BASE.color.cursor_dot); + document.documentElement.style.setProperty('--cursor-ring', config.BASE.color.cursor_ring); - // color logs - document.documentElement.style.setProperty("--log-color", config.BASE.color.logs); + // color logs + document.documentElement.style.setProperty('--log-color', config.BASE.color.logs); - // color music text - document.documentElement.style.setProperty("--music-color", config.BASE.color.music_text); + // color music text + document.documentElement.style.setProperty('--music-color', config.BASE.color.music_text); - // color music icons - document.documentElement.style.setProperty("--music-icons", config.BASE.color.music_icons); + // color music icons + document.documentElement.style.setProperty('--music-icons', config.BASE.color.music_icons); - // color nav - const nav_background = Object.values(config.BASE.color.nav_background); - const nav_text = Object.values(config.BASE.color.nav_text); + // color nav + const nav_background = Object.values(config.BASE.color.nav_background); + const nav_text = Object.values(config.BASE.color.nav_text); - document.documentElement.style.setProperty("--nav-icon", config.BASE.color.music_icons); - document.documentElement.style.setProperty("--nav-background", nav_background[0]); - document.documentElement.style.setProperty("--nav-background-back", nav_background[1]); - document.documentElement.style.setProperty("--nav-underline", config.BASE.color.nav_underline); - document.documentElement.style.setProperty("--nav-text", nav_text[0]); - document.documentElement.style.setProperty("--nav-text-highlight", nav_text[1]); + document.documentElement.style.setProperty('--nav-icon', config.BASE.color.music_icons); + document.documentElement.style.setProperty('--nav-background', nav_background[0]); + document.documentElement.style.setProperty('--nav-background-back', nav_background[1]); + document.documentElement.style.setProperty('--nav-underline', config.BASE.color.nav_underline); + document.documentElement.style.setProperty('--nav-text', nav_text[0]); + document.documentElement.style.setProperty('--nav-text-highlight', nav_text[1]); - // color loadingbar - const loadingbar_background = Object.values(config.BASE.color.loadingbar_background); + // color loadingbar + const loadingbar_background = Object.values(config.BASE.color.loadingbar_background); - document.documentElement.style.setProperty("--bg-first", loadingbar_background[0]); - document.documentElement.style.setProperty("--bg-second", loadingbar_background[1]); - document.documentElement.style.setProperty("--bg-third", loadingbar_background[2]); - document.documentElement.style.setProperty("--bg-fourth", loadingbar_background[3]); + document.documentElement.style.setProperty('--bg-first', loadingbar_background[0]); + document.documentElement.style.setProperty('--bg-second', loadingbar_background[1]); + document.documentElement.style.setProperty('--bg-third', loadingbar_background[2]); + document.documentElement.style.setProperty('--bg-fourth', loadingbar_background[3]); - const loadingbar_text = Object.values(config.BASE.color.loadingbar_text); + const loadingbar_text = Object.values(config.BASE.color.loadingbar_text); - document.documentElement.style.setProperty("--text-first", loadingbar_text[0]); - document.documentElement.style.setProperty("--text-second", loadingbar_text[1]); - document.documentElement.style.setProperty("--text-third", loadingbar_text[2]); - document.documentElement.style.setProperty("--text-fourth", loadingbar_text[3]); + document.documentElement.style.setProperty('--text-first', loadingbar_text[0]); + document.documentElement.style.setProperty('--text-second', loadingbar_text[1]); + document.documentElement.style.setProperty('--text-third', loadingbar_text[2]); + document.documentElement.style.setProperty('--text-fourth', loadingbar_text[3]); - // color waves - const waves_color = Object.values(config.BASE.color.waves); + // color waves + const waves_color = Object.values(config.BASE.color.waves); - document.documentElement.style.setProperty("--waves-first", waves_color[0]); - document.documentElement.style.setProperty("--waves-second", waves_color[1]); - document.documentElement.style.setProperty("--waves-third", waves_color[2]); - document.documentElement.style.setProperty("--waves-fourth", waves_color[3]); + document.documentElement.style.setProperty('--waves-first', waves_color[0]); + document.documentElement.style.setProperty('--waves-second', waves_color[1]); + document.documentElement.style.setProperty('--waves-third', waves_color[2]); + document.documentElement.style.setProperty('--waves-fourth', waves_color[3]); } updateColors(); \ No newline at end of file diff --git a/server-data/resources/[bpt_addons]/bpt_loadscreen/js/loadingbar.js b/server-data/resources/[bpt_addons]/bpt_loadscreen/js/loadingbar.js index 6407ad8e4..760c9f851 100644 --- a/server-data/resources/[bpt_addons]/bpt_loadscreen/js/loadingbar.js +++ b/server-data/resources/[bpt_addons]/bpt_loadscreen/js/loadingbar.js @@ -1,212 +1,223 @@ if (!String.format) { - String.format = function (format) { - var args = Array.prototype.slice.call(arguments, 1); - return format.replace(/{(\d+)}/g, function (match, number) { - return typeof args[number] != 'undefined' - ? args[number] - : match - ; - }); - }; + String.format = function(format) { + const args = Array.prototype.slice.call(arguments, 1); + return format.replace(/{(\d+)}/g, function(match, number) { + return typeof args[number] != 'undefined' + ? args[number] + : match + ; + }); + }; } -const loadingStages = ["Pre-map", "Map", "Post-map", "Session"]; -const technicalNames = ["INIT_BEFORE_MAP_LOADED", "MAP", "INIT_AFTER_MAP_LOADED", "INIT_SESSION"]; -var currentLoadingStage = 0; -var loadingWeights = [1.5 / 10, 4 / 10, 1.5 / 10, 3 / 10]; +// eslint-disable-next-line no-unused-vars +const loadingStages = ['Pre-map', 'Map', 'Post-map', 'Session']; +const technicalNames = ['INIT_BEFORE_MAP_LOADED', 'MAP', 'INIT_AFTER_MAP_LOADED', 'INIT_SESSION']; +let currentLoadingStage = 0; +const loadingWeights = [1.5 / 10, 4 / 10, 1.5 / 10, 3 / 10]; -var loadingTotals = [70, 70, 70, 220]; -var registeredTotals = [0, 0, 0, 0]; -var stageVisible = [false, false, false, false]; +const loadingTotals = [70, 70, 70, 220]; +const registeredTotals = [0, 0, 0, 0]; +const stageVisible = [false, false, false, false]; -var currentProgress = [0.0, 0.0, 0.0, 0.0]; -var currentProgressSum = 0.0; -var currentLoadingCount = 0; +const currentProgress = [0.0, 0.0, 0.0, 0.0]; +// eslint-disable-next-line no-unused-vars +const currentProgressSum = 0.0; +let currentLoadingCount = 0; -var minScale = 1.03 -var maxScale = 1.20 -var diffScale = maxScale - minScale -var backgroundPositionEnd = [0, 0]; +const minScale = 1.03; +const maxScale = 1.20; +// eslint-disable-next-line no-unused-vars +const diffScale = maxScale - minScale; +// eslint-disable-next-line no-unused-vars +const backgroundPositionEnd = [0, 0]; function doProgress(stage) { - var idx = technicalNames.indexOf(stage); - if (idx >= 0) { - registeredTotals[idx]++; - if (idx > currentLoadingStage) { - while (currentLoadingStage < idx) { - currentProgress[currentLoadingStage] = 1.0; - currentLoadingStage++; - } - currentLoadingCount = 1; - } - else - currentLoadingCount++; - currentProgress[currentLoadingStage] = Math.min(currentLoadingCount / loadingTotals[idx], 1.0); - updateProgress(); - } + const idx = technicalNames.indexOf(stage); + if (idx >= 0) { + registeredTotals[idx]++; + if (idx > currentLoadingStage) { + while (currentLoadingStage < idx) { + currentProgress[currentLoadingStage] = 1.0; + currentLoadingStage++; + } + currentLoadingCount = 1; + } + else {currentLoadingCount++;} + currentProgress[currentLoadingStage] = Math.min(currentLoadingCount / loadingTotals[idx], 1.0); + updateProgress(); + } } const totalWidth = 99.1; -var progressPositions = []; -var progressMaxLengths = []; +const progressPositions = []; +const progressMaxLengths = []; progressPositions[0] = 0.0; -var i = 0; +let i = 0; while (i < currentProgress.length) { - progressMaxLengths[i] = loadingWeights[i] * totalWidth; - progressPositions[i + 1] = progressPositions[i] + progressMaxLengths[i]; - i++; + progressMaxLengths[i] = loadingWeights[i] * totalWidth; + progressPositions[i + 1] = progressPositions[i] + progressMaxLengths[i]; + i++; } function updateProgress() { - document.querySelector('#debug').innerHTML = ''; - var i = 0; - while (i <= currentLoadingStage) { - if ((currentProgress[i] > 0 || !currentProgress[i - 1]) && !stageVisible[i]) { - document.querySelector("#" + technicalNames[i] + "-label").style.display = 'inline-block'; - - document.querySelector("#" + technicalNames[i] + "-bar").style.display = 'inline-block'; - stageVisible[i] = true; - } - document.querySelector("#" + technicalNames[i] + "-bar").style.width = currentProgress[i] * progressMaxLengths[i] + '%'; - document.querySelector("#" + technicalNames[i] + "-label").style.width = progressMaxLengths[i] + '%'; - if (config.LOG.enable) { - document.querySelector('#debug').innerHTML += String.format('{0}: {1}
', technicalNames[i], currentProgress[i]); - } - i++; - } + document.querySelector('#debug').innerHTML = ''; + // eslint-disable-next-line no-shadow + let i = 0; + while (i <= currentLoadingStage) { + if ((currentProgress[i] > 0 || !currentProgress[i - 1]) && !stageVisible[i]) { + document.querySelector('#' + technicalNames[i] + '-label').style.display = 'inline-block'; + + document.querySelector('#' + technicalNames[i] + '-bar').style.display = 'inline-block'; + stageVisible[i] = true; + } + document.querySelector('#' + technicalNames[i] + '-bar').style.width = currentProgress[i] * progressMaxLengths[i] + '%'; + document.querySelector('#' + technicalNames[i] + '-label').style.width = progressMaxLengths[i] + '%'; + if (config.LOG.enable) { + document.querySelector('#debug').innerHTML += String.format('{0}: {1}
', technicalNames[i], currentProgress[i]); + } + i++; + } } updateProgress(); -var count = 0; -var thisCount = 0; +let count = 0; +// eslint-disable-next-line no-unused-vars +const thisCount = 0; const gstate = { - elems: [], - log: [] + elems: [], + log: [], }; +// eslint-disable-next-line no-unused-vars const emoji = { - INIT_BEFORE_MAP_LOADED: ['🍉'], - INIT_AFTER_MAP_LOADED: ['🍋', '🍊'], - INIT_SESSION: ['🍐', '🍅', '🍆'], + INIT_BEFORE_MAP_LOADED: ['🍉'], + INIT_AFTER_MAP_LOADED: ['🍋', '🍊'], + INIT_SESSION: ['🍐', '🍅', '🍆'], }; function printLog(type, str) { - gstate.log.push({ type: type, str: str }); + gstate.log.push({ type: type, str: str }); }; -Array.prototype.last = function () { - return this[this.length - 1]; +Array.prototype.last = function() { + return this[this.length - 1]; }; const handlers = { - startInitFunction(data) { - printLog(1, String.format('Running {0} init functions', data.type)); - if (data.type) doProgress(data.type); - }, - - startInitFunctionOrder(data) { - count = data.count; - - printLog(1, String.format('[{0}] Running functions of order {1} ({2} total)', data.type, data.order, data.count)); - if (data.type) doProgress(data.type); - }, - - initFunctionInvoking(data) { - printLog(3, String.format('Invoking {0} {1} init ({2} of {3})', data.name, data.type, data.idx, count)); - if (data.type) doProgress(data.type); - }, - - initFunctionInvoked(data) { - if (data.type) doProgress(data.type); - }, - - endInitFunction(data) { - printLog(1, String.format('Done running {0} init functions', data.type)); - if (data.type) doProgress(data.type); - }, - - startDataFileEntries(data) { - count = data.count; - - printLog(1, 'Loading map'); - if (data.type) doProgress(data.type); - }, - - onDataFileEntry(data) { - printLog(3, String.format('Loading {0}', data.name)); - doProgress(data.type); - if (data.type) doProgress(data.type); - }, - - endDataFileEntries() { - printLog(1, 'Done loading map'); - }, - - performMapLoadFunction(data) { - doProgress('MAP'); - }, - - onLogLine(data) { - printLog(3, data.message); - } + startInitFunction(data) { + printLog(1, String.format('Running {0} init functions', data.type)); + if (data.type) doProgress(data.type); + }, + + startInitFunctionOrder(data) { + count = data.count; + + printLog(1, String.format('[{0}] Running functions of order {1} ({2} total)', data.type, data.order, data.count)); + if (data.type) doProgress(data.type); + }, + + initFunctionInvoking(data) { + printLog(3, String.format('Invoking {0} {1} init ({2} of {3})', data.name, data.type, data.idx, count)); + if (data.type) doProgress(data.type); + }, + + initFunctionInvoked(data) { + if (data.type) doProgress(data.type); + }, + + endInitFunction(data) { + printLog(1, String.format('Done running {0} init functions', data.type)); + if (data.type) doProgress(data.type); + }, + + startDataFileEntries(data) { + count = data.count; + + printLog(1, 'Loading map'); + if (data.type) doProgress(data.type); + }, + + onDataFileEntry(data) { + printLog(3, String.format('Loading {0}', data.name)); + doProgress(data.type); + if (data.type) doProgress(data.type); + }, + + endDataFileEntries() { + printLog(1, 'Done loading map'); + }, + + performMapLoadFunction() { + doProgress('MAP'); + }, + + onLogLine(data) { + printLog(3, data.message); + }, }; -setInterval(function () { - if (config.LOG.enable) { - document.querySelector('#log').innerHTML = gstate.log.slice(-10).map( - function (e) { - return String.format("[{0}] {1}", e.type, e.str) - } - ).join('
'); - } +setInterval(function() { + if (config.LOG.enable) { + document.querySelector('#log').innerHTML = gstate.log.slice(-10).map( + function(e) { + return String.format('[{0}] {1}', e.type, e.str); + }, + ).join('
'); + } }, 100); if (!window.invokeNative) { - const newType = name => () => handlers.startInitFunction({ type: name }); - - const newOrder = (name, idx, count) => () => handlers.startInitFunctionOrder({ type: name, order: idx, count }); - - const newInvoke = (name, func, i) => () => { handlers.initFunctionInvoking({ type: name, name: func, idx: i }); handlers.initFunctionInvoked({ type: name }); }; - - const startEntries = (count) => () => handlers.startDataFileEntries({ count }); - - const addEntry = () => () => handlers.onDataFileEntry({ name: 'meow', isNew: true }); - - const stopEntries = () => () => handlers.endDataFileEntries({}); - - const newTypeWithOrder = (name, count) => () => { newType(name)(); newOrder(name, 1, count)(); }; - - const meowList = []; - for (let i = 0; i < 50; i++) { - meowList.push(newInvoke('INIT_SESSION', `meow${i + 1}`, i + 1)); - } - - const demoFuncs = [ - newTypeWithOrder('MAP', 5), - newInvoke('MAP', 'meow1', 1), - newInvoke('MAP', 'meow2', 2), - newInvoke('MAP', 'meow3', 3), - newInvoke('MAP', 'meow4', 4), - newInvoke('MAP', 'meow5', 5), - newOrder('MAP', 2, 2), - newInvoke('MAP', 'meow1', 1), - newInvoke('MAP', 'meow2', 2), - startEntries(6), - addEntry(), - addEntry(), - addEntry(), - addEntry(), - addEntry(), - addEntry(), - stopEntries(), - newTypeWithOrder('INIT_SESSION', 50), - ...meowList, - ]; - - setInterval(() => { - demoFuncs.length && demoFuncs.shift()(); - }, 120); + const newType = name => () => handlers.startInitFunction({ type: name }); + + // eslint-disable-next-line no-shadow + const newOrder = (name, idx, count) => () => handlers.startInitFunctionOrder({ type: name, order: idx, count }); + + // eslint-disable-next-line no-shadow, max-statements-per-line + const newInvoke = (name, func, i) => () => { handlers.initFunctionInvoking({ type: name, name: func, idx: i }); handlers.initFunctionInvoked({ type: name }); }; + + // eslint-disable-next-line no-shadow + const startEntries = (count) => () => handlers.startDataFileEntries({ count }); + + const addEntry = () => () => handlers.onDataFileEntry({ name: 'meow', isNew: true }); + + const stopEntries = () => () => handlers.endDataFileEntries({}); + + // eslint-disable-next-line no-shadow, max-statements-per-line + const newTypeWithOrder = (name, count) => () => { newType(name)(); newOrder(name, 1, count)(); }; + + const meowList = []; + // eslint-disable-next-line no-shadow + for (let i = 0; i < 50; i++) { + meowList.push(newInvoke('INIT_SESSION', `meow${i + 1}`, i + 1)); + } + + const demoFuncs = [ + newTypeWithOrder('MAP', 5), + newInvoke('MAP', 'meow1', 1), + newInvoke('MAP', 'meow2', 2), + newInvoke('MAP', 'meow3', 3), + newInvoke('MAP', 'meow4', 4), + newInvoke('MAP', 'meow5', 5), + newOrder('MAP', 2, 2), + newInvoke('MAP', 'meow1', 1), + newInvoke('MAP', 'meow2', 2), + startEntries(6), + addEntry(), + addEntry(), + addEntry(), + addEntry(), + addEntry(), + addEntry(), + stopEntries(), + newTypeWithOrder('INIT_SESSION', 50), + ...meowList, + ]; + + setInterval(() => { + demoFuncs.length && demoFuncs.shift()(); + }, 120); } \ No newline at end of file From fd4b2a83de8d9ceb8cb5993ca724899b4e63dc80 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 29 Jul 2024 20:29:13 +0200 Subject: [PATCH 15/23] =?UTF-8?q?chore:=20[bpt=5Faddons]\bpt=5Fstatus\fxma?= =?UTF-8?q?nifest.lua=20=F0=9F=8E=A8=20Run=20formatter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../[bpt_addons]/bpt_status/fxmanifest.lua | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/server-data/resources/[bpt_addons]/bpt_status/fxmanifest.lua b/server-data/resources/[bpt_addons]/bpt_status/fxmanifest.lua index d5f2a38fb..b122ddb2c 100644 --- a/server-data/resources/[bpt_addons]/bpt_status/fxmanifest.lua +++ b/server-data/resources/[bpt_addons]/bpt_status/fxmanifest.lua @@ -1,30 +1,30 @@ -fx_version 'adamant' -game 'gta5' -author 'bitpredator' -description 'Handles the overall status system for Hunger, Thrist and others' -version '1.0.1' -lua54 'yes' +fx_version("adamant") +game("gta5") +author("bitpredator") +description("Handles the overall status system for Hunger, Thrist and others") +version("1.0.1") +lua54("yes") -shared_script '@es_extended/imports.lua' +shared_script("@es_extended/imports.lua") -server_scripts { - '@oxmysql/lib/MySQL.lua', - 'config.lua', - 'server/main.lua' -} +server_scripts({ + "@oxmysql/lib/MySQL.lua", + "config.lua", + "server/main.lua", +}) -client_scripts { - 'config.lua', - 'client/classes/status.lua', - 'client/main.lua' -} +client_scripts({ + "config.lua", + "client/classes/status.lua", + "client/main.lua", +}) -ui_page 'html/ui.html' +ui_page("html/ui.html") -files { - 'html/ui.html', - 'html/css/app.css', - 'html/scripts/app.js' -} +files({ + "html/ui.html", + "html/css/app.css", + "html/scripts/app.js", +}) -dependency 'es_extended' +dependency("es_extended") From 7afd92eb432a7fafb68560037f8456cc39d64df8 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Tue, 30 Jul 2024 16:22:18 +0200 Subject: [PATCH 16/23] chore: removed the crafting system built into ox_inventory --- .../resources/[ox]/ox_inventory/client.lua | 75 +----- .../[ox]/ox_inventory/locales/cs.json | 3 - .../[ox]/ox_inventory/locales/de.json | 3 - .../[ox]/ox_inventory/locales/en.json | 3 - .../[ox]/ox_inventory/locales/es.json | 5 +- .../[ox]/ox_inventory/locales/et.json | 3 - .../[ox]/ox_inventory/locales/fi.json | 3 - .../[ox]/ox_inventory/locales/fr.json | 3 - .../[ox]/ox_inventory/locales/hu.json | 3 - .../[ox]/ox_inventory/locales/id.json | 2 - .../[ox]/ox_inventory/locales/it.json | 2 - .../[ox]/ox_inventory/locales/lt.json | 3 - .../[ox]/ox_inventory/locales/nl.json | 3 - .../[ox]/ox_inventory/locales/no.json | 180 +++++++------- .../[ox]/ox_inventory/locales/pl.json | 3 - .../[ox]/ox_inventory/locales/pt.json | 3 - .../[ox]/ox_inventory/locales/sr.json | 3 - .../[ox]/ox_inventory/locales/tr.json | 3 - .../[ox]/ox_inventory/locales/zh-cn.json | 3 - .../[ox]/ox_inventory/locales/zh-tw.json | 3 - .../ox_inventory/modules/crafting/client.lua | 103 -------- .../ox_inventory/modules/crafting/server.lua | 230 ------------------ .../ox_inventory/modules/utils/client.lua | 2 - .../resources/[ox]/ox_inventory/server.lua | 1 - .../web/build/assets/index-9aba2ab3.css | 15 -- 25 files changed, 90 insertions(+), 570 deletions(-) delete mode 100644 server-data/resources/[ox]/ox_inventory/modules/crafting/client.lua delete mode 100644 server-data/resources/[ox]/ox_inventory/modules/crafting/server.lua diff --git a/server-data/resources/[ox]/ox_inventory/client.lua b/server-data/resources/[ox]/ox_inventory/client.lua index 48ec5c55a..e8578c92e 100644 --- a/server-data/resources/[ox]/ox_inventory/client.lua +++ b/server-data/resources/[ox]/ox_inventory/client.lua @@ -109,7 +109,6 @@ local function closeTrunk() end end -local CraftingBenches = require 'modules.crafting.client' local Vehicles = lib.load('data.vehicles') local Inventory = require 'modules.inventory.client' @@ -189,39 +188,6 @@ function client.openInventory(inv, data) end left, right, accessError = lib.callback.await('ox_inventory:openShop', 200, data) - elseif inv == 'crafting' then - if cache.vehicle then - return lib.notify({ id = 'cannot_perform', type = 'error', description = locale('cannot_perform') }) - end - - left, right, accessError = lib.callback.await('ox_inventory:openCraftingBench', 200, data.id, data.index) - - if left then - right = CraftingBenches[data.id] - - if not right?.items then return end - - local coords, distance - - if not right.zones and not right.points then - coords = GetEntityCoords(cache.ped) - distance = 2 - else - coords = shared.target and right.zones and right.zones[data.index].coords or right.points and right.points[data.index] - distance = coords and shared.target and right.zones[data.index].distance or 2 - end - - right = { - type = 'crafting', - id = data.id, - label = right.label or locale('crafting_bench'), - index = data.index, - slots = right.slots, - items = right.items, - coords = coords, - distance = distance - } - end elseif invOpen ~= nil then if inv == 'policeevidence' then if not data then @@ -769,9 +735,7 @@ local function registerCommands() local closest = lib.points.getClosestPoint() if closest and closest.currentDistance < 1.2 and (not closest.instance or closest.instance == currentInstance) then - if closest.inv == 'crafting' then - return client.openInventory('crafting', { id = closest.id, index = closest.index }) - elseif closest.inv ~= 'license' and closest.inv ~= 'policeevidence' then + if closest.inv ~= 'license' and closest.inv ~= 'policeevidence' then return client.openInventory(closest.inv or 'drop', { id = closest.invId, type = closest.type }) end end @@ -1738,24 +1702,6 @@ RegisterNUICallback('exit', function(_, cb) cb(1) end) -lib.callback.register('ox_inventory:startCrafting', function(id, recipe) - recipe = CraftingBenches[id].items[recipe] - - return lib.progressCircle({ - label = locale('crafting_item', recipe.metadata?.label or Items[recipe.name].label), - duration = recipe.duration or 3000, - canCancel = true, - disable = { - move = true, - combat = true, - }, - anim = { - dict = 'anim@amb@clubhouse@tutorial@bkr_tut_ig3@', - clip = 'machinic_loop_mechandplayer', - } - }) -end) - local swapActive = false ---Synchronise and validate all item movement between the NUI and server. @@ -1859,25 +1805,6 @@ RegisterNUICallback('buyItem', function(data, cb) cb(response) end) -RegisterNUICallback('craftItem', function(data, cb) - cb(true) - - local id, index = currentInventory.id, currentInventory.index - - for i = 1, data.count do - local success, response = lib.callback.await('ox_inventory:craftItem', 200, id, index, data.fromSlot, data.toSlot) - - if not success then - if response then lib.notify({ type = 'error', description = locale(response or 'cannot_perform') }) end - break - end - end - - if not currentInventory or currentInventory.type ~= 'crafting' then - client.openInventory('crafting', { id = id, index = index }) - end -end) - lib.callback.register('ox_inventory:getVehicleData', function(netid) local entity = NetworkGetEntityFromNetworkId(netid) diff --git a/server-data/resources/[ox]/ox_inventory/locales/cs.json b/server-data/resources/[ox]/ox_inventory/locales/cs.json index 43fb9df0d..32d4dd34f 100644 --- a/server-data/resources/[ox]/ox_inventory/locales/cs.json +++ b/server-data/resources/[ox]/ox_inventory/locales/cs.json @@ -85,9 +85,6 @@ "cannot_give": "Této osobě nemůžete dát %s %s", "evidence_cannot_take": "Nejste dostatečně kvalifikovaný pro přístup", "dumpster": "Popelnice", - "crafting_item": "Vyrábíš %s", - "crafting_bench": "Pracovní stůl", - "open_crafting_bench": "Otevřít pracovní stůl", "not_enough_durability": "%s je příliš poškozený", "storage": "Úložný prostor" } diff --git a/server-data/resources/[ox]/ox_inventory/locales/de.json b/server-data/resources/[ox]/ox_inventory/locales/de.json index a5654fe17..2b7f54240 100644 --- a/server-data/resources/[ox]/ox_inventory/locales/de.json +++ b/server-data/resources/[ox]/ox_inventory/locales/de.json @@ -85,9 +85,6 @@ "cannot_give": "%s %s kann nicht übergeben werden", "evidence_cannot_take": "Dein Rang ist hierfür zu niedrig", "dumpster": "Mülleimer", - "crafting_item": "%s herstellen", - "crafting_bench": "Werkbank", - "open_crafting_bench": "Werkbank öffnen", "not_enough_durability": "Haltbarkeit von %s reicht nicht mehr aus", "storage": "Kofferraum" } diff --git a/server-data/resources/[ox]/ox_inventory/locales/en.json b/server-data/resources/[ox]/ox_inventory/locales/en.json index 1e9c0e8a5..4f461997d 100644 --- a/server-data/resources/[ox]/ox_inventory/locales/en.json +++ b/server-data/resources/[ox]/ox_inventory/locales/en.json @@ -85,9 +85,6 @@ "cannot_give": "Unable to give %s %s to the target", "evidence_cannot_take": "You are not authorised to withdraw evidence", "dumpster": "Dumpster", - "crafting_item": "Crafting %s", - "crafting_bench": "Crafting Bench", - "open_crafting_bench": "Open Crafting Bench", "not_enough_durability": "%s does not have enough durability", "storage": "Storage" } diff --git a/server-data/resources/[ox]/ox_inventory/locales/es.json b/server-data/resources/[ox]/ox_inventory/locales/es.json index e3093681f..2a0077b5a 100644 --- a/server-data/resources/[ox]/ox_inventory/locales/es.json +++ b/server-data/resources/[ox]/ox_inventory/locales/es.json @@ -84,9 +84,6 @@ "cannot_give": "No se puede dar %s %s al objetivo", "evidence_cannot_take": "No estás autorizado a retirar pruebas", "dumpster": "Contenedor de basura", - "crafting_item": "Creando %s", - "crafting_bench": "Banco de trabajo", - "open_crafting_bench": "Abrir banco de trabajo", "not_enough_durability": "%s no tiene suficiente durabilidad", - "storage": "Maletero", + "storage": "Maletero" } diff --git a/server-data/resources/[ox]/ox_inventory/locales/et.json b/server-data/resources/[ox]/ox_inventory/locales/et.json index 92823e345..119ac24f4 100644 --- a/server-data/resources/[ox]/ox_inventory/locales/et.json +++ b/server-data/resources/[ox]/ox_inventory/locales/et.json @@ -85,9 +85,6 @@ "cannot_give": "%s %s ei saa antud isikule anda", "evidence_cannot_take": "Pole piisavalt kõrge auaste, et tõendeid võtta", "dumpster": "Prügikast", - "crafting_item": "Meisterdamine %s", - "crafting_bench": "Meisterdamispink", - "open_crafting_bench": "Ava meisterdamispink", "not_enough_durability": "Esemel %s pole piisavalt vastupidavust", "storage": "Hoidla" } \ No newline at end of file diff --git a/server-data/resources/[ox]/ox_inventory/locales/fi.json b/server-data/resources/[ox]/ox_inventory/locales/fi.json index 2b197a199..8db62bb36 100644 --- a/server-data/resources/[ox]/ox_inventory/locales/fi.json +++ b/server-data/resources/[ox]/ox_inventory/locales/fi.json @@ -85,8 +85,5 @@ "cannot_give": "Ei voida antaa %s %s kohteelle", "evidence_cannot_take": "Et ole tarpeeksi korkea-arvoinen, että voisit ottaa tavaraa todistusaineista", "dumpster": "Roskis", - "crafting_item": "Valmistetaan %s", - "crafting_bench": "Työkalupenkki", - "open_crafting_bench": "Avaa työkalupenkki", "not_enough_durability": "%s on liian huonossa kunnossa" } diff --git a/server-data/resources/[ox]/ox_inventory/locales/fr.json b/server-data/resources/[ox]/ox_inventory/locales/fr.json index 7469d2f6b..53583bcf0 100644 --- a/server-data/resources/[ox]/ox_inventory/locales/fr.json +++ b/server-data/resources/[ox]/ox_inventory/locales/fr.json @@ -85,8 +85,5 @@ "cannot_give": "Impossible de donner %s %s à cet inventaire", "evidence_cannot_take": "Votre grade ne vous permet pas de récupérer des preuves", "dumpster": "Poubelle", - "crafting_item": "Fabrication %s", - "crafting_bench": "Table de fabrication", - "open_crafting_bench": "Ouvrir la table de fabrication", "not_enough_durability": "%s n'a pas assez de durabilité" } diff --git a/server-data/resources/[ox]/ox_inventory/locales/hu.json b/server-data/resources/[ox]/ox_inventory/locales/hu.json index 67e78bb2f..b74b22ce8 100644 --- a/server-data/resources/[ox]/ox_inventory/locales/hu.json +++ b/server-data/resources/[ox]/ox_inventory/locales/hu.json @@ -85,9 +85,6 @@ "cannot_give": "%s %s nem adható meg a célnak", "evidence_cannot_take": "Nem elég magas a rangod a bizonyítékok kezeléséhez", "dumpster": "Szemetes", - "crafting_item": "%s barkácsolása ", - "crafting_bench": "Barkácsasztal", - "open_crafting_bench": "Barkácsasztal megnyitása", "not_enough_durability": "%s elhasználodott!", "storage": "Tároló" } diff --git a/server-data/resources/[ox]/ox_inventory/locales/id.json b/server-data/resources/[ox]/ox_inventory/locales/id.json index 9ac4f3a03..ae665ff9c 100644 --- a/server-data/resources/[ox]/ox_inventory/locales/id.json +++ b/server-data/resources/[ox]/ox_inventory/locales/id.json @@ -82,7 +82,5 @@ "cannot_give": "Tidak dapat memberikan %s %s ke target", "evidence_cannot_take": "Anda tidak berwenang untuk mengambil barang bukti", "dumpster": "Tempat Sampah", - "crafting_item": "Membuat %s", - "crafting_bench": "Bangku Kerajinan", "not_enough_durability": "%s tidak memiliki daya tahan yang cukup" } diff --git a/server-data/resources/[ox]/ox_inventory/locales/it.json b/server-data/resources/[ox]/ox_inventory/locales/it.json index 6897ee2dd..ad10ebbb7 100644 --- a/server-data/resources/[ox]/ox_inventory/locales/it.json +++ b/server-data/resources/[ox]/ox_inventory/locales/it.json @@ -82,7 +82,5 @@ "cannot_give": "Impossibile dare %s %s al giocatore selezionato", "evidence_cannot_take": "Il tuo grado non può prendere oggetti dal deposito", "dumpster": "Cassonetto", - "crafting_item": "Craftando %s", - "crafting_bench": "Banco da lavoro", "not_enough_durability": "%s non ha abbastanza durabilità" } diff --git a/server-data/resources/[ox]/ox_inventory/locales/lt.json b/server-data/resources/[ox]/ox_inventory/locales/lt.json index 140cd27a1..e7c60cf5d 100644 --- a/server-data/resources/[ox]/ox_inventory/locales/lt.json +++ b/server-data/resources/[ox]/ox_inventory/locales/lt.json @@ -84,8 +84,5 @@ "cannot_give": "Nepavyko paduoti %s %s", "evidence_cannot_take": "Negalite paimti įkalčių", "dumpster": "Konteineris", -"crafting_item": "Gaminti %s", -"crafting_bench": "Gamybos stalas", -"open_crafting_bench": "Atidaryti Gamybos stalą", "not_enough_durability": "%s nėra pakankamai patvarus" } diff --git a/server-data/resources/[ox]/ox_inventory/locales/nl.json b/server-data/resources/[ox]/ox_inventory/locales/nl.json index e6fb57bc5..03e8ca5db 100644 --- a/server-data/resources/[ox]/ox_inventory/locales/nl.json +++ b/server-data/resources/[ox]/ox_inventory/locales/nl.json @@ -82,8 +82,5 @@ "cannot_give": "Niet in staat om %s %s te geven aan het doel", "evidence_cannot_take": "Je rang is niet hoog genoeg om van de bewijskluis te pakken", "dumpster": "Afvalcontainer", - "crafting_item": "%s aan het maken", - "crafting_bench": "Werkbank", - "open_crafting_bench": "Open Werkbank", "not_enough_durability": "%s heeft niet genoeg levensduur." } diff --git a/server-data/resources/[ox]/ox_inventory/locales/no.json b/server-data/resources/[ox]/ox_inventory/locales/no.json index 0e6ff1f07..33a964574 100644 --- a/server-data/resources/[ox]/ox_inventory/locales/no.json +++ b/server-data/resources/[ox]/ox_inventory/locales/no.json @@ -1,93 +1,89 @@ { - "ui_use": "Bruk", - "ui_give": "Gi", - "ui_close": "Lukk", - "ui_drop": "Slipp", - "ui_removeattachments": "Fjern vedlegg", - "ui_copy": "Kopier serienummer", - "ui_durability": "Holdbarhet", - "ui_ammo": "Ammunisjon", - "ui_serial": "Serienummer", - "ui_components": "Komponenter", - "ui_tint": "Fargetone", - "ui_usefulcontrols": "Nyttige kontroller", - "ui_rmb": "Åpne elementkontekstmeny", - "ui_ctrl_lmb": "Flytt en stabel med elementer raskt til en annen inventar", - "ui_shift_drag": "Del antall elementer i to", - "ui_ctrl_shift_lmb": "Flytt halvparten av en stabel med elementer raskt til en annen inventar", - "ui_alt_lmb": "Bruk et element raskt", - "ui_ctrl_c": "Når du svever over et våpen, kopierer du serienummeret", - "ui_remove_ammo": "Fjern ammunisjon", - "ammo_type": "Ammunisjonstype", - "$": "$", - "male": "Mann", - "female": "Kvinne", - "used": "Brukt", - "ui_removed": "Fjernet", - "ui_added": " Lagt til", - "ui_holstered": "Lagt tilbake", - "ui_equipped": "Utstyrt", - "using": "Bruker %s", - "inventory_setup": "Inventar er klart til bruk", - "inventory_player_access": "Du kan ikke åpne inventaret ditt akkurat nå", - "inventory_right_access": "Du har ikke tilgang til å åpne dette inventaret", - "inventory_lost_access": "Kan ikke lenger få tilgang til dette inventaret", - "wrong_ammo": "Du kan ikke lade %s med %s ammunisjon", - "license": "%s lisens", - "already_have": "Du har allerede en %s", - "have_purchased": "Du har kjøpt en %s", - "can_not_afford": "Du har ikke råd til en %s", - "purchase_license": "Kjøp en %s-lisens", - "interact_prompt": "Interager med [%s]", - "weapon_unregistered": "%s er ikke registrert til noen", - "weapon_registered": "%s (%s) er registrert til %s", - "weapon_broken": "Dette våpenet er ødelagt", - "vehicle_locked": "Kjøretøyet er låst", - "nobody_nearby": "Det er ingen i nærheten", - "give_amount": "Du må angi et beløp å gi", - "buy_amount": "Du må angi et beløp å kjøpe", - "component_has": "Dette våpenet har allerede en %s", - "component_invalid": "Dette våpenet er ikke kompatibelt med %s", - "component_slot_occupied": "Dette våpenets %s-plass er allerede opptatt", - "cannot_perform": "Du kan ikke utføre denne handlingen", - "cannot_carry": "Du kan ikke bære så mye", - "cannot_carry_other": "Mål-inventaret kan ikke holde så mye", - "cannot_carry_limit": "Du kan ikke bære mer enn %s %s", - "cannot_carry_limit_other": "Målet kan ikke bære mer enn %s %s", - "items_confiscated": "Dine gjenstander har blitt konfiskert", - "items_returned": "Dine gjenstander har blitt returnert", - "item_unauthorised": "Du har ikke tillatelse til å kjøpe denne gjenstanden", - "item_unlicensed": "Du har ikke lisens til å kjøpe denne gjenstanden", - "item_not_enough": "Du har ikke nok %s", - "cannot_afford": "Du har ikke råd til det (mangler %s)", - "stash_lowgrade": "Du har ikke tillatelse til å ta denne gjenstanden", - "cannot_use": "Kan ikke bruke %s", - "shop_nostock": "Gjenstanden er utsolgt", - "identification": "Kjønn: %s \nFødselsdato: %s", - "search_dumpster": "Søk i søppelkassen", - "open_label": "Åpne %s", - "purchased_for": "Kjøpt %s %s for %s%s", - "unable_stack_items": "Du kan ikke stable disse gjenstandene", - "police_evidence": "Bevis lager", - "open_police_evidence": "Åpne bevis lager", - "open_stash": "Åpne lager", - "locker_number": "Låsenummer", - "locker_no_value": "Må inneholde verdi for å åpne låsen", - "locker_must_number": "Låsen må være et tall", - "weapon_hand_required": "Du må ha et våpen i hånden", - "weapon_hand_wrong": "Feil våpen i hånden", - "open_player_inventory": "Åpne spillers inventar~", - "open_secondary_inventory": "Åpne sekundært inventar~", - "disable_hotbar": "Vis inventar-hotbar~", - "reload_weapon": "Lad våpenet~", - "use_hotbar": "Bruk hotbar-objekt %s~", - "no_durability": "%s holdbarhet er brukt opp", - "cannot_give": "Kan ikke gi %s %s til målet", - "evidence_cannot_take": "Du er ikke autorisert til å trekke ut bevis", - "dumpster": "Søppelkasse", - "crafting_item": "Lager %s", - "crafting_bench": "Lagebenk", - "open_crafting_bench": "Åpne lagebenk", - "not_enough_durability": "%s har ikke nok holdbarhet" - } - \ No newline at end of file + "ui_use": "Bruk", + "ui_give": "Gi", + "ui_close": "Lukk", + "ui_drop": "Slipp", + "ui_removeattachments": "Fjern vedlegg", + "ui_copy": "Kopier serienummer", + "ui_durability": "Holdbarhet", + "ui_ammo": "Ammunisjon", + "ui_serial": "Serienummer", + "ui_components": "Komponenter", + "ui_tint": "Fargetone", + "ui_usefulcontrols": "Nyttige kontroller", + "ui_rmb": "Åpne elementkontekstmeny", + "ui_ctrl_lmb": "Flytt en stabel med elementer raskt til en annen inventar", + "ui_shift_drag": "Del antall elementer i to", + "ui_ctrl_shift_lmb": "Flytt halvparten av en stabel med elementer raskt til en annen inventar", + "ui_alt_lmb": "Bruk et element raskt", + "ui_ctrl_c": "Når du svever over et våpen, kopierer du serienummeret", + "ui_remove_ammo": "Fjern ammunisjon", + "ammo_type": "Ammunisjonstype", + "$": "$", + "male": "Mann", + "female": "Kvinne", + "used": "Brukt", + "ui_removed": "Fjernet", + "ui_added": " Lagt til", + "ui_holstered": "Lagt tilbake", + "ui_equipped": "Utstyrt", + "using": "Bruker %s", + "inventory_setup": "Inventar er klart til bruk", + "inventory_player_access": "Du kan ikke åpne inventaret ditt akkurat nå", + "inventory_right_access": "Du har ikke tilgang til å åpne dette inventaret", + "inventory_lost_access": "Kan ikke lenger få tilgang til dette inventaret", + "wrong_ammo": "Du kan ikke lade %s med %s ammunisjon", + "license": "%s lisens", + "already_have": "Du har allerede en %s", + "have_purchased": "Du har kjøpt en %s", + "can_not_afford": "Du har ikke råd til en %s", + "purchase_license": "Kjøp en %s-lisens", + "interact_prompt": "Interager med [%s]", + "weapon_unregistered": "%s er ikke registrert til noen", + "weapon_registered": "%s (%s) er registrert til %s", + "weapon_broken": "Dette våpenet er ødelagt", + "vehicle_locked": "Kjøretøyet er låst", + "nobody_nearby": "Det er ingen i nærheten", + "give_amount": "Du må angi et beløp å gi", + "buy_amount": "Du må angi et beløp å kjøpe", + "component_has": "Dette våpenet har allerede en %s", + "component_invalid": "Dette våpenet er ikke kompatibelt med %s", + "component_slot_occupied": "Dette våpenets %s-plass er allerede opptatt", + "cannot_perform": "Du kan ikke utføre denne handlingen", + "cannot_carry": "Du kan ikke bære så mye", + "cannot_carry_other": "Mål-inventaret kan ikke holde så mye", + "cannot_carry_limit": "Du kan ikke bære mer enn %s %s", + "cannot_carry_limit_other": "Målet kan ikke bære mer enn %s %s", + "items_confiscated": "Dine gjenstander har blitt konfiskert", + "items_returned": "Dine gjenstander har blitt returnert", + "item_unauthorised": "Du har ikke tillatelse til å kjøpe denne gjenstanden", + "item_unlicensed": "Du har ikke lisens til å kjøpe denne gjenstanden", + "item_not_enough": "Du har ikke nok %s", + "cannot_afford": "Du har ikke råd til det (mangler %s)", + "stash_lowgrade": "Du har ikke tillatelse til å ta denne gjenstanden", + "cannot_use": "Kan ikke bruke %s", + "shop_nostock": "Gjenstanden er utsolgt", + "identification": "Kjønn: %s \nFødselsdato: %s", + "search_dumpster": "Søk i søppelkassen", + "open_label": "Åpne %s", + "purchased_for": "Kjøpt %s %s for %s%s", + "unable_stack_items": "Du kan ikke stable disse gjenstandene", + "police_evidence": "Bevis lager", + "open_police_evidence": "Åpne bevis lager", + "open_stash": "Åpne lager", + "locker_number": "Låsenummer", + "locker_no_value": "Må inneholde verdi for å åpne låsen", + "locker_must_number": "Låsen må være et tall", + "weapon_hand_required": "Du må ha et våpen i hånden", + "weapon_hand_wrong": "Feil våpen i hånden", + "open_player_inventory": "Åpne spillers inventar~", + "open_secondary_inventory": "Åpne sekundært inventar~", + "disable_hotbar": "Vis inventar-hotbar~", + "reload_weapon": "Lad våpenet~", + "use_hotbar": "Bruk hotbar-objekt %s~", + "no_durability": "%s holdbarhet er brukt opp", + "cannot_give": "Kan ikke gi %s %s til målet", + "evidence_cannot_take": "Du er ikke autorisert til å trekke ut bevis", + "dumpster": "Søppelkasse", + "not_enough_durability": "%s har ikke nok holdbarhet" +} \ No newline at end of file diff --git a/server-data/resources/[ox]/ox_inventory/locales/pl.json b/server-data/resources/[ox]/ox_inventory/locales/pl.json index 2bbccddac..e6c2ba4e1 100644 --- a/server-data/resources/[ox]/ox_inventory/locales/pl.json +++ b/server-data/resources/[ox]/ox_inventory/locales/pl.json @@ -85,9 +85,6 @@ "cannot_give": "Nie można przekazać %s %s", "evidence_cannot_take": "Nie posiadasz autoryzacji do zabrania dowodu", "dumpster": "Śmietnik", - "crafting_item": "Wytwórz %s", - "crafting_bench": "Stół do wytwarzania", - "open_crafting_bench": "Otwórz stół do wytwarzania", "not_enough_durability": "%s nie posiada wystarczająco wytrzymałości", "storage": "Magazyn" } diff --git a/server-data/resources/[ox]/ox_inventory/locales/pt.json b/server-data/resources/[ox]/ox_inventory/locales/pt.json index 0cf66e344..08e2dca4b 100644 --- a/server-data/resources/[ox]/ox_inventory/locales/pt.json +++ b/server-data/resources/[ox]/ox_inventory/locales/pt.json @@ -85,9 +85,6 @@ "cannot_give": "Não foi possível dar %s %s ao alvo", "evidence_cannot_take": "Não estás autorizado(a) a retirar provas", "dumpster": "Contentor de Lixo", - "crafting_item": "A fabricar %s", - "crafting_bench": "Bancada de Fabrico", - "open_crafting_bench": "Abrir Bancada de Fabrico", "not_enough_durability": "%s não tem durabilidade suficiente", "storage": "Armazenamento" } diff --git a/server-data/resources/[ox]/ox_inventory/locales/sr.json b/server-data/resources/[ox]/ox_inventory/locales/sr.json index cca9e20b2..31c383d71 100644 --- a/server-data/resources/[ox]/ox_inventory/locales/sr.json +++ b/server-data/resources/[ox]/ox_inventory/locales/sr.json @@ -86,8 +86,5 @@ "cannot_give": "Nemoguce dati %s %s osobi", "evidence_cannot_take": "Niste autorizovani da uzmete dokaz", "dumpster": "Kontejner", - "crafting_item": "Kraftovanje %s", - "crafting_bench": "Sto za Kraftovanje", - "open_crafting_bench": "Otvori sto za kraftovanje", "not_enough_durability": "%s nema dovoljno izdrzljivosti" } diff --git a/server-data/resources/[ox]/ox_inventory/locales/tr.json b/server-data/resources/[ox]/ox_inventory/locales/tr.json index 480ab86e7..f28642c40 100644 --- a/server-data/resources/[ox]/ox_inventory/locales/tr.json +++ b/server-data/resources/[ox]/ox_inventory/locales/tr.json @@ -85,8 +85,5 @@ "cannot_give": "Hedefe %s %s verilmedi", "evidence_cannot_take": "Kanıtlara erişebilmek için yeterli rütbede değilsiniz", "dumpster": "Çöplük", - "crafting_item": "Üretiliyor %s", - "crafting_bench": "Üretim Tezgahı", - "open_crafting_bench": "Üretim Tezgahını Aç", "not_enough_durability": "%s Yeterli dayanıklılığa sahip değil" } diff --git a/server-data/resources/[ox]/ox_inventory/locales/zh-cn.json b/server-data/resources/[ox]/ox_inventory/locales/zh-cn.json index f1c88c0a2..0db6e829a 100644 --- a/server-data/resources/[ox]/ox_inventory/locales/zh-cn.json +++ b/server-data/resources/[ox]/ox_inventory/locales/zh-cn.json @@ -85,9 +85,6 @@ "cannot_give": "无法将 %s %s 交给目标", "evidence_cannot_take": "您无权撤回证据", "dumpster": "垃圾箱", - "crafting_item": "制作 %s", - "crafting_bench": "工作台", - "open_crafting_bench": "打开工作台", "not_enough_durability": "%s 没有足够的耐久度", "storage": "储物柜" } \ No newline at end of file diff --git a/server-data/resources/[ox]/ox_inventory/locales/zh-tw.json b/server-data/resources/[ox]/ox_inventory/locales/zh-tw.json index bbe58060f..e11dcf023 100644 --- a/server-data/resources/[ox]/ox_inventory/locales/zh-tw.json +++ b/server-data/resources/[ox]/ox_inventory/locales/zh-tw.json @@ -85,9 +85,6 @@ "cannot_give": "無法將 %s %s 給予目標 ", "evidence_cannot_take": "階級不夠,無法拿取證物", "dumpster": "垃圾桶", - "crafting_item": "製作 %s", - "crafting_bench": "工作台", - "open_crafting_bench": "打開工作台", "not_enough_durability": "%s 沒有足夠的耐久度", "storage": "儲櫃" } diff --git a/server-data/resources/[ox]/ox_inventory/modules/crafting/client.lua b/server-data/resources/[ox]/ox_inventory/modules/crafting/client.lua deleted file mode 100644 index ea3793ee9..000000000 --- a/server-data/resources/[ox]/ox_inventory/modules/crafting/client.lua +++ /dev/null @@ -1,103 +0,0 @@ -if not lib then - return -end - -local CraftingBenches = {} -local Items = require("modules.items.client") -local createBlip = require("modules.utils.client").CreateBlip -local Utils = require("modules.utils.client") -local markerColour = { 150, 150, 30 } -local prompt = { - options = { icon = "fa-wrench" }, - message = ("**%s** \n%s"):format(locale("open_crafting_bench"), locale("interact_prompt", GetControlInstructionalButton(0, 38, true):sub(3))), -} - ----@param id number ----@param data table -local function createCraftingBench(id, data) - CraftingBenches[id] = {} - local recipes = data.items - - if recipes then - data.slots = #recipes - - for i = 1, data.slots do - local recipe = recipes[i] - local item = Items[recipe.name] - - if item then - recipe.weight = item.weight - recipe.slot = i - else - warn(('failed to setup crafting recipe (bench: %s, slot: %s) - item "%s" does not exist'):format(id, i, recipe.name)) - end - end - - local blip = data.blip - - if blip then - blip.name = blip.name or ("ox_crafting_%s"):format(data.label and id or 0) - AddTextEntry(blip.name, data.label or locale("crafting_bench")) - end - - if shared.target then - data.points = nil - if data.zones then - for i = 1, #data.zones do - local zone = data.zones[i] - zone.name = ("craftingbench_%s:%s"):format(id, i) - zone.id = id - zone.index = i - zone.options = { - { - label = zone.label or locale("open_crafting_bench"), - canInteract = data.groups and function() - return client.hasGroup(data.groups) - end or nil, - onSelect = function() - client.openInventory("crafting", { id = id, index = i }) - end, - distance = zone.distance or 2.0, - icon = zone.icon or "fas fa-wrench", - }, - } - - exports.ox_target:addBoxZone(zone) - - if blip then - createBlip(blip, zone.coords) - end - end - end - elseif data.points then - data.zones = nil - - for i = 1, #data.points do - local coords = data.points[i] - - lib.points.new({ - coords = coords, - distance = 16, - benchid = id, - index = i, - inv = "crafting", - prompt = prompt, - marker = markerColour, - nearby = Utils.nearbyMarker, - }) - - if blip then - createBlip(blip, coords) - end - end - end - - CraftingBenches[id] = data - end -end - -for id, data in pairs(lib.load("data.crafting")) do - createCraftingBench(id, data) -end - -return CraftingBenches diff --git a/server-data/resources/[ox]/ox_inventory/modules/crafting/server.lua b/server-data/resources/[ox]/ox_inventory/modules/crafting/server.lua deleted file mode 100644 index f0cbb9249..000000000 --- a/server-data/resources/[ox]/ox_inventory/modules/crafting/server.lua +++ /dev/null @@ -1,230 +0,0 @@ -if not lib then return end - -local CraftingBenches = {} -local Items = require 'modules.items.server' -local Inventory = require 'modules.inventory.server' - ----@param id number ----@param data table -local function createCraftingBench(id, data) - CraftingBenches[id] = {} - local recipes = data.items - - if recipes then - for i = 1, #recipes do - local recipe = recipes[i] - local item = Items(recipe.name) - - if item then - recipe.weight = item.weight - recipe.slot = i - else - warn(('failed to setup crafting recipe (bench: %s, slot: %s) - item "%s" does not exist'):format(id, i, recipe.name)) - end - - for ingredient, needs in pairs(recipe.ingredients) do - if needs < 1 then - item = Items(ingredient) - - if item and not item.durability then - item.durability = true - end - end - end - end - - if shared.target then - data.points = nil - else - data.zones = nil - end - - CraftingBenches[id] = data - end -end - -for id, data in pairs(lib.load('data.crafting')) do createCraftingBench(id, data) end - ----falls back to player coords if zones and points are both nil ----@param source number ----@param bench table ----@param index number ----@return vector3 -local function getCraftingCoords(source, bench, index) - if not bench.zones and not bench.points then - return GetEntityCoords(GetPlayerPed(source)) - else - return shared.target and bench.zones[index].coords or bench.points[index] - end -end - -lib.callback.register('ox_inventory:openCraftingBench', function(source, id, index) - local left, bench = Inventory(source), CraftingBenches[id] - - if not left then return end - - if bench then - local groups = bench.groups - local coords = getCraftingCoords(source, bench, index) - - if not coords then return end - - if groups and not server.hasGroup(left, groups) then return end - if #(GetEntityCoords(GetPlayerPed(source)) - coords) > 10 then return end - - if left.open and left.open ~= source then - local inv = Inventory(left.open) --[[@as OxInventory]] - - -- Why would the player inventory open with an invalid target? Can't repro but whatever. - if inv?.player then - inv:closeInventory() - end - end - - left:openInventory(left) - end - - return { label = left.label, type = left.type, slots = left.slots, weight = left.weight, maxWeight = left.maxWeight } -end) - -local TriggerEventHooks = require 'modules.hooks.server' - -lib.callback.register('ox_inventory:craftItem', function(source, id, index, recipeId, toSlot) - local left, bench = Inventory(source), CraftingBenches[id] - - if not left then return end - - if bench then - local groups = bench.groups - local coords = getCraftingCoords(source, bench, index) - - if groups and not server.hasGroup(left, groups) then return end - if #(GetEntityCoords(GetPlayerPed(source)) - coords) > 10 then return end - - local recipe = bench.items[recipeId] - - if recipe then - local tbl, num = {}, 0 - - for name in pairs(recipe.ingredients) do - num += 1 - tbl[num] = name - end - - local craftedItem = Items(recipe.name) - local craftCount = (type(recipe.count) == 'number' and recipe.count) or (table.type(recipe.count) == 'array' and math.random(recipe.count[1], recipe.count[2])) or 1 - local newWeight = left.weight + (craftedItem.weight + (recipe.metadata?.weight or 0)) * craftCount - ---@todo new iterator or something to accept a map - local items = Inventory.Search(left, 'slots', tbl) or {} - table.wipe(tbl) - - for name, needs in pairs(recipe.ingredients) do - local slots = items[name] or items - - for i = 1, #slots do - local slot = slots[i] - - if needs == 0 then - if not slot.metadata.durability or slot.metadata.durability > 0 then - break - end - elseif needs < 1 then - local item = Items(name) - local durability = slot.metadata.durability - - if durability and durability >= needs * 100 then - if durability > 100 then - local degrade = (slot.metadata.degrade or item.degrade) * 60 - local percentage = ((durability - os.time()) * 100) / degrade - - if percentage >= needs * 100 then - tbl[slot.slot] = needs - break - end - else - tbl[slot.slot] = needs - break - end - end - elseif needs <= slot.count then - local itemWeight = slot.weight / slot.count - newWeight = (newWeight - slot.weight) + (slot.count - needs) * itemWeight - tbl[slot.slot] = needs - break - else - tbl[slot.slot] = slot.count - newWeight -= slot.weight - needs -= slot.count - end - - if needs == 0 then break end - -- Player does not have enough items (ui should prevent crafting if lacking items, so this shouldn't trigger) - if needs > 0 and i == #slots then return end - end - end - - if newWeight > left.maxWeight then - return false, 'cannot_carry' - end - - if not TriggerEventHooks('craftItem', { - source = source, - benchId = id, - benchIndex = index, - recipe = recipe, - toInventory = left.id, - toSlot = toSlot, - }) then return false end - - local success = lib.callback.await('ox_inventory:startCrafting', source, id, recipeId) - - if success then - for name, needs in pairs(recipe.ingredients) do - if Inventory.GetItemCount(left, name) < needs then return end - end - - for slot, count in pairs(tbl) do - local invSlot = left.items[slot] - - if not invSlot then return end - - if count < 1 then - local item = Items(invSlot.name) - local durability = invSlot.metadata.durability or 100 - - if durability > 100 then - local degrade = (invSlot.metadata.degrade or item.degrade) * 60 - durability -= degrade * count - else - durability -= count * 100 - end - - if invSlot.count > 1 then - local emptySlot = Inventory.GetEmptySlot(left) - - if emptySlot then - local newItem = Inventory.SetSlot(left, item, 1, table.deepclone(invSlot.metadata), emptySlot) - - if newItem then - Items.UpdateDurability(left, newItem, item, durability < 0 and 0 or durability) - end - end - - invSlot.count -= 1 - else - Items.UpdateDurability(left, invSlot, item, durability < 0 and 0 or durability) - end - else - local removed = invSlot and Inventory.RemoveItem(left, invSlot.name, count, nil, slot) - -- Failed to remove item (inventory state unexpectedly changed?) - if not removed then return end - end - end - - Inventory.AddItem(left, craftedItem, craftCount, recipe.metadata or {}, craftedItem.stack and toSlot or nil) - end - - return success - end - end -end) diff --git a/server-data/resources/[ox]/ox_inventory/modules/utils/client.lua b/server-data/resources/[ox]/ox_inventory/modules/utils/client.lua index 3e7f031b9..8e15d05f8 100644 --- a/server-data/resources/[ox]/ox_inventory/modules/utils/client.lua +++ b/server-data/resources/[ox]/ox_inventory/modules/utils/client.lua @@ -220,8 +220,6 @@ function Utils.nearbyMarker(point) CreateThread(function() if point.inv == "policeevidence" then client.openInventory("policeevidence") - elseif point.inv == "crafting" then - client.openInventory("crafting", { id = point.benchid, index = point.index }) else client.openInventory(point.inv or "drop", { id = point.invId, type = point.type }) end diff --git a/server-data/resources/[ox]/ox_inventory/server.lua b/server-data/resources/[ox]/ox_inventory/server.lua index 00dc3e5b0..f470ad2b4 100644 --- a/server-data/resources/[ox]/ox_inventory/server.lua +++ b/server-data/resources/[ox]/ox_inventory/server.lua @@ -9,7 +9,6 @@ local db = require 'modules.mysql.server' local Items = require 'modules.items.server' local Inventory = require 'modules.inventory.server' -require 'modules.crafting.server' require 'modules.shops.server' require 'modules.pefcl.server' require 'modules.bridge.server' diff --git a/server-data/resources/[ox]/ox_inventory/web/build/assets/index-9aba2ab3.css b/server-data/resources/[ox]/ox_inventory/web/build/assets/index-9aba2ab3.css index b1ec75e8e..f7f40d176 100644 --- a/server-data/resources/[ox]/ox_inventory/web/build/assets/index-9aba2ab3.css +++ b/server-data/resources/[ox]/ox_inventory/web/build/assets/index-9aba2ab3.css @@ -408,21 +408,6 @@ button:active { font-weight: 400 } -.tooltip-crafting-duration { - display: flex; - flex-direction: row; - align-items: center; - justify-content: center -} - -.tooltip-crafting-duration svg { - padding-right: 3px -} - -.tooltip-crafting-duration p { - font-size: 14px -} - .tooltip-ingredients { padding-top: 5px } From a9fd5db9dc4a1ed254a7596bd45cbecd125fa1e9 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Tue, 30 Jul 2024 16:29:31 +0200 Subject: [PATCH 17/23] =?UTF-8?q?chore:=20=F0=9F=8E=A8=20Run=20formatter?= =?UTF-8?q?=20+=20=20replace=20=5FU=20with=20TranslateCap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../[esx]/esx_society/client/main.lua | 846 +++++++++--------- .../[esx]/esx_society/server/main.lua | 28 +- 2 files changed, 429 insertions(+), 445 deletions(-) diff --git a/server-data/resources/[esx]/esx_society/client/main.lua b/server-data/resources/[esx]/esx_society/client/main.lua index 3bbd79f8f..a5a9d61c9 100644 --- a/server-data/resources/[esx]/esx_society/client/main.lua +++ b/server-data/resources/[esx]/esx_society/client/main.lua @@ -1,483 +1,467 @@ RegisterNetEvent("esx:setJob") AddEventHandler("esx:setJob", function(job) - ESX.PlayerData.job = job - RefreshBussHUD() + ESX.PlayerData.job = job + RefreshBussHUD() end) RegisterNetEvent("esx:playerLoaded") AddEventHandler("esx:playerLoaded", function(xPlayer) - ESX.PlayerData = xPlayer - ESX.PlayerLoaded = true - RefreshBussHUD() + ESX.PlayerData = xPlayer + ESX.PlayerLoaded = true + RefreshBussHUD() end) function RefreshBussHUD() - DisableSocietyMoneyHUDElement() + DisableSocietyMoneyHUDElement() - if ESX.PlayerData.job.grade_name == "boss" then - EnableSocietyMoneyHUDElement() + if ESX.PlayerData.job.grade_name == "boss" then + EnableSocietyMoneyHUDElement() - ESX.TriggerServerCallback("esx_society:getSocietyMoney", function(money) - UpdateSocietyMoneyHUDElement(money) - end, ESX.PlayerData.job.name) - end + ESX.TriggerServerCallback("esx_society:getSocietyMoney", function(money) + UpdateSocietyMoneyHUDElement(money) + end, ESX.PlayerData.job.name) + end end RegisterNetEvent("bpt_addonaccount:setMoney") AddEventHandler("bpt_addonaccount:setMoney", function(society, money) - if - ESX.PlayerData.job - and ESX.PlayerData.job.grade_name == "boss" - and "society_" .. ESX.PlayerData.job.name == society - then - UpdateSocietyMoneyHUDElement(money) - end + if ESX.PlayerData.job and ESX.PlayerData.job.grade_name == "boss" and "society_" .. ESX.PlayerData.job.name == society then + UpdateSocietyMoneyHUDElement(money) + end end) function EnableSocietyMoneyHUDElement() - TriggerEvent("esx_society:toggleSocietyHud", true) + TriggerEvent("esx_society:toggleSocietyHud", true) end function DisableSocietyMoneyHUDElement() - TriggerEvent("esx_society:toggleSocietyHud", false) + TriggerEvent("esx_society:toggleSocietyHud", false) end function UpdateSocietyMoneyHUDElement(money) - TriggerEvent("esx_society:setSocietyMoney", money) + TriggerEvent("esx_society:setSocietyMoney", money) end function OpenBossMenu(society, _, options) - options = options or {} - local elements = { - { unselectable = true, icon = "fas fa-user", title = _U("boss_menu") }, - } - - ESX.TriggerServerCallback("esx_society:isBoss", function(isBoss) - if isBoss then - local defaultOptions = { - checkBal = true, - withdraw = true, - deposit = true, - wash = true, - employees = true, - salary = true, - grades = true, - } - - for k, v in pairs(defaultOptions) do - if options[k] == nil then - options[k] = v - end - end - - if options.checkBal then - elements[#elements + 1] = - { icon = "fas fa-wallet", title = _U("check_society_balance"), value = "check_society_balance" } - end - if options.withdraw then - elements[#elements + 1] = - { icon = "fas fa-wallet", title = _U("withdraw_society_money"), value = "withdraw_society_money" } - end - if options.deposit then - elements[#elements + 1] = - { icon = "fas fa-wallet", title = _U("deposit_society_money"), value = "deposit_money" } - end - if options.wash then - elements[#elements + 1] = { icon = "fas fa-wallet", title = _U("wash_money"), value = "wash_money" } - end - if options.employees then - elements[#elements + 1] = - { icon = "fas fa-users", title = _U("employee_management"), value = "manage_employees" } - end - if options.salary then - elements[#elements + 1] = - { icon = "fas fa-wallet", title = _U("salary_management"), value = "manage_salary" } - end - if options.grades then - elements[#elements + 1] = - { icon = "fas fa-scroll", title = _U("grade_management"), value = "manage_grades" } - end - - ESX.OpenContext("right", elements, function(menu, element) - if element.value == "check_society_balance" then - TriggerServerEvent("esx_society:checkSocietyBalance", society) - elseif element.value == "withdraw_society_money" then - local elements = { - { - unselectable = true, - icon = "fas fa-wallet", - title = _U("withdraw_amount"), - description = "Withdraw money from the society account", - }, - { - icon = "fas fa-wallet", - title = "Amount", - input = true, - inputType = "number", - inputPlaceholder = "Amount to withdraw..", - inputMin = 1, - inputMax = 250000, - name = "withdraw", - }, - { icon = "fas fa-check", title = "Confirm", value = "confirm" }, - { icon = "fas fa-arrow-left", title = "Return", value = "return" }, - } - ESX.RefreshContext(elements) - elseif element.value == "confirm" then - local amount = tonumber(menu.eles[2].inputValue) - if amount == nil then - ESX.ShowNotification(_U("invalid_amount")) - else - TriggerServerEvent("esx_society:withdrawMoney", society, amount) - ESX.CloseContext() - end - elseif element.value == "deposit_money" then - local elements = { - { - unselectable = true, - icon = "fas fa-wallet", - title = _U("deposit_amount"), - description = "Deposit some money into the society account", - }, - { - icon = "fas fa-wallet", - title = "Amount", - input = true, - inputType = "number", - inputPlaceholder = "Amount to deposit..", - inputMin = 1, - inputMax = 250000, - name = "deposit", - }, - { icon = "fas fa-check", title = "Confirm", value = "confirm2" }, - { icon = "fas fa-arrow-left", title = "Return", value = "return" }, - } - ESX.RefreshContext(elements) - elseif element.value == "confirm2" then - local amount = tonumber(menu.eles[2].inputValue) - if amount == nil then - ESX.ShowNotification(_U("invalid_amount")) - else - TriggerServerEvent("esx_society:depositMoney", society, amount) - ESX.CloseContext() - end - elseif element.value == "wash_money" then - local elements = { - { - unselectable = true, - icon = "fas fa-wallet", - title = _U("wash_money_amount"), - description = "Deposit some money into the money wash", - }, - { - icon = "fas fa-wallet", - title = "Amount", - input = true, - inputType = "number", - inputPlaceholder = "Amount to wash..", - inputMin = 1, - inputMax = 250000, - name = "wash", - }, - { icon = "fas fa-check", title = "Confirm", value = "confirm3" }, - { icon = "fas fa-arrow-left", title = "Return", value = "return" }, - } - ESX.RefreshContext(elements) - elseif element.value == "confirm3" then - local amount = tonumber(menu.eles[2].inputValue) - if amount == nil then - ESX.ShowNotification(_U("invalid_amount")) - else - TriggerServerEvent("esx_society:washMoney", society, amount) - ESX.CloseContext() - end - elseif element.value == "manage_employees" then - OpenManageEmployeesMenu(society, options) - elseif element.value == "manage_salary" then - OpenManageSalaryMenu(society, options) - elseif element.value == "manage_grades" then - OpenManageGradesMenu(society, options) - elseif element.value == "return" then - OpenBossMenu(society, nil, options) - end - end) - end - end, society) + options = options or {} + local elements = { + { unselectable = true, icon = "fas fa-user", title = TranslateCap("boss_menu") }, + } + + ESX.TriggerServerCallback("esx_society:isBoss", function(isBoss) + if isBoss then + local defaultOptions = { + checkBal = true, + withdraw = true, + deposit = true, + wash = true, + employees = true, + salary = true, + grades = true, + } + + for k, v in pairs(defaultOptions) do + if options[k] == nil then + options[k] = v + end + end + + if options.checkBal then + elements[#elements + 1] = { icon = "fas fa-wallet", title = TranslateCap("check_society_balance"), value = "check_society_balance" } + end + if options.withdraw then + elements[#elements + 1] = { icon = "fas fa-wallet", title = TranslateCap("withdraw_society_money"), value = "withdraw_society_money" } + end + if options.deposit then + elements[#elements + 1] = { icon = "fas fa-wallet", title = TranslateCap("deposit_society_money"), value = "deposit_money" } + end + if options.wash then + elements[#elements + 1] = { icon = "fas fa-wallet", title = TranslateCap("wash_money"), value = "wash_money" } + end + if options.employees then + elements[#elements + 1] = { icon = "fas fa-users", title = TranslateCap("employee_management"), value = "manage_employees" } + end + if options.salary then + elements[#elements + 1] = { icon = "fas fa-wallet", title = TranslateCap("salary_management"), value = "manage_salary" } + end + if options.grades then + elements[#elements + 1] = { icon = "fas fa-scroll", title = TranslateCap("grade_management"), value = "manage_grades" } + end + + ESX.OpenContext("right", elements, function(menu, element) + if element.value == "check_society_balance" then + TriggerServerEvent("esx_society:checkSocietyBalance", society) + elseif element.value == "withdraw_society_money" then + local elements = { + { + unselectable = true, + icon = "fas fa-wallet", + title = TranslateCap("withdraw_amount"), + description = "Withdraw money from the society account", + }, + { + icon = "fas fa-wallet", + title = "Amount", + input = true, + inputType = "number", + inputPlaceholder = "Amount to withdraw..", + inputMin = 1, + inputMax = 250000, + name = "withdraw", + }, + { icon = "fas fa-check", title = "Confirm", value = "confirm" }, + { icon = "fas fa-arrow-left", title = "Return", value = "return" }, + } + ESX.RefreshContext(elements) + elseif element.value == "confirm" then + local amount = tonumber(menu.eles[2].inputValue) + if amount == nil then + ESX.ShowNotification(TranslateCap("invalid_amount")) + else + TriggerServerEvent("esx_society:withdrawMoney", society, amount) + ESX.CloseContext() + end + elseif element.value == "deposit_money" then + local elements = { + { + unselectable = true, + icon = "fas fa-wallet", + title = TranslateCap("deposit_amount"), + description = "Deposit some money into the society account", + }, + { + icon = "fas fa-wallet", + title = "Amount", + input = true, + inputType = "number", + inputPlaceholder = "Amount to deposit..", + inputMin = 1, + inputMax = 250000, + name = "deposit", + }, + { icon = "fas fa-check", title = "Confirm", value = "confirm2" }, + { icon = "fas fa-arrow-left", title = "Return", value = "return" }, + } + ESX.RefreshContext(elements) + elseif element.value == "confirm2" then + local amount = tonumber(menu.eles[2].inputValue) + if amount == nil then + ESX.ShowNotification(TranslateCap("invalid_amount")) + else + TriggerServerEvent("esx_society:depositMoney", society, amount) + ESX.CloseContext() + end + elseif element.value == "wash_money" then + local elements = { + { + unselectable = true, + icon = "fas fa-wallet", + title = TranslateCap("wash_money_amount"), + description = "Deposit some money into the money wash", + }, + { + icon = "fas fa-wallet", + title = "Amount", + input = true, + inputType = "number", + inputPlaceholder = "Amount to wash..", + inputMin = 1, + inputMax = 250000, + name = "wash", + }, + { icon = "fas fa-check", title = "Confirm", value = "confirm3" }, + { icon = "fas fa-arrow-left", title = "Return", value = "return" }, + } + ESX.RefreshContext(elements) + elseif element.value == "confirm3" then + local amount = tonumber(menu.eles[2].inputValue) + if amount == nil then + ESX.ShowNotification(TranslateCap("invalid_amount")) + else + TriggerServerEvent("esx_society:washMoney", society, amount) + ESX.CloseContext() + end + elseif element.value == "manage_employees" then + OpenManageEmployeesMenu(society, options) + elseif element.value == "manage_salary" then + OpenManageSalaryMenu(society, options) + elseif element.value == "manage_grades" then + OpenManageGradesMenu(society, options) + elseif element.value == "return" then + OpenBossMenu(society, nil, options) + end + end) + end + end, society) end function OpenManageEmployeesMenu(society, options) - local elements = { - { unselectable = true, icon = "fas fa-users", title = _U("employee_management") }, - { icon = "fas fa-users", title = _U("employee_list"), value = "employee_list" }, - { icon = "fas fa-users", title = _U("recruit"), value = "recruit" }, - } - - elements[#elements + 1] = { icon = "fas fa-arrow-left", title = "Return", value = "return" } - - ESX.OpenContext("right", elements, function(_, element) - if element.value == "employee_list" then - OpenEmployeeList(society, options) - elseif element.value == "recruit" then - OpenRecruitMenu(society, options) - elseif element.value == "return" then - OpenBossMenu(society, nil, options) - end - end) + local elements = { + { unselectable = true, icon = "fas fa-users", title = TranslateCap("employee_management") }, + { icon = "fas fa-users", title = TranslateCap("employee_list"), value = "employee_list" }, + { icon = "fas fa-users", title = TranslateCap("recruit"), value = "recruit" }, + } + + elements[#elements + 1] = { icon = "fas fa-arrow-left", title = "Return", value = "return" } + + ESX.OpenContext("right", elements, function(_, element) + if element.value == "employee_list" then + OpenEmployeeList(society, options) + elseif element.value == "recruit" then + OpenRecruitMenu(society, options) + elseif element.value == "return" then + OpenBossMenu(society, nil, options) + end + end) end function OpenEmployeeList(society, options) - ESX.TriggerServerCallback("esx_society:getEmployees", function(employees) - local elements = { - { unselectable = true, icon = "fas fa-user", title = "Employees" }, - } - - for i = 1, #employees, 1 do - local gradeLabel = ( - employees[i].job.grade_label == "" and employees[i].job.label or employees[i].job.grade_label - ) - - elements[#elements + 1] = { - icon = "fas fa-user", - title = employees[i].name .. " | " .. gradeLabel, - gradeLabel = gradeLabel, - data = employees[i], - } - end - - elements[#elements + 1] = { icon = "fas fa-arrow-left", title = "Return", value = "return" } - - ESX.OpenContext("right", elements, function(_, element) - if element.value == "return" then - OpenManageEmployeesMenu(society, options) - else - local elements2 = { - { unselectable = true, icon = "fas fa-user", title = element.title }, - { icon = "fas fa-user", title = "Promote", value = "promote" }, - { icon = "fas fa-user", title = "Fire", value = "fire" }, - { icon = "fas fa-arrow-left", title = "Return", value = "return" }, - } - ESX.OpenContext("right", elements2, function(_, element2) - local employee = element.data - if element2.value == "promote" then - ESX.CloseContext() - OpenPromoteMenu(society, employee, options) - elseif element2.value == "fire" then - ESX.ShowNotification(_U("you_have_fired", employee.name)) - - ESX.TriggerServerCallback("esx_society:setJob", function() - OpenEmployeeList(society, options) - end, employee.identifier, "unemployed", 0, "fire") - elseif element2.value == "return" then - OpenEmployeeList(society, options) - end - end) - end - end) - end, society) + ESX.TriggerServerCallback("esx_society:getEmployees", function(employees) + local elements = { + { unselectable = true, icon = "fas fa-user", title = "Employees" }, + } + + for i = 1, #employees, 1 do + local gradeLabel = (employees[i].job.grade_label == "" and employees[i].job.label or employees[i].job.grade_label) + + elements[#elements + 1] = { + icon = "fas fa-user", + title = employees[i].name .. " | " .. gradeLabel, + gradeLabel = gradeLabel, + data = employees[i], + } + end + + elements[#elements + 1] = { icon = "fas fa-arrow-left", title = "Return", value = "return" } + + ESX.OpenContext("right", elements, function(_, element) + if element.value == "return" then + OpenManageEmployeesMenu(society, options) + else + local elements2 = { + { unselectable = true, icon = "fas fa-user", title = element.title }, + { icon = "fas fa-user", title = "Promote", value = "promote" }, + { icon = "fas fa-user", title = "Fire", value = "fire" }, + { icon = "fas fa-arrow-left", title = "Return", value = "return" }, + } + ESX.OpenContext("right", elements2, function(_, element2) + local employee = element.data + if element2.value == "promote" then + ESX.CloseContext() + OpenPromoteMenu(society, employee, options) + elseif element2.value == "fire" then + ESX.ShowNotification(TranslateCap("you_have_fired", employee.name)) + + ESX.TriggerServerCallback("esx_society:setJob", function() + OpenEmployeeList(society, options) + end, employee.identifier, "unemployed", 0, "fire") + elseif element2.value == "return" then + OpenEmployeeList(society, options) + end + end) + end + end) + end, society) end function OpenRecruitMenu(society, options) - ESX.TriggerServerCallback("esx_society:getOnlinePlayers", function(players) - local elements = { - { unselectable = true, icon = "fas fa-user", title = _U("recruiting") }, - } - - for i = 1, #players, 1 do - if players[i].job.name ~= society then - elements[#elements + 1] = { - icon = "fas fa-user", - title = players[i].name, - value = players[i].source, - name = players[i].name, - identifier = players[i].identifier, - } - end - end - - elements[#elements + 1] = { icon = "fas fa-arrow-left", title = "Return", value = "return" } - - ESX.OpenContext("right", elements, function(_, element) - if element.value == "return" then - OpenManageEmployeesMenu(society, options) - else - local elements2 = { - { unselectable = true, icon = "fas fa-user", title = "Confirm" }, - { icon = "fas fa-times", title = _U("no"), value = "no" }, - { icon = "fas fa-check", title = _U("yes"), value = "yes" }, - } - ESX.OpenContext("right", elements2, function(_, element2) - if element2.value == "yes" then - ESX.ShowNotification(_U("you_have_hired", element.name)) - - ESX.TriggerServerCallback("esx_society:setJob", function() - OpenRecruitMenu(society, options) - end, element.identifier, society, 0, "hire") - end - end) - end - end) - end) + ESX.TriggerServerCallback("esx_society:getOnlinePlayers", function(players) + local elements = { + { unselectable = true, icon = "fas fa-user", title = TranslateCap("recruiting") }, + } + + for i = 1, #players, 1 do + if players[i].job.name ~= society then + elements[#elements + 1] = { + icon = "fas fa-user", + title = players[i].name, + value = players[i].source, + name = players[i].name, + identifier = players[i].identifier, + } + end + end + + elements[#elements + 1] = { icon = "fas fa-arrow-left", title = "Return", value = "return" } + + ESX.OpenContext("right", elements, function(_, element) + if element.value == "return" then + OpenManageEmployeesMenu(society, options) + else + local elements2 = { + { unselectable = true, icon = "fas fa-user", title = "Confirm" }, + { icon = "fas fa-times", title = TranslateCap("no"), value = "no" }, + { icon = "fas fa-check", title = TranslateCap("yes"), value = "yes" }, + } + ESX.OpenContext("right", elements2, function(_, element2) + if element2.value == "yes" then + ESX.ShowNotification(TranslateCap("you_have_hired", element.name)) + + ESX.TriggerServerCallback("esx_society:setJob", function() + OpenRecruitMenu(society, options) + end, element.identifier, society, 0, "hire") + end + end) + end + end) + end) end function OpenPromoteMenu(society, employee, options) - ESX.TriggerServerCallback("esx_society:getJob", function(job) - local elements = { - { unselectable = true, icon = "fas fa-user", title = _U("promote_employee", employee.name) }, - } - - for i = 1, #job.grades, 1 do - local gradeLabel = (job.grades[i].label == "" and job.label or job.grades[i].label) - - elements[#elements + 1] = { - icon = "fas fa-user", - title = gradeLabel, - value = job.grades[i].grade, - selected = (employee.job.grade == job.grades[i].grade), - } - end - - elements[#elements + 1] = { icon = "fas fa-arrow-left", title = "Return", value = "return" } - - ESX.OpenContext("right", elements, function(_, element) - if element.value == "return" then - OpenEmployeeList(society, options) - else - ESX.ShowNotification(_U("you_have_promoted", employee.name, element.title)) - - ESX.TriggerServerCallback("esx_society:setJob", function() - OpenEmployeeList(society, options) - end, employee.identifier, society, element.value, "promote") - end - end, function() - OpenEmployeeList(society, options) - end) - end, society) + ESX.TriggerServerCallback("esx_society:getJob", function(job) + local elements = { + { unselectable = true, icon = "fas fa-user", title = TranslateCap("promote_employee", employee.name) }, + } + + for i = 1, #job.grades, 1 do + local gradeLabel = (job.grades[i].label == "" and job.label or job.grades[i].label) + + elements[#elements + 1] = { + icon = "fas fa-user", + title = gradeLabel, + value = job.grades[i].grade, + selected = (employee.job.grade == job.grades[i].grade), + } + end + + elements[#elements + 1] = { icon = "fas fa-arrow-left", title = "Return", value = "return" } + + ESX.OpenContext("right", elements, function(_, element) + if element.value == "return" then + OpenEmployeeList(society, options) + else + ESX.ShowNotification(TranslateCap("you_have_promoted", employee.name, element.title)) + + ESX.TriggerServerCallback("esx_society:setJob", function() + OpenEmployeeList(society, options) + end, employee.identifier, society, element.value, "promote") + end + end, function() + OpenEmployeeList(society, options) + end) + end, society) end function OpenManageSalaryMenu(society, options) - ESX.TriggerServerCallback("esx_society:getJob", function(job) - local elements = { - { unselectable = true, icon = "fas fa-wallet", title = _U("salary_management") }, - } - - for i = 1, #job.grades, 1 do - local gradeLabel = (job.grades[i].label == "" and job.label or job.grades[i].label) - - elements[#elements + 1] = { - icon = "fas fa-wallet", - title = ('%s - %s'):format( - gradeLabel, - _U("money_generic", ESX.Math.GroupDigits(job.grades[i].salary)) - ), - value = job.grades[i].grade, - } - end - - elements[#elements + 1] = { icon = "fas fa-arrow-left", title = "Return", value = "return" } - - ESX.OpenContext("right", elements, function(menu, element) - local elements = { - { - unselectable = true, - icon = "fas fa-wallet", - title = element.title, - description = "Change a grade salary amount", - value = element.value, - }, - { - icon = "fas fa-wallet", - title = "Amount", - input = true, - inputType = "number", - inputPlaceholder = "Amount to change grade salary..", - inputMin = 1, - inputMax = Config.MaxSalary, - name = "gradesalary", - }, - { icon = "fas fa-check", title = "Confirm", value = "confirm" }, - } - - ESX.RefreshContext(elements) - if element.value == "confirm" then - local amount = tonumber(menu.eles[2].inputValue) - - if amount == nil then - ESX.ShowNotification(_U("invalid_value_nochanges")) - OpenManageSalaryMenu(society, options) - elseif amount > Config.MaxSalary then - ESX.ShowNotification(_U("invalid_amount_max")) - OpenManageSalaryMenu(society, options) - else - ESX.CloseContext() - ESX.TriggerServerCallback("esx_society:setJobSalary", function() - OpenManageSalaryMenu(society, options) - end, society, menu.eles[1].value, amount) - end - elseif element.value == "return" then - OpenBossMenu(society, nil, options) - end - end) - end, society) + ESX.TriggerServerCallback("esx_society:getJob", function(job) + local elements = { + { unselectable = true, icon = "fas fa-wallet", title = TranslateCap("salary_management") }, + } + + for i = 1, #job.grades, 1 do + local gradeLabel = (job.grades[i].label == "" and job.label or job.grades[i].label) + + elements[#elements + 1] = { + icon = "fas fa-wallet", + title = ('%s - %s'):format(gradeLabel, TranslateCap("money_generic", ESX.Math.GroupDigits(job.grades[i].salary))), + value = job.grades[i].grade, + } + end + + elements[#elements + 1] = { icon = "fas fa-arrow-left", title = "Return", value = "return" } + + ESX.OpenContext("right", elements, function(menu, element) + local elements = { + { + unselectable = true, + icon = "fas fa-wallet", + title = element.title, + description = "Change a grade salary amount", + value = element.value, + }, + { + icon = "fas fa-wallet", + title = "Amount", + input = true, + inputType = "number", + inputPlaceholder = "Amount to change grade salary..", + inputMin = 1, + inputMax = Config.MaxSalary, + name = "gradesalary", + }, + { icon = "fas fa-check", title = "Confirm", value = "confirm" }, + } + + ESX.RefreshContext(elements) + if element.value == "confirm" then + local amount = tonumber(menu.eles[2].inputValue) + + if amount == nil then + ESX.ShowNotification(TranslateCap("invalid_value_nochanges")) + OpenManageSalaryMenu(society, options) + elseif amount > Config.MaxSalary then + ESX.ShowNotification(TranslateCap("invalid_amount_max")) + OpenManageSalaryMenu(society, options) + else + ESX.CloseContext() + ESX.TriggerServerCallback("esx_society:setJobSalary", function() + OpenManageSalaryMenu(society, options) + end, society, menu.eles[1].value, amount) + end + elseif element.value == "return" then + OpenBossMenu(society, nil, options) + end + end) + end, society) end function OpenManageGradesMenu(society, options) - ESX.TriggerServerCallback("esx_society:getJob", function(job) - local elements = { - { unselectable = true, icon = "fas fa-wallet", title = _U("grade_management") }, - } - - for i = 1, #job.grades, 1 do - local gradeLabel = (job.grades[i].label == "" and job.label or job.grades[i].label) - - elements[#elements + 1] = - { icon = "fas fa-wallet", title = ("%s"):format(gradeLabel), value = job.grades[i].grade } - end - - elements[#elements + 1] = { icon = "fas fa-arrow-left", title = "Return", value = "return" } - - ESX.OpenContext("right", elements, function(menu, element) - local elements = { - { - unselectable = true, - icon = "fas fa-wallet", - title = element.title, - description = "Change a grade label", - value = element.value, - }, - { - icon = "fas fa-wallet", - title = "Label", - input = true, - inputType = "text", - inputPlaceholder = "Label to change job grade label..", - name = "gradelabel", - }, - { icon = "fas fa-check", title = "Confirm", value = "confirm" }, - } - - ESX.RefreshContext(elements) - if element.value == "confirm" then - if menu.eles[2].inputValue then - local label = tostring(menu.eles[2].inputValue) - - ESX.TriggerServerCallback("esx_society:setJobLabel", function() - OpenManageGradesMenu(society, options) - end, society, menu.eles[1].value, label) - else - ESX.ShowNotification(_U("invalid_value_nochanges")) - OpenManageGradesMenu(society, options) - end - elseif element.value == "return" then - OpenBossMenu(society, nil, options) - end - end) - end, society) + ESX.TriggerServerCallback("esx_society:getJob", function(job) + local elements = { + { unselectable = true, icon = "fas fa-wallet", title = TranslateCap("grade_management") }, + } + + for i = 1, #job.grades, 1 do + local gradeLabel = (job.grades[i].label == "" and job.label or job.grades[i].label) + + elements[#elements + 1] = { icon = "fas fa-wallet", title = ("%s"):format(gradeLabel), value = job.grades[i].grade } + end + + elements[#elements + 1] = { icon = "fas fa-arrow-left", title = "Return", value = "return" } + + ESX.OpenContext("right", elements, function(menu, element) + local elements = { + { + unselectable = true, + icon = "fas fa-wallet", + title = element.title, + description = "Change a grade label", + value = element.value, + }, + { + icon = "fas fa-wallet", + title = "Label", + input = true, + inputType = "text", + inputPlaceholder = "Label to change job grade label..", + name = "gradelabel", + }, + { icon = "fas fa-check", title = "Confirm", value = "confirm" }, + } + + ESX.RefreshContext(elements) + if element.value == "confirm" then + if menu.eles[2].inputValue then + local label = tostring(menu.eles[2].inputValue) + + ESX.TriggerServerCallback("esx_society:setJobLabel", function() + OpenManageGradesMenu(society, options) + end, society, menu.eles[1].value, label) + else + ESX.ShowNotification(TranslateCap("invalid_value_nochanges")) + OpenManageGradesMenu(society, options) + end + elseif element.value == "return" then + OpenBossMenu(society, nil, options) + end + end) + end, society) end AddEventHandler("esx_society:openBossMenu", function(society, close, options) - OpenBossMenu(society, close, options) + OpenBossMenu(society, close, options) end) if ESX.PlayerLoaded then - RefreshBussHUD() + RefreshBussHUD() end diff --git a/server-data/resources/[esx]/esx_society/server/main.lua b/server-data/resources/[esx]/esx_society/server/main.lua index 0374b9934..5042493e9 100644 --- a/server-data/resources/[esx]/esx_society/server/main.lua +++ b/server-data/resources/[esx]/esx_society/server/main.lua @@ -69,7 +69,7 @@ AddEventHandler("esx_society:checkSocietyBalance", function(society) end TriggerEvent("bpt_addonaccount:getSharedAccount", society.account, function(account) - TriggerClientEvent("esx:showNotification", xPlayer.source, _U("check_balance", ESX.Math.GroupDigits(account.money))) + TriggerClientEvent("esx:showNotification", xPlayer.source, TranslateCap("check_balance", ESX.Math.GroupDigits(account.money))) end) end) @@ -88,9 +88,9 @@ AddEventHandler("esx_society:withdrawMoney", function(societyName, amount) if amount > 0 and account.money >= amount then account.removeMoney(amount) xPlayer.addMoney(amount, "Society Withdraw") - xPlayer.showNotification(_U("have_withdrawn", ESX.Math.GroupDigits(amount))) + xPlayer.showNotification(TranslateCap("have_withdrawn", ESX.Math.GroupDigits(amount))) else - xPlayer.showNotification(_U("invalid_amount")) + xPlayer.showNotification(TranslateCap("invalid_amount")) end end) else @@ -113,11 +113,11 @@ AddEventHandler("esx_society:depositMoney", function(societyName, amount) if amount > 0 and xPlayer.getMoney() >= amount then TriggerEvent("bpt_addonaccount:getSharedAccount", society.account, function(account) xPlayer.removeMoney(amount, "Society Deposit") - xPlayer.showNotification(_U("have_deposited", ESX.Math.GroupDigits(amount))) + xPlayer.showNotification(TranslateCap("have_deposited", ESX.Math.GroupDigits(amount))) account.addMoney(amount) end) else - xPlayer.showNotification(_U("invalid_amount")) + xPlayer.showNotification(TranslateCap("invalid_amount")) end else print(("[^3WARNING^7] Player ^5%s^7 attempted to deposit to society - ^5%s^7!"):format(source, society.name)) @@ -136,10 +136,10 @@ AddEventHandler("esx_society:washMoney", function(society, amount) xPlayer.removeAccountMoney("black_money", amount, "Washing") MySQL.insert("INSERT INTO society_moneywash (identifier, society, amount) VALUES (?, ?, ?)", { xPlayer.identifier, society, amount }, function() - xPlayer.showNotification(_U("you_have", ESX.Math.GroupDigits(amount))) + xPlayer.showNotification(TranslateCap("you_have", ESX.Math.GroupDigits(amount))) end) else - xPlayer.showNotification(_U("invalid_amount")) + xPlayer.showNotification(TranslateCap("invalid_amount")) end else print(("[^3WARNING^7] Player ^5%s^7 attempted to wash money in society - ^5%s^7!"):format(source, society)) @@ -294,14 +294,14 @@ ESX.RegisterServerCallback("esx_society:setJob", function(source, cb, identifier xTarget.setJob(job, grade) if type == "hire" then - xTarget.showNotification(_U("you_have_been_hired", job)) - xPlayer.showNotification(_U("you_have_hired", xTarget.getName())) + xTarget.showNotification(TranslateCap("you_have_been_hired", job)) + xPlayer.showNotification(TranslateCap("you_have_hired", xTarget.getName())) elseif type == "promote" then - xTarget.showNotification(_U("you_have_been_promoted")) - xPlayer.showNotification(_U("you_have_promoted", xTarget.getName())) + xTarget.showNotification(TranslateCap("you_have_been_promoted")) + xPlayer.showNotification(TranslateCap("you_have_promoted", xTarget.getName())) elseif type == "fire" then - xTarget.showNotification(_U("you_have_been_fired", xTarget.getJob().label)) - xPlayer.showNotification(_U("you_have_fired", xTarget.getName())) + xTarget.showNotification(TranslateCap("you_have_been_fired", xTarget.getJob().label)) + xPlayer.showNotification(TranslateCap("you_have_fired", xTarget.getName())) end cb() @@ -432,7 +432,7 @@ function WashMoneyCRON() -- send notification if player is online if xPlayer then - xPlayer.showNotification(_U("you_have_laundered", ESX.Math.GroupDigits(result[i].amount))) + xPlayer.showNotification(TranslateCap("you_have_laundered", ESX.Math.GroupDigits(result[i].amount))) end end MySQL.update("DELETE FROM society_moneywash") From 84b93580be465b11e65c14a64ec1b3a8a57d88f1 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Tue, 30 Jul 2024 16:57:38 +0200 Subject: [PATCH 18/23] refactor: Improved code style respecting ESLint rules --- .../[esx_addons]/esx_garage/nui/js/app.js | 451 +++++++++--------- 1 file changed, 228 insertions(+), 223 deletions(-) diff --git a/server-data/resources/[esx_addons]/esx_garage/nui/js/app.js b/server-data/resources/[esx_addons]/esx_garage/nui/js/app.js index 104a5cbec..f1f32dd6a 100644 --- a/server-data/resources/[esx_addons]/esx_garage/nui/js/app.js +++ b/server-data/resources/[esx_addons]/esx_garage/nui/js/app.js @@ -1,230 +1,235 @@ -$(window).ready(function () { - window.addEventListener("message", function (event) { - let data = event.data; - - if (data.showMenu) { - $("#container").fadeIn(); - $("#menu").fadeIn(); - - if (data.type === "impound") { - $("#header ul").hide(); - } else { - $("#header ul").show(); - } - - if (data.vehiclesList != undefined) { - $("#container").data("spawnpoint", data.spawnPoint); - if (data.poundCost) $("#container").data("poundcost", data.poundCost); - - if (data.poundCost != undefined) { - $(".content .vehicle-list").html( - getVehicles(data.locales, data.vehiclesList, data.poundCost) - ); - } else { - $(".content .vehicle-list").html( - getVehicles(data.locales, data.vehiclesList) - ); - } - - $(".content h2").hide(); - } else { - $(".content h2").show(); - $(".content .vehicle-list").empty(); - } - - if (data.vehiclesImpoundedList != undefined) { - $(".impounded_content").data("poundName", data.poundName); - $(".impounded_content").data("poundSpawnPoint", data.poundSpawnPoint); - - if (data.poundCost) $("#container").data("poundcost", data.poundCost); - - $(".impounded_content .vehicle-list").html( - getImpoundedVehicles(data.locales, data.vehiclesImpoundedList) - ); - $(".impounded_content h2").hide(); - } else { - $(".impounded_content h2").show(); - $(".impounded_content .vehicle-list").empty(); - } - - // Locales - - // needs a rework - // $(".content h2").html(function (i, text) { - // return text.replace("No vehicle in this garage.", data.locales.no_veh_parking); - // }); - - // $(".impounded_content h2").html(function (i, text) { - // return text.replace("No vehicle impounded.", data.locales.no_veh_impounded); - // }); - - $(".vehicle-listing").html(function (i, text) { - return text.replace("Model", data.locales.veh_model); - }); - $(".vehicle-listing").html(function (i, text) { - return text.replace("Plate", data.locales.veh_plate); - }); - $(".vehicle-listing").html(function (i, text) { - return text.replace("Condition", data.locales.veh_condition); - }); - } else if (data.hideAll) { - $("#container").fadeOut(); - } - }); - - $("#container").hide(); - - $(".close").click(function (event) { - $("#container").hide(); - $.post("https://esx_garage/escape", "{}"); - - $(".impounded_content").hide(); - $(".content").show(); - $('li[data-page="garage"]').addClass("selected"); - $('li[data-page="impounded"]').removeClass("selected"); - }); - - document.onkeyup = function (data) { - if (data.which == 27) { - $.post("https://esx_garage/escape", "{}"); - - $(".impounded_content").hide(); - $(".content").show(); - $('li[data-page="garage"]').addClass("selected"); - $('li[data-page="impounded"]').removeClass("selected"); - } - }; - - function getVehicles(locale, vehicle, amount = null) { - let html = ""; - let vehicleData = JSON.parse(vehicle); - let bodyHealth = 1000; - let engineHealth = 1000; - let tankHealth = 1000; - let vehicleDamagePercent = ""; - - for (let i = 0; i < vehicleData.length; i++) { - bodyHealth = (vehicleData[i].props.bodyHealth / 1000) * 100; - engineHealth = (vehicleData[i].props.engineHealth / 1000) * 100; - tankHealth = (vehicleData[i].props.tankHealth / 1000) * 100; - - vehicleDamagePercent = +$(window).ready(function() { + window.addEventListener('message', function(event) { + const data = event.data; + + if (data.showMenu) { + $('#container').fadeIn(); + $('#menu').fadeIn(); + + if (data.type === 'impound') { + $('#header ul').hide(); + } + else { + $('#header ul').show(); + } + + if (data.vehiclesList != undefined) { + $('#container').data('spawnpoint', data.spawnPoint); + if (data.poundCost) $('#container').data('poundcost', data.poundCost); + + if (data.poundCost != undefined) { + $('.content .vehicle-list').html( + getVehicles(data.locales, data.vehiclesList, data.poundCost), + ); + } + else { + $('.content .vehicle-list').html( + getVehicles(data.locales, data.vehiclesList), + ); + } + + $('.content h2').hide(); + } + else { + $('.content h2').show(); + $('.content .vehicle-list').empty(); + } + + if (data.vehiclesImpoundedList != undefined) { + $('.impounded_content').data('poundName', data.poundName); + $('.impounded_content').data('poundSpawnPoint', data.poundSpawnPoint); + + if (data.poundCost) $('#container').data('poundcost', data.poundCost); + + $('.impounded_content .vehicle-list').html( + getImpoundedVehicles(data.locales, data.vehiclesImpoundedList), + ); + $('.impounded_content h2').hide(); + } + else { + $('.impounded_content h2').show(); + $('.impounded_content .vehicle-list').empty(); + } + + // Locales + + // needs a rework + // $(".content h2").html(function (i, text) { + // return text.replace("No vehicle in this garage.", data.locales.no_veh_parking); + // }); + + // $(".impounded_content h2").html(function (i, text) { + // return text.replace("No vehicle impounded.", data.locales.no_veh_impounded); + // }); + + $('.vehicle-listing').html(function(i, text) { + return text.replace('Model', data.locales.veh_model); + }); + $('.vehicle-listing').html(function(i, text) { + return text.replace('Plate', data.locales.veh_plate); + }); + $('.vehicle-listing').html(function(i, text) { + return text.replace('Condition', data.locales.veh_condition); + }); + } + else if (data.hideAll) { + $('#container').fadeOut(); + } + }); + + $('#container').hide(); + + $('.close').click(function() { + $('#container').hide(); + $.post('https://esx_garage/escape', '{}'); + + $('.impounded_content').hide(); + $('.content').show(); + $('li[data-page="garage"]').addClass('selected'); + $('li[data-page="impounded"]').removeClass('selected'); + }); + + document.onkeyup = function(data) { + if (data.which == 27) { + $.post('https://esx_garage/escape', '{}'); + + $('.impounded_content').hide(); + $('.content').show(); + $('li[data-page="garage"]').addClass('selected'); + $('li[data-page="impounded"]').removeClass('selected'); + } + }; + + function getVehicles(locale, vehicle, amount = null) { + let html = ''; + const vehicleData = JSON.parse(vehicle); + let bodyHealth = 1000; + let engineHealth = 1000; + let tankHealth = 1000; + let vehicleDamagePercent = ''; + + for (let i = 0; i < vehicleData.length; i++) { + bodyHealth = (vehicleData[i].props.bodyHealth / 1000) * 100; + engineHealth = (vehicleData[i].props.engineHealth / 1000) * 100; + tankHealth = (vehicleData[i].props.tankHealth / 1000) * 100; + + vehicleDamagePercent = Math.round(((bodyHealth + engineHealth + tankHealth) / 300) * 100) + - "%"; - - html += "
"; - html += "
Model: " + vehicleData[i].model + "
"; - html += "
Plate: " + vehicleData[i].plate + "
"; - html += - "
Condition: " + vehicleDamagePercent + "
"; - html += - ""; - html += "
"; - } - - return html; - } - - function getImpoundedVehicles(locale, vehicle) { - let html = ""; - let vehicleData = JSON.parse(vehicle); - let bodyHealth = 1000; - let engineHealth = 1000; - let tankHealth = 1000; - let vehicleDamagePercent = ""; - - for (let i = 0; i < vehicleData.length; i++) { - bodyHealth = (vehicleData[i].props.bodyHealth / 1000) * 100; - engineHealth = (vehicleData[i].props.engineHealth / 1000) * 100; - tankHealth = (vehicleData[i].props.tankHealth / 1000) * 100; - - vehicleDamagePercent = + (amount ? ' ($' + amount + ')' : '') + + ''; + html += ''; + } + + return html; + } + + function getImpoundedVehicles(locale, vehicle) { + let html = ''; + const vehicleData = JSON.parse(vehicle); + let bodyHealth = 1000; + let engineHealth = 1000; + let tankHealth = 1000; + let vehicleDamagePercent = ''; + + for (let i = 0; i < vehicleData.length; i++) { + bodyHealth = (vehicleData[i].props.bodyHealth / 1000) * 100; + engineHealth = (vehicleData[i].props.engineHealth / 1000) * 100; + tankHealth = (vehicleData[i].props.tankHealth / 1000) * 100; + + vehicleDamagePercent = Math.round(((bodyHealth + engineHealth + tankHealth) / 300) * 100) + - "%"; - - html += "
"; - html += "
Model: " + vehicleData[i].model + "
"; - html += "
Plate: " + vehicleData[i].plate + "
"; - html += - "
Condition: " + vehicleDamagePercent + "
"; - html += - ""; - html += "
"; - } - - return html; - } - - $('li[data-page="garage"]').click(function (event) { - $(".impounded_content").hide(); - $(".content").show(); - $('li[data-page="garage"]').addClass("selected"); - $('li[data-page="impounded"]').removeClass("selected"); - }); - - $('li[data-page="impounded"]').click(function (event) { - $(".content").hide(); - $(".impounded_content").show(); - $('li[data-page="impounded"]').addClass("selected"); - $('li[data-page="garage"]').removeClass("selected"); - }); - - $(document).on( - "click", - "button[data-button='spawn'].vehicle-action", - function (event) { - let spawnPoint = $("#container").data("spawnpoint"); - let poundCost = $("#container").data("poundcost"); - let vehicleProps = $(this).data("vehprops"); - - // prevent empty cost - if (poundCost === undefined) poundCost = 0; - - $.post( - "https://esx_garage/spawnVehicle", - JSON.stringify({ - vehicleProps: vehicleProps, - spawnPoint: spawnPoint, - exitVehicleCost: poundCost, - }) - ); - - $(".impounded_content").hide(); - $(".content").show(); - $('li[data-page="garage"]').addClass("selected"); - $('li[data-page="impounded"]').removeClass("selected"); - } - ); - - $(document).on( - "click", - "button[data-button='impounded'].vehicle-action", - function (event) { - let vehicleProps = $(this).data("vehprops"); - let poundName = $(".impounded_content").data("poundName"); - let poundSpawnPoint = $(".impounded_content").data("poundSpawnPoint"); - $.post( - "https://esx_garage/impound", - JSON.stringify({ - vehicleProps: vehicleProps, - poundName: poundName, - poundSpawnPoint: poundSpawnPoint, - }) - ); - - $(".impounded_content").hide(); - $(".content").show(); - $('li[data-page="garage"]').addClass("selected"); - $('li[data-page="impounded"]').removeClass("selected"); - } - ); + ''; + html += ''; + } + + return html; + } + + $('li[data-page="garage"]').click(function() { + $('.impounded_content').hide(); + $('.content').show(); + $('li[data-page="garage"]').addClass('selected'); + $('li[data-page="impounded"]').removeClass('selected'); + }); + + $('li[data-page="impounded"]').click(function() { + $('.content').hide(); + $('.impounded_content').show(); + $('li[data-page="impounded"]').addClass('selected'); + $('li[data-page="garage"]').removeClass('selected'); + }); + + $(document).on( + 'click', + 'button[data-button=\'spawn\'].vehicle-action', + function() { + const spawnPoint = $('#container').data('spawnpoint'); + let poundCost = $('#container').data('poundcost'); + const vehicleProps = $(this).data('vehprops'); + + // prevent empty cost + if (poundCost === undefined) poundCost = 0; + + $.post( + 'https://esx_garage/spawnVehicle', + JSON.stringify({ + vehicleProps: vehicleProps, + spawnPoint: spawnPoint, + exitVehicleCost: poundCost, + }), + ); + + $('.impounded_content').hide(); + $('.content').show(); + $('li[data-page="garage"]').addClass('selected'); + $('li[data-page="impounded"]').removeClass('selected'); + }, + ); + + $(document).on( + 'click', + 'button[data-button=\'impounded\'].vehicle-action', + function() { + const vehicleProps = $(this).data('vehprops'); + const poundName = $('.impounded_content').data('poundName'); + const poundSpawnPoint = $('.impounded_content').data('poundSpawnPoint'); + $.post( + 'https://esx_garage/impound', + JSON.stringify({ + vehicleProps: vehicleProps, + poundName: poundName, + poundSpawnPoint: poundSpawnPoint, + }), + ); + + $('.impounded_content').hide(); + $('.content').show(); + $('li[data-page="garage"]').addClass('selected'); + $('li[data-page="impounded"]').removeClass('selected'); + }, + ); }); From e917ef38d916f2452a3155e1abf3a6bde24a0f2b Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Wed, 31 Jul 2024 10:33:37 +0200 Subject: [PATCH 19/23] chore: creation of mechanical shops for the sale of their products --- .../wasabi_oxshops/configuration/config.lua | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/server-data/resources/[wasabi]/wasabi_oxshops/configuration/config.lua b/server-data/resources/[wasabi]/wasabi_oxshops/configuration/config.lua index 2ad7f86e9..f0874e8d1 100644 --- a/server-data/resources/[wasabi]/wasabi_oxshops/configuration/config.lua +++ b/server-data/resources/[wasabi]/wasabi_oxshops/configuration/config.lua @@ -47,4 +47,28 @@ Config.Shops = { }, }, }, + + ["mechanic"] = { + label = "Mechanic Shop", + blip = { + enabled = true, + coords = vec3(811.147278, -2157.349365, 29.616821), + sprite = 61, + color = 8, + scale = 0.7, + string = "mechanic", + }, + locations = { + stash = { + string = "[E] - Access Inventory", + coords = vec3(-319.410980, -131.907684, 38.968506), + range = 3.0, + }, + shop = { + string = "[E] - Access Shop", + coords = vec3(-344.149445, -139.951645, 39.002197), + range = 4.0, + }, + }, + }, } From b495543cba7123e2e7dd037cb88847bc3efd202c Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Wed, 31 Jul 2024 11:25:03 +0200 Subject: [PATCH 20/23] refactor: Improved code style respecting ESLint rules --- .../[esx]/es_extended/html/js/app.js | 64 +- .../[esx]/es_extended/html/js/mustache.min.js | 699 +++++++++--------- .../[esx]/es_extended/html/js/wrapper.js | 48 +- .../resources/[esx]/es_extended/locale.js | 22 +- 4 files changed, 427 insertions(+), 406 deletions(-) diff --git a/server-data/resources/[esx]/es_extended/html/js/app.js b/server-data/resources/[esx]/es_extended/html/js/app.js index 4a95fe120..8c0607e43 100644 --- a/server-data/resources/[esx]/es_extended/html/js/app.js +++ b/server-data/resources/[esx]/es_extended/html/js/app.js @@ -1,40 +1,42 @@ (() => { - 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); + const 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() { + window.addEventListener('message', (event) => { + onData(event.data); + }); + }; })(); diff --git a/server-data/resources/[esx]/es_extended/html/js/mustache.min.js b/server-data/resources/[esx]/es_extended/html/js/mustache.min.js index f36565977..049f60333 100644 --- a/server-data/resources/[esx]/es_extended/html/js/mustache.min.js +++ b/server-data/resources/[esx]/es_extended/html/js/mustache.min.js @@ -1,347 +1,364 @@ (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); - } + 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 = + const objectToString = Object.prototype.toString; + const isArray = Array.isArray || function isArrayPolyfill(object) { - return objectToString.call(object) === "[object Array]"; + 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; 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; + 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; + } + const regExpTest = RegExp.prototype.test; + function testRegExp(re, string) { + return regExpTest.call(re, string); + } + const nonSpaceRe = /\S/; + function isWhitespace(string) { + return !testRegExp(nonSpaceRe, string); + } + const entityMap = { '&': '&', '<': '<', '>': '>', '"': '"', '\'': ''', '/': '/', '`': '`', '=': '=' }; + function escapeHtml(string) { + return String(string).replace(/[&<>"'`=/]/g, function fromEntityMap(s) { + return entityMap[s]; + }); + } + const whiteRe = /\s*/; + const spaceRe = /\s+/; + const equalsRe = /\s*=/; + const curlyRe = /\s*\}/; + const tagRe = /#|\^|\/|>|\{|&|=|!/; + function parseTemplate(template, tags) { + if (!template) return []; + const sections = []; + const tokens = []; + let spaces = []; + let hasTag = false; + let nonSpace = false; + function stripSpace() { + if (hasTag && !nonSpace) { + while (spaces.length) delete tokens[spaces.pop()]; + } + else { + spaces = []; + } + hasTag = false; + nonSpace = false; + } + let 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); + const scanner = new Scanner(template); + let start, type, value, chr, token, openSection; + while (!scanner.eos()) { + start = scanner.pos; + value = scanner.scanUntil(openingTagRe); + if (value) { + for (let 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) { + const squashedTokens = []; + let token, lastToken; + for (let 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) { + const nestedTokens = []; + let collector = nestedTokens; + const sections = []; + let token, section; + for (let 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) { + const match = this.tail.match(re); + if (!match || match.index !== 0) return ''; + const string = match[0]; + this.tail = this.tail.substring(string.length); + this.pos += string.length; + return string; + }; + Scanner.prototype.scanUntil = function scanUntil(re) { + // eslint-disable-next-line prefer-const + let 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) { + const cache = this.cache; + let value; + if (Object.prototype.hasOwnProperty.call(cache, name)) { + value = cache[name]; + } + else { + let 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) { + const cache = this.cache; + let tokens = cache[template]; + if (tokens == null) tokens = cache[template] = parseTemplate(template, tags); + return tokens; + }; + Writer.prototype.render = function render(template, view, partials) { + const tokens = this.parse(template); + const context = view instanceof Context ? view : new Context(view); + return this.renderTokens(tokens, context, partials, template); + }; + Writer.prototype.renderTokens = function renderTokens(tokens, context, partials, originalTemplate) { + let buffer = ''; + let token, symbol, value; + for (let 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) { + const self = this; + let buffer = ''; + let value = context.lookup(token[1]); + function subRender(template) { + return self.render(template, context, partials); + } + if (!value) return; + if (isArray(value)) { + for (let 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) { + const 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; + const 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) { + const value = context.lookup(token[1]); + if (value != null) return value; + }; + Writer.prototype.escapedValue = function escapedValue(token, context) { + const 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 = ['{{', '}}']; + const 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) { + const 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/server-data/resources/[esx]/es_extended/html/js/wrapper.js b/server-data/resources/[esx]/es_extended/html/js/wrapper.js index ee20f2611..e9e5169dc 100644 --- a/server-data/resources/[esx]/es_extended/html/js/wrapper.js +++ b/server-data/resources/[esx]/es_extended/html/js/wrapper.js @@ -1,34 +1,34 @@ (() => { - let ESXWrapper = {}; - ESXWrapper.MessageSize = 1024; - ESXWrapper.messageId = 0; + const 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/server-data/resources/[esx]/es_extended/locale.js b/server-data/resources/[esx]/es_extended/locale.js index e47e4345c..d3e17dd52 100644 --- a/server-data/resources/[esx]/es_extended/locale.js +++ b/server-data/resources/[esx]/es_extended/locale.js @@ -1,4 +1,4 @@ -var locale = []; +const locale = []; /** * Similar to the concept of gettext, this function returns the @@ -9,9 +9,10 @@ var locale = []; * @return {string} Returns the localized string * */ +// eslint-disable-next-line no-unused-vars function _U() { - var args = arguments; - var string = args[0]; + const args = arguments; + const string = args[0]; // Was a string specified? if (!string) { @@ -34,15 +35,16 @@ function _U() { // Do we need to format the string? if (args.length === 1) { return capitalize(locale[string]); - } else { + } + else { return formatString(args); } } function formatString(args) { - var string = capitalize(locale[args[0]]); + let string = capitalize(locale[args[0]]); - for (var i = 1; i < args.length; i++) { + for (let i = 1; i < args.length; i++) { string = string.replace(/%s/, args[i]); } @@ -54,12 +56,12 @@ function capitalize(string) { } // https://stackoverflow.com/a/35359503 -String.prototype.format = function () { - var args = arguments; - return this.replace(/{(\d+)}/g, function (match, number) { +String.prototype.format = function() { + const args = arguments; + return this.replace(/{(\d+)}/g, function(match, number) { return typeof args[number] != 'undefined' ? args[number] : match - ; + ; }); }; From 1183e27c922f74d6934b0e26d79a0e8189ea6514 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Wed, 31 Jul 2024 11:37:36 +0200 Subject: [PATCH 21/23] fix: corrected the use of some unused variables --- server-data/resources/[esx_addons]/esx_garage/nui/js/app.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server-data/resources/[esx_addons]/esx_garage/nui/js/app.js b/server-data/resources/[esx_addons]/esx_garage/nui/js/app.js index f1f32dd6a..65656e83b 100644 --- a/server-data/resources/[esx_addons]/esx_garage/nui/js/app.js +++ b/server-data/resources/[esx_addons]/esx_garage/nui/js/app.js @@ -62,13 +62,13 @@ $(window).ready(function() { // return text.replace("No vehicle impounded.", data.locales.no_veh_impounded); // }); - $('.vehicle-listing').html(function(i, text) { + $('.vehicle-listing').html(function(_i, text) { return text.replace('Model', data.locales.veh_model); }); - $('.vehicle-listing').html(function(i, text) { + $('.vehicle-listing').html(function(_i, text) { return text.replace('Plate', data.locales.veh_plate); }); - $('.vehicle-listing').html(function(i, text) { + $('.vehicle-listing').html(function(_i, text) { return text.replace('Condition', data.locales.veh_condition); }); } From e6988962dee66d813fc7847f3fa4648a243d9710 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Wed, 31 Jul 2024 12:39:37 +0200 Subject: [PATCH 22/23] =?UTF-8?q?refactor:=20Improved=20code=20style=20res?= =?UTF-8?q?pecting=20ESLint=20rules=20+=20=F0=9F=8E=A8=20Run=20formatter?= =?UTF-8?q?=20lua?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../[esx]/esx_menu_list/fxmanifest.lua | 21 +- .../[esx]/esx_menu_list/html/js/app.js | 374 +++++----- .../esx_menu_list/html/js/mustache.min.js | 699 +++++++++--------- .../resources/[esx]/esx_textui/TextUI.lua | 50 +- 4 files changed, 579 insertions(+), 565 deletions(-) diff --git a/server-data/resources/[esx]/esx_menu_list/fxmanifest.lua b/server-data/resources/[esx]/esx_menu_list/fxmanifest.lua index 318743ca5..7de4541fe 100644 --- a/server-data/resources/[esx]/esx_menu_list/fxmanifest.lua +++ b/server-data/resources/[esx]/esx_menu_list/fxmanifest.lua @@ -6,23 +6,20 @@ lua54("yes") version("1.0.1") client_scripts({ - "@es_extended/imports.lua", - "@es_extended/client/wrapper.lua", - "client/main.lua", + "@es_extended/imports.lua", + "@es_extended/client/wrapper.lua", + "client/main.lua", }) ui_page("html/ui.html") files({ - "html/ui.html", - - "html/css/app.css", - - "html/js/mustache.min.js", - "html/js/app.js", - - "html/fonts/pdown.ttf", - "html/fonts/bankgothic.ttf", + "html/ui.html", + "html/css/app.css", + "html/js/mustache.min.js", + "html/js/app.js", + "html/fonts/pdown.ttf", + "html/fonts/bankgothic.ttf", }) dependency("es_extended") diff --git a/server-data/resources/[esx]/esx_menu_list/html/js/app.js b/server-data/resources/[esx]/esx_menu_list/html/js/app.js index c81460099..67a2a5147 100644 --- a/server-data/resources/[esx]/esx_menu_list/html/js/app.js +++ b/server-data/resources/[esx]/esx_menu_list/html/js/app.js @@ -1,189 +1,189 @@ -(function () { - let MenuTpl = +(function() { + const MenuTpl = '"; - window.ESX_MENU = {}; - ESX_MENU.ResourceName = "esx_menu_list"; - ESX_MENU.opened = {}; - ESX_MENU.focus = []; - ESX_MENU.data = {}; - - 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); - } - - data._namespace = namespace; - data._name = name; - - ESX_MENU.opened[namespace][name] = data; - - ESX_MENU.focus.push({ - namespace: namespace, - name: name, - }); - - ESX_MENU.render(); - }; - - 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) { - if (typeof ESX_MENU.data[namespace] === "undefined") { - ESX_MENU.data[namespace] = {}; - } - - for (let name in ESX_MENU.opened[namespace]) { - ESX_MENU.data[namespace][name] = []; - - let menuData = ESX_MENU.opened[namespace][name]; - let view = { - _namespace: menuData._namespace, - _name: menuData._name, - head: [], - rows: [], - }; - - for (let i = 0; i < menuData.head.length; i++) { - let item = { content: menuData.head[i] }; - view.head.push(item); - } - - for (let i = 0; i < menuData.rows.length; i++) { - let row = menuData.rows[i]; - let data = row.data; - - ESX_MENU.data[namespace][name].push(data); - - view.rows.push({ cols: [] }); - - for (let j = 0; j < row.cols.length; j++) { - let col = menuData.rows[i].cols[j]; - let regex = /\{\{(.*?)\|(.*?)\}\}/g; - let matches = []; - let match; - - while ((match = regex.exec(col)) != null) { - matches.push(match); - } - - for (let k = 0; k < matches.length; k++) { - col = col.replace("{{" + matches[k][1] + "|" + matches[k][2] + "}}", '"); - } - - view.rows[i].cols.push({ data: data, content: col }); - } - } - - let menu = $(Mustache.render(MenuTpl, view)); - - menu.find("button[data-namespace][data-name]").click(function () { - ESX_MENU.data[$(this).data("namespace")][$(this).data("name")][parseInt($(this).data("id"))].currentRow = parseInt($(this).data("id")) + 1; - ESX_MENU.submit($(this).data("namespace"), $(this).data("name"), { - data: ESX_MENU.data[$(this).data("namespace")][$(this).data("name")][parseInt($(this).data("id"))], - value: $(this).data("value"), - }); - }); - - menu.hide(); - - menuContainer.appendChild(menu[0]); - } - } - - 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, - data: data.data, - value: data.value, - }) - ); - }; - - ESX_MENU.cancel = function (namespace, name) { - $.post( - "http://" + ESX_MENU.ResourceName + "/menu_cancel", - JSON.stringify({ - _namespace: namespace, - _name: name, - }) - ); - }; - - 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; - } - } - }; - - window.onload = function (e) { - window.addEventListener("message", (event) => { - onData(event.data); - }); - }; - - document.onkeyup = function (data) { - if (data.which === 27) { - let focused = ESX_MENU.getFocused(); - ESX_MENU.cancel(focused.namespace, focused.name); - } - }; + '' + + '' + + '' + + '{{#head}}{{/head}}' + + '' + + '' + + '' + + '{{#rows}}' + + '' + + '{{#cols}}{{/cols}}' + + '' + + '{{/rows}}' + + '' + + '
{{content}}
{{{content}}}
' + + ''; + window.ESX_MENU = {}; + ESX_MENU.ResourceName = 'esx_menu_list'; + ESX_MENU.opened = {}; + ESX_MENU.focus = []; + ESX_MENU.data = {}; + + 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); + } + + data._namespace = namespace; + data._name = name; + + ESX_MENU.opened[namespace][name] = data; + + ESX_MENU.focus.push({ + namespace: namespace, + name: name, + }); + + ESX_MENU.render(); + }; + + 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() { + const menuContainer = document.getElementById('menus'); + const focused = ESX_MENU.getFocused(); + menuContainer.innerHTML = ''; + + $(menuContainer).hide(); + + for (const namespace in ESX_MENU.opened) { + if (typeof ESX_MENU.data[namespace] === 'undefined') { + ESX_MENU.data[namespace] = {}; + } + + for (const name in ESX_MENU.opened[namespace]) { + ESX_MENU.data[namespace][name] = []; + + const menuData = ESX_MENU.opened[namespace][name]; + const view = { + _namespace: menuData._namespace, + _name: menuData._name, + head: [], + rows: [], + }; + + for (let i = 0; i < menuData.head.length; i++) { + const item = { content: menuData.head[i] }; + view.head.push(item); + } + + for (let i = 0; i < menuData.rows.length; i++) { + const row = menuData.rows[i]; + const data = row.data; + + ESX_MENU.data[namespace][name].push(data); + + view.rows.push({ cols: [] }); + + for (let j = 0; j < row.cols.length; j++) { + let col = menuData.rows[i].cols[j]; + const regex = /\{\{(.*?)\|(.*?)\}\}/g; + const matches = []; + let match; + + while ((match = regex.exec(col)) != null) { + matches.push(match); + } + + for (let k = 0; k < matches.length; k++) { + col = col.replace('{{' + matches[k][1] + '|' + matches[k][2] + '}}', ''); + } + + view.rows[i].cols.push({ data: data, content: col }); + } + } + + const menu = $(Mustache.render(MenuTpl, view)); + + menu.find('button[data-namespace][data-name]').click(function() { + ESX_MENU.data[$(this).data('namespace')][$(this).data('name')][parseInt($(this).data('id'))].currentRow = parseInt($(this).data('id')) + 1; + ESX_MENU.submit($(this).data('namespace'), $(this).data('name'), { + data: ESX_MENU.data[$(this).data('namespace')][$(this).data('name')][parseInt($(this).data('id'))], + value: $(this).data('value'), + }); + }); + + menu.hide(); + + menuContainer.appendChild(menu[0]); + } + } + + 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, + data: data.data, + value: data.value, + }), + ); + }; + + ESX_MENU.cancel = function(namespace, name) { + $.post( + 'http://' + ESX_MENU.ResourceName + '/menu_cancel', + JSON.stringify({ + _namespace: namespace, + _name: name, + }), + ); + }; + + 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; + } + } + }; + + window.onload = function() { + window.addEventListener('message', (event) => { + onData(event.data); + }); + }; + + document.onkeyup = function(data) { + if (data.which === 27) { + const focused = ESX_MENU.getFocused(); + ESX_MENU.cancel(focused.namespace, focused.name); + } + }; })(); diff --git a/server-data/resources/[esx]/esx_menu_list/html/js/mustache.min.js b/server-data/resources/[esx]/esx_menu_list/html/js/mustache.min.js index f36565977..049f60333 100644 --- a/server-data/resources/[esx]/esx_menu_list/html/js/mustache.min.js +++ b/server-data/resources/[esx]/esx_menu_list/html/js/mustache.min.js @@ -1,347 +1,364 @@ (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); - } + 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 = + const objectToString = Object.prototype.toString; + const isArray = Array.isArray || function isArrayPolyfill(object) { - return objectToString.call(object) === "[object Array]"; + 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; 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; + 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; + } + const regExpTest = RegExp.prototype.test; + function testRegExp(re, string) { + return regExpTest.call(re, string); + } + const nonSpaceRe = /\S/; + function isWhitespace(string) { + return !testRegExp(nonSpaceRe, string); + } + const entityMap = { '&': '&', '<': '<', '>': '>', '"': '"', '\'': ''', '/': '/', '`': '`', '=': '=' }; + function escapeHtml(string) { + return String(string).replace(/[&<>"'`=/]/g, function fromEntityMap(s) { + return entityMap[s]; + }); + } + const whiteRe = /\s*/; + const spaceRe = /\s+/; + const equalsRe = /\s*=/; + const curlyRe = /\s*\}/; + const tagRe = /#|\^|\/|>|\{|&|=|!/; + function parseTemplate(template, tags) { + if (!template) return []; + const sections = []; + const tokens = []; + let spaces = []; + let hasTag = false; + let nonSpace = false; + function stripSpace() { + if (hasTag && !nonSpace) { + while (spaces.length) delete tokens[spaces.pop()]; + } + else { + spaces = []; + } + hasTag = false; + nonSpace = false; + } + let 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); + const scanner = new Scanner(template); + let start, type, value, chr, token, openSection; + while (!scanner.eos()) { + start = scanner.pos; + value = scanner.scanUntil(openingTagRe); + if (value) { + for (let 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) { + const squashedTokens = []; + let token, lastToken; + for (let 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) { + const nestedTokens = []; + let collector = nestedTokens; + const sections = []; + let token, section; + for (let 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) { + const match = this.tail.match(re); + if (!match || match.index !== 0) return ''; + const string = match[0]; + this.tail = this.tail.substring(string.length); + this.pos += string.length; + return string; + }; + Scanner.prototype.scanUntil = function scanUntil(re) { + // eslint-disable-next-line prefer-const + let 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) { + const cache = this.cache; + let value; + if (Object.prototype.hasOwnProperty.call(cache, name)) { + value = cache[name]; + } + else { + let 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) { + const cache = this.cache; + let tokens = cache[template]; + if (tokens == null) tokens = cache[template] = parseTemplate(template, tags); + return tokens; + }; + Writer.prototype.render = function render(template, view, partials) { + const tokens = this.parse(template); + const context = view instanceof Context ? view : new Context(view); + return this.renderTokens(tokens, context, partials, template); + }; + Writer.prototype.renderTokens = function renderTokens(tokens, context, partials, originalTemplate) { + let buffer = ''; + let token, symbol, value; + for (let 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) { + const self = this; + let buffer = ''; + let value = context.lookup(token[1]); + function subRender(template) { + return self.render(template, context, partials); + } + if (!value) return; + if (isArray(value)) { + for (let 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) { + const 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; + const 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) { + const value = context.lookup(token[1]); + if (value != null) return value; + }; + Writer.prototype.escapedValue = function escapedValue(token, context) { + const 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 = ['{{', '}}']; + const 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) { + const 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/server-data/resources/[esx]/esx_textui/TextUI.lua b/server-data/resources/[esx]/esx_textui/TextUI.lua index d5c8beee0..de603ebe7 100644 --- a/server-data/resources/[esx]/esx_textui/TextUI.lua +++ b/server-data/resources/[esx]/esx_textui/TextUI.lua @@ -3,22 +3,22 @@ local isShowing = false ---@param message string ---@param typ string local function TextUI(message, typ) - isShowing = true - SendNUIMessage({ - action = "show", - message = message and message or "ESX-TextUI", - type = type(typ) == "string" and typ or "info", - }) + isShowing = true + SendNUIMessage({ + action = "show", + message = message and message or "ESX-TextUI", + type = type(typ) == "string" and typ or "info", + }) end local function HideUI() - if not isShowing then - return - end - isShowing = false - SendNUIMessage({ - action = "hide", - }) + if not isShowing then + return + end + isShowing = false + SendNUIMessage({ + action = "hide", + }) end exports("TextUI", TextUI) @@ -27,19 +27,19 @@ RegisterNetEvent("ESX:TextUI", TextUI) RegisterNetEvent("ESX:HideUI", HideUI) if Debug then - RegisterCommand("textui:error", function() - ESX.TextUI("i ~r~love~s~ donuts", "error") - end) + RegisterCommand("textui:error", function() + ESX.TextUI("i ~r~love~s~ donuts", "error") + end) - RegisterCommand("textui:success", function() - ESX.TextUI("i ~g~love~s~ donuts", "success") - end) + RegisterCommand("textui:success", function() + ESX.TextUI("i ~g~love~s~ donuts", "success") + end) - RegisterCommand("textui:info", function() - ESX.TextUI("i ~b~love~s~ donuts", "info") - end) + RegisterCommand("textui:info", function() + ESX.TextUI("i ~b~love~s~ donuts", "info") + end) - RegisterCommand("textui:hide", function() - ESX.HideUI() - end) + RegisterCommand("textui:hide", function() + ESX.HideUI() + end) end From 80d0dbba875a2d11b06a4abb69c7a4b9c641fb7c Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Wed, 31 Jul 2024 23:45:43 +0200 Subject: [PATCH 23/23] feat: file upload for eslint worlflow --- .github/workflows/ESlint.yml | 23 + eslint.config.mjs | 8 + package-lock.json | 1115 ++++++++++++++++++++++++++++++++++ package.json | 5 + 4 files changed, 1151 insertions(+) create mode 100644 .github/workflows/ESlint.yml create mode 100644 eslint.config.mjs create mode 100644 package-lock.json create mode 100644 package.json diff --git a/.github/workflows/ESlint.yml b/.github/workflows/ESlint.yml new file mode 100644 index 000000000..7fa6d198f --- /dev/null +++ b/.github/workflows/ESlint.yml @@ -0,0 +1,23 @@ +name: ESLint + +on: + push: + branches: [ "main", "dev" ] + pull_request: + branches: [ "main" ] + +jobs: + eslint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 16 + - run: npm ci # or yarn install + - uses: sibiraj-s/action-eslint@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} # optional + eslint-args: '--ignore-pattern=.gitignore --quiet' + extensions: 'js,jsx,ts,tsx' + annotations: true \ No newline at end of file diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 000000000..f730b12f9 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,8 @@ +import globals from 'globals'; +import pluginJs from '@eslint/js'; + + +export default [ + { languageOptions: { globals: globals.browser } }, + pluginJs.configs.recommended, +]; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..ca8a47c41 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1115 @@ +{ + "name": "empiretown", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "devDependencies": { + "eslint": "^9.0.0" + } + }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.11.0", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.11.0.tgz", + "integrity": "sha512-G/M/tIiMrTAxEWRfLfQJMmGNX28IxBg4PBz8XqQhqUHLFI6TL2htpIB1iQCj144V5ee/JaKyT9/WZ0MGZWfA7A==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.1.0.tgz", + "integrity": "sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^10.0.1", + "globals": "^14.0.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/js": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.0.0.tgz", + "integrity": "sha512-RThY/MnKrhubF6+s1JflwUjPEsnCEmYCWwqa/aRISKWNXGZ9epUwft4bUMM35SdKF9xvBrLydAM1RDHd1Z//ZQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@humanwhocodes/config-array": { + "version": "0.12.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.12.3.tgz", + "integrity": "sha512-jsNnTBlMWuTpDkeE3on7+dWJi0D6fdDfeANj/w7MpS8ztROCoLvIO2nG0CcFj+E4k8j4QrSTh4Oryi3i2G669g==", + "deprecated": "Use @eslint/config-array instead", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanwhocodes/object-schema": "^2.0.3", + "debug": "^4.3.1", + "minimatch": "^3.0.5" + }, + "engines": { + "node": ">=10.10.0" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/object-schema": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", + "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", + "deprecated": "Use @eslint/object-schema instead", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/acorn": { + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", + "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, + "license": "Python-2.0" + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true, + "license": "MIT" + }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/debug": { + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", + "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.0.0.tgz", + "integrity": "sha512-IMryZ5SudxzQvuod6rUdIUz29qFItWx281VhtFVc2Psy/ZhlCeD/5DT6lBIJ4H3G+iamGJoTln1v+QSuPw0p7Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^3.0.2", + "@eslint/js": "9.0.0", + "@humanwhocodes/config-array": "^0.12.3", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^8.0.1", + "eslint-visitor-keys": "^4.0.0", + "espree": "^10.0.1", + "esquery": "^1.4.2", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^8.0.0", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "graphemer": "^1.4.0", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3", + "strip-ansi": "^6.0.1", + "text-table": "^0.2.0" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-scope": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.0.2.tgz", + "integrity": "sha512-6E4xmrTw5wtxnLA5wYL3WDfhZ/1bUBGOXV0zQvVRDOtrR8D0p6W7fs3JweNYhwRYeGvd/1CKX2se0/2s7Q/nJA==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", + "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/espree": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.1.0.tgz", + "integrity": "sha512-M1M6CpiE6ffoigIOWYO9UDP8TMUw9kqb21tf+08IgDYjCsOvCuDt4jQcZmoYxx+w7zlKw9/N0KXfto+I8/FrXA==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "acorn": "^8.12.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^4.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/esquery": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz", + "integrity": "sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fastq": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", + "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==", + "dev": true, + "license": "ISC", + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/file-entry-cache": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", + "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "flat-cache": "^4.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat-cache": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", + "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "flatted": "^3.2.9", + "keyv": "^4.5.4" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/flatted": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.1.tgz", + "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", + "dev": true, + "license": "ISC" + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true, + "license": "MIT" + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/ignore": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", + "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/keyv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "json-buffer": "3.0.1" + } + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true, + "license": "MIT" + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true, + "license": "MIT" + }, + "node_modules/optionator": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.5" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "license": "MIT", + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true, + "license": "MIT", + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", + "dev": true, + "license": "MIT" + }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/word-wrap": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 000000000..75f1d17e0 --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "devDependencies": { + "eslint": "^9.0.0" + } +}