diff --git a/src/main/resources/public/js/fuzzyRule.js b/src/main/resources/public/js/fuzzyRule.js index 58a1b7c..248aa27 100644 --- a/src/main/resources/public/js/fuzzyRule.js +++ b/src/main/resources/public/js/fuzzyRule.js @@ -1,12 +1,10 @@ - // Rules parsing // antecedent function getAntecedent(rule) { - var withoutIf = rule.split('if'); + let withoutIf = rule.split('if'); return withoutIf[1].trim().split('then')[0].trim(); } - // TODO: remove duplicate function getAntecedentComponents(antecedent) { return antecedent.split('and').map((i) => i.trim()); @@ -14,7 +12,7 @@ function getAntecedentComponents(antecedent) { // consequent function getConsequent(rule) { - var withoutIf = rule.split('if'); + let withoutIf = rule.split('if'); return withoutIf[1].trim().split('then')[1].trim(); } @@ -35,7 +33,7 @@ function getVariableValue(variableComponents) { // Rules creation /* exported MessageTypesEnum */ -var MessageTypesEnum = { +let MessageTypesEnum = { INFO: "info", SUCCESS: "success", WARNING: "warning", @@ -44,7 +42,7 @@ var MessageTypesEnum = { Object.freeze(MessageTypesEnum); function isEmpty(value) { - if (typeof value === "function") { + if (typeof value === "function") { return false; } return (value == null || value.length === 0); @@ -54,6 +52,7 @@ function isEmpty(value) { function showFeedbackMessage(message, type) { alert(type + ' ' + message); } + /* exported errorHandler */ function errorHandler(response, callBack, errorCallBack) { if (!isEmpty(response.error)) { @@ -82,11 +81,15 @@ function getFromRest(url, callBack) { } /* exported createRule */ - function createRule() { - var ruleString = "if "; - var inp = $('.selectpicker.inputVar').children(':selected').map(function() {return $(this).text();}).get(); - var inpVal = $('.selectpicker.inputVal').children(':selected').map(function() {return $(this).text();}).get(); - for (var i = 0; i < inp.length; i++) { +function createRule() { + let ruleString = "if "; + let inp = $('.selectpicker.inputVar').children(':selected').map(function () { + return $(this).text(); + }).get(); + let inpVal = $('.selectpicker.inputVal').children(':selected').map(function () { + return $(this).text(); + }).get(); + for (let i = 0; i < inp.length; i++) { if (i > 0) { ruleString += ' and '; } @@ -101,7 +104,7 @@ function fillSelect(selectElement, values, selectedVal) { $.each(values, function (key, value) { $(selectElement).append($("