diff --git a/resources/static/embedded-json-enc.js b/resources/static/embedded-json-enc.js new file mode 100644 index 0000000..afacf62 --- /dev/null +++ b/resources/static/embedded-json-enc.js @@ -0,0 +1,47 @@ +(function () { + function _isNumeric(str) { + if (typeof str != "string") { + return false + } + return !isNaN(str) && !isNaN(parseFloat(str)); + } + + function _cast(str) { + return _isNumeric(str) ? parseFloat(str) : str; + } + + function _addAssocToDict(obj, key, value) { + let splittedKey = Array.isArray(key) ? key : key.split("."); + const keyToAdd = splittedKey.shift(); + const isTerminal = splittedKey.length === 0; + if (isTerminal) { + obj[keyToAdd] = _cast(value); + return obj; + } + if (!(keyToAdd in obj)) { + obj[keyToAdd] = {}; + } + return _addAssocToDict(obj[keyToAdd], splittedKey, value); + } + + function _createPayload(params) { + let ret = {}; + for (let key of Object.keys(params)) { + _addAssocToDict(ret, key, params[key]); + } + return ret; + } + + htmx.defineExtension('json-enc', { + onEvent: function (name, evt) { + if (name === "htmx:configRequest") { + evt.detail.headers['Content-Type'] = "application/json"; + } + }, + + encodeParameters: function (xhr, parameters, elt) { + xhr.overrideMimeType('text/json'); + return (JSON.stringify(_createPayload(parameters))); + } + }); +})(); \ No newline at end of file diff --git a/resources/static/htmx.org@1.8.5 b/resources/static/vendor/htmx.org@1.8.5 similarity index 100% rename from resources/static/htmx.org@1.8.5 rename to resources/static/vendor/htmx.org@1.8.5 diff --git a/resources/static/json-enc.js b/resources/static/vendor/json-enc.js similarity index 100% rename from resources/static/json-enc.js rename to resources/static/vendor/json-enc.js diff --git a/resources/static/uikit-icons.min.js b/resources/static/vendor/uikit-icons.min.js similarity index 100% rename from resources/static/uikit-icons.min.js rename to resources/static/vendor/uikit-icons.min.js diff --git a/resources/static/uikit.min.css b/resources/static/vendor/uikit.min.css similarity index 100% rename from resources/static/uikit.min.css rename to resources/static/vendor/uikit.min.css diff --git a/resources/static/uikit.min.js b/resources/static/vendor/uikit.min.js similarity index 100% rename from resources/static/uikit.min.js rename to resources/static/vendor/uikit.min.js diff --git a/resources/templates/actions.html b/resources/templates/actions.html index 982b5c6..6f52ddb 100644 --- a/resources/templates/actions.html +++ b/resources/templates/actions.html @@ -24,9 +24,6 @@
- - - diff --git a/resources/templates/base.html b/resources/templates/base.html index 3144491..69cf45d 100644 --- a/resources/templates/base.html +++ b/resources/templates/base.html @@ -4,11 +4,11 @@