From aab9d010bebf3b0c33facc5e87eb54e0a681089c Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 28 Feb 2025 13:59:31 +0400 Subject: [PATCH] #4 -- Fix code --- src/main/resources/public/js/fuzzyRule.js | 21 +++++++++++++++++++ .../resources/templates/project/edit.html | 18 +--------------- src/main/resources/templates/rule/edit.html | 6 +++++- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/main/resources/public/js/fuzzyRule.js b/src/main/resources/public/js/fuzzyRule.js index f075a52..1f07ffb 100644 --- a/src/main/resources/public/js/fuzzyRule.js +++ b/src/main/resources/public/js/fuzzyRule.js @@ -1,3 +1,24 @@ + +// Rules parsing +function getAntecedent(rule) { + withoutIf = rule.split('if'); + return withoutIf[1].trim().split('then')[0].trim(); +} + +function getAntecedentComponents(antecedent) { + return antecedent.split('and').map((i) => i.trim()); +} + +function getVariable(antecedent) { + return antecedent.split('is')[0].trim(); +} + +function getVariableValue(antecedent) { + return antecedent.split('is')[1].trim(); +} + +// Rules creation + /* exported MessageTypesEnum */ var MessageTypesEnum = { INFO: "info", diff --git a/src/main/resources/templates/project/edit.html b/src/main/resources/templates/project/edit.html index 61e8c8b..c683dbb 100644 --- a/src/main/resources/templates/project/edit.html +++ b/src/main/resources/templates/project/edit.html @@ -57,24 +57,8 @@ class="btn btn-outline-dark">Добавить правило +