From dd21d23d9922694b38af55c1900aa95adac4b3ec Mon Sep 17 00:00:00 2001 From: ta-hinokihara Date: Wed, 19 Nov 2025 00:47:21 +0900 Subject: [PATCH 1/2] Replace the $\[\[ \]\] section with the calculated result --- public/form.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/public/form.js b/public/form.js index 5f42c9f..88b423f 100644 --- a/public/form.js +++ b/public/form.js @@ -656,6 +656,8 @@ ocForm.showLine = function(selectedValues, line, keys, widgets, canHide, separat } } } + // After variable substitution, replace the $[[ ]] section with the calculated result. + line = line.replace(/\$\[\[(.*?)\]\]/g, (_, expr) => eval(expr)) if (line) { selectedValues.push(line); From 45f22a59badb6671d7e0cdb0c42d39559f96e6ce Mon Sep 17 00:00:00 2001 From: ta-hinokihara Date: Wed, 19 Nov 2025 02:16:50 +0900 Subject: [PATCH 2/2] Modify to do nothing if expr returns an error. --- public/form.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/public/form.js b/public/form.js index 88b423f..889fbb3 100644 --- a/public/form.js +++ b/public/form.js @@ -657,8 +657,16 @@ ocForm.showLine = function(selectedValues, line, keys, widgets, canHide, separat } } // After variable substitution, replace the $[[ ]] section with the calculated result. - line = line.replace(/\$\[\[(.*?)\]\]/g, (_, expr) => eval(expr)) - + line = line.replace(/\$\[\[(.*?)\]\]/g, (_, expr) => { + try { + // Return calculation result + return eval(expr); + } catch (e) { + // Nothing to do + return `$[[${expr}]]`; + } + }); + if (line) { selectedValues.push(line); }