diff --git a/www/layout/admin/javascript/edit.jq.js b/www/layout/admin/javascript/edit.jq.js index c9344b52..bb05fbba 100644 --- a/www/layout/admin/javascript/edit.jq.js +++ b/www/layout/admin/javascript/edit.jq.js @@ -342,6 +342,31 @@ function valueInObject(object, value) // }) ? true : false; } +/** + * true deep copy for Javascript objects + * if Object.assign({}, obj) is not working (shallow) + * or if JSON.parse(JSON.stringify(obj)) is failing + * @param {Object} inObject Object to copy + * @return {Object} Copied Object + */ +function deepCopyFunction(inObject) +{ + var outObject, value, key; + if (typeof inObject !== "object" || inObject === null) { + return inObject; // Return the value if inObject is not an object + } + // Create an array or object to hold the values + outObject = Array.isArray(inObject) ? [] : {}; + // loop over ech entry in object + for (key in inObject) { + value = inObject[key]; + // Recursively (deep) copy for nested objects, including arrays + outObject[key] = deepCopyFunction(value); + } + + return outObject; +} + /** * checks if a DOM element actually exists * @param {String} id Element id to check for diff --git a/www/psalm.xml b/www/psalm.xml index 953246a6..ecb85e0f 100644 --- a/www/psalm.xml +++ b/www/psalm.xml @@ -6,6 +6,7 @@ xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" autoloader="lib/autoloader.php" + errorLevel="8" > @@ -28,7 +29,8 @@ - + +