generic_expression.js 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634
  1. import { Types } from "../types";
  2. import * as Models from "../ivprog_elements";
  3. import { LocalizedStrings } from "../../services/localizedStringsService";
  4. import * as VariableValueMenuManagement from "./variable_value_menu";
  5. import { registerUserEvent, ActionTypes } from "../../services/userLog";
  6. import WatchJS from "melanke-watchjs";
  7. import * as Utils from '../utils';
  8. window.timer = false;
  9. export function renderExpression (
  10. command,
  11. function_obj,
  12. div_to_render,
  13. expression_array
  14. ) {
  15. div_to_render.empty();
  16. WatchJS.unwatch(command, "expression");
  17. WatchJS.watch(
  18. command,
  19. "expression",
  20. function () {
  21. if (window.timer) return;
  22. const m = div_to_render
  23. .find(".single_element_expression")
  24. .not(".mouse_distance")
  25. .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)
  32. .find(".text")
  33. .text();
  34. s += $(this)
  35. .find(".var_name")
  36. .text();
  37. s += $(this)
  38. .find(".parameters_function_called")
  39. .text();
  40. s += $(this)
  41. .find(".value_rendered")
  42. .text();
  43. s += " ";
  44. }
  45. });
  46. if (s) {
  47. window.timer = true;
  48. } else {
  49. return;
  50. }
  51. registerUserEvent(
  52. function_obj.name,
  53. ActionTypes.CHANGE_COMMAND_EXP,
  54. command.type,
  55. "/",
  56. s
  57. );
  58. setTimeout(function () {
  59. window.timer = false;
  60. }, 200);
  61. },
  62. 20,
  63. true
  64. );
  65. if (command.type === Models.COMMAND_TYPES.attribution) {
  66. WatchJS.unwatch(command.variable);
  67. WatchJS.watch(
  68. command.variable,
  69. function () {
  70. renderExpression(
  71. command,
  72. function_obj,
  73. div_to_render,
  74. expression_array
  75. );
  76. },
  77. 0
  78. );
  79. if (command.variable.content) {
  80. const types_included = [];
  81. if (
  82. command.variable.content.type == Types.INTEGER ||
  83. command.variable.content.type == Types.REAL
  84. ) {
  85. types_included.push(Models.EXPRESSION_TYPES.exp_arithmetic);
  86. } else if (command.variable.content.type == Types.BOOLEAN) {
  87. types_included.push(Models.EXPRESSION_TYPES.exp_conditional);
  88. types_included.push(Models.EXPRESSION_TYPES.exp_logic);
  89. types_included.push(Models.EXPRESSION_TYPES.exp_arithmetic);
  90. } else if (command.variable.content.type == Types.TEXT) {
  91. types_included.push(Models.EXPRESSION_TYPES.exp_conditional);
  92. types_included.push(Models.EXPRESSION_TYPES.exp_logic);
  93. types_included.push(Models.EXPRESSION_TYPES.exp_arithmetic);
  94. } else {
  95. //console.log("NÃO RECONHECI! VEJA: ", command.variable.content.type);
  96. }
  97. renderElements(
  98. command,
  99. function_obj,
  100. div_to_render,
  101. expression_array,
  102. types_included
  103. );
  104. } else {
  105. div_to_render.text(
  106. LocalizedStrings.getUI("var_menu_select_var").toLowerCase()
  107. );
  108. }
  109. } else {
  110. const types_included = [];
  111. types_included.push(Models.EXPRESSION_TYPES.exp_conditional);
  112. types_included.push(Models.EXPRESSION_TYPES.exp_logic);
  113. if (command.type === Models.COMMAND_TYPES.writer)
  114. types_included.push(Models.EXPRESSION_TYPES.write_sep);
  115. types_included.push(Models.EXPRESSION_TYPES.exp_arithmetic);
  116. renderElements(
  117. command,
  118. function_obj,
  119. div_to_render,
  120. expression_array,
  121. types_included
  122. );
  123. }
  124. div_to_render.children(".mouse_distance").addClass("mouse_distance_hidden");
  125. div_to_render.children(".higher_element").on("mousemove", function (evt) {
  126. if (!window.open_or_close) {
  127. $(this).css("position", "relative", "!important");
  128. $(this)
  129. .children(".mouse_distance")
  130. .css("opacity", "1");
  131. }
  132. });
  133. div_to_render.children(".higher_element").on("mouseout", function (evt) {
  134. if (!window.open_or_close) {
  135. $(this).css("position", "absolute", "!important");
  136. $(this)
  137. .children(".mouse_distance")
  138. .css("opacity", "0");
  139. }
  140. });
  141. const lixeira = $('<div class="lixeira" draggable="true"></div>');
  142. div_to_render
  143. .find(".single_element_expression")
  144. .on("mousedown", function (evt) {
  145. window.posX = evt.clientX;
  146. window.posY = evt.clientY;
  147. });
  148. Sortable.create(div_to_render[0], {
  149. animation: 100,
  150. ghostClass: "ghost",
  151. group: {
  152. name: "shared",
  153. put: false, // Do not allow items to be put into this list
  154. },
  155. draggable: ".single_element_expression",
  156. sort: false,
  157. filter: ".not_allowed",
  158. onStart: function () {
  159. $("body").append(lixeira);
  160. lixeira.css("display", "block");
  161. lixeira.css("top", window.posY + 70, "!important");
  162. lixeira.css("left", window.posX - 20, "!important");
  163. },
  164. onMove: function () {
  165. lixeira.addClass("color_test");
  166. },
  167. onEnd: function () {
  168. lixeira.remove();
  169. div_to_render.find(".ghost").removeClass("ghost");
  170. },
  171. });
  172. new Sortable(lixeira[0], {
  173. group: "shared",
  174. animation: 150,
  175. onAdd: function (evt) {
  176. lixeira.css("display", "none");
  177. lixeira.find(".single_element_expression").remove();
  178. lixeira.css("background-color", "");
  179. lixeira.remove();
  180. removeElement(evt, expression_array);
  181. renderExpression(command, function_obj, div_to_render, expression_array);
  182. },
  183. });
  184. }
  185. function removeElement (event, expression_array) {
  186. const indice = $(event.item).data("index");
  187. const first = expression_array[0];
  188. if (expression_array[indice].type) {
  189. // if is alone in expression:
  190. if (expression_array.length == 1) {
  191. //function_obj.commands.splice(function_obj.commands.indexOf(command), 1);
  192. expression_array.splice(0, 1);
  193. } else if (expression_array.length > 1) {
  194. if (indice > 0 && expression_array[indice - 1].type_op) {
  195. if (
  196. indice < expression_array.length &&
  197. expression_array[indice - 2] == "(" &&
  198. expression_array[indice + 1].type_op
  199. ) {
  200. expression_array.splice(indice + 1, 1);
  201. }
  202. expression_array.splice(indice, 1);
  203. expression_array.splice(indice - 1, 1);
  204. if (
  205. indice - 2 < expression_array.length &&
  206. expression_array[indice - 2] == "(" &&
  207. expression_array[indice - 1] == ")"
  208. ) {
  209. expression_array.splice(indice - 1, 1);
  210. expression_array.splice(indice - 2, 1);
  211. if (
  212. indice - 3 >= 0 &&
  213. indice - 3 < expression_array.length &&
  214. expression_array[indice - 3].type_op
  215. ) {
  216. expression_array.splice(indice - 3, 1);
  217. }
  218. }
  219. } else if (
  220. indice < expression_array.length - 1 &&
  221. expression_array[indice + 1].type_op
  222. ) {
  223. expression_array.splice(indice + 1, 1);
  224. expression_array.splice(indice, 1);
  225. } else if (
  226. indice < expression_array.length - 1 &&
  227. indice > 0 &&
  228. expression_array[indice - 1] == "(" &&
  229. expression_array[indice + 1] == ")"
  230. ) {
  231. if (indice > 1 && expression_array[indice - 2].type_op) {
  232. expression_array.splice(indice + 1, 1);
  233. expression_array.splice(indice, 1);
  234. expression_array.splice(indice - 1, 1);
  235. expression_array.splice(indice - 2, 1);
  236. } else if (
  237. indice < expression_array.length - 2 &&
  238. expression_array[indice + 2].type_op
  239. ) {
  240. expression_array.splice(indice + 1, 1);
  241. expression_array.splice(indice, 1);
  242. expression_array.splice(indice - 1, 1);
  243. } else {
  244. expression_array.splice(indice + 1, 1);
  245. expression_array.splice(indice, 1);
  246. expression_array.splice(indice - 1, 1);
  247. }
  248. }
  249. }
  250. } else if (expression_array[indice].type_op) {
  251. // iVProg doesn't support operator remove
  252. } else {
  253. let opening = -1;
  254. let closing = -1;
  255. if (expression_array[indice] == "(") {
  256. opening = indice;
  257. for (var i = indice + 1; i < expression_array.length; i++) {
  258. if (expression_array[i] == ")") {
  259. closing = i;
  260. break;
  261. }
  262. }
  263. } else {
  264. closing = indice;
  265. for (var i = indice - 1; i >= 0; i--) {
  266. if (expression_array[i] == "(") {
  267. opening = i;
  268. break;
  269. }
  270. }
  271. }
  272. if (expression_array[opening + 1].type_op) {
  273. expression_array.splice(closing, 1);
  274. expression_array.splice(opening + 1, 1);
  275. expression_array.splice(opening, 1);
  276. } else {
  277. expression_array.splice(closing, 1);
  278. expression_array.splice(opening, 1);
  279. }
  280. }
  281. // if expression is empty, add a new var value:
  282. if (expression_array.length == 0) {
  283. expression_array.push(
  284. new Models.VariableValueMenu(
  285. VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all,
  286. null,
  287. null,
  288. null,
  289. true
  290. )
  291. );
  292. }
  293. if (first != expression_array[0] && expression_array[0].type_op) {
  294. expression_array.splice(0, 1);
  295. }
  296. }
  297. function renderElements (
  298. command,
  299. function_obj,
  300. div_to_render,
  301. expression_array,
  302. types_included
  303. ) {
  304. /*if (expression_array.length > 0) {
  305. if (!expression_array[0].type_op) {
  306. renderStartAddOperator(div_to_render, types_included, expression_array, command, function_obj, 0);
  307. }
  308. }*/
  309. let i = 0;
  310. for (i = 0; i < expression_array.length; i++) {
  311. if (expression_array[i].type == "var_value") {
  312. const div_temp = $(
  313. '<div class="single_element_expression" data-index="' + i + '"></div>'
  314. );
  315. if (i == 0) {
  316. if (expression_array.length > 0 && !expression_array[0].type_op) {
  317. //renderStartAddOperator(div_to_render, types_included, expression_array, command, function_obj, 0);
  318. }
  319. }
  320. VariableValueMenuManagement.renderMenu(
  321. command,
  322. expression_array[i],
  323. div_temp,
  324. function_obj
  325. );
  326. div_to_render.append(div_temp);
  327. } else if (expression_array[i] == "(" || expression_array[i] == ")") {
  328. if (expression_array[i] == ")") {
  329. renderFinalAddElements(
  330. div_to_render,
  331. types_included,
  332. expression_array,
  333. command,
  334. function_obj,
  335. i
  336. );
  337. renderParenthesis(
  338. div_to_render,
  339. expression_array[i],
  340. command,
  341. function_obj,
  342. i,
  343. expression_array
  344. );
  345. } else if (
  346. expression_array[i] == "(" &&
  347. !expression_array[i + 1].type_op
  348. ) {
  349. renderParenthesis(
  350. div_to_render,
  351. expression_array[i],
  352. command,
  353. function_obj,
  354. i,
  355. expression_array
  356. );
  357. renderStartAddOperator(
  358. div_to_render,
  359. types_included,
  360. expression_array,
  361. command,
  362. function_obj,
  363. i + 1
  364. );
  365. } else {
  366. renderParenthesis(
  367. div_to_render,
  368. expression_array[i],
  369. command,
  370. function_obj,
  371. i,
  372. expression_array
  373. );
  374. }
  375. } else {
  376. if (i == 0) {
  377. } else if (expression_array[i - 1] == "(") {
  378. }
  379. renderOperatorMenu(
  380. command,
  381. function_obj,
  382. div_to_render,
  383. expression_array[i],
  384. types_included,
  385. i,
  386. expression_array
  387. );
  388. }
  389. }
  390. renderFinalAddElements(
  391. div_to_render,
  392. types_included,
  393. expression_array,
  394. command,
  395. function_obj,
  396. i,
  397. true
  398. );
  399. renderAddParenthesis(
  400. command,
  401. function_obj,
  402. div_to_render,
  403. expression_array,
  404. types_included
  405. );
  406. }
  407. window.parentheses_activate = false;
  408. window.open_or_close = null;
  409. function renderAddParenthesis (
  410. command,
  411. function_obj,
  412. div_to_render,
  413. expression_array,
  414. types_included
  415. ) {
  416. const addParentheses = $(
  417. '<div class="single_element_expression add_parentheses not_allowed"><img style="width: 15px; position: relative; top: 3px; left: 1px; height: 15px;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOgAAAEjCAYAAAA48U27AAAasXpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHjarZtZkhw5km3/sYpeAkYFsByMIm8Hvfw+Fx4kg6zM7HolHaykOz3MzWA63EFh5c5//7/r/osfK8m7XGqzbub5yT33OHjT/Ofn8xp8fn+/n/Pjd+H3z11MX28jr4nX9PmFna/jB5+XX1+o+evz+fvnrq7Pm9i+TvT1C078fpKurPf7a5FfJ0rx83n4+rfrX18Y9u12vv6L6+u0Xyf/89+5EoxdOF+KLp4Ukv/8/blSYhWpp8Grvb9L1CeJ9+n9HVL71/g5/Wutvw7gz3d/xM//WFn6FQ73iezXAfZHnL4+D+WPz9PPy8TfVhTizyvH7yuyEZr//vMtfvfudu/53N3I5giXfd3Uj1t57zhwEs70vmb8qfxXeF/fn86f5odfZG1zq9P5yT96iMT6hhx2GOGG815XWCwxxxMrrzGumN5nLdXY43pJyfoTbqyO/OzUyNUic4mP48+1hHfdrutxscaVd+DIGDhZ4Bu//XF/fvCf/vntRPeqDkLw7RMnyoJ1RZUsy1Dm9DdHkZBwv2JaXnyD+7z4P3+U2EQGywtz4waHn59TzBJ+1VZ6eU6+OA7N/tMvoe6vExAirl1YTEhkwFtIJVjwNcYaAnFs5Gew8phynGQgFFfiZpUxp2Qkp0Vdm+/U8I6NJX4+Bl5IRKFpKqmhgUhWziUb/dYooeFKKrmUYqWWVnoZlixbMbNqwqlRU821VKu1ttrraKnlVpq12lrrbfTYEzBWXLdee+u9j8FFRx6ca3D84IMZZ5p5lmmzzjb7HIvyWXmVZauutvoaO+60gQC3bdfddt/jhEMpnXzKsVNPO/2MS63ddPMt12697fY7fmYtfLXtb1n7M3P/nLXwlbX4EqXj6q+s8XGtP04RBCdFOSNjMQcyXpUBCjo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so/3rlCimWX5RB3TOC0vgn4gRRSsA/wR1LImGbETE/IXNAIHwbWSSEFf2lrF+kZ2bh2RynTyWLLCQUKGjhFl1J/hWFqNeAdUshUs/bZpcdIGdNYz8aNuRYziPY56kVN7ZPOuVlSyDTmnFu8Yf1z+0q5TqUxPQF6brwxx/mXLQVO0ReA90ghBfNo8aVR2sSF4Js+K2i21HPttddKmSQCS3o9cJUUUvAB59ygFDITc86dBrTszR+paU1PGJ2ga9askXKt5APUXxuX0hTgC1LIbGv0JFuu1TE6Xt/IyAjXX389p59+upRVFzhFH3POnQNcLAUjvdE591Xv/a1S0GzhPcDLpFAnqw3pPYLaA/Cd7+RamlbNJdTfkpbal13A3RXdyjm3Ey36CF+76gG44447uPfee6Vsyxi92+ed1B/wTmkJ9sqIZnwKsGfkFL14HfSyyy5rlGs53vtfkuclOJ93zk2TQt3OObeQPGfZu8qLBf3BD37A6tW5lqZV80ngESkUaTfgQ1LI8FeA3YWl7MWCrlu3ju9+97uNsi3He7/Ge7+b994l/t+Q9P+l23nvX7/15zb3pUfZ5xZpi6dZLr/8cs4666yQp06M2Ubf5r5vbOwbuV7KaerftPl3Uqad/DepALQulhENnAAAAABJRU5ErkJggg=="></div>'
  418. );
  419. div_to_render.append(addParentheses);
  420. addParentheses.popup({
  421. content: "Adicionar parênteses",
  422. delay: {
  423. show: 750,
  424. hide: 0,
  425. },
  426. });
  427. addParentheses.on("click", function (mouse_event) {
  428. // verificar se já está ativado
  429. if (window.parentheses_activate) {
  430. return;
  431. }
  432. div_to_render.find(".usepointer").off("click");
  433. window.parentheses_activate = true;
  434. window.open_or_close = "open";
  435. div_to_render.find(".dropdown").addClass("disabled");
  436. div_to_render.find(".ghost_element").addClass("temp_class");
  437. div_to_render.find(".ghost_element").removeClass("ghost_element");
  438. const floatingObject = $('<div class="floating_parenthesis"> ( </div>');
  439. floatingObject.draggable().appendTo("body");
  440. floatingObject.css("position", "absolute");
  441. mouse_event.type = "mousedown.draggable";
  442. mouse_event.target = floatingObject[0];
  443. floatingObject.css("left", mouse_event.pageX + 10);
  444. floatingObject.css("top", mouse_event.pageY + 10);
  445. floatingObject.trigger(mouse_event);
  446. div_to_render.on("mousemove", function (evt) {
  447. let actual_target = null;
  448. if ($(evt.target).hasClass("single_element_expression")) {
  449. actual_target = $(evt.target);
  450. } else {
  451. actual_target = $(evt.target).closest(".single_element_expression");
  452. }
  453. if (
  454. $(evt.target).hasClass("temp_class") ||
  455. actual_target.length < 1 ||
  456. actual_target.hasClass("add_parentheses") ||
  457. actual_target.hasClass("rendered_parentheses") ||
  458. $(evt.target).hasClass("expression_elements")
  459. ) {
  460. return;
  461. }
  462. renderGhostParentheses(
  463. actual_target,
  464. command,
  465. function_obj,
  466. div_to_render,
  467. expression_array
  468. );
  469. });
  470. div_to_render.on("mouseleave", function () {
  471. /*window.open_parentheses.remove();
  472. window.close_parentheses.remove();*/
  473. });
  474. let floating;
  475. $("body").on("mouseup", function (evt) {
  476. if (window.open_or_close == "open") {
  477. window.open_or_close = "close";
  478. floatingObject.remove();
  479. var comando_que_esta = $(evt.target).closest(".command_container");
  480. var comando_certo = div_to_render.closest(".command_container");
  481. if (!comando_que_esta.is(comando_certo)) {
  482. window.parentheses_activate = false;
  483. div_to_render.find(".temp_class").addClass("ghost_element");
  484. div_to_render.find(".temp_class").removeClass("temp_class");
  485. div_to_render.off("mousemove");
  486. div_to_render.off("mouseleave");
  487. $("body").off("mouseup");
  488. window.open_parentheses.remove();
  489. window.close_parentheses.remove();
  490. window.inserir_open = -1;
  491. window.inserir_close = -1;
  492. window.open_or_close = null;
  493. renderExpression(
  494. command,
  495. function_obj,
  496. div_to_render,
  497. expression_array
  498. );
  499. return;
  500. }
  501. window.open_parentheses.addClass("parentheses_fixed");
  502. floating = $('<div class="floating_parenthesis"> ) </div>');
  503. floating.draggable().appendTo("body");
  504. floating.css("position", "absolute");
  505. floating.css("left", evt.pageX + 10);
  506. floating.css("top", evt.pageY + 10);
  507. $("body").on("mousemove", function (evts) {
  508. floating.css("left", evts.pageX + 10);
  509. floating.css("top", evts.pageY + 10);
  510. });
  511. } else {
  512. floating.remove();
  513. window.open_parentheses.removeClass("parentheses_fixed");
  514. div_to_render.off("mousemove");
  515. div_to_render.off("mouseleave");
  516. $("body").off("mouseup");
  517. setTimeout(function () {
  518. window.parentheses_activate = false;
  519. }, 50);
  520. var comando_que_esta = $(evt.target).closest(".command_container");
  521. var comando_certo = div_to_render.closest(".command_container");
  522. let is_correct = false;
  523. if (comando_que_esta.is(comando_certo)) {
  524. is_correct = true;
  525. }
  526. if (is_correct) {
  527. expression_array.splice(window.inserir_open, 0, "(");
  528. expression_array.splice(window.inserir_close, 0, ")");
  529. }
  530. window.inserir_open = -1;
  531. window.inserir_close = -1;
  532. window.open_or_close = null;
  533. renderExpression(
  534. command,
  535. function_obj,
  536. div_to_render,
  537. expression_array
  538. );
  539. }
  540. });
  541. });
  542. }
  543. window.open_parentheses = $('<div class="parentheses_ghost">(</div>');
  544. window.close_parentheses = $('<div class="parentheses_ghost">)</div>');
  545. window.inserir_open = -1;
  546. window.inserir_close = -1;
  547. function renderGhostParentheses (
  548. actual_target,
  549. command,
  550. function_obj,
  551. div_to_render,
  552. expression_array
  553. ) {
  554. /*window.open_parentheses.remove();
  555. window.close_parentheses.remove();*/
  556. const index_in_array = actual_target.data("index");
  557. if (
  558. expression_array[index_in_array] == "(" ||
  559. expression_array[index_in_array] == ")"
  560. ) {
  561. return;
  562. }
  563. if (window.open_or_close == "close") {
  564. if (index_in_array < window.inserir_open) {
  565. return;
  566. }
  567. }
  568. // Tratando a situação quando é na primeira posição:
  569. if (index_in_array == 0) {
  570. if (expression_array[index_in_array].type == "var_value") {
  571. if (window.open_or_close == "open") {
  572. window.open_parentheses.insertBefore(actual_target);
  573. window.inserir_open = index_in_array;
  574. }
  575. /*if (expression_array.length == 1) {
  576. if (window.open_or_close == "close") {
  577. window.close_parentheses.insertAfter(actual_target);
  578. window.inserir_close = index_in_array + 2;
  579. }*/
  580. //} else {
  581. var count_opened = 0;
  582. var count_closed = 0;
  583. for (var i = 0; i < expression_array.length; i++) {
  584. if (expression_array[i] == "(") {
  585. count_opened++;
  586. }
  587. if (expression_array[i] == ")") {
  588. count_closed++;
  589. }
  590. if (count_opened != count_closed) {
  591. } else {
  592. if (count_opened > 0) {
  593. if (window.open_or_close == "close") {
  594. window.close_parentheses.insertAfter(
  595. div_to_render.find(
  596. '.single_element_expression[data-index="' + i + '"]'
  597. )
  598. );
  599. window.inserir_close = i + 2;
  600. }
  601. break;
  602. } else {
  603. if (expression_array[i].type == "var_value") {
  604. if (window.open_or_close == "close") {
  605. window.close_parentheses.insertAfter(
  606. div_to_render.find(
  607. '.single_element_expression[data-index="' + i + '"]'
  608. )
  609. );
  610. window.inserir_close = i + 2;
  611. }
  612. break;
  613. }
  614. }
  615. }
  616. }
  617. //}
  618. } else if (expression_array[index_in_array].type_op) {
  619. if (window.open_or_close == "open") {
  620. window.open_parentheses.insertBefore(actual_target);
  621. window.inserir_open = index_in_array;
  622. }
  623. var count_opened = 0;
  624. var count_closed = 0;
  625. for (var i = 1; i < expression_array.length; i++) {
  626. // $('.slide-link[data-slide="0"]')
  627. if (expression_array[i] == "(") {
  628. count_opened++;
  629. }
  630. if (expression_array[i] == ")") {
  631. count_closed++;
  632. }
  633. if (count_opened != count_closed) {
  634. } else {
  635. if (count_opened > 0) {
  636. if (expression_array[i].type == "var_value") {
  637. window.close_parentheses.insertAfter(
  638. div_to_render.find(
  639. '.single_element_expression[data-index="' + i + '"]'
  640. )
  641. );
  642. window.inserir_close = i + 2;
  643. }
  644. break;
  645. } else {
  646. if (expression_array[i].type == "var_value") {
  647. if (expression_array[i].type == "var_value") {
  648. window.close_parentheses.insertAfter(
  649. div_to_render.find(
  650. '.single_element_expression[data-index="' + i + '"]'
  651. )
  652. );
  653. window.inserir_close = i + 2;
  654. }
  655. break;
  656. }
  657. }
  658. }
  659. }
  660. }
  661. return;
  662. }
  663. // Tratando quando não é no índice 0:
  664. if (expression_array[index_in_array].type == "var_value") {
  665. if (window.open_or_close == "open") {
  666. window.open_parentheses.insertBefore(actual_target);
  667. window.inserir_open = index_in_array;
  668. }
  669. if (window.open_or_close == "close") {
  670. window.close_parentheses.insertAfter(actual_target);
  671. window.inserir_close = index_in_array + 2;
  672. }
  673. return;
  674. }
  675. if (expression_array[index_in_array].type_op) {
  676. // buscar para a esquerda primeiro:
  677. if (expression_array[index_in_array - 1] == "(") {
  678. if (window.open_or_close == "open") {
  679. window.open_parentheses.insertBefore(actual_target);
  680. window.inserir_open = index_in_array;
  681. }
  682. } else if (expression_array[index_in_array - 1] == ")") {
  683. // buscar a abertura
  684. var count_opened = 0;
  685. var count_closed = 0;
  686. for (var j = index_in_array - 1; j >= 0; j--) {
  687. if (expression_array[j] == "(") {
  688. count_opened++;
  689. }
  690. if (expression_array[j] == ")") {
  691. count_closed++;
  692. }
  693. if (count_opened != count_closed) {
  694. } else {
  695. if (count_closed > 0) {
  696. if (window.open_or_close == "open") {
  697. window.open_parentheses.insertBefore(
  698. div_to_render.find(
  699. '.single_element_expression[data-index="' + j + '"]'
  700. )
  701. );
  702. window.inserir_open = j;
  703. }
  704. break;
  705. }
  706. }
  707. }
  708. } else if (expression_array[index_in_array - 1].type == "var_value") {
  709. if (window.open_or_close == "open") {
  710. window.open_parentheses.insertBefore(
  711. div_to_render.find(
  712. '.single_element_expression[data-index="' +
  713. (index_in_array - 1) +
  714. '"]'
  715. )
  716. );
  717. window.inserir_open = index_in_array - 1;
  718. }
  719. }
  720. // buscar para a direita agora:
  721. if (expression_array[index_in_array + 1] == "(") {
  722. // buscar o fechamento:
  723. var count_opened = 0;
  724. var count_closed = 0;
  725. for (var j = index_in_array + 1; j < expression_array.length; j++) {
  726. if (expression_array[j] == "(") {
  727. count_opened++;
  728. }
  729. if (expression_array[j] == ")") {
  730. count_closed++;
  731. }
  732. if (count_opened != count_closed) {
  733. } else {
  734. if (count_opened > 0) {
  735. if (window.open_or_close == "close") {
  736. window.close_parentheses.insertAfter(
  737. div_to_render.find(
  738. '.single_element_expression[data-index="' + j + '"]'
  739. )
  740. );
  741. window.inserir_close = j + 2;
  742. }
  743. break;
  744. }
  745. }
  746. }
  747. } else if (expression_array[index_in_array + 1].type == "var_value") {
  748. if (window.open_or_close == "close") {
  749. window.close_parentheses.insertAfter(
  750. div_to_render.find(
  751. '.single_element_expression[data-index="' +
  752. (index_in_array + 1) +
  753. '"]'
  754. )
  755. );
  756. window.inserir_close = index_in_array + 3;
  757. }
  758. }
  759. }
  760. }
  761. function renderParenthesis (
  762. div_to_render,
  763. expression_content,
  764. command,
  765. function_obj,
  766. position,
  767. expression_array
  768. ) {
  769. const ghost_parenthesis = $(
  770. '<div class="single_element_expression parentheses_in_expression" data-index="' +
  771. position +
  772. '">' +
  773. expression_content +
  774. "</div>"
  775. );
  776. div_to_render.append(ghost_parenthesis);
  777. }
  778. function renderStartAddOperator (
  779. div_to_render,
  780. types_included,
  781. expression_array,
  782. command,
  783. function_obj,
  784. position
  785. ) {
  786. let menu_final =
  787. '<div class="ui dropdown disabled usepointer"><div class="text"> + </div><i class="dropdown icon"></i><div class="menu">';
  788. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_arithmetic) >= 0) {
  789. if (types_included.length > 1) {
  790. menu_final +=
  791. '<div class="item"><i class="dropdown icon"></i>' +
  792. LocalizedStrings.getUI("text_arithmetic_expression") +
  793. '<div class="menu">';
  794. menu_final += getArithmeticOperators();
  795. menu_final += "</div></div>";
  796. } else {
  797. menu_final += getArithmeticOperators();
  798. }
  799. }
  800. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_logic) >= 0) {
  801. if (types_included.length > 1) {
  802. menu_final +=
  803. '<div class="item"><i class="dropdown icon"></i>' +
  804. LocalizedStrings.getUI("text_logic_expression") +
  805. '<div class="menu">';
  806. menu_final += getLogicOperators();
  807. menu_final += "</div></div>";
  808. } else {
  809. menu_final += getLogicOperators();
  810. }
  811. }
  812. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_conditional) >= 0) {
  813. if (types_included.length > 1) {
  814. menu_final +=
  815. '<div class="item"><i class="dropdown icon"></i>' +
  816. LocalizedStrings.getUI("text_relational_expression") +
  817. '<div class="menu">';
  818. menu_final += getRelationalOperators();
  819. menu_final += "</div></div>";
  820. } else {
  821. menu_final += getRelationalOperators();
  822. }
  823. }
  824. menu_final += "</div></div>";
  825. menu_final = $(menu_final);
  826. const div_temp = $(
  827. '<div class="single_element_expression ghost_element mouse_distance"></div>'
  828. );
  829. div_temp.append(menu_final);
  830. const div_higher = $('<div class="higher_element"></div>');
  831. div_higher.append(div_temp);
  832. div_to_render.append(div_higher);
  833. menu_final.dropdown("set selected", Models.ARITHMETIC_TYPES.minus);
  834. div_temp.on("click", function () {
  835. if (!window.open_or_close) {
  836. const sera = position;
  837. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_arithmetic) >= 0) {
  838. expression_array.splice(
  839. sera,
  840. 0,
  841. new Models.ExpressionOperator(
  842. Models.EXPRESSION_TYPES.exp_arithmetic,
  843. Models.ARITHMETIC_TYPES.minus
  844. )
  845. );
  846. } else if (
  847. types_included.indexOf(Models.EXPRESSION_TYPES.exp_logic) >= 0
  848. ) {
  849. expression_array.splice(
  850. sera,
  851. 0,
  852. new Models.ExpressionOperator(
  853. Models.EXPRESSION_TYPES.exp_logic,
  854. Models.LOGIC_COMPARISON.equals_to
  855. )
  856. );
  857. } else if (
  858. types_included.indexOf(Models.EXPRESSION_TYPES.exp_conditional) >= 0
  859. ) {
  860. expression_array.splice(
  861. sera,
  862. 0,
  863. new Models.ExpressionOperator(
  864. Models.EXPRESSION_TYPES.exp_conditional,
  865. Models.ARITHMETIC_COMPARISON.greater_than
  866. )
  867. );
  868. }
  869. renderExpression(command, function_obj, div_to_render, expression_array);
  870. }
  871. });
  872. }
  873. function renderFinalAddElements (
  874. div_to_render,
  875. types_included,
  876. expression_array,
  877. command,
  878. function_obj,
  879. position,
  880. is_last = false
  881. ) {
  882. let menu_final =
  883. '<div class="ui dropdown disabled usepointer"><div class="text"> + </div><i class="dropdown icon"></i><div class="menu">';
  884. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_arithmetic) >= 0) {
  885. if (types_included.length > 1) {
  886. menu_final +=
  887. '<div class="item"><i class="dropdown icon"></i>' +
  888. LocalizedStrings.getUI("text_arithmetic_expression") +
  889. '<div class="menu">';
  890. menu_final += getArithmeticOperators();
  891. menu_final += "</div></div>";
  892. } else {
  893. menu_final += getArithmeticOperators();
  894. }
  895. }
  896. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_logic) >= 0) {
  897. if (types_included.length > 1) {
  898. menu_final +=
  899. '<div class="item"><i class="dropdown icon"></i>' +
  900. LocalizedStrings.getUI("text_logic_expression") +
  901. '<div class="menu">';
  902. menu_final += getLogicOperators();
  903. menu_final += "</div></div>";
  904. } else {
  905. menu_final += getLogicOperators();
  906. }
  907. }
  908. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_conditional) >= 0) {
  909. if (types_included.length > 1) {
  910. menu_final +=
  911. '<div class="item"><i class="dropdown icon"></i>' +
  912. LocalizedStrings.getUI("text_relational_expression") +
  913. '<div class="menu">';
  914. menu_final += getRelationalOperators();
  915. menu_final += "</div></div>";
  916. } else {
  917. menu_final += getRelationalOperators();
  918. }
  919. }
  920. menu_final += "</div></div>";
  921. menu_final = $(menu_final);
  922. const div_temp = $('<div class="simple_add mouse_distance"></div>');
  923. const div_higher = $('<div class="higher_element"></div>');
  924. const button = $(
  925. '<button class="ui button green add_expression"><i class="plus circle inverted icon"></i></button>'
  926. );
  927. div_temp.append(button);
  928. if (!is_last) {
  929. div_higher.append(div_temp);
  930. div_to_render.append(div_higher);
  931. //div_temp.append(menu_final);
  932. div_temp.css("opacity", "0", "!important");
  933. } else {
  934. div_temp.removeClass("mouse_distance");
  935. div_temp.css("opacity", "1", "!important");
  936. //div_temp.append(menu_final);
  937. div_to_render.append(div_temp);
  938. }
  939. menu_final.dropdown("set selected", Models.ARITHMETIC_TYPES.plus);
  940. div_temp.on("click", function () {
  941. const sera = position;
  942. if (expression_array[sera] == ")" && expression_array[sera - 1] == "(") {
  943. expression_array.splice(
  944. sera,
  945. 0,
  946. new Models.VariableValueMenu(
  947. VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all,
  948. null,
  949. null,
  950. null,
  951. true
  952. )
  953. );
  954. renderExpression(command, function_obj, div_to_render, expression_array);
  955. return;
  956. }
  957. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_arithmetic) >= 0) {
  958. expression_array.splice(
  959. sera,
  960. 0,
  961. new Models.ExpressionOperator(
  962. Models.EXPRESSION_TYPES.exp_arithmetic,
  963. Models.ARITHMETIC_TYPES.plus
  964. )
  965. );
  966. expression_array.splice(
  967. sera + 1,
  968. 0,
  969. new Models.VariableValueMenu(
  970. VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all,
  971. null,
  972. null,
  973. null,
  974. true
  975. )
  976. );
  977. } else if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_logic) >= 0) {
  978. expression_array.splice(
  979. sera,
  980. 0,
  981. new Models.ExpressionOperator(
  982. Models.EXPRESSION_TYPES.exp_logic,
  983. Models.LOGIC_COMPARISON.equals_to
  984. )
  985. );
  986. expression_array.splice(
  987. sera + 1,
  988. 0,
  989. new Models.VariableValueMenu(
  990. VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all,
  991. null,
  992. null,
  993. null,
  994. true
  995. )
  996. );
  997. } else if (
  998. types_included.indexOf(Models.EXPRESSION_TYPES.exp_conditional) >= 0
  999. ) {
  1000. expression_array.splice(
  1001. sera,
  1002. 0,
  1003. new Models.ExpressionOperator(
  1004. Models.EXPRESSION_TYPES.exp_conditional,
  1005. Models.ARITHMETIC_COMPARISON.greater_than
  1006. )
  1007. );
  1008. expression_array.splice(
  1009. sera + 1,
  1010. 0,
  1011. new Models.VariableValueMenu(
  1012. VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all,
  1013. null,
  1014. null,
  1015. null,
  1016. true
  1017. )
  1018. );
  1019. }
  1020. renderExpression(command, function_obj, div_to_render, expression_array);
  1021. });
  1022. }
  1023. function renderOperatorMenu (
  1024. command,
  1025. function_obj,
  1026. div_to_render,
  1027. expression_element,
  1028. types_included,
  1029. position,
  1030. expression_array
  1031. ) {
  1032. let menu_final =
  1033. '<div class="ui dropdown"><div class="text"> + </div><i class="dropdown icon"></i><div class="menu">';
  1034. if (types_included.indexOf(Models.EXPRESSION_TYPES.write_sep) >= 0) {
  1035. menu_final += getSeparator();
  1036. }
  1037. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_arithmetic) >= 0) {
  1038. if (types_included.length > 1) {
  1039. menu_final +=
  1040. '<div class="item"><i class="dropdown icon"></i>' +
  1041. LocalizedStrings.getUI("text_arithmetic_expression") +
  1042. '<div class="menu">';
  1043. menu_final += getArithmeticOperators();
  1044. menu_final += "</div></div>";
  1045. } else {
  1046. menu_final += getArithmeticOperators();
  1047. }
  1048. }
  1049. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_logic) >= 0) {
  1050. if (types_included.length > 1) {
  1051. menu_final +=
  1052. '<div class="item"><i class="dropdown icon"></i>' +
  1053. LocalizedStrings.getUI("text_logic_expression") +
  1054. '<div class="menu">';
  1055. menu_final += getLogicOperators();
  1056. menu_final += "</div></div>";
  1057. } else {
  1058. menu_final += getLogicOperators();
  1059. }
  1060. }
  1061. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_conditional) >= 0) {
  1062. if (types_included.length > 1) {
  1063. menu_final +=
  1064. '<div class="item"><i class="dropdown icon"></i>' +
  1065. LocalizedStrings.getUI("text_relational_expression") +
  1066. '<div class="menu">';
  1067. menu_final += getRelationalOperators();
  1068. menu_final += "</div></div>";
  1069. } else {
  1070. menu_final += getRelationalOperators();
  1071. }
  1072. }
  1073. menu_final += "</div></div>";
  1074. menu_final = $(menu_final);
  1075. menu_final.find(".ivprog-write-sep").popup({
  1076. content: LocalizedStrings.getUI("write_seprator_menu_tooltip"),
  1077. delay: {
  1078. show: 500,
  1079. hide: 0,
  1080. },
  1081. });
  1082. const div_temp = $(
  1083. '<div class="single_element_expression not_allowed" data-index="' +
  1084. position +
  1085. '"></div>'
  1086. );
  1087. div_temp.append(menu_final);
  1088. div_to_render.append(div_temp);
  1089. menu_final.dropdown({
  1090. onChange: function (_value, _text, $selectedItem) {
  1091. expression_element.item = $selectedItem.data("value");
  1092. expression_element.type_op = $selectedItem.data("type");
  1093. },
  1094. });
  1095. menu_final.dropdown("set selected", expression_element.item);
  1096. }
  1097. function getArithmeticOperators () {
  1098. let arithmetic_operators;
  1099. arithmetic_operators =
  1100. '<div class="item" data-type="' +
  1101. Models.EXPRESSION_TYPES.exp_arithmetic +
  1102. '" data-value="' +
  1103. Models.ARITHMETIC_TYPES.plus +
  1104. '">+</div>';
  1105. arithmetic_operators +=
  1106. '<div class="item" data-type="' +
  1107. Models.EXPRESSION_TYPES.exp_arithmetic +
  1108. '" data-value="' +
  1109. Models.ARITHMETIC_TYPES.minus +
  1110. '">-</div>';
  1111. arithmetic_operators +=
  1112. '<div class="item" data-type="' +
  1113. Models.EXPRESSION_TYPES.exp_arithmetic +
  1114. '" data-value="' +
  1115. Models.ARITHMETIC_TYPES.multiplication +
  1116. '">*</div>';
  1117. arithmetic_operators +=
  1118. '<div class="item" data-type="' +
  1119. Models.EXPRESSION_TYPES.exp_arithmetic +
  1120. '" data-value="' +
  1121. Models.ARITHMETIC_TYPES.division +
  1122. '">/</div>';
  1123. arithmetic_operators +=
  1124. '<div class="item" data-type="' +
  1125. Models.EXPRESSION_TYPES.exp_arithmetic +
  1126. '" data-value="' +
  1127. Models.ARITHMETIC_TYPES.module +
  1128. '">%</div>';
  1129. return arithmetic_operators;
  1130. }
  1131. function getLogicOperators () {
  1132. let logic_operators;
  1133. logic_operators =
  1134. '<div class="item" data-type="' +
  1135. Models.EXPRESSION_TYPES.exp_logic +
  1136. '" data-value="' +
  1137. Models.LOGIC_COMPARISON.equals_to +
  1138. '">==</div>';
  1139. logic_operators +=
  1140. '<div class="item" data-type="' +
  1141. Models.EXPRESSION_TYPES.exp_logic +
  1142. '" data-value="' +
  1143. Models.LOGIC_COMPARISON.not_equals_to +
  1144. '">!=</div>';
  1145. logic_operators +=
  1146. '<div class="item" data-type="' +
  1147. Models.EXPRESSION_TYPES.exp_logic +
  1148. '" data-value="' +
  1149. Models.LOGIC_COMPARISON.and +
  1150. '">' +
  1151. LocalizedStrings.getUI("logic_operator_and") +
  1152. "</div>";
  1153. logic_operators +=
  1154. '<div class="item" data-type="' +
  1155. Models.EXPRESSION_TYPES.exp_logic +
  1156. '" data-value="' +
  1157. Models.LOGIC_COMPARISON.or +
  1158. '">' +
  1159. LocalizedStrings.getUI("logic_operator_or") +
  1160. "</div>";
  1161. logic_operators +=
  1162. '<div class="item" data-type="' +
  1163. Models.EXPRESSION_TYPES.exp_logic +
  1164. '" data-value="' +
  1165. Models.LOGIC_COMPARISON.not +
  1166. '">' +
  1167. LocalizedStrings.getUI("logic_operator_not") +
  1168. "</div>";
  1169. return logic_operators;
  1170. }
  1171. function getRelationalOperators () {
  1172. let relational_operators;
  1173. relational_operators =
  1174. '<div class="item" data-type="' +
  1175. Models.EXPRESSION_TYPES.exp_conditional +
  1176. '" data-value="' +
  1177. Models.ARITHMETIC_COMPARISON.greater_than +
  1178. '">></div>';
  1179. relational_operators +=
  1180. '<div class="item" data-type="' +
  1181. Models.EXPRESSION_TYPES.exp_conditional +
  1182. '" data-value="' +
  1183. Models.ARITHMETIC_COMPARISON.less_than +
  1184. '"><</div>';
  1185. relational_operators +=
  1186. '<div class="item" data-type="' +
  1187. Models.EXPRESSION_TYPES.exp_conditional +
  1188. '" data-value="' +
  1189. Models.ARITHMETIC_COMPARISON.equals_to +
  1190. '">==</div>';
  1191. relational_operators +=
  1192. '<div class="item" data-type="' +
  1193. Models.EXPRESSION_TYPES.exp_conditional +
  1194. '" data-value="' +
  1195. Models.ARITHMETIC_COMPARISON.not_equals_to +
  1196. '">!=</div>';
  1197. relational_operators +=
  1198. '<div class="item" data-type="' +
  1199. Models.EXPRESSION_TYPES.exp_conditional +
  1200. '" data-value="' +
  1201. Models.ARITHMETIC_COMPARISON.greater_than_or_equals_to +
  1202. '">>=</div>';
  1203. relational_operators +=
  1204. '<div class="item" data-type="' +
  1205. Models.EXPRESSION_TYPES.exp_conditional +
  1206. '" data-value="' +
  1207. Models.ARITHMETIC_COMPARISON.less_than_or_equals_to +
  1208. '"><=</div>';
  1209. return relational_operators;
  1210. }
  1211. function getSeparator () {
  1212. return `<div class="item ivprog-write-sep" data-type="${
  1213. Models.EXPRESSION_TYPES.write_sep
  1214. }" data-value="${Models.EXPRESSION_TYPES.write_sep}">${LocalizedStrings.getUI(
  1215. "write_seprator_menu_text"
  1216. )}</div>`;
  1217. }
  1218. function getVariable (function_obj, search) {
  1219. if (search == ")" || search == "(") {
  1220. return search;
  1221. }
  1222. if (search.instance == "operator") {
  1223. var obj;
  1224. switch (search.value) {
  1225. case '+':
  1226. obj = new Models.ExpressionOperator(
  1227. Models.EXPRESSION_TYPES.exp_arithmetic,
  1228. Models.ARITHMETIC_TYPES.plus);
  1229. break;
  1230. case '-':
  1231. obj = new Models.ExpressionOperator(
  1232. Models.EXPRESSION_TYPES.exp_arithmetic,
  1233. Models.ARITHMETIC_TYPES.minus);
  1234. break;
  1235. case '*':
  1236. obj = new Models.ExpressionOperator(
  1237. Models.EXPRESSION_TYPES.exp_arithmetic,
  1238. Models.ARITHMETIC_TYPES.multiplication);
  1239. break;
  1240. case '/':
  1241. obj = new Models.ExpressionOperator(
  1242. Models.EXPRESSION_TYPES.exp_arithmetic,
  1243. Models.ARITHMETIC_TYPES.division);
  1244. break;
  1245. case '%':
  1246. obj = new Models.ExpressionOperator(
  1247. Models.EXPRESSION_TYPES.exp_arithmetic,
  1248. Models.ARITHMETIC_TYPES.module);
  1249. break;
  1250. case '>':
  1251. obj = new Models.ExpressionOperator(
  1252. Models.EXPRESSION_TYPES.exp_conditional,
  1253. Models.ARITHMETIC_COMPARISON.greater_than);
  1254. break;
  1255. case '<':
  1256. obj = new Models.ExpressionOperator(
  1257. Models.EXPRESSION_TYPES.exp_conditional,
  1258. Models.ARITHMETIC_COMPARISON.less_than);
  1259. break;
  1260. case '>=':
  1261. obj = new Models.ExpressionOperator(
  1262. Models.EXPRESSION_TYPES.exp_conditional,
  1263. Models.ARITHMETIC_COMPARISON.greater_than_or_equals_to);
  1264. break;
  1265. case '<=':
  1266. obj = new Models.ExpressionOperator(
  1267. Models.EXPRESSION_TYPES.exp_conditional,
  1268. Models.ARITHMETIC_COMPARISON.less_than_or_equals_to);
  1269. break;
  1270. case '==':
  1271. obj = new Models.ExpressionOperator(
  1272. Models.EXPRESSION_TYPES.exp_conditional,
  1273. Models.ARITHMETIC_COMPARISON.equals_to);
  1274. break;
  1275. case '!=':
  1276. obj = new Models.ExpressionOperator(
  1277. Models.EXPRESSION_TYPES.exp_conditional,
  1278. Models.ARITHMETIC_COMPARISON.not_equals_to);
  1279. break;
  1280. case 'and':
  1281. obj = new Models.ExpressionOperator(
  1282. Models.EXPRESSION_TYPES.exp_logic,
  1283. Models.LOGIC_COMPARISON.and);
  1284. break;
  1285. case 'or':
  1286. obj = new Models.ExpressionOperator(
  1287. Models.EXPRESSION_TYPES.exp_logic,
  1288. Models.LOGIC_COMPARISON.or);
  1289. break;
  1290. case 'not':
  1291. obj = new Models.ExpressionOperator(
  1292. Models.EXPRESSION_TYPES.exp_logic,
  1293. Models.LOGIC_COMPARISON.not);
  1294. break;
  1295. }
  1296. return obj;
  1297. }
  1298. if (search.instance == "expression"
  1299. && search.type == "const") {
  1300. if (search.value === true) {
  1301. var obj = new Models.VariableValueMenu(
  1302. VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all,
  1303. LocalizedStrings.getUI('logic_value_true'),
  1304. null,
  1305. null,
  1306. true
  1307. );
  1308. return obj;
  1309. }
  1310. if (search.value === false) {
  1311. var obj = new Models.VariableValueMenu(
  1312. VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all,
  1313. LocalizedStrings.getUI('logic_value_false'),
  1314. null,
  1315. null,
  1316. true
  1317. );
  1318. return obj;
  1319. }
  1320. var obj = new Models.VariableValueMenu(
  1321. VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all,
  1322. search.value,
  1323. null,
  1324. null,
  1325. true
  1326. );
  1327. return obj;
  1328. }
  1329. var variavel = null;
  1330. if (search.instance == "expression"
  1331. && search.type == "var") {
  1332. // 1. Procurar a variável na função:
  1333. for (var j = 0; j < function_obj.variables_list.length; j++) {
  1334. if (function_obj.variables_list[j].name == search.value) {
  1335. variavel = function_obj.variables_list[j];
  1336. break;
  1337. }
  1338. }
  1339. // 2. Procurar a variável nas gloais:
  1340. if (!variavel)
  1341. for (var j = 0; j < program_obj.globals.length; j++) {
  1342. if (program_obj.globals[j].name == search.value) {
  1343. variavel = program_obj.globals[j];
  1344. break;
  1345. }
  1346. }
  1347. // 3. Procurar na lista de parâmetros:
  1348. if (!variavel)
  1349. for (var j = 0; j < function_obj.parameters_list.length; j++) {
  1350. if (function_obj.parameters_list[j].name == search.value) {
  1351. variavel = function_obj.parameters_list[j];
  1352. break;
  1353. }
  1354. }
  1355. }
  1356. if (search.instance == "expression"
  1357. && search.type == "var"
  1358. && !search.line) {
  1359. var obj = new Models.VariableValueMenu(
  1360. VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all,
  1361. variavel,
  1362. null,
  1363. null,
  1364. true
  1365. );
  1366. return obj;
  1367. }
  1368. if (search.instance == "expression"
  1369. && search.type == "var"
  1370. && search.class == "vector") {
  1371. var obj = new Models.VariableValueMenu(
  1372. VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all,
  1373. variavel,
  1374. null,
  1375. getVariable(function_obj, search.line[0]),
  1376. true
  1377. );
  1378. return obj;
  1379. }
  1380. if (search.instance == "expression"
  1381. && search.type == "var"
  1382. && search.class == "matrix") {
  1383. var obj = new Models.VariableValueMenu(
  1384. VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all,
  1385. variavel,
  1386. getVariable(function_obj, search.line[0]),
  1387. getVariable(function_obj, search.column[0]),
  1388. true
  1389. );
  1390. return obj;
  1391. }
  1392. if (search.instance == "expression"
  1393. && search.type == "function") {
  1394. var obj = new Models.VariableValueMenu(
  1395. VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all,
  1396. variavel,
  1397. null,
  1398. null,
  1399. true
  1400. );
  1401. // Procurar a função para referência:
  1402. for (var i = 0; i < program_obj.functions.length; i++) {
  1403. if (program_obj.functions[i].name == search.value) {
  1404. obj.function_called = program_obj.functions[i];
  1405. }
  1406. }
  1407. // Se ainda não foi encontrada, procurar na biblioteca do iVProg:
  1408. if (!obj.function_called) {
  1409. for (var i = 0; i < window.system_functions.length; i++) {
  1410. if (search.value.split(".")[1] && search.value.split(".")[1]
  1411. == window.system_functions[i].identifier) {
  1412. obj.function_called = window.system_functions[i];
  1413. } else if (search.value == window.system_functions[i].identifier) {
  1414. obj.function_called = window.system_functions[i];
  1415. }
  1416. }
  1417. }
  1418. obj.parameters_list = [];
  1419. for (var i = 0; i < search.params.length; i++) {
  1420. obj.parameters_list.push(getVariable(function_obj,search.params[i][0]));
  1421. }
  1422. return obj;
  1423. }
  1424. }
  1425. export function expressionParserToVisual (text, function_obj, input_field) {
  1426. if (text.trim().length == 0) {
  1427. return [new Models.VariableValueMenu(
  1428. VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all,
  1429. null,
  1430. null,
  1431. null,
  1432. true
  1433. )];
  1434. }
  1435. var var_not_found = [];
  1436. var fun_not_found = [];
  1437. var parsed;
  1438. try {
  1439. parsed = ivprogCore.parseExpression(text);
  1440. } catch (ex) {
  1441. Utils.renderErrorMessage(input_field, LocalizedStrings.getUI('expression_invalid'));
  1442. }
  1443. if (!parsed) return null;
  1444. for (var i = 0; i < parsed.length; i++) {
  1445. var variavel = null;
  1446. if (parsed[i].instance == "expression"
  1447. && parsed[i].type == "var") {
  1448. // 1. Procurar a variável na função:
  1449. for (var j = 0; j < function_obj.variables_list.length; j++) {
  1450. if (function_obj.variables_list[j].name == parsed[i].value) {
  1451. variavel = function_obj.variables_list[j];
  1452. break;
  1453. }
  1454. }
  1455. // 2. Procurar a variável nas globais:
  1456. if (!variavel)
  1457. for (var j = 0; j < program_obj.globals.length; j++) {
  1458. if (program_obj.globals[j].name == parsed[i].value) {
  1459. variavel = program_obj.globals[j];
  1460. break;
  1461. }
  1462. }
  1463. // 3. Procurar a variável nos parâmetros:
  1464. if (!variavel)
  1465. for (var j = 0; j < function_obj.parameters_list.length; j++) {
  1466. if (function_obj.parameters_list[j].name == parsed[i].value) {
  1467. variavel = function_obj.parameters_list[j];
  1468. break;
  1469. }
  1470. }
  1471. if (!variavel)
  1472. var_not_found.push(parsed[i].value);
  1473. }
  1474. var funcao;
  1475. if (parsed[i].instance == "expression"
  1476. && parsed[i].type == "function") {
  1477. // Procurar a função para referência:
  1478. for (var j = 0; j < program_obj.functions.length; j++) {
  1479. if (program_obj.functions[j].name == parsed[i].value) {
  1480. funcao = program_obj.functions[j];
  1481. }
  1482. }
  1483. // Se ainda não encontrou, procurar na biblioteca do iVProg:
  1484. if (!funcao) {
  1485. for (var j = 0; j < window.system_functions.length; j++) {
  1486. if (parsed[i].value.split(".")[1] && parsed[i].value.split(".")[1]
  1487. == window.system_functions[j].identifier) {
  1488. funcao = window.system_functions[j];
  1489. } else if (parsed[i].value == window.system_functions[j].identifier) {
  1490. funcao = window.system_functions[j];
  1491. }
  1492. }
  1493. }
  1494. if (!funcao) {
  1495. fun_not_found.push(parsed[i].value);
  1496. }
  1497. }
  1498. }
  1499. if (fun_not_found.length > 0) {
  1500. let uniqueWords = [...new Set(fun_not_found)];
  1501. Utils.renderErrorMessage(input_field, LocalizedStrings.getUI('expression_undeclared_function') + " " + uniqueWords.join(", "));
  1502. return null;
  1503. }
  1504. if (var_not_found.length > 0) {
  1505. let uniqueWords = [...new Set(var_not_found)];
  1506. Utils.renderErrorMessage(input_field, LocalizedStrings.getUI('expression_undelcared_variable') + " " + uniqueWords.join(", "));
  1507. return null;
  1508. }
  1509. var exp_obj = [];
  1510. for (var i = 0; i < parsed.length; i++) {
  1511. exp_obj.push(getVariable(function_obj, parsed[i]));
  1512. }
  1513. return exp_obj;
  1514. }