From f0badb8177db86ba5f928aa537955ca8f470a825 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Sun, 14 Jan 2024 14:07:55 +0100 Subject: [PATCH] chore: esx_menu_default update to version 1.0.0 --- .github/CHANGELOG.md | 3 +- .../resources/[esx]/esx_menu_default/LICENSE | 4 +- .../[esx]/esx_menu_default/README.md | 2 +- .../[esx]/esx_menu_default/client/main.lua | 6 +- .../[esx]/esx_menu_default/fxmanifest.lua | 2 +- .../[esx]/esx_menu_default/html/css/app.css | 6 +- .../[esx]/esx_menu_default/html/js/app.js | 578 +++++++++--------- .../esx_menu_default/html/js/mustache.min.js | 348 ++++++++++- .../[esx]/esx_menu_default/html/ui.html | 35 +- 9 files changed, 654 insertions(+), 330 deletions(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 58d46461a..2ab7ea71a 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -96,4 +96,5 @@ fix lint error: unused argument last; accessing undefined variable Invoke; unuse 70. [bpt_vehicletax]: chore: bpt_vehicletax update to version 1.0.0 @bitpredator 71. [bpt_wallet]: chore: bpt_wallet update to version 1.0.0 @bitpredator 72. [es_extended]: chore: es_extended add underflow check for removeAccountMoney @bitpredator -73. [esx_context]: chore: esx_context update to version 1.0.0 @bitpredator \ No newline at end of file +73. [esx_context]: chore: esx_context update to version 1.0.0 @bitpredator +74. [esx_menu_default]: chore: esx_menu_default update to version 1.0.0 @bitpredator \ No newline at end of file diff --git a/server-data/resources/[esx]/esx_menu_default/LICENSE b/server-data/resources/[esx]/esx_menu_default/LICENSE index 85ce0959a..4f474f077 100644 --- a/server-data/resources/[esx]/esx_menu_default/LICENSE +++ b/server-data/resources/[esx]/esx_menu_default/LICENSE @@ -632,7 +632,7 @@ state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. esx_menu_default - Copyright (C) 2015-2023 Jérémie N'gadi + Copyright (C) 2015-2024 Jérémie N'gadi This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - esx_menu_default Copyright (C) 2015-2023 Jérémie N'gadi + esx_menu_default Copyright (C) 2015-2024 Jérémie N'gadi This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. diff --git a/server-data/resources/[esx]/esx_menu_default/README.md b/server-data/resources/[esx]/esx_menu_default/README.md index 1cb671869..368f65bb0 100644 --- a/server-data/resources/[esx]/esx_menu_default/README.md +++ b/server-data/resources/[esx]/esx_menu_default/README.md @@ -2,7 +2,7 @@ esx_menu_defualt - Default Menu! -Copyright (C) 2015-2023 +Copyright (C) 2015-2024 This program Is free software: you can redistribute it And/Or modify it under the terms Of the GNU General Public License As published by the Free Software Foundation, either version 3 Of the License, Or (at your option) any later version. diff --git a/server-data/resources/[esx]/esx_menu_default/client/main.lua b/server-data/resources/[esx]/esx_menu_default/client/main.lua index d3ab74d5c..486729539 100644 --- a/server-data/resources/[esx]/esx_menu_default/client/main.lua +++ b/server-data/resources/[esx]/esx_menu_default/client/main.lua @@ -14,8 +14,10 @@ end local function closeMenu(namespace, name) CurrentNameSpace = namespace - if OpenedMenus < 1 then return end OpenedMenus = OpenedMenus - 1 + if OpenedMenus < 0 then + OpenedMenus = 0 + end SendNUIMessage({ action = 'closeMenu', namespace = namespace, @@ -24,7 +26,7 @@ local function closeMenu(namespace, name) end AddEventHandler('onResourceStop', function(resource) - if GetCurrentResourceName() == resource and OpenedMenus > 0 then + if GetCurrentResourceName() == resource and OpenedMenus > 0 then ESX.UI.Menu.CloseAll() elseif CurrentNameSpace ~= nil and CurrentNameSpace == resource and OpenedMenus > 0 then ESX.UI.Menu.CloseAll() diff --git a/server-data/resources/[esx]/esx_menu_default/fxmanifest.lua b/server-data/resources/[esx]/esx_menu_default/fxmanifest.lua index 8acf953bd..4e4b6542e 100644 --- a/server-data/resources/[esx]/esx_menu_default/fxmanifest.lua +++ b/server-data/resources/[esx]/esx_menu_default/fxmanifest.lua @@ -4,7 +4,7 @@ game 'gta5' description 'Menu Default' lua54 'yes' -version '0.0.4' +version '1.0.0' client_scripts {'@es_extended/imports.lua', 'client/main.lua'} diff --git a/server-data/resources/[esx]/esx_menu_default/html/css/app.css b/server-data/resources/[esx]/esx_menu_default/html/css/app.css index a4312dfea..353c701eb 100644 --- a/server-data/resources/[esx]/esx_menu_default/html/css/app.css +++ b/server-data/resources/[esx]/esx_menu_default/html/css/app.css @@ -1,11 +1,11 @@ -@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@500;600&display=swap'); +@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@500;600&display=swap"); ::-webkit-scrollbar { display: none; } .menu { - font-family: 'Poppins', sans-serif; + font-family: "Poppins", sans-serif; min-width: 350px; color: #fff; position: absolute; @@ -107,4 +107,4 @@ left: 50%; top: 35%; transform: translate(-50%, 50%); -} +} \ No newline at end of file diff --git a/server-data/resources/[esx]/esx_menu_default/html/js/app.js b/server-data/resources/[esx]/esx_menu_default/html/js/app.js index 2ce7a0f97..9ee22bc7e 100644 --- a/server-data/resources/[esx]/esx_menu_default/html/js/app.js +++ b/server-data/resources/[esx]/esx_menu_default/html/js/app.js @@ -1,378 +1,362 @@ -;(function () { +(function () { let MenuTpl = '' + - '' - window.ESX_MENU = {} - ESX_MENU.ResourceName = 'esx_menu_default' - ESX_MENU.opened = {} - ESX_MENU.focus = [] - ESX_MENU.pos = {} + "{{{label}}}{{#isSlider}} : <{{{sliderLabel}}}>{{/isSlider}}" + + "" + + "{{/elements}}" + + "" + + "" + + ""; + window.ESX_MENU = {}; + ESX_MENU.ResourceName = "esx_menu_default"; + ESX_MENU.opened = {}; + ESX_MENU.focus = []; + ESX_MENU.pos = {}; ESX_MENU.open = function (namespace, name, data) { - if (typeof ESX_MENU.opened[namespace] == 'undefined') { - ESX_MENU.opened[namespace] = {} - } + if (typeof ESX_MENU.opened[namespace] === "undefined") { + ESX_MENU.opened[namespace] = {}; + } - if (typeof ESX_MENU.opened[namespace][name] != 'undefined') { - ESX_MENU.close(namespace, name) - } + if (typeof ESX_MENU.opened[namespace][name] != "undefined") { + ESX_MENU.close(namespace, name); + } - if (typeof ESX_MENU.pos[namespace] == 'undefined') { - ESX_MENU.pos[namespace] = {} - } + if (typeof ESX_MENU.pos[namespace] === "undefined") { + ESX_MENU.pos[namespace] = {}; + } - for (let i = 0; i < data.elements.length; i++) { - if (typeof data.elements[i].type == 'undefined') { - data.elements[i].type = 'default' + for (let i = 0; i < data.elements.length; i++) { + if (typeof data.elements[i].type === "undefined") { + data.elements[i].type = "default"; + } } - } - data._index = ESX_MENU.focus.length - data._namespace = namespace - data._name = name + data._index = ESX_MENU.focus.length; + data._namespace = namespace; + data._name = name; - for (let i = 0; i < data.elements.length; i++) { - data.elements[i]._namespace = namespace - data.elements[i]._name = name - } + for (let i = 0; i < data.elements.length; i++) { + data.elements[i]._namespace = namespace; + data.elements[i]._name = name; + } - ESX_MENU.opened[namespace][name] = data - ESX_MENU.pos[namespace][name] = 0 + ESX_MENU.opened[namespace][name] = data; + ESX_MENU.pos[namespace][name] = 0; - for (let i = 0; i < data.elements.length; i++) { - if (data.elements[i].selected) { - ESX_MENU.pos[namespace][name] = i - } else { - data.elements[i].selected = false + for (let i = 0; i < data.elements.length; i++) { + if (data.elements[i].selected) { + ESX_MENU.pos[namespace][name] = i; + } else { + data.elements[i].selected = false; + } } - } - ESX_MENU.focus.push({ - namespace: namespace, - name: name - }) + ESX_MENU.focus.push({ + namespace: namespace, + name: name, + }); - ESX_MENU.render() - $('#menu_' + namespace + '_' + name) - .find('.menu-item.selected')[0] - .scrollIntoView() - } + ESX_MENU.render(); + $("#menu_" + namespace + "_" + name) + .find(".menu-item.selected")[0] + .scrollIntoView(); + }; 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 + 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(); + }; 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) { - for (let name in ESX_MENU.opened[namespace]) { - let menuData = ESX_MENU.opened[namespace][name] - let view = JSON.parse(JSON.stringify(menuData)) - - for (let i = 0; i < menuData.elements.length; i++) { - let element = view.elements[i] - - switch (element.type) { - case 'default': - break - - case 'slider': { - element.isSlider = true - element.sliderLabel = - typeof element.options == 'undefined' - ? element.value - : element.options[element.value] - - break - } - - default: - break - } + let menuContainer = document.getElementById("menus"); + let focused = ESX_MENU.getFocused(); + menuContainer.innerHTML = ""; + $(menuContainer).hide(); - if (i == ESX_MENU.pos[namespace][name]) { - element.selected = true - } - } + for (let namespace in ESX_MENU.opened) { + for (let name in ESX_MENU.opened[namespace]) { + let menuData = ESX_MENU.opened[namespace][name]; + let view = JSON.parse(JSON.stringify(menuData)); - let menu = $(Mustache.render(MenuTpl, view))[0] - $(menu).hide() - menuContainer.appendChild(menu) - } - } + for (let i = 0; i < menuData.elements.length; i++) { + let element = view.elements[i]; - if (typeof focused != 'undefined') { - $('#menu_' + focused.namespace + '_' + focused.name).show() - } + switch (element.type) { + case "default": + break; - $(menuContainer).show() - } + case "slider": { + element.isSlider = true; + element.sliderLabel = typeof element.options === "undefined" ? element.value : element.options[element.value]; - ESX_MENU.submit = function (namespace, name, data) { - $.post( - 'http://' + ESX_MENU.ResourceName + '/menu_submit', - JSON.stringify({ - _namespace: namespace, - _name: name, - current: data, - elements: ESX_MENU.opened[namespace][name].elements - }) - ) - } + break; + } - ESX_MENU.cancel = function (namespace, name) { - $.post( - 'http://' + ESX_MENU.ResourceName + '/menu_cancel', - JSON.stringify({ - _namespace: namespace, - _name: name - }) - ) - } + default: + break; + } - ESX_MENU.change = function (namespace, name, data) { - $.post( - 'http://' + ESX_MENU.ResourceName + '/menu_change', - JSON.stringify({ - _namespace: namespace, - _name: name, - current: data, - elements: ESX_MENU.opened[namespace][name].elements - }) - ) - } + if (i === ESX_MENU.pos[namespace][name]) { + element.selected = true; + } + } - 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 + let menu = $(Mustache.render(MenuTpl, view))[0]; + $(menu).hide(); + menuContainer.appendChild(menu); + } } - case 'closeMenu': { - ESX_MENU.close(data.namespace, data.name) - break + if (typeof focused != "undefined") { + $("#menu_" + focused.namespace + "_" + focused.name).show(); } - case 'controlPressed': { - switch (data.control) { - case 'ENTER': { - let focused = ESX_MENU.getFocused() + $(menuContainer).show(); + }; - if (typeof focused != 'undefined') { - let menu = ESX_MENU.opened[focused.namespace][focused.name] - let pos = ESX_MENU.pos[focused.namespace][focused.name] - let elem = menu.elements[pos] + ESX_MENU.submit = function (namespace, name, data) { + $.post("http://" + ESX_MENU.ResourceName + "/menu_submit", + JSON.stringify({ + _namespace: namespace, + _name: name, + current: data, + elements: ESX_MENU.opened[namespace][name].elements, + }) + ); + }; - if (menu.elements.length > 0) { - ESX_MENU.submit(focused.namespace, focused.name, elem) - } - } + ESX_MENU.cancel = function (namespace, name) { + $.post("http://" + ESX_MENU.ResourceName + "/menu_cancel", + JSON.stringify({ + _namespace: namespace, + _name: name, + }) + ); + }; + + ESX_MENU.change = function (namespace, name, data) { + $.post("http://" + ESX_MENU.ResourceName + "/menu_change", + JSON.stringify({ + _namespace: namespace, + _name: name, + current: data, + elements: ESX_MENU.opened[namespace][name].elements, + })); + }; - break + 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 'BACKSPACE': { - let focused = ESX_MENU.getFocused() + case "closeMenu": { + ESX_MENU.close(data.namespace, data.name); + break; + } - if (typeof focused != 'undefined') { - ESX_MENU.cancel(focused.namespace, focused.name) - } + case "controlPressed": { + switch (data.control) { + case "ENTER": { + let focused = ESX_MENU.getFocused(); - break - } + if (typeof focused != "undefined") { + let menu = ESX_MENU.opened[focused.namespace][focused.name]; + let pos = ESX_MENU.pos[focused.namespace][focused.name]; + let elem = menu.elements[pos]; - case 'TOP': { - let focused = ESX_MENU.getFocused() + if (menu.elements.length > 0) { + ESX_MENU.submit(focused.namespace, focused.name, elem); + } + } - if (typeof focused != 'undefined') { - let menu = ESX_MENU.opened[focused.namespace][focused.name] - let pos = ESX_MENU.pos[focused.namespace][focused.name] + break; + } - if (pos > 0) { - ESX_MENU.pos[focused.namespace][focused.name]-- - } else { - ESX_MENU.pos[focused.namespace][focused.name] = - menu.elements.length - 1 - } + case "BACKSPACE": { + let focused = ESX_MENU.getFocused(); - let elem = - menu.elements[ESX_MENU.pos[focused.namespace][focused.name]] + if (typeof focused != "undefined") { + ESX_MENU.cancel(focused.namespace, focused.name); + } - for (let i = 0; i < menu.elements.length; i++) { - if (i == ESX_MENU.pos[focused.namespace][focused.name]) { - menu.elements[i].selected = true - } else { - menu.elements[i].selected = false - } - } + break; + } - ESX_MENU.change(focused.namespace, focused.name, elem) - ESX_MENU.render() + case "TOP": { + let focused = ESX_MENU.getFocused(); - $('#menu_' + focused.namespace + '_' + focused.name) - .find('.menu-item.selected')[0] - .scrollIntoView() - } + if (typeof focused != "undefined") { + let menu = ESX_MENU.opened[focused.namespace][focused.name]; + let pos = ESX_MENU.pos[focused.namespace][focused.name]; - break - } + if (pos > 0) { + ESX_MENU.pos[focused.namespace][focused.name]--; + } else { + ESX_MENU.pos[focused.namespace][focused.name] = menu.elements.length - 1; + } - case 'DOWN': { - let focused = ESX_MENU.getFocused() + let elem = menu.elements[ESX_MENU.pos[focused.namespace][focused.name]]; - if (typeof focused != 'undefined') { - let menu = ESX_MENU.opened[focused.namespace][focused.name] - let pos = ESX_MENU.pos[focused.namespace][focused.name] - let length = menu.elements.length + for (let i = 0; i < menu.elements.length; i++) { + if (i === ESX_MENU.pos[focused.namespace][focused.name]) { + menu.elements[i].selected = true; + } else { + menu.elements[i].selected = false; + } + } - if (pos < length - 1) { - ESX_MENU.pos[focused.namespace][focused.name]++ - } else { - ESX_MENU.pos[focused.namespace][focused.name] = 0 - } + ESX_MENU.change(focused.namespace, focused.name, elem); + ESX_MENU.render(); - let elem = - menu.elements[ESX_MENU.pos[focused.namespace][focused.name]] + $("#menu_" + focused.namespace + "_" + focused.name) + .find(".menu-item.selected")[0] + .scrollIntoView(); + } - for (let i = 0; i < menu.elements.length; i++) { - if (i == ESX_MENU.pos[focused.namespace][focused.name]) { - menu.elements[i].selected = true - } else { - menu.elements[i].selected = false - } - } + break; + } - ESX_MENU.change(focused.namespace, focused.name, elem) - ESX_MENU.render() + case "DOWN": { + let focused = ESX_MENU.getFocused(); - $('#menu_' + focused.namespace + '_' + focused.name) - .find('.menu-item.selected')[0] - .scrollIntoView() - } + if (typeof focused != "undefined") { + let menu = ESX_MENU.opened[focused.namespace][focused.name]; + let pos = ESX_MENU.pos[focused.namespace][focused.name]; + let length = menu.elements.length; - break - } + if (pos < length - 1) { + ESX_MENU.pos[focused.namespace][focused.name]++; + } else { + ESX_MENU.pos[focused.namespace][focused.name] = 0; + } - case 'LEFT': { - let focused = ESX_MENU.getFocused() + let elem = menu.elements[ESX_MENU.pos[focused.namespace][focused.name]]; - if (typeof focused != 'undefined') { - let menu = ESX_MENU.opened[focused.namespace][focused.name] - let pos = ESX_MENU.pos[focused.namespace][focused.name] - let elem = menu.elements[pos] + for (let i = 0; i < menu.elements.length; i++) { + if (i === ESX_MENU.pos[focused.namespace][focused.name]) { + menu.elements[i].selected = true; + } else { + menu.elements[i].selected = false; + } + } - switch (elem.type) { - case 'default': - break + ESX_MENU.change(focused.namespace, focused.name, elem); + ESX_MENU.render(); - case 'slider': { - let min = typeof elem.min == 'undefined' ? 0 : elem.min + $("#menu_" + focused.namespace + "_" + focused.name) + .find(".menu-item.selected")[0] + .scrollIntoView(); + } - if (elem.value > min) { - elem.value-- - ESX_MENU.change(focused.namespace, focused.name, elem) + break; } - ESX_MENU.render() - break - } + case "LEFT": { + let focused = ESX_MENU.getFocused(); - default: - break - } + if (typeof focused != "undefined") { + let menu = ESX_MENU.opened[focused.namespace][focused.name]; + let pos = ESX_MENU.pos[focused.namespace][focused.name]; + let elem = menu.elements[pos]; - $('#menu_' + focused.namespace + '_' + focused.name) - .find('.menu-item.selected')[0] - .scrollIntoView() - } + switch (elem.type) { + case "default": + break; - break - } + case "slider": { + let min = typeof elem.min === "undefined" ? 0 : elem.min; - case 'RIGHT': { - let focused = ESX_MENU.getFocused() - - if (typeof focused != 'undefined') { - let menu = ESX_MENU.opened[focused.namespace][focused.name] - let pos = ESX_MENU.pos[focused.namespace][focused.name] - let elem = menu.elements[pos] - - switch (elem.type) { - case 'default': - break - - case 'slider': { - if ( - typeof elem.options != 'undefined' && - elem.value < elem.options.length - 1 - ) { - elem.value++ - ESX_MENU.change(focused.namespace, focused.name, elem) - } + if (elem.value > min) { + elem.value--; + ESX_MENU.change(focused.namespace, focused.name, elem); + } - if (typeof elem.max != 'undefined' && elem.value < elem.max) { - elem.value++ - ESX_MENU.change(focused.namespace, focused.name, elem) + ESX_MENU.render(); + break; + } + + default: + break; + } + + $("#menu_" + focused.namespace + "_" + focused.name) + .find(".menu-item.selected")[0] + .scrollIntoView(); + } + + break; } - ESX_MENU.render() - break - } + case "RIGHT": { + let focused = ESX_MENU.getFocused(); - default: - break - } + if (typeof focused != "undefined") { + let menu = ESX_MENU.opened[focused.namespace][focused.name]; + let pos = ESX_MENU.pos[focused.namespace][focused.name]; + let elem = menu.elements[pos]; - $('#menu_' + focused.namespace + '_' + focused.name) - .find('.menu-item.selected')[0] - .scrollIntoView() - } + switch (elem.type) { + case "default": + break; - break - } + case "slider": { + if (typeof elem.options != "undefined" && elem.value < elem.options.length - 1) { + elem.value++; + ESX_MENU.change(focused.namespace, focused.name, elem); + } + + if (typeof elem.max != "undefined" && elem.value < elem.max) { + elem.value++; + ESX_MENU.change(focused.namespace, focused.name, elem); + } + + ESX_MENU.render(); + break; + } - default: - break - } + default: + break; + } - break + $("#menu_" + focused.namespace + "_" + focused.name) + .find(".menu-item.selected")[0] + .scrollIntoView(); + } + + break; + } + + default: + break; + } + + break; + } } - } - } + }; window.onload = function (e) { - window.addEventListener('message', event => { - onData(event.data) - }) - } -})() + window.addEventListener("message", (event) => { + onData(event.data); + }); + }; +})(); \ No newline at end of file diff --git a/server-data/resources/[esx]/esx_menu_default/html/js/mustache.min.js b/server-data/resources/[esx]/esx_menu_default/html/js/mustache.min.js index 520cfcb9e..773d0ad36 100644 --- a/server-data/resources/[esx]/esx_menu_default/html/js/mustache.min.js +++ b/server-data/resources/[esx]/esx_menu_default/html/js/mustache.min.js @@ -1 +1,347 @@ -(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)}})(this,function mustacheFactory(mustache){var objectToString=Object.prototype.toString;var isArray=Array.isArray||function isArrayPolyfill(object){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;i0?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")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": ">", '"': """, "'": "'", "/": "/", "`": "`", "=": "=" }; + 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; +}); \ No newline at end of file diff --git a/server-data/resources/[esx]/esx_menu_default/html/ui.html b/server-data/resources/[esx]/esx_menu_default/html/ui.html index 5c090697a..e7660d818 100644 --- a/server-data/resources/[esx]/esx_menu_default/html/ui.html +++ b/server-data/resources/[esx]/esx_menu_default/html/ui.html @@ -1,25 +1,16 @@ - - - - - - + + + + + + - - + + - - - - - + + + + + \ No newline at end of file