Skip to content

Commit

Permalink
formatting(all): Format with prettier and lua formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpredator committed Jan 24, 2024
1 parent 403c040 commit 8c9158b
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 61 deletions.
3 changes: 2 additions & 1 deletion .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,5 @@ fix lint error: unused argument last; accessing undefined variable Invoke; unuse
74. [esx_menu_default]: chore: esx_menu_default update to version 1.0.0 @bitpredator
75. [esx_multicharacter]: refactor: esx_multicharacter @bitpredator
76. [esx_multicharacter]: fix: fixed problem which prevented the menu from opening @bitpredator
77. [esx_notify]: refactor: formatting(all): Format with prettier and lua formatter @bitpredator
77. [esx_notify]: refactor: formatting(all): Format with prettier and lua formatter @bitpredator
78. [esx_progressbar]: refactor: formatting(all): Format with prettier and lua formatter @bitpredator
20 changes: 12 additions & 8 deletions server-data/resources/[esx]/esx_progressbar/Progress.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
local CurrentProgress = nil
local function Progressbar(message,length,Options)

local function Progressbar(message, length, Options)
if CurrentProgress then
return false
end
CurrentProgress = Options or {}
if CurrentProgress.animation then
if CurrentProgress.animation.type == "anim" then
ESX.Streaming.RequestAnimDict(CurrentProgress.animation.dict, function()
TaskPlayAnim(ESX.PlayerData.ped, CurrentProgress.animation.dict, CurrentProgress.animation.lib, 1.0, 1.0, length, 1, 1.0, false,false,false)
TaskPlayAnim(ESX.PlayerData.ped, CurrentProgress.animation.dict, CurrentProgress.animation.lib, 1.0, 1.0, length, 1, 1.0, false, false, false)
RemoveAnimDict(CurrentProgress.animation.dict)
end)
elseif CurrentProgress.animation.type == "Scenario" then
Expand All @@ -23,7 +24,7 @@ local function Progressbar(message,length,Options)
CurrentProgress.length = length or 3000
while CurrentProgress ~= nil do
if CurrentProgress.length > 0 then
CurrentProgress.length -= 1000
CurrentProgress.length = CurrentProgress.length - 1000
else
ClearPedTasks(ESX.PlayerData.ped)
if CurrentProgress.FreezePlayer then FreezeEntityPosition(PlayerPedId(), false) end
Expand All @@ -34,17 +35,20 @@ local function Progressbar(message,length,Options)
end
end

ESX.RegisterInput("cancelprog", "[ProgressBar] Cancel Progressbar", "keyboard", "BACK", function()
local function CancelProgressbar()
if not CurrentProgress then return end
if not CurrentProgress.onCancel then return end
SendNUIMessage({
type = "Close"
})
ClearPedTasks(ESX.PlayerData.ped)
if CurrentProgress.FreezePlayer then FreezeEntityPosition(PlayerPedId(), false) end
if CurrentProgress.onCancel then CurrentProgress.onCancel() end
CurrentProgress.canceled = true
CurrentProgress.length = 0
CurrentProgress.onCancel()
CurrentProgress = nil
end)
exports('Progressbar', Progressbar)
end

ESX.RegisterInput("cancelprog", "[ProgressBar] Cancel Progressbar", "keyboard", "BACK", CancelProgressbar)

exports('Progressbar', Progressbar)
exports('CancelProgressbar', CancelProgressbar)
4 changes: 2 additions & 2 deletions server-data/resources/[esx]/esx_progressbar/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ game 'gta5'
author 'BPT-Framework'
lua54 'yes'
description 'BPT Progressbar'
version '0.0.4'
version '1.0.0'

client_scripts { 'Progress.lua' }
shared_script '@es_extended/imports.lua'
Expand All @@ -13,4 +13,4 @@ files {
'nui/index.html',
'nui/js/*.js',
'nui/css/*.css',
}
}
63 changes: 30 additions & 33 deletions server-data/resources/[esx]/esx_progressbar/nui/index.html
Original file line number Diff line number Diff line change
@@ -1,49 +1,46 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://kit.fontawesome.com/a81368914c.js"></script>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div id="notifyInfo" class="notify">
<div class="innerText">
<i class="fas fa-info-circle icon info"></i>
<p class="text" id="infoMessage"></p>
<head>
<script src="https://kit.fontawesome.com/a81368914c.js"></script>
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<div id="notifyInfo" class="notify">
<div class="innerText">
<i class="fas fa-info-circle icon info"></i>
<p class="text" id="infoMessage"></p>
</div>
<div id="progline" class="progline"></div>
</div>
<div id="progline" class="progline">
</div>
</div>
</body>
<script src="js/script.js"></script>
</body>
<script src="js/script.js"></script>
</html>

<style>


.notify {
.notify {
flex: auto;
display: none;
position:absolute;
position: absolute;
margin: 0 auto;
left: 0;
right: 0;
bottom: 100px;
min-width:15%;
width:fit-content;
height:45px;
background-color:rgba(5, 5, 5, 0.800);
min-width: 15%;
width: fit-content;
height: 45px;
background-color: rgba(5, 5, 5, 0.8);
border-radius: 5px;
animation: growDown 300ms ease-in-out;
padding-right: 10px;
}

.progline {
position:absolute;
bottom:0;
left:0;
right:0;
height:2px;
width:100%;
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 2px;
width: 100%;
border-radius: 20px;
background: linear-gradient(to right, #0052d4, #4364f7, #6fb1fc); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}
Expand All @@ -55,16 +52,16 @@
.innerText {
flex: auto;
margin-top: 15px;
width:100%;
width: 100%;
}

.innerText{
.innerText {
margin-left: 10px;
}
p {
flex: auto;
word-wrap: break-word;
margin-left: 30px;
margin-left: 30px;
margin-top: 15px;
}

Expand All @@ -79,10 +76,10 @@
transform: scaleY(0);
}
80% {
transform: scaleY(1.1)
transform: scaleY(1.1);
}
100% {
transform: scaleY(1)
transform: scaleY(1);
}
}
</style>
34 changes: 17 additions & 17 deletions server-data/resources/[esx]/esx_progressbar/nui/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ const codes = {
"~c~": "grey",
"~m~": "#212121",
"~u~": "black",
"~o~": "orange"
}
"~o~": "orange",
};

const elems = {
infoMessage: document.getElementById('infoMessage'),
infoMessage: document.getElementById("infoMessage"),
notifyInfo: document.getElementById("notifyInfo"),
progline: document.getElementById('progline')
}
progline: document.getElementById("progline"),
};

const replaceColors = (str, obj) => {
let strToReplace = str;
Expand All @@ -23,26 +23,26 @@ const replaceColors = (str, obj) => {
strToReplace = strToReplace.replace(new RegExp(id, "g"), obj[id]);
}

return strToReplace
}
return strToReplace;
};

window.addEventListener('message', function({data}) {
window.addEventListener("message", function ({ data }) {
if (data.type === "Progressbar") {
let { message } = data
let { message } = data;

for (color in codes) {
if (message.includes(color)) {
let objArr = {};
objArr[color] = `<span style="color: ${codes[color]}">`;
objArr["~s~"] = "</span>";

let newStr = replaceColors(message, objArr);
message = newStr

message = newStr;
}
}

elems.infoMessage.innerHTML = message
elems.infoMessage.innerHTML = message;

Check failure

Code scanning / CodeQL

Client-side cross-site scripting High

Cross-site scripting vulnerability due to
user-provided value
.
elems.notifyInfo.style.display = "block";

const start = new Date();
Expand All @@ -53,17 +53,17 @@ window.addEventListener('message', function({data}) {
function animUpdate() {
const now = new Date();
const timeoutDiff = now.getTime() - start.getTime();
const prc = Math.round((timeoutDiff/maxTime)*100);
const prc = Math.round((timeoutDiff / maxTime) * 100);
if (prc <= 100) {
elems.progline.style.width = prc + "%"
elems.progline.style.width = prc + "%";
this.timeoutID = setTimeout(animUpdate, timeoutValue);
} else {
elems.notifyInfo.style.display = "none";
}
}
} else {
elems.notifyInfo.style.display = 'none'
elems.notifyInfo.style.display = "none";
clearTimeout(this.timeoutID);
timeoutValue = 0;
}
})
});

0 comments on commit 8c9158b

Please sign in to comment.