generic_expression.js 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437
  1. // iVProg - www.usp.br/line/ivprog
  2. // LInE - Free Education, Private Data
  3. import { Types } from "../types";
  4. import * as Models from "../ivprog_elements";
  5. import { LocalizedStrings } from "../../services/localizedStringsService";
  6. import * as VariableValueMenuManagement from "./variable_value_menu";
  7. import { registerUserEvent, ActionTypes } from "../../services/userLog";
  8. import WatchJS from "melanke-watchjs";
  9. import * as Utils from '../utils';
  10. window.timer = false;
  11. // @calledby ./ivprog/js/util/codeParser.js: function parseWriter(command, function_obj)
  12. export function renderExpression (command, function_obj, div_to_render, expression_array) {
  13. console.log("./ivprog/js/visualUI/commands/generic_expression.js: renderExpression(.): expression_array=" + JSON.stringify(expression_array)); //leo
  14. if (!expression_array || !expression_array[0] || expression_array[0]===undefined) {
  15. console.log(" *** ERROR! expression_array or expression_array[0] empty");
  16. return; //leo
  17. }
  18. //D command=" + JSON.stringify(command) + "\nexpression_array=" + JSON.stringify(expression_array) + "\n"); //leo
  19. //D function_obj=||" + JSON.stringify(function_obj) + "||\n
  20. div_to_render.empty();
  21. WatchJS.unwatch(command, "expression");
  22. WatchJS.watch(command, "expression",
  23. function () {
  24. if (window.timer) return;
  25. const m = div_to_render.find(".single_element_expression").not(".mouse_distance").not(".add_parentheses");
  26. let s = "";
  27. m.each(function (e) {
  28. if ($(this).hasClass("parentheses_in_expression")) {
  29. s += $(this).text() + " ";
  30. } else {
  31. s += $(this).find(".text").text();
  32. s += $(this).find(".var_name").text();
  33. s += $(this).find(".parameters_function_called").text();
  34. s += $(this).find(".value_rendered").text();
  35. s += " ";
  36. }
  37. });
  38. if (s) {
  39. window.timer = true;
  40. } else {
  41. return;
  42. }
  43. registerUserEvent(function_obj.name, ActionTypes.CHANGE_COMMAND_EXP, command.type, "/", s);
  44. setTimeout(function () { window.timer = false; }, 200);
  45. },
  46. 20,
  47. true
  48. );
  49. if (command.type === Models.COMMAND_TYPES.attribution) {
  50. WatchJS.unwatch(command.variable);
  51. WatchJS.watch(
  52. command.variable,
  53. function () { renderExpression(command, function_obj, div_to_render, expression_array); },
  54. 0
  55. );
  56. if (command.variable.content) {
  57. const types_included = [];
  58. if (command.variable.content.type == Types.INTEGER || command.variable.content.type == Types.REAL) {
  59. types_included.push(Models.EXPRESSION_TYPES.exp_arithmetic);
  60. } else if (command.variable.content.type == Types.BOOLEAN) {
  61. types_included.push(Models.EXPRESSION_TYPES.exp_conditional);
  62. types_included.push(Models.EXPRESSION_TYPES.exp_logic);
  63. types_included.push(Models.EXPRESSION_TYPES.exp_arithmetic);
  64. } else if (command.variable.content.type == Types.TEXT) {
  65. types_included.push(Models.EXPRESSION_TYPES.exp_conditional);
  66. types_included.push(Models.EXPRESSION_TYPES.exp_logic);
  67. types_included.push(Models.EXPRESSION_TYPES.exp_arithmetic);
  68. } else {
  69. console.log("./ivprog/js/visualUI/commands/generic_expression.js: renderExpression(.): NOT RECOGNIZED! SEE command.variable.content.type=" + command.variable.content.type);
  70. }
  71. //D console.log("generic_expression.js: renderExpression(.): command.variable.content: command=" + JSON.stringify(command)); //leo
  72. renderElements(command, function_obj, div_to_render, expression_array, types_included);
  73. } else {
  74. div_to_render.text(LocalizedStrings.getUI("var_menu_select_var").toLowerCase());
  75. }
  76. } else {
  77. const types_included = [];
  78. types_included.push(Models.EXPRESSION_TYPES.exp_conditional);
  79. types_included.push(Models.EXPRESSION_TYPES.exp_logic);
  80. if (command.type === Models.COMMAND_TYPES.writer)
  81. types_included.push(Models.EXPRESSION_TYPES.write_sep);
  82. types_included.push(Models.EXPRESSION_TYPES.exp_arithmetic);
  83. //D console.log("generic_expression.js: renderExpression(.): else de Models.COMMAND_TYPES.attribution: command.type=" + command.type); //leo
  84. //D console.log("generic_expression.js: renderExpression(.): else de Models.COMMAND_TYPES.attribution: expression_array=" + JSON.stringify(expression_array)); //leo
  85. renderElements(command, function_obj, div_to_render, expression_array, types_included);
  86. }
  87. div_to_render.children(".mouse_distance").addClass("mouse_distance_hidden");
  88. div_to_render.children(".higher_element").on("mousemove", function (evt) {
  89. if (!window.open_or_close) {
  90. $(this).css("position", "relative", "!important");
  91. $(this).children(".mouse_distance").css("opacity", "1");
  92. }
  93. });
  94. div_to_render.children(".higher_element").on("mouseout", function (evt) {
  95. if (!window.open_or_close) {
  96. $(this).css("position", "absolute", "!important");
  97. $(this).children(".mouse_distance").css("opacity", "0");
  98. }
  99. });
  100. const lixeira = $('<div class="lixeira" draggable="true"></div>');
  101. div_to_render.find(".single_element_expression").on("mousedown", function (evt) { window.posX = evt.clientX; window.posY = evt.clientY; });
  102. Sortable.create(div_to_render[0], {
  103. animation: 100,
  104. ghostClass: "ghost",
  105. group: {
  106. name: "shared",
  107. put: false, // Do not allow items to be put into this list
  108. },
  109. draggable: ".single_element_expression",
  110. sort: false,
  111. filter: ".not_allowed",
  112. onStart: function () {
  113. $("body").append(lixeira);
  114. lixeira.css("display", "block");
  115. lixeira.css("top", window.posY + 70, "!important");
  116. lixeira.css("left", window.posX - 20, "!important");
  117. },
  118. onMove: function () { lixeira.addClass("color_test"); },
  119. onEnd: function () {
  120. lixeira.remove();
  121. div_to_render.find(".ghost").removeClass("ghost");
  122. },
  123. });
  124. new Sortable(lixeira[0], {
  125. group: "shared",
  126. animation: 150,
  127. onAdd: function (evt) {
  128. lixeira.css("display", "none");
  129. lixeira.find(".single_element_expression").remove();
  130. lixeira.css("background-color", "");
  131. lixeira.remove();
  132. removeElement(evt, expression_array);
  133. renderExpression(command, function_obj, div_to_render, expression_array);
  134. },
  135. });
  136. } // export function renderExpression(command, function_obj, div_to_render, expression_array)
  137. function removeElement (event, expression_array) {
  138. const indice = $(event.item).data("index");
  139. const first = expression_array[0];
  140. if (expression_array[indice].type) {
  141. // if is alone in expression:
  142. if (expression_array.length == 1) {
  143. //function_obj.commands.splice(function_obj.commands.indexOf(command), 1);
  144. expression_array.splice(0, 1);
  145. } else if (expression_array.length > 1) {
  146. if (indice > 0 && expression_array[indice - 1].type_op) {
  147. if (indice < expression_array.length && expression_array[indice - 2] == "(" && expression_array[indice + 1].type_op) { // ")" Jed
  148. expression_array.splice(indice + 1, 1);
  149. }
  150. expression_array.splice(indice, 1);
  151. expression_array.splice(indice - 1, 1);
  152. if (indice - 2 < expression_array.length && expression_array[indice - 2] == "(" && expression_array[indice - 1] == ")") {
  153. expression_array.splice(indice - 1, 1);
  154. expression_array.splice(indice - 2, 1);
  155. if (indice - 3 >= 0 && indice - 3 < expression_array.length && expression_array[indice - 3].type_op) {
  156. expression_array.splice(indice - 3, 1);
  157. }
  158. }
  159. }
  160. else if (indice < expression_array.length - 1 && expression_array[indice + 1].type_op) {
  161. expression_array.splice(indice + 1, 1);
  162. expression_array.splice(indice, 1);
  163. }
  164. else if (indice < expression_array.length - 1 && indice > 0 && expression_array[indice - 1] == "(" && expression_array[indice + 1] == ")") {
  165. if (indice > 1 && expression_array[indice - 2].type_op) {
  166. expression_array.splice(indice + 1, 1);
  167. expression_array.splice(indice, 1);
  168. expression_array.splice(indice - 1, 1);
  169. expression_array.splice(indice - 2, 1);
  170. } else if (indice < expression_array.length - 2 && expression_array[indice + 2].type_op) {
  171. expression_array.splice(indice + 1, 1);
  172. expression_array.splice(indice, 1);
  173. expression_array.splice(indice - 1, 1);
  174. } else {
  175. expression_array.splice(indice + 1, 1);
  176. expression_array.splice(indice, 1);
  177. expression_array.splice(indice - 1, 1);
  178. }
  179. }
  180. }
  181. } else if (expression_array[indice].type_op) {
  182. // iVProg doesn't support operator remove
  183. } else { // else if (expression_array[indice].type_op)
  184. let opening = -1;
  185. let closing = -1;
  186. if (expression_array[indice] == "(") { // ")" Jed
  187. opening = indice;
  188. for (var i = indice + 1; i < expression_array.length; i++) {
  189. if (expression_array[i] == ")") { // ")" Jed
  190. closing = i;
  191. break;
  192. }
  193. }
  194. } else { // if (expression_array[indice] == "(") // ")" Jed
  195. closing = indice;
  196. for (var i = indice - 1; i >= 0; i--) {
  197. if (expression_array[i] == "(") { // ")" to Jed
  198. opening = i;
  199. break;
  200. }
  201. }
  202. }
  203. if (expression_array[opening + 1].type_op) {
  204. expression_array.splice(closing, 1);
  205. expression_array.splice(opening + 1, 1);
  206. expression_array.splice(opening, 1);
  207. } else {
  208. expression_array.splice(closing, 1);
  209. expression_array.splice(opening, 1);
  210. }
  211. }
  212. // if expression is empty, add a new var value:
  213. if (expression_array.length == 0) {
  214. expression_array.push(new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true));
  215. }
  216. if (first != expression_array[0] && expression_array[0].type_op) {
  217. expression_array.splice(0, 1);
  218. }
  219. } // function removeElement(event, expression_array)
  220. function renderElements (command, function_obj, div_to_render, expression_array, types_included) {
  221. //if (expression_array.length > 0) {if (!expression_array[0].type_op) {renderStartAddOperator(div_to_render, types_included, expression_array, command, function_obj, 0);}}
  222. let i = 0;
  223. //D console.log(" xxx 3 : expression_array.length=" + expression_array.length + " : " + JSON.stringify(expression_array));
  224. for (i = 0; i < expression_array.length; i++) {
  225. if (expression_array[i].type == "var_value") {
  226. const div_temp = $('<div class="single_element_expression" data-index="' + i + '"></div>');
  227. if (i == 0) {
  228. if (expression_array.length > 0 && !expression_array[0].type_op) {
  229. //renderStartAddOperator(div_to_render, types_included, expression_array, command, function_obj, 0);
  230. }
  231. }
  232. VariableValueMenuManagement.renderMenu(command, expression_array[i], div_temp, function_obj);
  233. div_to_render.append(div_temp);
  234. } else if (expression_array[i] == "(" || expression_array[i] == ")") {
  235. if (expression_array[i] == ")") {
  236. renderFinalAddElements( div_to_render, types_included, expression_array, command, function_obj, i);
  237. renderParenthesis(div_to_render, expression_array[i], command, function_obj, i, expression_array);
  238. } else if (expression_array[i] == "(" && !expression_array[i + 1].type_op) {
  239. renderParenthesis(div_to_render, expression_array[i], command, function_obj, i, expression_array);
  240. renderStartAddOperator(div_to_render, types_included, expression_array, command, function_obj, i + 1);
  241. } else {
  242. renderParenthesis(div_to_render, expression_array[i], command, function_obj, i, expression_array);
  243. }
  244. } else {
  245. //leo if (i == 0) { }
  246. //leo else if (expression_array[i - 1] == "(") { } // ")" close to Jed editor
  247. renderOperatorMenu(command, function_obj, div_to_render, expression_array[i], types_included, i, expression_array);
  248. }
  249. } // for (i = 0; i < expression_array.length; i++)
  250. renderFinalAddElements(div_to_render, types_included, expression_array, command, function_obj, i, true);
  251. renderAddParenthesis(command, function_obj, div_to_render, expression_array, types_included);
  252. } // function renderElements(command, function_obj, div_to_render, expression_array, types_included)
  253. window.parentheses_activate = false;
  254. window.open_or_close = null;
  255. function renderAddParenthesis (command, function_obj, div_to_render, expression_array, types_included) {
  256. // Insert img of "(" ")"
  257. const addParentheses = $(
  258. '<div class="single_element_expression add_parentheses not_allowed"><img ' +
  259. 'style="width: 15px; position: relative; top: 3px; left: 1px; height: 15px;" ' +
  260. 'src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOgAAAEjCAYAAAA48U27AAAasXpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHjarZtZkhw5km3/sYpeAkYFsByMIm8Hvfw+Fx4k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DITc86dBrTszR+paU1PGJ2ga9askXKt5APUXxuX0hTgC1LIbGv0JFuu1TE6Xt/IyAjXX389p59+upRVFzhFH3POnQNcLAUjvdE591Xv/a1S0GzhPcDLpFAnqw3pPYLaA/Cd7+RamlbNJdTfkpbal13A3RXdyjm3Ey36CF+76gG44447uPfee6Vsyxi92+ed1B/wTmkJ9sqIZnwKsGfkFL14HfSyyy5rlGs53vtfkuclOJ93zk2TQt3OObeQPGfZu8qLBf3BD37A6tW5lqZV80ngESkUaTfgQ1LI8FeA3YWl7MWCrlu3ju9+97uNsi3He7/Ge7+b994l/t+Q9P+l23nvX7/15zb3pUfZ5xZpi6dZLr/8cs4666yQp06M2Ubf5r5vbOwbuV7KaerftPl3Uqad/DepALQulhENnAAAAABJRU5ErkJggg=="></div>'
  261. );
  262. div_to_render.append(addParentheses);
  263. addParentheses.popup({
  264. content: "Adicionar parênteses",
  265. delay: { show: 750, hide: 0, },
  266. });
  267. addParentheses.on("click", function (mouse_event) {
  268. // verificar se já está ativado
  269. if (window.parentheses_activate) {
  270. return;
  271. }
  272. div_to_render.find(".usepointer").off("click");
  273. window.parentheses_activate = true;
  274. window.open_or_close = "open";
  275. div_to_render.find(".dropdown").addClass("disabled");
  276. div_to_render.find(".ghost_element").addClass("temp_class");
  277. div_to_render.find(".ghost_element").removeClass("ghost_element");
  278. const floatingObject = $('<div class="floating_parenthesis"> ( </div>');
  279. floatingObject.draggable().appendTo("body");
  280. floatingObject.css("position", "absolute");
  281. mouse_event.type = "mousedown.draggable";
  282. mouse_event.target = floatingObject[0];
  283. floatingObject.css("left", mouse_event.pageX + 10);
  284. floatingObject.css("top", mouse_event.pageY + 10);
  285. floatingObject.trigger(mouse_event);
  286. div_to_render.on("mousemove", function (evt) {
  287. let actual_target = null;
  288. if ($(evt.target).hasClass("single_element_expression")) {
  289. actual_target = $(evt.target);
  290. } else {
  291. actual_target = $(evt.target).closest(".single_element_expression");
  292. }
  293. if (
  294. $(evt.target).hasClass("temp_class") ||
  295. actual_target.length < 1 ||
  296. actual_target.hasClass("add_parentheses") ||
  297. actual_target.hasClass("rendered_parentheses") ||
  298. $(evt.target).hasClass("expression_elements")
  299. ) {
  300. return;
  301. }
  302. renderGhostParentheses(
  303. actual_target,
  304. command,
  305. function_obj,
  306. div_to_render,
  307. expression_array
  308. );
  309. });
  310. div_to_render.on("mouseleave", function () {
  311. // window.open_parentheses.remove(); window.close_parentheses.remove();
  312. });
  313. let floating;
  314. $("body").on("mouseup", function (evt) {
  315. if (window.open_or_close == "open") {
  316. window.open_or_close = "close";
  317. floatingObject.remove();
  318. var comando_que_esta = $(evt.target).closest(".command_container");
  319. var comando_certo = div_to_render.closest(".command_container");
  320. if (!comando_que_esta.is(comando_certo)) {
  321. window.parentheses_activate = false;
  322. div_to_render.find(".temp_class").addClass("ghost_element");
  323. div_to_render.find(".temp_class").removeClass("temp_class");
  324. div_to_render.off("mousemove");
  325. div_to_render.off("mouseleave");
  326. $("body").off("mouseup");
  327. window.open_parentheses.remove();
  328. window.close_parentheses.remove();
  329. window.inserir_open = -1;
  330. window.inserir_close = -1;
  331. window.open_or_close = null;
  332. renderExpression(command, function_obj, div_to_render, expression_array);
  333. return;
  334. }
  335. window.open_parentheses.addClass("parentheses_fixed");
  336. floating = $('<div class="floating_parenthesis"> ) </div>');
  337. floating.draggable().appendTo("body");
  338. floating.css("position", "absolute");
  339. floating.css("left", evt.pageX + 10);
  340. floating.css("top", evt.pageY + 10);
  341. $("body").on("mousemove", function (evts) {
  342. floating.css("left", evts.pageX + 10);
  343. floating.css("top", evts.pageY + 10);
  344. });
  345. } else {
  346. floating.remove();
  347. window.open_parentheses.removeClass("parentheses_fixed");
  348. div_to_render.off("mousemove");
  349. div_to_render.off("mouseleave");
  350. $("body").off("mouseup");
  351. setTimeout(function () {
  352. window.parentheses_activate = false;
  353. }, 50);
  354. var comando_que_esta = $(evt.target).closest(".command_container");
  355. var comando_certo = div_to_render.closest(".command_container");
  356. let is_correct = false;
  357. if (comando_que_esta.is(comando_certo)) {
  358. is_correct = true;
  359. }
  360. if (is_correct) {
  361. expression_array.splice(window.inserir_open, 0, "(");
  362. expression_array.splice(window.inserir_close, 0, ")");
  363. }
  364. window.inserir_open = -1;
  365. window.inserir_close = -1;
  366. window.open_or_close = null;
  367. renderExpression(command, function_obj, div_to_render, expression_array);
  368. }
  369. });
  370. });
  371. }
  372. window.open_parentheses = $('<div class="parentheses_ghost">(</div>');
  373. window.close_parentheses = $('<div class="parentheses_ghost">)</div>');
  374. window.inserir_open = -1;
  375. window.inserir_close = -1;
  376. function renderGhostParentheses (actual_target, command, function_obj, div_to_render, expression_array) {
  377. // window.open_parentheses.remove(); window.close_parentheses.remove();
  378. const index_in_array = actual_target.data("index");
  379. if (
  380. expression_array[index_in_array] == "(" ||
  381. expression_array[index_in_array] == ")"
  382. ) {
  383. return;
  384. }
  385. if (window.open_or_close == "close") {
  386. if (index_in_array < window.inserir_open) {
  387. return;
  388. }
  389. }
  390. // Tratando a situacao quando e' na primeira posicao:
  391. if (index_in_array == 0) {
  392. if (expression_array[index_in_array].type == "var_value") {
  393. if (window.open_or_close == "open") {
  394. window.open_parentheses.insertBefore(actual_target);
  395. window.inserir_open = index_in_array;
  396. }
  397. //if (expression_array.length == 1) { if (window.open_or_close == "close") { window.close_parentheses.insertAfter(actual_target); window.inserir_close = index_in_array + 2; }
  398. //} else {
  399. var count_opened = 0;
  400. var count_closed = 0;
  401. for (var i = 0; i < expression_array.length; i++) {
  402. if (expression_array[i] == "(") {
  403. count_opened++;
  404. }
  405. if (expression_array[i] == ")") {
  406. count_closed++;
  407. }
  408. if (count_opened != count_closed) {
  409. } else {
  410. if (count_opened > 0) {
  411. if (window.open_or_close == "close") {
  412. window.close_parentheses.insertAfter(
  413. div_to_render.find(
  414. '.single_element_expression[data-index="' + i + '"]'
  415. )
  416. );
  417. window.inserir_close = i + 2;
  418. }
  419. break;
  420. } else {
  421. if (expression_array[i].type == "var_value") {
  422. if (window.open_or_close == "close") {
  423. window.close_parentheses.insertAfter(
  424. div_to_render.find(
  425. '.single_element_expression[data-index="' + i + '"]'
  426. )
  427. );
  428. window.inserir_close = i + 2;
  429. }
  430. break;
  431. }
  432. }
  433. }
  434. }
  435. //}
  436. } else if (expression_array[index_in_array].type_op) {
  437. if (window.open_or_close == "open") {
  438. window.open_parentheses.insertBefore(actual_target);
  439. window.inserir_open = index_in_array;
  440. }
  441. var count_opened = 0;
  442. var count_closed = 0;
  443. for (var i = 1; i < expression_array.length; i++) {
  444. // $('.slide-link[data-slide="0"]')
  445. if (expression_array[i] == "(") {
  446. count_opened++;
  447. }
  448. if (expression_array[i] == ")") {
  449. count_closed++;
  450. }
  451. if (count_opened != count_closed) {
  452. } else {
  453. if (count_opened > 0) {
  454. if (expression_array[i].type == "var_value") {
  455. window.close_parentheses.insertAfter(
  456. div_to_render.find(
  457. '.single_element_expression[data-index="' + i + '"]'
  458. )
  459. );
  460. window.inserir_close = i + 2;
  461. }
  462. break;
  463. } else {
  464. if (expression_array[i].type == "var_value") {
  465. if (expression_array[i].type == "var_value") {
  466. window.close_parentheses.insertAfter(
  467. div_to_render.find(
  468. '.single_element_expression[data-index="' + i + '"]'
  469. )
  470. );
  471. window.inserir_close = i + 2;
  472. }
  473. break;
  474. }
  475. }
  476. }
  477. }
  478. }
  479. return;
  480. }
  481. // Tratando quando não é no índice 0:
  482. if (expression_array[index_in_array].type == "var_value") {
  483. if (window.open_or_close == "open") {
  484. window.open_parentheses.insertBefore(actual_target);
  485. window.inserir_open = index_in_array;
  486. }
  487. if (window.open_or_close == "close") {
  488. window.close_parentheses.insertAfter(actual_target);
  489. window.inserir_close = index_in_array + 2;
  490. }
  491. return;
  492. }
  493. if (expression_array[index_in_array].type_op) {
  494. // buscar para a esquerda primeiro:
  495. if (expression_array[index_in_array - 1] == "(") {
  496. if (window.open_or_close == "open") {
  497. window.open_parentheses.insertBefore(actual_target);
  498. window.inserir_open = index_in_array;
  499. }
  500. } else if (expression_array[index_in_array - 1] == ")") {
  501. // buscar a abertura
  502. var count_opened = 0;
  503. var count_closed = 0;
  504. for (var j = index_in_array - 1; j >= 0; j--) {
  505. if (expression_array[j] == "(") { // "}){" Jed
  506. count_opened++;
  507. }
  508. if (expression_array[j] == ")") {
  509. count_closed++;
  510. }
  511. if (count_opened != count_closed) {
  512. } else {
  513. if (count_closed > 0) {
  514. if (window.open_or_close == "open") {
  515. window.open_parentheses.insertBefore(
  516. div_to_render.find(
  517. '.single_element_expression[data-index="' + j + '"]'
  518. )
  519. );
  520. window.inserir_open = j;
  521. }
  522. break;
  523. }
  524. }
  525. }
  526. } else if (expression_array[index_in_array - 1].type == "var_value") {
  527. if (window.open_or_close == "open") {
  528. window.open_parentheses.insertBefore(
  529. div_to_render.find(
  530. '.single_element_expression[data-index="' +
  531. (index_in_array - 1) +
  532. '"]'
  533. )
  534. );
  535. window.inserir_open = index_in_array - 1;
  536. }
  537. }
  538. // buscar para a direita agora:
  539. if (expression_array[index_in_array + 1] == "(") { // "}){" Jed
  540. // buscar o fechamento:
  541. var count_opened = 0;
  542. var count_closed = 0;
  543. for (var j = index_in_array + 1; j < expression_array.length; j++) {
  544. if (expression_array[j] == "(") { // "}){" Jed
  545. count_opened++;
  546. }
  547. if (expression_array[j] == ")") {
  548. count_closed++;
  549. }
  550. if (count_opened != count_closed) {
  551. } else {
  552. if (count_opened > 0) {
  553. if (window.open_or_close == "close") {
  554. window.close_parentheses.insertAfter(
  555. div_to_render.find(
  556. '.single_element_expression[data-index="' + j + '"]'
  557. )
  558. );
  559. window.inserir_close = j + 2;
  560. }
  561. break;
  562. }
  563. }
  564. }
  565. } else if (expression_array[index_in_array + 1].type == "var_value") {
  566. if (window.open_or_close == "close") {
  567. window.close_parentheses.insertAfter(div_to_render.find('.single_element_expression[data-index="' + (index_in_array + 1) + '"]'));
  568. window.inserir_close = index_in_array + 3;
  569. }
  570. }
  571. }
  572. }
  573. function renderParenthesis (div_to_render, expression_content, command, function_obj, position, expression_array) {
  574. const ghost_parenthesis = $(
  575. '<div class="single_element_expression parentheses_in_expression" data-index="' +
  576. position + '">' + expression_content + "</div>\n");
  577. div_to_render.append(ghost_parenthesis);
  578. }
  579. function renderStartAddOperator (div_to_render, types_included, expression_array, command, function_obj, position) {
  580. let menu_final =
  581. '<div class="ui dropdown disabled usepointer"><div class="text"> + </div><i class="dropdown icon"></i><div class="menu">';
  582. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_arithmetic) >= 0) {
  583. if (types_included.length > 1) {
  584. menu_final +=
  585. '<div class="item"><i class="dropdown icon"></i>' +
  586. LocalizedStrings.getUI("text_arithmetic_expression") +
  587. '<div class="menu">';
  588. menu_final += getArithmeticOperators();
  589. menu_final += "</div></div>";
  590. } else {
  591. menu_final += getArithmeticOperators();
  592. }
  593. }
  594. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_logic) >= 0) {
  595. if (types_included.length > 1) {
  596. menu_final +=
  597. '<div class="item"><i class="dropdown icon"></i>' +
  598. LocalizedStrings.getUI("text_logic_expression") +
  599. '<div class="menu">';
  600. menu_final += getLogicOperators();
  601. menu_final += "</div></div>";
  602. } else {
  603. menu_final += getLogicOperators();
  604. }
  605. }
  606. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_conditional) >= 0) {
  607. if (types_included.length > 1) {
  608. menu_final +=
  609. '<div class="item"><i class="dropdown icon"></i>' +
  610. LocalizedStrings.getUI("text_relational_expression") +
  611. '<div class="menu">';
  612. menu_final += getRelationalOperators();
  613. menu_final += "</div></div>";
  614. } else {
  615. menu_final += getRelationalOperators();
  616. }
  617. }
  618. menu_final += "</div></div>";
  619. menu_final = $(menu_final);
  620. const div_temp = $(
  621. '<div class="single_element_expression ghost_element mouse_distance"></div>'
  622. );
  623. div_temp.append(menu_final);
  624. const div_higher = $('<div class="higher_element"></div>');
  625. div_higher.append(div_temp);
  626. div_to_render.append(div_higher);
  627. menu_final.dropdown("set selected", Models.ARITHMETIC_TYPES.minus);
  628. div_temp.on("click", function () {
  629. if (!window.open_or_close) {
  630. const sera = position;
  631. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_arithmetic) >= 0) {
  632. expression_array.splice(
  633. sera,
  634. 0,
  635. new Models.ExpressionOperator(
  636. Models.EXPRESSION_TYPES.exp_arithmetic,
  637. Models.ARITHMETIC_TYPES.minus
  638. )
  639. );
  640. } else if (
  641. types_included.indexOf(Models.EXPRESSION_TYPES.exp_logic) >= 0
  642. ) {
  643. expression_array.splice(
  644. sera,
  645. 0,
  646. new Models.ExpressionOperator(
  647. Models.EXPRESSION_TYPES.exp_logic,
  648. Models.LOGIC_COMPARISON.equals_to
  649. )
  650. );
  651. } else if (
  652. types_included.indexOf(Models.EXPRESSION_TYPES.exp_conditional) >= 0
  653. ) {
  654. expression_array.splice(
  655. sera,
  656. 0,
  657. new Models.ExpressionOperator(
  658. Models.EXPRESSION_TYPES.exp_conditional,
  659. Models.ARITHMETIC_COMPARISON.greater_than
  660. )
  661. );
  662. }
  663. renderExpression(command, function_obj, div_to_render, expression_array);
  664. }
  665. });
  666. }
  667. function renderFinalAddElements (div_to_render, types_included, expression_array, command, function_obj, position, is_last = false) {
  668. let menu_final =
  669. '<div class="ui dropdown disabled usepointer"><div class="text"> + </div><i class="dropdown icon"></i><div class="menu">';
  670. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_arithmetic) >= 0) {
  671. if (types_included.length > 1) {
  672. menu_final +=
  673. '<div class="item"><i class="dropdown icon"></i>' +
  674. LocalizedStrings.getUI("text_arithmetic_expression") +
  675. '<div class="menu">';
  676. menu_final += getArithmeticOperators();
  677. menu_final += "</div></div>";
  678. } else {
  679. menu_final += getArithmeticOperators();
  680. }
  681. }
  682. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_logic) >= 0) {
  683. if (types_included.length > 1) {
  684. menu_final +=
  685. '<div class="item"><i class="dropdown icon"></i>' +
  686. LocalizedStrings.getUI("text_logic_expression") +
  687. '<div class="menu">';
  688. menu_final += getLogicOperators();
  689. menu_final += "</div></div>";
  690. } else {
  691. menu_final += getLogicOperators();
  692. }
  693. }
  694. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_conditional) >= 0) {
  695. if (types_included.length > 1) {
  696. menu_final +=
  697. '<div class="item"><i class="dropdown icon"></i>' +
  698. LocalizedStrings.getUI("text_relational_expression") +
  699. '<div class="menu">';
  700. menu_final += getRelationalOperators();
  701. menu_final += "</div></div>";
  702. } else {
  703. menu_final += getRelationalOperators();
  704. }
  705. }
  706. menu_final += "</div></div>";
  707. menu_final = $(menu_final);
  708. const div_temp = $('<div class="simple_add mouse_distance"></div>');
  709. const div_higher = $('<div class="higher_element"></div>');
  710. const button = $('<button class="ui button green add_expression"><i class="plus circle inverted icon"></i></button>');
  711. div_temp.append(button);
  712. if (!is_last) {
  713. div_higher.append(div_temp);
  714. div_to_render.append(div_higher);
  715. //div_temp.append(menu_final);
  716. div_temp.css("opacity", "0", "!important");
  717. } else {
  718. div_temp.removeClass("mouse_distance");
  719. div_temp.css("opacity", "1", "!important");
  720. //div_temp.append(menu_final);
  721. div_to_render.append(div_temp);
  722. }
  723. menu_final.dropdown("set selected", Models.ARITHMETIC_TYPES.plus);
  724. div_temp.on("click", function () {
  725. const sera = position;
  726. if (expression_array[sera] == ")" && expression_array[sera - 1] == "(") {
  727. expression_array.splice(
  728. sera,
  729. 0,
  730. new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true)
  731. );
  732. renderExpression(command, function_obj, div_to_render, expression_array);
  733. return;
  734. }
  735. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_arithmetic) >= 0) {
  736. expression_array.splice(
  737. sera,
  738. 0,
  739. new Models.ExpressionOperator(
  740. Models.EXPRESSION_TYPES.exp_arithmetic,
  741. Models.ARITHMETIC_TYPES.plus
  742. )
  743. );
  744. expression_array.splice(
  745. sera + 1,
  746. 0,
  747. new Models.VariableValueMenu(
  748. VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all,
  749. null,
  750. null,
  751. null,
  752. true
  753. )
  754. );
  755. } else if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_logic) >= 0) {
  756. expression_array.splice(
  757. sera,
  758. 0,
  759. new Models.ExpressionOperator(
  760. Models.EXPRESSION_TYPES.exp_logic,
  761. Models.LOGIC_COMPARISON.equals_to
  762. )
  763. );
  764. expression_array.splice(
  765. sera + 1,
  766. 0,
  767. new Models.VariableValueMenu(
  768. VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all,
  769. null,
  770. null,
  771. null,
  772. true
  773. )
  774. );
  775. } else if (
  776. types_included.indexOf(Models.EXPRESSION_TYPES.exp_conditional) >= 0
  777. ) {
  778. expression_array.splice(sera, 0,
  779. new Models.ExpressionOperator(Models.EXPRESSION_TYPES.exp_conditional, Models.ARITHMETIC_COMPARISON.greater_than)
  780. );
  781. expression_array.splice(sera + 1, 0,
  782. new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true)
  783. );
  784. }
  785. renderExpression(command, function_obj, div_to_render, expression_array);
  786. });
  787. }
  788. // Construct HTML menu item with: Space \n Arithmetics \n Logics \n Relational
  789. function renderOperatorMenu (command, function_obj, div_to_render, expression_element, types_included, position, expression_array) {
  790. let menu_final = '<div class="ui dropdown"><div class="text"> + </div><i class="dropdown icon"></i><div class="menu">' + "\n";
  791. //D console.log("./ivprog/js/visualUI/commands/generic_expression.js: generic_expression.js: renderOperatorMenu(.): ");
  792. //D command=" + JSON.stringify(command)
  793. //D console.log("types_included=" + JSON.stringify(types_included)
  794. if (types_included.indexOf(Models.EXPRESSION_TYPES.write_sep) >= 0) {
  795. menu_final += getSeparator();
  796. }
  797. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_arithmetic) >= 0) {
  798. if (types_included.length > 1) {
  799. menu_final += '<div class="item"><i class="dropdown icon"></i>' + LocalizedStrings.getUI("text_arithmetic_expression") + '<div class="menu">';
  800. menu_final += getArithmeticOperators();
  801. menu_final += "</div></div>\n";
  802. } else {
  803. menu_final += getArithmeticOperators();
  804. }
  805. }
  806. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_logic) >= 0) {
  807. if (types_included.length > 1) {
  808. menu_final += '<div class="item"><i class="dropdown icon"></i>' + LocalizedStrings.getUI("text_logic_expression") + '<div class="menu">';
  809. menu_final += getLogicOperators();
  810. menu_final += "</div></div>\n";
  811. } else {
  812. menu_final += getLogicOperators();
  813. }
  814. }
  815. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_conditional) >= 0) {
  816. if (types_included.length > 1) {
  817. menu_final += '<div class="item"><i class="dropdown icon"></i>' + LocalizedStrings.getUI("text_relational_expression") + '<div class="menu">';
  818. menu_final += getRelationalOperators();
  819. menu_final += "</div></div>\n";
  820. } else {
  821. menu_final += getRelationalOperators();
  822. }
  823. }
  824. menu_final += "</div></div>\n";
  825. menu_final = $(menu_final);
  826. menu_final.find(".ivprog-write-sep").popup({
  827. content: LocalizedStrings.getUI("write_seprator_menu_tooltip"),
  828. delay: { show: 500, hide: 0, },
  829. });
  830. const div_temp = $('<div class="single_element_expression not_allowed" data-index="' + position + '"></div>');
  831. div_temp.append(menu_final);
  832. div_to_render.append(div_temp);
  833. menu_final.dropdown({
  834. onChange: function (_value, _text, $selectedItem) {
  835. expression_element.item = $selectedItem.data("value");
  836. expression_element.type_op = $selectedItem.data("type");
  837. },
  838. });
  839. menu_final.dropdown("set selected", expression_element.item);
  840. } // function renderOperatorMenu(command, function_obj, div_to_render, expression_element, types_included, position, expression_array)
  841. function getArithmeticOperators () {
  842. let arithmetic_operators;
  843. arithmetic_operators =
  844. '<div class="item" data-type="' +
  845. Models.EXPRESSION_TYPES.exp_arithmetic +
  846. '" data-value="' +
  847. Models.ARITHMETIC_TYPES.plus + '">+</div>';
  848. arithmetic_operators +=
  849. '<div class="item" data-type="' +
  850. Models.EXPRESSION_TYPES.exp_arithmetic +
  851. '" data-value="' +
  852. Models.ARITHMETIC_TYPES.minus + '">-</div>';
  853. arithmetic_operators +=
  854. '<div class="item" data-type="' +
  855. Models.EXPRESSION_TYPES.exp_arithmetic +
  856. '" data-value="' +
  857. Models.ARITHMETIC_TYPES.multiplication + '">*</div>';
  858. arithmetic_operators +=
  859. '<div class="item" data-type="' +
  860. Models.EXPRESSION_TYPES.exp_arithmetic +
  861. '" data-value="' +
  862. Models.ARITHMETIC_TYPES.division + '">/</div>';
  863. arithmetic_operators +=
  864. '<div class="item" data-type="' +
  865. Models.EXPRESSION_TYPES.exp_arithmetic +
  866. '" data-value="' +
  867. Models.ARITHMETIC_TYPES.module + '">%</div>';
  868. return arithmetic_operators;
  869. }
  870. function getLogicOperators () {
  871. let logic_operators;
  872. /* logic_operators =
  873. '<div class="item" data-type="' +
  874. Models.EXPRESSION_TYPES.exp_logic +
  875. '" data-value="' +
  876. Models.LOGIC_COMPARISON.equals_to + '">==</div>';
  877. logic_operators +=
  878. '<div class="item" data-type="' +
  879. Models.EXPRESSION_TYPES.exp_logic +
  880. '" data-value="' +
  881. Models.LOGIC_COMPARISON.not_equals_to + '">!=</div>'; */
  882. logic_operators =
  883. '<div class="item" data-type="' +
  884. Models.EXPRESSION_TYPES.exp_logic +
  885. '" data-value="' +
  886. Models.LOGIC_COMPARISON.and + '">' +
  887. LocalizedStrings.getUI("logic_operator_and") + "</div>\n";
  888. logic_operators +=
  889. '<div class="item" data-type="' +
  890. Models.EXPRESSION_TYPES.exp_logic +
  891. '" data-value="' +
  892. Models.LOGIC_COMPARISON.or + '">' +
  893. LocalizedStrings.getUI("logic_operator_or") + "</div>\n";
  894. logic_operators +=
  895. '<div class="item" data-type="' +
  896. Models.EXPRESSION_TYPES.exp_logic +
  897. '" data-value="' +
  898. Models.LOGIC_COMPARISON.not + '">' +
  899. LocalizedStrings.getUI("logic_operator_not") + "</div>\n";
  900. return logic_operators;
  901. }
  902. function getRelationalOperators () {
  903. let relational_operators;
  904. relational_operators =
  905. '<div class="item" data-type="' +
  906. Models.EXPRESSION_TYPES.exp_conditional +
  907. '" data-value="' +
  908. Models.ARITHMETIC_COMPARISON.greater_than + '">></div>';
  909. relational_operators +=
  910. '<div class="item" data-type="' +
  911. Models.EXPRESSION_TYPES.exp_conditional +
  912. '" data-value="' +
  913. Models.ARITHMETIC_COMPARISON.less_than + '"><</div>';
  914. relational_operators +=
  915. '<div class="item" data-type="' +
  916. Models.EXPRESSION_TYPES.exp_conditional +
  917. '" data-value="' +
  918. Models.ARITHMETIC_COMPARISON.equals_to + '">==</div>';
  919. relational_operators +=
  920. '<div class="item" data-type="' +
  921. Models.EXPRESSION_TYPES.exp_conditional +
  922. '" data-value="' +
  923. Models.ARITHMETIC_COMPARISON.not_equals_to + '">!=</div>';
  924. relational_operators +=
  925. '<div class="item" data-type="' +
  926. Models.EXPRESSION_TYPES.exp_conditional +
  927. '" data-value="' +
  928. Models.ARITHMETIC_COMPARISON.greater_than_or_equals_to + '">>=</div>';
  929. relational_operators +=
  930. '<div class="item" data-type="' +
  931. Models.EXPRESSION_TYPES.exp_conditional +
  932. '" data-value="' +
  933. Models.ARITHMETIC_COMPARISON.less_than_or_equals_to + '"><=</div>';
  934. return relational_operators;
  935. } // function getRelationalOperators()
  936. function getSeparator () {
  937. //leo return '<div class="item ivprog-write-sep" data-type="${Models.EXPRESSION_TYPES.write_sep}" ' +
  938. //leo ' data-value="${Models.EXPRESSION_TYPES.write_sep}">${LocalizedStrings.getUI("write_seprator_menu_text")}</div>' + "\n";
  939. return '<div class="item ivprog-write-sep" data-type="' + Models.EXPRESSION_TYPES.write_sep + '" ' +
  940. ' data-value="' + Models.EXPRESSION_TYPES.write_sep + '">' + LocalizedStrings.getUI("write_seprator_menu_text") + '</div>' + "\n";
  941. }
  942. // @calledby export function expressionParserCodeVisual(parsed, function_obj)
  943. function getVariable (function_obj, search) {
  944. //D console.log("./ivprog/js/visualUI/commands/generic_expression.js: getVariable(.): search=" + JSON.stringify(search)); //leo
  945. if (search == ")" || search == "(") { return search; }
  946. if (search.instance == "operator") {
  947. var obj;
  948. switch (search.value) {
  949. case '+':
  950. obj = new Models.ExpressionOperator(Models.EXPRESSION_TYPES.exp_arithmetic, Models.ARITHMETIC_TYPES.plus);
  951. break;
  952. case '-':
  953. obj = new Models.ExpressionOperator(Models.EXPRESSION_TYPES.exp_arithmetic, Models.ARITHMETIC_TYPES.minus);
  954. break;
  955. case '*':
  956. obj = new Models.ExpressionOperator(Models.EXPRESSION_TYPES.exp_arithmetic, Models.ARITHMETIC_TYPES.multiplication);
  957. break;
  958. case '/':
  959. obj = new Models.ExpressionOperator(Models.EXPRESSION_TYPES.exp_arithmetic, Models.ARITHMETIC_TYPES.division);
  960. break;
  961. case '%':
  962. obj = new Models.ExpressionOperator(Models.EXPRESSION_TYPES.exp_arithmetic, Models.ARITHMETIC_TYPES.module);
  963. break;
  964. case '>':
  965. obj = new Models.ExpressionOperator(Models.EXPRESSION_TYPES.exp_conditional, Models.ARITHMETIC_COMPARISON.greater_than);
  966. break;
  967. case '<':
  968. obj = new Models.ExpressionOperator(Models.EXPRESSION_TYPES.exp_conditional, Models.ARITHMETIC_COMPARISON.less_than);
  969. break;
  970. case '>=':
  971. obj = new Models.ExpressionOperator(Models.EXPRESSION_TYPES.exp_conditional, Models.ARITHMETIC_COMPARISON.greater_than_or_equals_to);
  972. break;
  973. case '<=':
  974. obj = new Models.ExpressionOperator(Models.EXPRESSION_TYPES.exp_conditional, Models.ARITHMETIC_COMPARISON.less_than_or_equals_to);
  975. break;
  976. case '==':
  977. obj = new Models.ExpressionOperator(Models.EXPRESSION_TYPES.exp_conditional, Models.ARITHMETIC_COMPARISON.equals_to);
  978. break;
  979. case '!=':
  980. obj = new Models.ExpressionOperator(Models.EXPRESSION_TYPES.exp_conditional, Models.ARITHMETIC_COMPARISON.not_equals_to);
  981. break;
  982. case 'and':
  983. obj = new Models.ExpressionOperator(Models.EXPRESSION_TYPES.exp_logic, Models.LOGIC_COMPARISON.and);
  984. break;
  985. case 'or':
  986. obj = new Models.ExpressionOperator(Models.EXPRESSION_TYPES.exp_logic, Models.LOGIC_COMPARISON.or);
  987. break;
  988. case 'not':
  989. obj = new Models.ExpressionOperator(Models.EXPRESSION_TYPES.exp_logic, Models.LOGIC_COMPARISON.not);
  990. break;
  991. } // switch (search.value)
  992. return obj;
  993. } // if (search.instance == "operator")
  994. if (search.instance == "expression" && search.type == "const") {
  995. if (search.value === true) {
  996. var obj = new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, LocalizedStrings.getUI('logic_value_true'), null, null, true);
  997. return obj;
  998. }
  999. if (search.value === false) {
  1000. var obj = new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, LocalizedStrings.getUI('logic_value_false'), null, null, true);
  1001. return obj;
  1002. }
  1003. //TODO If constant has value 0, then it is not updating element (let "Select")
  1004. // ./ivprog/js/visualUI/ivprog_elements.js : export class VariableValueMenu
  1005. // ./ivprog/js/visualUI/commands/variable_value_menu.js: function isVarInProgram (var_obj, function_obj)
  1006. var obj = new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, search.value, null, null, true);
  1007. return obj;
  1008. }
  1009. var variavel = null;
  1010. if (search.instance == "expression" && search.type == "var") {
  1011. // 1. Procurar a variável na função:
  1012. for (var j = 0; j < function_obj.variables_list.length; j++) {
  1013. if (function_obj.variables_list[j].name == search.value) {
  1014. variavel = function_obj.variables_list[j];
  1015. break;
  1016. }
  1017. }
  1018. // 2. Procurar a variável nas gloais:
  1019. if (!variavel)
  1020. for (var j = 0; j < program_obj.globals.length; j++) {
  1021. if (program_obj.globals[j].name == search.value) {
  1022. variavel = program_obj.globals[j];
  1023. break;
  1024. }
  1025. }
  1026. // 3. Procurar na lista de parâmetros:
  1027. if (!variavel)
  1028. for (var j = 0; j < function_obj.parameters_list.length; j++) {
  1029. if (function_obj.parameters_list[j].name == search.value) {
  1030. variavel = function_obj.parameters_list[j];
  1031. break;
  1032. }
  1033. }
  1034. }
  1035. if (search.instance == "expression" && search.type == "var" && !search.line) {
  1036. var obj = new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, variavel, null, null, true);
  1037. return obj;
  1038. }
  1039. if (search.instance == "expression" && search.type == "var" && search.class == "vector") {
  1040. var obj = new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, variavel, null, getVariable(function_obj, search.line[0]), true);
  1041. return obj;
  1042. }
  1043. if (search.instance == "expression" && search.type == "var" && search.class == "matrix") {
  1044. var varL0 = getVariable(function_obj, search.line[0]);
  1045. var varC0 = getVariable(function_obj, search.column[0]);
  1046. var obj = new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, variavel, varL0, varC0, true);
  1047. return obj;
  1048. }
  1049. if (search.instance == "expression" && search.type == "function") {
  1050. var obj = new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, variavel, null, null, true);
  1051. // Search fuction to reference - Procurar a funcao para referencia:
  1052. for (var i = 0; i < program_obj.functions.length; i++) {
  1053. if (program_obj.functions[i].name == search.value) {
  1054. obj.function_called = program_obj.functions[i];
  1055. }
  1056. }
  1057. // Se ainda não foi encontrada, procurar na biblioteca do iVProg:
  1058. if (!obj.function_called) {
  1059. for (var i = 0; i < window.system_functions.length; i++) {
  1060. if (search.value.split(".")[1] && search.value.split(".")[1] == window.system_functions[i].identifier) {
  1061. obj.function_called = window.system_functions[i];
  1062. } else if (search.value == window.system_functions[i].identifier) {
  1063. obj.function_called = window.system_functions[i];
  1064. }
  1065. }
  1066. }
  1067. obj.parameters_list = [];
  1068. for (var i = 0; i < search.params.length; i++) {
  1069. obj.parameters_list.push(getVariable(function_obj,search.params[i][0]));
  1070. }
  1071. return obj;
  1072. }
  1073. } // function getVariable(function_obj, search)
  1074. // @calledby codeParser.js: parseWriter(.)
  1075. export function expressionParserToVisual (text, function_obj, input_field) {
  1076. console.log("./ivprog/js/visualUI/commands/generic_expression.js: expressionParserToVisual(.)"); //leo
  1077. if (text.trim().length == 0) {
  1078. return [new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true)];
  1079. }
  1080. var var_not_found = [];
  1081. var fun_not_found = [];
  1082. var parsed;
  1083. try {
  1084. parsed = ivprogCore.parseExpression(text);
  1085. } catch (ex) {
  1086. Utils.renderErrorMessage(input_field, LocalizedStrings.getUI('expression_invalid'));
  1087. }
  1088. if (!parsed) return null;
  1089. var item_parsed; // to receive each parsed[i] and eventually remove '[' and ']'
  1090. var sizeOfParsed = parsed.length;
  1091. for (var i = 0; i < sizeOfParsed; i++) {
  1092. var variavel = null;
  1093. item_parsed = parsed[i];
  1094. //D console.log(" - " + i + " : type=" + item_parsed.type + " |" + parsed[i] + "| -> " + item_parsed + "|");
  1095. if (item_parsed.instance == "expression" && item_parsed.type == "var") {
  1096. // 1. Procurar a variável na função:
  1097. for (var j = 0; j < function_obj.variables_list.length; j++) {
  1098. if (function_obj.variables_list[j].name == item_parsed.value) {
  1099. variavel = function_obj.variables_list[j];
  1100. break;
  1101. }
  1102. }
  1103. // 2. Procurar a variável nas globais:
  1104. if (!variavel)
  1105. for (var j = 0; j < program_obj.globals.length; j++) {
  1106. if (program_obj.globals[j].name == item_parsed.value) {
  1107. variavel = program_obj.globals[j];
  1108. break;
  1109. }
  1110. }
  1111. // 3. Procurar a variável nos parâmetros:
  1112. if (!variavel)
  1113. for (var j = 0; j < function_obj.parameters_list.length; j++) {
  1114. if (function_obj.parameters_list[j].name == item_parsed.value) {
  1115. variavel = function_obj.parameters_list[j];
  1116. break;
  1117. }
  1118. }
  1119. if (!variavel)
  1120. var_not_found.push(item_parsed.value);
  1121. }
  1122. var funcao;
  1123. if (item_parsed.instance == "expression" && item_parsed.type == "function") {
  1124. // Procurar a funcao para referencia:
  1125. for (var j = 0; j < program_obj.functions.length; j++) {
  1126. if (program_obj.functions[j].name == item_parsed.value) {
  1127. funcao = program_obj.functions[j];
  1128. }
  1129. }
  1130. // Se ainda nao encontrou, procurar na biblioteca do iVProg:
  1131. if (!funcao) {
  1132. for (var j = 0; j < window.system_functions.length; j++) {
  1133. if (item_parsed.value.split(".")[1] && item_parsed.value.split(".")[1] == window.system_functions[j].identifier) {
  1134. funcao = window.system_functions[j];
  1135. } else if (item_parsed.value == window.system_functions[j].identifier) {
  1136. funcao = window.system_functions[j];
  1137. }
  1138. }
  1139. }
  1140. if (!funcao) {
  1141. fun_not_found.push(item_parsed.value);
  1142. }
  1143. }
  1144. } // for (var i = 0; i < sizeOfParsed; i++)
  1145. if (fun_not_found.length > 0) {
  1146. let uniqueWords = [...new Set(fun_not_found)];
  1147. Utils.renderErrorMessage(input_field, LocalizedStrings.getUI('expression_undeclared_function') + " " + uniqueWords.join(", "));
  1148. return null;
  1149. }
  1150. if (var_not_found.length > 0) {
  1151. let uniqueWords = [...new Set(var_not_found)];
  1152. Utils.renderErrorMessage(input_field, LocalizedStrings.getUI('expression_undelcared_variable') + " " + uniqueWords.join(", "));
  1153. return null;
  1154. }
  1155. var exp_obj = [];
  1156. for (var i = 0; i < sizeOfParsed; i++) {
  1157. item_parsed = parsed[i];
  1158. exp_obj.push(getVariable(function_obj, item_parsed));
  1159. }
  1160. return exp_obj;
  1161. } // export function expressionParserToVisual(text, function_obj, input_field)
  1162. export function searchFunction (function_name) {
  1163. for (var j = 0; j < program_obj.functions.length; j++) {
  1164. if (program_obj.functions[j].name == function_name) {
  1165. return program_obj.functions[j];
  1166. }
  1167. }
  1168. // Se ainda não encontrou, procurar na biblioteca do iVProg:
  1169. for (var j = 0; j < window.system_functions.length; j++) {
  1170. if (function_name.split(".")[1] && function_name.split(".")[1]
  1171. == window.system_functions[j].identifier) {
  1172. return window.system_functions[j];
  1173. } else if (function_name == window.system_functions[j].identifier) {
  1174. return window.system_functions[j];
  1175. }
  1176. }
  1177. } // export function searchFunction(function_name)
  1178. // Verify if it is list with "write_separator" inside "write(.)"
  1179. // @calledby expressionParserCodeVisual((parsed, function_obj): item = checkIfWriteSeparator(function_obj, item_parsed2, sizeParsed);
  1180. export function checkIfWriteSeparator (function_obj, item_parsed, sizeParsed) { // verify if it is list with "write_separator" inside "write(.)
  1181. var item;
  1182. var check_write_esp = 0, i;
  1183. if (item_parsed.length==1) item_parsed = item_parsed[0]; // is array with object (get the object)
  1184. if (item_parsed.type=="const" && item_parsed.class=="simple" && item_parsed.value==" ") { // avoid regular const with value 0
  1185. console.log(" [GE.cws] const, simple, branco! #parsed=" + sizeParsed + ", item_parsed.value.length=" +
  1186. item_parsed.value.length + ", item_parsed.value='" + item_parsed.value + "'*******"); //leo
  1187. if (sizeParsed>1 && item_parsed.value.length==1 && item_parsed.value.toUpperCase() == item_parsed.value.toLowerCase()) { // String
  1188. // isNaN(item_parsed.value)
  1189. if (item_parsed.value.charCodeAt(0)==32) // be sure it is space (not value 0)
  1190. check_write_esp = 1; // ASCII 32 = ' '
  1191. }
  1192. }
  1193. if (check_write_esp == 1) { // is 'write_separator'?
  1194. //TODO Implementar o construtor para espaco em branco - por enquanto troco o espaco pelo operador "+"
  1195. //TODO Must be used: Models.EXPRESSION_TYPES.write_sep
  1196. console.log(" [GE.cws] const, simple, branco! check_write_esp=" + check_write_esp + " : " + JSON.stringify(item_parsed) + "*******"); //leo
  1197. item_parsed.type = Models.EXPRESSION_TYPES.exp_arithmetic; // "write_separator";
  1198. item_parsed.value = Models.ARITHMETIC_TYPES.plus; // "plus"
  1199. item = new Models.ExpressionOperator(Models.EXPRESSION_TYPES.exp_arithmetic, Models.ARITHMETIC_TYPES.plus);
  1200. // item = new Models.ExpressionOperator(Models.EXPRESSION_TYPES.exp_arithmetic, Models.ARITHMETIC_TYPES.write_sep);
  1201. }
  1202. else
  1203. item = getVariable(function_obj, item_parsed); // if only 1 then the elements are inside it [[{...},{...}...]]
  1204. return item;
  1205. }
  1206. // Process expression
  1207. // @calledby ./ivprog/js/util/codeParser.js: parseWriter(.): send parameters of "write(<list_parameters>)" command
  1208. export function expressionParserCodeVisual (parsed, function_obj) {
  1209. if (!parsed) return null;
  1210. var var_not_found = [];
  1211. var fun_not_found = [];
  1212. var vet_obj = []; //leo
  1213. //D var str1 = ""; for (var ii=0; ii<parsed.length; ii++) str1 += ii + " : " + JSON.stringify(parsed[ii]) + "\n";
  1214. console.log("./ivprog/js/visualUI/commands/generic_expression.js [GE]: expressionParserCodeVisual(.): #parsed=" + parsed.length); //D parsed=\n" + str1); //leo
  1215. var item_parsed; // to receive each parsed[i] and eventually remove '[' and ']'
  1216. for (var i = 0; i < parsed.length; i++) {
  1217. item_parsed = parsed[i];
  1218. //if (item_parsed.length>0) item_parsed = item_parsed[0]; // if vector get the first
  1219. console.log(" [GE] " + i + " : type=" + (item_parsed[0] ? item_parsed[0].type : "<>") + " : parsed[" + i + "]=" + JSON.stringify(parsed[i]));
  1220. var variavel = null;
  1221. if (item_parsed.instance == "expression" && item_parsed.type == "var") {
  1222. // 1. Search variable in function:
  1223. for (var j = 0; j < function_obj.variables_list.length; j++) {
  1224. if (function_obj.variables_list[j].name == item_parsed.value) {
  1225. variavel = function_obj.variables_list[j];
  1226. break;
  1227. }
  1228. }
  1229. // 2. Search variable in global variables:
  1230. if (!variavel)
  1231. for (var j = 0; j < program_obj.globals.length; j++) {
  1232. if (program_obj.globals[j].name == item_parsed.value) {
  1233. variavel = program_obj.globals[j];
  1234. break;
  1235. }
  1236. }
  1237. // 3. Search variable in parameters:
  1238. if (!variavel)
  1239. for (var j = 0; j < function_obj.parameters_list.length; j++) {
  1240. if (function_obj.parameters_list[j].name == item_parsed.value) {
  1241. variavel = function_obj.parameters_list[j];
  1242. break;
  1243. }
  1244. }
  1245. if (!variavel)
  1246. var_not_found.push(item_parsed.value);
  1247. } // if (item_parsed.instance == "expression" && item_parsed.type == "var")
  1248. var funcao;
  1249. if (item_parsed.instance == "expression" && item_parsed.type == "function") {
  1250. // Search the function to reference = Procurar a funcao para referencia:
  1251. for (var j = 0; j < program_obj.functions.length; j++) {
  1252. if (program_obj.functions[j].name == item_parsed.value) {
  1253. funcao = program_obj.functions[j];
  1254. }
  1255. }
  1256. // If not yet found, search in iVProg library = Se ainda nao encontrou, procurar na biblioteca do iVProg
  1257. if (!funcao) {
  1258. for (var j = 0; j < window.system_functions.length; j++) {
  1259. if (item_parsed.value.split(".")[1] && item_parsed.value.split(".")[1] == window.system_functions[j].identifier) {
  1260. funcao = window.system_functions[j];
  1261. } else if (item_parsed.value == window.system_functions[j].identifier) {
  1262. funcao = window.system_functions[j];
  1263. }
  1264. }
  1265. }
  1266. if (!funcao) {
  1267. fun_not_found.push(item_parsed.value);
  1268. }
  1269. }
  1270. } // for (var i = 0; i < parsed.length; i++)
  1271. //ATTENTION: sensible cases ("write(a," ",b)"; "write(a+b)"; "repeat_for i from 0 to 10")
  1272. var sizeParsed = parsed.length;
  1273. if (sizeParsed==1) { // array with a single item
  1274. //D console.log(" [GE] Final: entrou - sizeParsed=" + sizeParsed + ", parsed.length=" + parsed.length); //leo
  1275. if (parsed[0].length>1) { // ignore constant (as 5 in "repeat_to i from 1 to 5"
  1276. parsed = parsed[0]; // change to get elements of "parsed" as an array - allaw to work "i+1" (as "write(i+1)")
  1277. sizeParsed = parsed.length;
  1278. }
  1279. }
  1280. console.log(" [GE] Final: sizeParsed=" + sizeParsed + ", parsed.length=" + parsed.length + "\n [GE] parsed=" + JSON.stringify(parsed)); //leo
  1281. var exp_obj = [];
  1282. var item;
  1283. for (var i=0; i < sizeParsed; i++) { // ./ivprog/js/util/codeParser.js : parseWriter(.): 'CodeParser.expressionParserCodeVisual(command.content, function_obj)'
  1284. var item_parsed2 = parsed[i];
  1285. if (parsed.length === undefined) // in i=0, if "parsed" is not any more an array
  1286. item_parsed2 = parsed;
  1287. console.log(" [GE] i=" + i + ": #item_parsed2=" + item_parsed2.length + ", item_parsed2=" + JSON.stringify(item_parsed2)); //leo
  1288. item = checkIfWriteSeparator(function_obj, item_parsed2, sizeParsed); // eventually change to work with "write(var1," ",var2)"
  1289. //TODO Trick to identify: write(VAR," ",VAR) => parse = [VAR, " ", VAR]
  1290. exp_obj.push(item);
  1291. console.log(" [GE] Type " + (item_parsed2[0] ? item_parsed2[0].type : "<>") + "; Insert in 'exp_obj[" + i + "]=|" + JSON.stringify(item) + "|"); //leo
  1292. } // for (var i = 0; i < sizeParsed; i++)
  1293. return exp_obj;
  1294. } // export function expressionParserCodeVisual(parsed, function_obj)