From a84c3528b08a25fc78bbf92297b88496cb037b1b Mon Sep 17 00:00:00 2001 From: Grovkillen Date: Thu, 16 Apr 2020 14:22:07 +0200 Subject: [PATCH 01/12] [readme] added link to Python download --- README.md | 4 ++-- src/gui_easy_pitcher.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 85d2fb4..5951b39 100644 --- a/README.md +++ b/README.md @@ -105,8 +105,8 @@ in your local network. Point to this unit inside a file called ``custom.json``, ### Run as COMPILED localhost To test different versions of the compiled code we have added the ``GzipSimpleHTTPServer.py`` -script. Given that you have python already installed you can simply double click on this -file will start the server and automatically open ``localhost:8000`` and you will see +script. Given that you have [Python](https://www.python.org/downloads/) already installed you can simply double click on this +file and it will start the server and automatically open ``localhost:8000`` and you will see the entire project folder listed. Click your way through to the build you want to test. The compiled code will, if started in localhost mode, search for the ``src/custom.json`` file so make sure you have that one setup according to your needs. diff --git a/src/gui_easy_pitcher.js b/src/gui_easy_pitcher.js index 5ec5819..5bb01ff 100644 --- a/src/gui_easy_pitcher.js +++ b/src/gui_easy_pitcher.js @@ -20,7 +20,7 @@ guiEasy.pitcher = async function (processID, processType) { guiEasy.nodes.push(jsonData); //THIS ONE IS USED TO RUN THE GUI FROM LOCALHOST }) .catch(error => { - helpEasy.addToLogDOM('Error fetching (custom.json): ' + error, 0, "error"); + helpEasy.addToLogDOM('Error fetching (src/custom.json): ' + error, 0, "error"); helpEasy.addToLogDOM('You should create a "custom.json", please refer to the "custom-template.json".', 0, "warn"); helpEasy.addToLogDOM('With this file you can specify what unit you want to connect to during development...', 0, "info"); }); From 0214de1d6ba754640706358adec31fd2a783f357 Mon Sep 17 00:00:00 2001 From: Grovkillen Date: Sun, 19 Apr 2020 08:04:40 +0200 Subject: [PATCH 02/12] [helper] made ini2object function better (number conversion) --- src/gui_easy_helper.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gui_easy_helper.js b/src/gui_easy_helper.js index 7d04c5e..fda75cb 100644 --- a/src/gui_easy_helper.js +++ b/src/gui_easy_helper.js @@ -460,15 +460,19 @@ const helpEasy = { }, 'iniFileToObject': function(string) { let object = {}; - let sections = string.match(/^\[[^\]\n]+](?:\n(?:[^[\n].*)?)*/gm); + let sections = string.match(/^\[[^\]\r\n]+](?:[\r\n]([^[\r\n].*)?)*/gm); for (let i=0; i < sections.length; i++) { let sectionName = sections[i].split("\n")[0]; - sectionName = sectionName.slice(1, sectionName.length-1); + sectionName = sectionName.replace(/[\[\]]/g, '').trim(); object[sectionName] = {}; - let key = sections[i].match(/^[^;\s][^;\n]*/gm); //we remove comments behind ";" character + let key = sections[i].match(/^((?!\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$).)+/gm); //we remove comments "//" syntax, single row for (let k=1; k < key.length; k++) { let keyValue = key[k].split("="); - object[sectionName][keyValue[0]] = keyValue[1]; + if (keyValue[1].charAt(0) === "0" || isNaN(Number(keyValue[1]))) { // leading zeros are interpreted as string values + object[sectionName][keyValue[0].trim()] = keyValue[1].trim(); + } else { + object[sectionName][keyValue[0].trim()] = Number(keyValue[1]); + } } } return object; From 48cf50e7174752a4563bfb909efda971609a8410 Mon Sep 17 00:00:00 2001 From: Grovkillen Date: Sun, 19 Apr 2020 08:05:16 +0200 Subject: [PATCH 03/12] [gzip server] default path to /build/ --- GzipSimpleHTTPServer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/GzipSimpleHTTPServer.py b/GzipSimpleHTTPServer.py index 45101d5..fa73658 100644 --- a/GzipSimpleHTTPServer.py +++ b/GzipSimpleHTTPServer.py @@ -3,6 +3,9 @@ This module builds on BaseHTTPServer by implementing the standard GET and HEAD requests in a fairly straightforward manner. +Tweaked version based on: +https://github.com/ksmith97/GzipSimpleHTTPServer + """ @@ -303,7 +306,7 @@ def test(HandlerClass = SimpleHTTPRequestHandler, sa = httpd.socket.getsockname() print "Serving HTTP on", sa[0], "port", sa[1], "..." - url = 'http://localhost:' + str(sa[1]) + url = 'http://localhost:' + str(sa[1]) + '/build/' webbrowser.open(url) httpd.serve_forever() BaseHTTPServer.test(HandlerClass, ServerClass) From 21a2ff8280771ef1abc767cf88e3bbc9f1047d3c Mon Sep 17 00:00:00 2001 From: Grovkillen Date: Sun, 19 Apr 2020 08:09:54 +0200 Subject: [PATCH 04/12] [helper] leading zeros AND length more than 1 --- src/gui_easy_helper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui_easy_helper.js b/src/gui_easy_helper.js index fda75cb..b22175f 100644 --- a/src/gui_easy_helper.js +++ b/src/gui_easy_helper.js @@ -468,7 +468,7 @@ const helpEasy = { let key = sections[i].match(/^((?!\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$).)+/gm); //we remove comments "//" syntax, single row for (let k=1; k < key.length; k++) { let keyValue = key[k].split("="); - if (keyValue[1].charAt(0) === "0" || isNaN(Number(keyValue[1]))) { // leading zeros are interpreted as string values + if ((keyValue[1].charAt(0) === "0" && keyValue[1].length > 1) || isNaN(Number(keyValue[1]))) { // leading zeros are interpreted as string values object[sectionName][keyValue[0].trim()] = keyValue[1].trim(); } else { object[sectionName][keyValue[0].trim()] = Number(keyValue[1]); From 0b6da6e879f006de848ecf83b56d746a85224916 Mon Sep 17 00:00:00 2001 From: Grovkillen Date: Mon, 20 Apr 2020 09:02:41 +0200 Subject: [PATCH 05/12] [ini parser] added "pipe2array" to turn "A|B" string into [A, B] array --- src/gui_easy_helper.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gui_easy_helper.js b/src/gui_easy_helper.js index b22175f..f71d9c7 100644 --- a/src/gui_easy_helper.js +++ b/src/gui_easy_helper.js @@ -458,7 +458,7 @@ const helpEasy = { return json[path[0]][path[1]][path[2]][path[3]][path[4]][path[5]][path[6]][path[7]][path[8]][path[9]]; } }, - 'iniFileToObject': function(string) { + 'iniFileToObject': function(string, pipe2array = false) { let object = {}; let sections = string.match(/^\[[^\]\r\n]+](?:[\r\n]([^[\r\n].*)?)*/gm); for (let i=0; i < sections.length; i++) { @@ -469,7 +469,11 @@ const helpEasy = { for (let k=1; k < key.length; k++) { let keyValue = key[k].split("="); if ((keyValue[1].charAt(0) === "0" && keyValue[1].length > 1) || isNaN(Number(keyValue[1]))) { // leading zeros are interpreted as string values - object[sectionName][keyValue[0].trim()] = keyValue[1].trim(); + if (pipe2array && keyValue[1].trim().includes("|")) { + object[sectionName][keyValue[0].trim()] = keyValue[1].trim().split("|"); + } else { + object[sectionName][keyValue[0].trim()] = keyValue[1].trim(); + } } else { object[sectionName][keyValue[0].trim()] = Number(keyValue[1]); } From b94a88d77b24f5a7c826154755850392679c4ecd Mon Sep 17 00:00:00 2001 From: Grovkillen Date: Sun, 7 Jun 2020 10:49:18 +0200 Subject: [PATCH 06/12] [qzip] made server code py3+ based --- GzipSimpleHTTPServer.py | 166 +++++++++++----------------------------- 1 file changed, 43 insertions(+), 123 deletions(-) diff --git a/GzipSimpleHTTPServer.py b/GzipSimpleHTTPServer.py index fa73658..3e9b038 100644 --- a/GzipSimpleHTTPServer.py +++ b/GzipSimpleHTTPServer.py @@ -1,39 +1,22 @@ -"""Simple HTTP Server. -This module builds on BaseHTTPServer by implementing the standard GET -and HEAD requests in a fairly straightforward manner. - -Tweaked version based on: -https://github.com/ksmith97/GzipSimpleHTTPServer - -""" - - -__version__ = "0.6" - -__all__ = ["SimpleHTTPRequestHandler"] +__version__ = '0.00.001' +SERVER_PORT = 8000 +encoding_type = 'gzip' +source = '' +source_files = ['index.html', 'index.htm', 'index.html.gz', 'index.htm.gz', 'index.gz'] import os import posixpath -import BaseHTTPServer import urllib -import cgi +import html import sys import mimetypes import zlib import webbrowser +import io +from http.server import HTTPServer, BaseHTTPRequestHandler from optparse import OptionParser -try: - from cStringIO import StringIO -except ImportError: - from StringIO import StringIO - -SERVER_PORT = 8000 -encoding_type = 'gzip' -source = '' -source_files = ['index.html', 'index.htm', 'index.html.gz', 'index.htm.gz', 'index.gz'] - def parse_options(): # Option parsing logic. parser = OptionParser() @@ -67,7 +50,6 @@ def parse_options(): sys.stderr.write("Usage: python GzipSimpleHTTPServer.py --encoding=\n") sys.exit() - def zlib_encode(content): zlib_compress = zlib.compressobj(9, zlib.DEFLATED, zlib.MAX_WBITS) data = zlib_compress.compress(content) + zlib_compress.flush() @@ -85,24 +67,15 @@ def gzip_encode(content): data = gzip_compress.compress(content) + gzip_compress.flush() return data +class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): -class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): - """Simple HTTP request handler with GET and HEAD commands. - - This serves files from the current directory and any of its - subdirectories. The MIME type for files is determined by - calling the .guess_type() method. - - The GET and HEAD requests are identical except that the HEAD - request omits the actual contents of the file. - - """ - - server_version = "SimpleHTTP/" + __version__ + server_version = 'SimpleHTTP/' + __version__ def do_GET(self): """Serve a GET request.""" content = self.send_head() + if isinstance(content, str): + content = content.encode() if content: self.wfile.write(content) @@ -111,24 +84,14 @@ def do_HEAD(self): content = self.send_head() def send_head(self): - """Common code for GET and HEAD commands. - - This sends the response code and MIME headers. - Return value is either a file object (which has to be copied - to the outputfile by the caller unless the command was HEAD, - and must be closed by the caller under all circumstances), or - None, in which case the caller has nothing further to do. - - """ path = self.translate_path(self.path) f = None type = 'normal' if os.path.isdir(path): if not self.path.endswith('/'): - # redirect browser - doing basically what apache does self.send_response(301) - self.send_header("Location", self.path + "/") + self.send_header('Location', self.path + '/') self.end_headers() return None if not source == '': @@ -154,92 +117,78 @@ def send_head(self): type = source_type ctype = self.guess_type(path, type) - print("Serving path '%s'" % path) + print('Serving path "%s"' % path) try: # Always read in binary mode. Opening files in text mode may cause # newline translations, making the actual size of the content # transmitted *less* than the content-length! f = open(path, 'rb') except IOError: - self.send_error(404, "File not found") + self.send_error(404, 'File not found') return None self.send_response(200) - self.send_header("Content-type", ctype) - self.send_header("Content-Encoding", encoding_type) + self.send_header('Content-type', ctype) + self.send_header('Content-Encoding', encoding_type) fs = os.fstat(f.fileno()) raw_content_length = fs[6] content = f.read() - if type == 'normal': # Encode content based on runtime arg - if encoding_type == "gzip": + if encoding_type == 'gzip': content = gzip_encode(content) - elif encoding_type == "deflate": + elif encoding_type == 'deflate': content = deflate_encode(content) - elif encoding_type == "zlib": + elif encoding_type == 'zlib': content = zlib_encode(content) compressed_content_length = len(content) - f.close() - self.send_header("Content-Length", max(raw_content_length, compressed_content_length)) - self.send_header("Last-Modified", self.date_time_string(fs.st_mtime)) + self.send_header('Content-Length', max(raw_content_length, compressed_content_length)) + self.send_header('Last-Modified', self.date_time_string(fs.st_mtime)) self.end_headers() return content def list_directory(self, path): - """Helper to produce a directory listing (absent index.html). - Return value is either a file object, or None (indicating an - error). In either case, the headers are sent, making the - interface the same as for send_head(). - - """ try: list = os.listdir(path) except os.error: - self.send_error(404, "No permission to list directory") + self.send_error(404, 'No permission to list directory') return None list.sort(key=lambda a: a.lower()) - f = StringIO() - displaypath = cgi.escape(urllib.unquote(self.path)) + f = io.StringIO() + displaypath = html.escape(urllib.parse.unquote(self.path)) f.write('') - f.write("\nGUI Easy %s\n" % displaypath) - f.write("\n

Directory: %s

\n" % displaypath) - f.write("
\n
    \n") + f.write('\nGUI Easy %s\n' % displaypath) + f.write('\n

    Directory: %s

    \n' % displaypath) + f.write('
    \n
      \n') for name in list: fullname = os.path.join(path, name) displayname = linkname = name # Append / for directories or @ for symbolic links if os.path.isdir(fullname): - displayname = name + "/" - linkname = name + "/" + displayname = name + '/' + linkname = name + '/' if os.path.islink(fullname): displayname = name + "@" # Note: a link to a directory displays with @ and links with / f.write('
    • %s\n' - % (urllib.quote(linkname), cgi.escape(displayname))) - f.write("
    \n
    \n\n\n") + % (urllib.parse.quote(linkname), html.escape(displayname))) + f.write('
\n
\n\n\n') length = f.tell() f.seek(0) self.send_response(200) encoding = sys.getfilesystemencoding() - self.send_header("Content-type", "text/html; charset=%s" % encoding) - self.send_header("Content-Length", str(length)) + self.send_header('Content-type', 'text/html; charset=%s' % encoding) + self.send_header('Content-Length', str(length)) self.end_headers() return f def translate_path(self, path): - """Translate a /-separated PATH to the local filename syntax. - - Components that mean special things to the local file system - (e.g. drive or directory names) are ignored. (XXX They should - probably be diagnosed.) - """ # abandon query parameters path = path.split('?',1)[0] path = path.split('#',1)[0] - path = posixpath.normpath(urllib.unquote(path)) + path = posixpath.normpath(urllib.parse.unquote(path)) words = path.split('/') words = filter(None, words) path = os.getcwd() @@ -251,19 +200,6 @@ def translate_path(self, path): return path def guess_type(self, path, type): - """Guess the type of a file. - - Argument is a PATH (a filename). - - Return value is a string of the form type/subtype, - usable for a MIME Content-type header. - - The default implementation looks the file's extension - up in the table self.extensions_map, using application/octet-stream - as a default; however it would be permissible (if - slow) to look inside the data to make a better guess. - - """ base, ext = posixpath.splitext(path) if type == 'gzipped': @@ -287,30 +223,14 @@ def guess_type(self, path, type): '.h': 'text/plain' }) +parse_options() -def test(HandlerClass = SimpleHTTPRequestHandler, - ServerClass = BaseHTTPServer.HTTPServer): - """Run the HTTP request handler class. - - This runs an HTTP server on port 8000 (or the first command line - argument). - - """ - - parse_options() - - server_address = ('localhost', SERVER_PORT) - - SimpleHTTPRequestHandler.protocol_version = "HTTP/1.0" - httpd = BaseHTTPServer.HTTPServer(server_address, SimpleHTTPRequestHandler) - - sa = httpd.socket.getsockname() - print "Serving HTTP on", sa[0], "port", sa[1], "..." - url = 'http://localhost:' + str(sa[1]) + '/build/' - webbrowser.open(url) - httpd.serve_forever() - BaseHTTPServer.test(HandlerClass, ServerClass) +server_address = ('localhost', SERVER_PORT) +httpd = HTTPServer(server_address, SimpleHTTPRequestHandler) -if __name__ == '__main__': - test() +sa = httpd.socket.getsockname() +print('Serving HTTP on', sa[0], 'port', sa[1], '...') +url = 'http://localhost:' + str(sa[1]) + '/build/' +webbrowser.open(url) +httpd.serve_forever() \ No newline at end of file From bb5aea7ed31f71e497a91b0cfaafbb79ead24945 Mon Sep 17 00:00:00 2001 From: Grovkillen Date: Sun, 7 Jun 2020 10:49:51 +0200 Subject: [PATCH 07/12] [ini parser] added null type --- src/gui_easy_helper.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui_easy_helper.js b/src/gui_easy_helper.js index f71d9c7..8f29bae 100644 --- a/src/gui_easy_helper.js +++ b/src/gui_easy_helper.js @@ -471,6 +471,8 @@ const helpEasy = { if ((keyValue[1].charAt(0) === "0" && keyValue[1].length > 1) || isNaN(Number(keyValue[1]))) { // leading zeros are interpreted as string values if (pipe2array && keyValue[1].trim().includes("|")) { object[sectionName][keyValue[0].trim()] = keyValue[1].trim().split("|"); + } else if (keyValue[1].trim() === "null") { + object[sectionName][keyValue[0].trim()] = null; } else { object[sectionName][keyValue[0].trim()] = keyValue[1].trim(); } From 7a72b8a9258f0a9fed9190f48f6cea968595a48b Mon Sep 17 00:00:00 2001 From: Grovkillen Date: Sun, 7 Jun 2020 10:50:16 +0200 Subject: [PATCH 08/12] [css] bottom tab z-index added --- src/gui_easy.css | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui_easy.css b/src/gui_easy.css index f652c6f..6513efd 100644 --- a/src/gui_easy.css +++ b/src/gui_easy.css @@ -291,6 +291,7 @@ div.bottom-drawer::before { box-shadow: inset 0 30px 25px -20px rgba(var(--main-inverted-color), 1); } div.bottom-tab { + z-index: 10000; display: flex; background-color: var(--main-inverted-color-rgba); padding: 2px 8px 6px; From e2787f55b936f6f168db16fd9c8729323ebc29eb Mon Sep 17 00:00:00 2001 From: Grovkillen Date: Wed, 9 Dec 2020 19:32:19 +0100 Subject: [PATCH 09/12] Made ini parser smarter --- src/gui_easy.css | 2 +- src/gui_easy_helper.js | 59 ++++++++++++++++++----------- src/gui_easy_helper_esp_specific.js | 1 + 3 files changed, 38 insertions(+), 24 deletions(-) diff --git a/src/gui_easy.css b/src/gui_easy.css index 6513efd..8d91cbc 100644 --- a/src/gui_easy.css +++ b/src/gui_easy.css @@ -294,7 +294,7 @@ div.bottom-tab { z-index: 10000; display: flex; background-color: var(--main-inverted-color-rgba); - padding: 2px 8px 6px; + padding: 2px 8px 0; width: auto; position: absolute; top: 4px; diff --git a/src/gui_easy_helper.js b/src/gui_easy_helper.js index 8f29bae..5b1a889 100644 --- a/src/gui_easy_helper.js +++ b/src/gui_easy_helper.js @@ -459,29 +459,42 @@ const helpEasy = { } }, 'iniFileToObject': function(string, pipe2array = false) { - let object = {}; - let sections = string.match(/^\[[^\]\r\n]+](?:[\r\n]([^[\r\n].*)?)*/gm); - for (let i=0; i < sections.length; i++) { - let sectionName = sections[i].split("\n")[0]; - sectionName = sectionName.replace(/[\[\]]/g, '').trim(); - object[sectionName] = {}; - let key = sections[i].match(/^((?!\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$).)+/gm); //we remove comments "//" syntax, single row - for (let k=1; k < key.length; k++) { - let keyValue = key[k].split("="); - if ((keyValue[1].charAt(0) === "0" && keyValue[1].length > 1) || isNaN(Number(keyValue[1]))) { // leading zeros are interpreted as string values - if (pipe2array && keyValue[1].trim().includes("|")) { - object[sectionName][keyValue[0].trim()] = keyValue[1].trim().split("|"); - } else if (keyValue[1].trim() === "null") { - object[sectionName][keyValue[0].trim()] = null; - } else { - object[sectionName][keyValue[0].trim()] = keyValue[1].trim(); - } - } else { - object[sectionName][keyValue[0].trim()] = Number(keyValue[1]); - } - } - } - return object; + let object = {}; + let sections = string.match(/^\[[^\]\r\n]+](?:[\r\n]([^[\r\n].*)?)*/gm); + if (sections === null) { + return object["error"] = "Cannot parse ini data!"; + } + for (let i=0; i < sections.length; i++) { + let sectionName = sections[i].split("\n")[0]; + sectionName = sectionName.replace(/[\[\]]/g, '').trim(); + object[sectionName] = {}; + let key = sections[i].match(/^((?!\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$).)+/gm); //we remove comments "//" syntax, single row + for (let k=1; k < key.length; k++) { + let keyValue = key[k].split("="); + if (keyValue.length === 1) { + continue; // since we don't have a "=" sign we treat this the same way we treat comments = remove them + } + if (keyValue.length > 2) { + keyValue[1] = keyValue.slice(1, keyValue.length).join('='); //join if = is used in the string value + } + if (keyValue[1] === "") { + object[sectionName][keyValue[0].trim()] = null; // make empty strings null + continue; + } + if ((keyValue[1].charAt(0) === "0" && keyValue[1].charAt(1) !== "." && keyValue[1].length > 1) || isNaN(Number(keyValue[1]))) { // leading zeros with no dot following are interpreted as string values + if (pipe2array && keyValue[1].trim().includes("|")) { + object[sectionName][keyValue[0].trim()] = keyValue[1].trim().split("|"); + } else if (keyValue[1].trim() === "null") { + object[sectionName][keyValue[0].trim()] = null; + } else { + object[sectionName][keyValue[0].trim()] = keyValue[1].trim(); + } + } else { + object[sectionName][keyValue[0].trim()] = Number(keyValue[1]); + } + } + } + return object; }, 'sortObjectArray': (propName) => (a, b) => a[propName] === b[propName] ? 0 : a[propName] < b[propName] ? -1 : 1 diff --git a/src/gui_easy_helper_esp_specific.js b/src/gui_easy_helper_esp_specific.js index be6913e..e0193b4 100644 --- a/src/gui_easy_helper_esp_specific.js +++ b/src/gui_easy_helper_esp_specific.js @@ -13,6 +13,7 @@ helpEasy.int32binaryBool = function (obj, int, names, base, emptyString = "_empt } }; +//should be async + await fetch helpEasy.getDataFromNode = function (array, index, endpoint, ttl_fallback) { array[index]["scheduler"].shift(); let timeStart = Date.now(); From c9147997588831f2b9996dbda8501dd066a9eb9c Mon Sep 17 00:00:00 2001 From: Grovkillen Date: Tue, 15 Dec 2020 11:25:16 +0100 Subject: [PATCH 10/12] [helper] added boolean parsing of INI files --- src/gui_easy_helper.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gui_easy_helper.js b/src/gui_easy_helper.js index 5b1a889..8cbd563 100644 --- a/src/gui_easy_helper.js +++ b/src/gui_easy_helper.js @@ -487,7 +487,13 @@ const helpEasy = { } else if (keyValue[1].trim() === "null") { object[sectionName][keyValue[0].trim()] = null; } else { - object[sectionName][keyValue[0].trim()] = keyValue[1].trim(); + object[sectionName][keyValue[0].trim()] = (function (string) { //parse booleans + switch(string){ + case "true": case "yes": return true; + case "false": case "no": return false; + default: return string; + } + })(keyValue[1].trim()); } } else { object[sectionName][keyValue[0].trim()] = Number(keyValue[1]); From 0683016988a0e481c804b99e24c47647bed06268 Mon Sep 17 00:00:00 2001 From: Grovkillen Date: Tue, 15 Dec 2020 11:27:05 +0100 Subject: [PATCH 11/12] [helper] made nulls part of check INI files --- src/gui_easy_helper.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gui_easy_helper.js b/src/gui_easy_helper.js index 8cbd563..3d53aaa 100644 --- a/src/gui_easy_helper.js +++ b/src/gui_easy_helper.js @@ -484,13 +484,12 @@ const helpEasy = { if ((keyValue[1].charAt(0) === "0" && keyValue[1].charAt(1) !== "." && keyValue[1].length > 1) || isNaN(Number(keyValue[1]))) { // leading zeros with no dot following are interpreted as string values if (pipe2array && keyValue[1].trim().includes("|")) { object[sectionName][keyValue[0].trim()] = keyValue[1].trim().split("|"); - } else if (keyValue[1].trim() === "null") { - object[sectionName][keyValue[0].trim()] = null; } else { - object[sectionName][keyValue[0].trim()] = (function (string) { //parse booleans + object[sectionName][keyValue[0].trim()] = (function (string) { //parse booleans and nulls switch(string){ case "true": case "yes": return true; case "false": case "no": return false; + case "null": return null; default: return string; } })(keyValue[1].trim()); From 7c141cf23e6b2d50d46882cf72de71640a2d3132 Mon Sep 17 00:00:00 2001 From: Grovkillen Date: Tue, 15 Dec 2020 11:32:15 +0100 Subject: [PATCH 12/12] [helper] made sure string switch test is lowercase --- src/gui_easy_helper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui_easy_helper.js b/src/gui_easy_helper.js index 3d53aaa..c0f73c2 100644 --- a/src/gui_easy_helper.js +++ b/src/gui_easy_helper.js @@ -492,7 +492,7 @@ const helpEasy = { case "null": return null; default: return string; } - })(keyValue[1].trim()); + })(keyValue[1].toLowerCase().trim()); } } else { object[sectionName][keyValue[0].trim()] = Number(keyValue[1]);