diff --git a/build.js b/build.js index cfd972d..b893454 100644 --- a/build.js +++ b/build.js @@ -3,6 +3,7 @@ const fs = require('fs'); if (!fs.existsSync("./build")) fs.mkdirSync("./build"); fs.cpSync("./static/", "./build/", { recursive: true }); +fs.writeFileSync("./build/index.html", fs.readFileSync("./build/index.html").toString().replace(/buildTimestamp/g, Date.now())); let script = fs.readFileSync('./game/latest.js', { encoding: 'utf8' }).replace("\n", "").trim(); const replaceOne = (expression, replaceValue) => { diff --git a/static/fx_core.js b/static/fx_core.js index c67afcc..1da483d 100644 --- a/static/fx_core.js +++ b/static/fx_core.js @@ -1,6 +1,5 @@ -const fx_version = '0.6.1'; // FX Client Version -const fx_update = 'Feb 21'; // FX Client Last Updated - +const fx_version = '0.6.1.1'; // FX Client Version +const fx_update = 'Feb 22'; // FX Client Last Updated if (localStorage.getItem("fx_winCount") == undefined || localStorage.getItem("fx_winCount") == null) { var wins_counter = 0; @@ -21,27 +20,27 @@ function KeybindsInput(containerElement) { this.displayObjects = function () { // Clear the content of the container this.container.innerHTML = ""; - if (this.objectArray.length === 0) return this.container.innerText = "No custom keybinds added"; + if (this.objectArray.length === 0) return this.container.innerText = "No custom attack percentage keybinds added"; // Loop through the array and display input fields for each object for (var i = 0; i < this.objectArray.length; i++) { var objectDiv = document.createElement("div"); // Create input fields for each key this.keys.forEach(function (key) { + let inputField = document.createElement(key === "type" ? "select" : "input"); if (key === "type") { - var selectMenu = document.createElement("select"); - selectMenu.innerHTML = ''; - selectMenu.value = this.objectArray[i][key]; - selectMenu.addEventListener("change", this.updateObject.bind(this, i, key)); - objectDiv.appendChild(selectMenu); - return; + inputField.innerHTML = ''; + inputField.addEventListener("change", this.updateObject.bind(this, i, key)); + } else if (key === "key") { + inputField.type = "text"; + inputField.setAttribute("readonly", ""); + inputField.setAttribute("placeholder", "No key set"); + inputField.addEventListener("click", this.startKeyInput.bind(this, i, key)); + } else { // key === "value" + inputField.type = "number"; + inputField.setAttribute("step", "0.1"); + inputField.addEventListener("input", this.updateObject.bind(this, i, key)); } - var inputField = document.createElement("input"); - inputField.type = key === "value" ? "number" : "text"; - if (key === "value") inputField.setAttribute("step", "0.1"); - if (key === "key") inputField.setAttribute("readonly", ""); inputField.value = this.objectArray[i][key]; - if (key === "key") inputField.addEventListener("click", this.startKeyInput.bind(this, i, key)); - else inputField.addEventListener("input", this.updateObject.bind(this, i, key)); // Append input field to the object div objectDiv.appendChild(inputField); }, this); @@ -55,9 +54,16 @@ function KeybindsInput(containerElement) { this.container.appendChild(objectDiv); } }; + /** @param {PointerEvent} event */ this.startKeyInput = function (index, property, event) { event.target.value = "Press any key"; - document.addEventListener('keydown', this.updateObject.bind(this, index, property), { once: true }); + const handler = this.updateObject.bind(this, index, property); + event.target.addEventListener('keydown', handler, { once: true }); + event.target.addEventListener("blur", () => { + event.target.removeEventListener('keydown', handler, { once: true }); + event.target.value = this.objectArray[index][property]; + //this.displayObjects(); + }, { once: true }); }; this.updateObject = function (index, property, event) { if (index >= this.objectArray.length) return; diff --git a/static/index.html b/static/index.html index 1d82e5c..b088b58 100644 --- a/static/index.html +++ b/static/index.html @@ -2,13 +2,13 @@ - + FX Client @@ -32,7 +32,7 @@ - +