From ec20a8580d2f75e6ba7397457ce643df5e6a41e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Maih=C3=B6fer?= Date: Fri, 17 Jan 2025 12:18:09 +0100 Subject: [PATCH] customop errorhandling with new op class --- .../Ops.Extension.Deprecated.Cables.CustomOp.js | 6 +++--- .../Ops.Extension.Deprecated.Cables.CustomOp.json | 6 ++++++ .../Ops.Extension.Deprecated.Cables.CustomOp_v2.js | 9 +++++---- .../Ops.Extension.Deprecated.Cables.CustomOp_v2.json | 6 ++++++ 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Ops.Extension.Deprecated/Ops.Extension.Deprecated.Cables.CustomOp/Ops.Extension.Deprecated.Cables.CustomOp.js b/Ops.Extension.Deprecated/Ops.Extension.Deprecated.Cables.CustomOp/Ops.Extension.Deprecated.Cables.CustomOp.js index 845420aa..786c6496 100644 --- a/Ops.Extension.Deprecated/Ops.Extension.Deprecated.Cables.CustomOp/Ops.Extension.Deprecated.Cables.CustomOp.js +++ b/Ops.Extension.Deprecated/Ops.Extension.Deprecated.Cables.CustomOp/Ops.Extension.Deprecated.Cables.CustomOp.js @@ -197,9 +197,9 @@ const execute = () => const name = "Ops.Custom.CUSTOM" + op.id.replace(/-/g, ""); const code = inJS.get(); let codeHead = "Ops.Custom = Ops.Custom || {};\n"; - codeHead += name + " = " + name + " || {};\n"; - codeHead += name + " = function()\n{\nCABLES.Op.apply(this,arguments);\nconst op=this;\n"; - let codeFoot = "\n\n};\n\n" + name + ".prototype = new CABLES.Op();\n"; + codeHead += name + " = class extends CABLES.Op \n{"; + codeHead += "constructor()\n{ super(...arguments);\nconst op=this;const attachments=op.attachments={};\n"; + let codeFoot = "}\n\n};\n\n"; codeFoot += "new " + name + "();\n"; const opCode = codeHead + code + codeFoot; op.setUiError("error", e); diff --git a/Ops.Extension.Deprecated/Ops.Extension.Deprecated.Cables.CustomOp/Ops.Extension.Deprecated.Cables.CustomOp.json b/Ops.Extension.Deprecated/Ops.Extension.Deprecated.Cables.CustomOp/Ops.Extension.Deprecated.Cables.CustomOp.json index 742a691a..b81cebbe 100644 --- a/Ops.Extension.Deprecated/Ops.Extension.Deprecated.Cables.CustomOp/Ops.Extension.Deprecated.Cables.CustomOp.json +++ b/Ops.Extension.Deprecated/Ops.Extension.Deprecated.Cables.CustomOp/Ops.Extension.Deprecated.Cables.CustomOp.json @@ -22,6 +22,12 @@ "type": "deprecation", "author": "stephan", "date": 1719915871534 + }, + { + "message": "refactor to use new op class", + "type": "improvement", + "author": "stephan", + "date": 1737112559414 } ], "authorName": "stephan", diff --git a/Ops.Extension.Deprecated/Ops.Extension.Deprecated.Cables.CustomOp_v2/Ops.Extension.Deprecated.Cables.CustomOp_v2.js b/Ops.Extension.Deprecated/Ops.Extension.Deprecated.Cables.CustomOp_v2/Ops.Extension.Deprecated.Cables.CustomOp_v2.js index 40951563..1fe83677 100644 --- a/Ops.Extension.Deprecated/Ops.Extension.Deprecated.Cables.CustomOp_v2/Ops.Extension.Deprecated.Cables.CustomOp_v2.js +++ b/Ops.Extension.Deprecated/Ops.Extension.Deprecated.Cables.CustomOp_v2/Ops.Extension.Deprecated.Cables.CustomOp_v2.js @@ -85,7 +85,7 @@ op.onError = function (ex) if (badLines[bj] == j) isBadLine = true; if (isBadLine) htmlWarning += ""; - htmlWarning += line.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """) + htmlWarning += line.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """) .replaceAll("'", "'"); if (isBadLine) htmlWarning += ""; } @@ -310,11 +310,12 @@ const execute = () => const name = "Ops.Custom.CUSTOM" + op.id.replace(/-/g, ""); const code = inJS.get(); let codeHead = "Ops.Custom = Ops.Custom || {};\n"; - codeHead += name + " = " + name + " || {};\n"; - codeHead += name + " = function()\n{\nCABLES.Op.apply(this,arguments);\nconst op=this;\n"; - let codeFoot = "\n\n};\n\n" + name + ".prototype = new CABLES.Op();\n"; + codeHead += name + " = class extends CABLES.Op \n{"; + codeHead += "constructor()\n{ super(...arguments);\nconst op=this;const attachments=op.attachments={};\n"; + let codeFoot = "}\n\n};\n\n"; codeFoot += "new " + name + "();\n"; const opCode = codeHead + code + codeFoot; + const errorEl = document.createElement("script"); errorEl.id = "customop-error-" + op.id; errorEl.type = "text/javascript"; diff --git a/Ops.Extension.Deprecated/Ops.Extension.Deprecated.Cables.CustomOp_v2/Ops.Extension.Deprecated.Cables.CustomOp_v2.json b/Ops.Extension.Deprecated/Ops.Extension.Deprecated.Cables.CustomOp_v2/Ops.Extension.Deprecated.Cables.CustomOp_v2.json index b5acf204..2cdfccdb 100644 --- a/Ops.Extension.Deprecated/Ops.Extension.Deprecated.Cables.CustomOp_v2/Ops.Extension.Deprecated.Cables.CustomOp_v2.json +++ b/Ops.Extension.Deprecated/Ops.Extension.Deprecated.Cables.CustomOp_v2/Ops.Extension.Deprecated.Cables.CustomOp_v2.json @@ -52,6 +52,12 @@ "type": "deprecation", "author": "stephan", "date": 1719915896310 + }, + { + "message": "refactor to use new op class", + "type": "improvement", + "author": "stephan", + "date": 1737112571269 } ], "authorName": "stephan",