#4 -- Read rule string #20

Merged
romanov73 merged 17 commits from 4-rule-input into master 2025-02-28 22:02:20 +04:00
3 changed files with 27 additions and 18 deletions
Showing only changes of commit aab9d010be - Show all commits

View File

@ -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",

View File

@ -57,24 +57,8 @@
class="btn btn-outline-dark">Добавить правило</a>
</div>
</div>
<script type="text/javascript" src="/js/fuzzyRule.js"></script>
<script>
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();
}
function addRule(index, el, rule) {
ruleHtml = "<div class='col col-md-12'><span class='badge badge-light'>"+(index+1) +". Если</span></div>"
antecedentComponents = getAntecedentComponents(getAntecedent(rule));

View File

@ -45,7 +45,11 @@
<script type="text/javascript" src="/js/fuzzyRule.js"></script>
<script>
/*<![CDATA[*/
addAntecedent($('#rules'), [[${projectId}]]);
if ($('#ruleContent').val()) {
alert('123');
} else {
addAntecedent($('#rules'), [[${projectId}]]);
}
/*]]>*/
</script>
</form>