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] 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 - ; + ; }); };