feat: esx_context update

This commit is contained in:
Benzo
2022-09-03 19:19:35 +02:00
committed by GitHub
parent 9b9eedb2b2
commit 26171d08f8
3 changed files with 140 additions and 43 deletions
+1 -1
View File
@@ -1 +1 @@
PREVIEW_KEYBIND = false -- "LMENU"
PREVIEW_KEYBIND = "LMENU"
+137 -42
View File
@@ -142,6 +142,61 @@
::-webkit-scrollbar-thumb:hover {
background: rgb(30,30,30);
}
.container {
display: flex;
position: relative;
cursor: pointer;
font-size: 14px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
flex-direction: row-reverse;
align-items: center;
justify-content: flex-end;
gap: 5px;
}
/* Hide the browser's default checkbox */
.container input {
position: relative;
opacity: 0;
cursor: pointer;
height: 0;
width: 0;
}
/* Create a custom checkbox */
.checkmark {
position: relative;
height: 10px;
width: 10px;
border-radius: 8px;
background-color: #eee;
}
/* On mouse-over, add a grey background color */
.container:hover input ~ .checkmark {
background-color: #ccc;
}
/* When the checkbox is checked, add a blue background */
.container input:checked ~ .checkmark {
background-color: #2196F3;
}
/* Create the checkmark/indicator (hidden when not checked) */
.checkmark:after {
content: "";
position: relative;
display: none;
}
/* Show the checkmark when checked */
.container input:checked ~ .checkmark:after {
display: block;
}
</style>
</head>
<body>
@@ -204,50 +259,72 @@
}
if (ele.input) {
let input = CreateElement("input","",div)
input.type = ele.inputType
if (ele.inputType == "radio") {
for (let j=0;j<ele.inputValues.length;j++) {
let v = ele.inputValues[j]
let container = CreateElement("label","container",div)
container.innerHTML = v.text
if (ele.inputValue) {
input.value = ele.inputValue
}
let input = CreateElement("INPUT","",container)
input.type = "radio"
input.name = i+1
input.checked = (ele.inputValue || ele.inputPlaceholder || -1) == v.value
if (ele.inputPlaceholder) {
input.placeholder = ele.inputPlaceholder
}
let span = CreateElement("SPAN","checkmark",container)
switch (ele.inputType) {
case "number":
if (ele.inputMin) input.min = ele.inputMin;
if (ele.inputMax) input.max = ele.inputMax;
input.onchange = function() {
let v = Number(input.value)
if (ele.inputMin) {
v = Math.max(ele.inputMin,v)
}
if (ele.inputMax) {
v = Math.min(ele.inputMax,v)
}
input.value = v
$.post(`https://${GetParentResourceName()}/changed`,JSON.stringify({
index:i+1,
value:v
}))
}
break
case "text":
input.onchange = function() {
$.post(`https://${GetParentResourceName()}/changed`,JSON.stringify({
index:i+1,
value:input.value
}))
value:v.value
}))
}
break
}
} else {
let input = CreateElement("input","",div)
input.type = ele.inputType
if (ele.inputValue) {
input.value = ele.inputValue
}
if (ele.inputPlaceholder) {
input.placeholder = ele.inputPlaceholder
}
switch (ele.inputType) {
case "number":
if (ele.inputMin) input.min = ele.inputMin;
if (ele.inputMax) input.max = ele.inputMax;
input.onchange = function() {
let v = Number(input.value)
if (ele.inputMin) {
v = Math.max(ele.inputMin,v)
}
if (ele.inputMax) {
v = Math.min(ele.inputMax,v)
}
input.value = v
$.post(`https://${GetParentResourceName()}/changed`,JSON.stringify({
index:i+1,
value:v
}))
}
break
case "text":
input.onchange = function() {
$.post(`https://${GetParentResourceName()}/changed`,JSON.stringify({
index:i+1,
value:input.value
}))
}
break
}
}
} else {
if (ele.disabled) {
@@ -323,17 +400,35 @@
// icon:"fas fa-times",
// title:"Input Text",
// inputType:"text",
// placeholder:"Placeholder..."
// inputPlaceholder:"Placeholder..."
// },
// {
// input:true,
// icon:"",
// title:"Input Number",
// inputType:"number",
// placeholder:"Placeholder...",
// value:0,
// min:0,
// max:50
// inputPlaceholder:"Placeholder...",
// inputValue:0,
// inputMin:0,
// inputMax:50
// },
// {
// input:true,
// icon:"",
// title:"Input Radio",
// inputType:"radio",
// inputPlaceholder:"turbocharger",
// inputValue:"supercharger",
// inputValues:[
// {
// value:"turbocharger",
// title:"Turbocharger"
// },
// {
// value:"supercharger",
// title:"Supercharger"
// },
// ]
// }
// ])
</script>
+2
View File
@@ -131,6 +131,8 @@ RegisterNUICallback("changed",function(data)
end
elseif ele.inputType == "text" then
ele.inputValue = data.value
elseif ele.inputType == "radio" then
ele.inputValue = data.value
end
end)