#4 -- Add parsing rule with consequent
All checks were successful
CI fuzzy controller / container-test-job (push) Successful in 58s
All checks were successful
CI fuzzy controller / container-test-job (push) Successful in 58s
This commit is contained in:
parent
984a719cbf
commit
40246d913b
@ -89,12 +89,25 @@ function createRule() {
|
|||||||
let inpVal = $('.selectpicker.inputVal').children(':selected').map(function () {
|
let inpVal = $('.selectpicker.inputVal').children(':selected').map(function () {
|
||||||
return $(this).text();
|
return $(this).text();
|
||||||
}).get();
|
}).get();
|
||||||
|
let out = $('.selectpicker.outVar').children(':selected').map(function () {
|
||||||
|
return $(this).text();
|
||||||
|
}).get();
|
||||||
|
let outVal = $('.selectpicker.outVal').children(':selected').map(function () {
|
||||||
|
return $(this).text();
|
||||||
|
}).get();
|
||||||
for (let i = 0; i < inp.length; i++) {
|
for (let i = 0; i < inp.length; i++) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
ruleString += ' and ';
|
ruleString += ' and ';
|
||||||
}
|
}
|
||||||
ruleString += inp[i] + " is " + inpVal[i];
|
ruleString += inp[i] + " is " + inpVal[i];
|
||||||
}
|
}
|
||||||
|
ruleString += " then ";
|
||||||
|
for (let i = 0; i < out.length; i++) {
|
||||||
|
if (i > 0) {
|
||||||
|
ruleString += ' and ';
|
||||||
|
}
|
||||||
|
ruleString += out[i] + " is " + outVal[i];
|
||||||
|
}
|
||||||
$('#ruleContent').val(ruleString);
|
$('#ruleContent').val(ruleString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,14 +162,14 @@ function fuzzyTermsValueChanged() {
|
|||||||
createRule();
|
createRule();
|
||||||
}
|
}
|
||||||
|
|
||||||
function createVariableSelect(projectId, variableVal) {
|
function createVariableSelect(cls, projectId, variableVal) {
|
||||||
let variablesElement = $("<select class='selectpicker inputVar m-2' data-live-search='true data-width='70%'></select>");
|
let variablesElement = $("<select class='selectpicker " + cls + " m-2' data-live-search='true data-width='70%'></select>");
|
||||||
fillVariables(projectId, variablesElement, variableVal);
|
fillVariables(projectId, variablesElement, variableVal);
|
||||||
return variablesElement;
|
return variablesElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createFuzzyTermsSelect(variablesElement, termVal) {
|
function createFuzzyTermsSelect(cls, variablesElement, termVal) {
|
||||||
let fuzzyTermsElement = $("<select class='selectpicker inputVal m-2' data-live-search='true data-width='70%'></select>");
|
let fuzzyTermsElement = $("<select class='selectpicker " + cls + " m-2' data-live-search='true data-width='70%'></select>");
|
||||||
if ($(variablesElement).val()) {
|
if ($(variablesElement).val()) {
|
||||||
fillFuzzyTerms(variablesElement, fuzzyTermsElement, termVal);
|
fillFuzzyTerms(variablesElement, fuzzyTermsElement, termVal);
|
||||||
}
|
}
|
||||||
@ -180,8 +193,8 @@ function addAntecedent(parentElement, projectId, variableVal, termVal) {
|
|||||||
} else {
|
} else {
|
||||||
$(rowElement).append("<label class='col col-md-1 m-2'> </label>");
|
$(rowElement).append("<label class='col col-md-1 m-2'> </label>");
|
||||||
}
|
}
|
||||||
let variablesElement = createVariableSelect(projectId, variableVal);
|
let variablesElement = createVariableSelect('inputVar', projectId, variableVal);
|
||||||
let fuzzyTermsElement = createFuzzyTermsSelect(variablesElement, termVal);
|
let fuzzyTermsElement = createFuzzyTermsSelect('inputVal', variablesElement, termVal);
|
||||||
$(variablesElement).on("change", function () {
|
$(variablesElement).on("change", function () {
|
||||||
variableValueChanged(variablesElement, fuzzyTermsElement)
|
variableValueChanged(variablesElement, fuzzyTermsElement)
|
||||||
});
|
});
|
||||||
@ -204,8 +217,8 @@ function addConsequent(parentElement, projectId, variableVal, termVal) {
|
|||||||
} else {
|
} else {
|
||||||
$(rowElement).append("<label class='col col-md-1 m-2'> </label>");
|
$(rowElement).append("<label class='col col-md-1 m-2'> </label>");
|
||||||
}
|
}
|
||||||
let variablesElement = createVariableSelect(projectId, variableVal);
|
let variablesElement = createVariableSelect('outVar', projectId, variableVal);
|
||||||
let fuzzyTermsElement = createFuzzyTermsSelect(variablesElement, termVal);
|
let fuzzyTermsElement = createFuzzyTermsSelect('outVal', variablesElement, termVal);
|
||||||
$(variablesElement).on("change", function () {
|
$(variablesElement).on("change", function () {
|
||||||
variableValueChanged(variablesElement, fuzzyTermsElement)
|
variableValueChanged(variablesElement, fuzzyTermsElement)
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user