generic_expression.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. import $ from 'jquery';
  2. import { Types } from '../types';
  3. import * as Models from '../ivprog_elements';
  4. import { LocalizedStrings } from '../../services/localizedStringsService';
  5. import * as GlobalsManagement from '../globals';
  6. import * as VariablesManagement from '../variables';
  7. import * as VariableValueMenuManagement from './variable_value_menu';
  8. import WatchJS from 'melanke-watchjs';
  9. export function renderExpression (command, function_obj, div_to_render, expression_array) {
  10. div_to_render.empty();
  11. if (command.type === Models.COMMAND_TYPES.attribution) {
  12. WatchJS.unwatch(command.variable);
  13. WatchJS.watch(command.variable, function(){
  14. renderExpression(command, function_obj, div_to_render, expression_array);
  15. }, 0);
  16. if (command.variable.content) {
  17. var types_included = [];
  18. if (command.variable.content.type == Types.INTEGER || command.variable.content.type == Types.REAL) {
  19. types_included.push(Models.EXPRESSION_TYPES.exp_arithmetic);
  20. } else if (command.variable.content.type == Types.BOOLEAN) {
  21. types_included.push(Models.EXPRESSION_TYPES.exp_conditional);
  22. types_included.push(Models.EXPRESSION_TYPES.exp_logic);
  23. types_included.push(Models.EXPRESSION_TYPES.exp_arithmetic);
  24. } else if (command.variable.content.type == Types.TEXT) {
  25. types_included.push(Models.EXPRESSION_TYPES.exp_conditional);
  26. types_included.push(Models.EXPRESSION_TYPES.exp_logic);
  27. types_included.push(Models.EXPRESSION_TYPES.exp_arithmetic);
  28. } else {
  29. console.log('NÃO RECONHECI! VEJA: ', command.variable.content.type);
  30. }
  31. renderElements(command, function_obj, div_to_render, expression_array, types_included);
  32. } else {
  33. div_to_render.text('selecione uma variável');
  34. }
  35. }
  36. }
  37. function renderElements (command, function_obj, div_to_render, expression_array, types_included) {
  38. /*if (expression_array.length > 0) {
  39. if (!expression_array[0].type_op) {
  40. renderStartAddOperator(div_to_render, types_included, expression_array, command, function_obj, 0);
  41. }
  42. }*/
  43. var i = 0;
  44. for (i = 0; i < expression_array.length; i++) {
  45. if (expression_array[i].type == "var_value") {
  46. var div_temp = $('<div class="single_element_expression" data-index="'+i+'"></div>');
  47. if (i == 0) {
  48. if (expression_array.length > 0 && !expression_array[1].type_op) {
  49. renderStartAddOperator(div_temp, types_included, expression_array, command, function_obj, 0);
  50. }
  51. }
  52. VariableValueMenuManagement.renderMenu(command, expression_array[i], div_temp, function_obj);
  53. div_to_render.append(div_temp);
  54. } else if (expression_array[i] == '(' || expression_array[i] == ')') {
  55. if (expression_array[i] == ')') {
  56. renderFinalAddElements(div_to_render, types_included, expression_array, command, function_obj, i);
  57. renderParenthesis(div_to_render, expression_array[i], command, function_obj, i, expression_array);
  58. } else if (expression_array[i] == '(' && !expression_array[i + 1].type_op) {
  59. renderParenthesis(div_to_render, expression_array[i], command, function_obj, i, expression_array);
  60. renderStartAddOperator(div_to_render, types_included, expression_array, command, function_obj, i + 1);
  61. } else {
  62. renderParenthesis(div_to_render, expression_array[i], command, function_obj, i, expression_array);
  63. }
  64. } else {
  65. renderOperatorMenu(command, function_obj, div_to_render, expression_array[i], types_included, i, expression_array);
  66. }
  67. }
  68. renderFinalAddElements(div_to_render, types_included, expression_array, command, function_obj, i);
  69. renderAddParenthesis(command, function_obj, div_to_render, expression_array, types_included);
  70. }
  71. window.parentheses_activate = false;
  72. window.open_or_close = null;
  73. function renderAddParenthesis (command, function_obj, div_to_render, expression_array, types_included) {
  74. var addParentheses = $('<div class="single_element_expression add_parentheses"><i class="icons"><b style="font-style: normal;">( )</b><i class="corner add icon blue" style="font-size: .6em;right: -3px;bottom: -2px;"></i></i></div>');
  75. div_to_render.append(addParentheses);
  76. addParentheses.popup({
  77. content : "Adicionar parênteses",
  78. delay: {
  79. show: 750,
  80. hide: 0
  81. }
  82. });
  83. addParentheses.on('click', function(mouse_event) {
  84. // verificar se já está ativado
  85. if (window.parentheses_activate) {
  86. return;
  87. }
  88. div_to_render.find('.usepointer').off('click');
  89. window.parentheses_activate = true;
  90. window.open_or_close = "open";
  91. div_to_render.find('.dropdown').addClass('disabled');
  92. div_to_render.find('.ghost_element').addClass('temp_class');
  93. div_to_render.find('.ghost_element').removeClass('ghost_element');
  94. var floatingObject = $('<div class="floating_parenthesis"> ( </div>');
  95. floatingObject.draggable().appendTo("body");
  96. floatingObject.css("position", "absolute");
  97. mouse_event.type = "mousedown.draggable";
  98. mouse_event.target = floatingObject[0];
  99. floatingObject.css("left", mouse_event.pageX + 10);
  100. floatingObject.css("top", mouse_event.pageY + 10);
  101. floatingObject.trigger(mouse_event);
  102. div_to_render.on('mousemove', function(evt) {
  103. var actual_target = null;
  104. if ($(evt.target).hasClass('single_element_expression')) {
  105. actual_target = $(evt.target);
  106. } else {
  107. actual_target = $(evt.target).closest('.single_element_expression');
  108. }
  109. if ($(evt.target).hasClass('temp_class')
  110. || actual_target.length < 1
  111. || actual_target.hasClass('add_parentheses')
  112. || actual_target.hasClass('rendered_parentheses')
  113. || $(evt.target).hasClass('expression_elements')) {
  114. return;
  115. }
  116. renderGhostParentheses(actual_target, command, function_obj, div_to_render, expression_array);
  117. });
  118. div_to_render.on('mouseleave', function(evt) {
  119. /*window.open_parentheses.remove();
  120. window.close_parentheses.remove();*/
  121. });
  122. var floating;
  123. $('body').on('mouseup', function(evt) {
  124. if (window.open_or_close == "open") {
  125. window.open_or_close = "close";
  126. floatingObject.remove();
  127. var comando_que_esta = $(evt.target).closest('.command_container');
  128. var comando_certo = div_to_render.closest('.command_container');
  129. if (!comando_que_esta.is(comando_certo)) {
  130. window.parentheses_activate = false;
  131. div_to_render.find('.temp_class').addClass('ghost_element');
  132. div_to_render.find('.temp_class').removeClass('temp_class');
  133. div_to_render.off('mousemove');
  134. div_to_render.off('mouseleave');
  135. $('body').off('mouseup');
  136. window.open_parentheses.remove();
  137. window.close_parentheses.remove();
  138. window.inserir_open = -1;
  139. window.inserir_close = -1;
  140. window.open_or_close = null;
  141. renderExpression(command, function_obj, div_to_render, expression_array);
  142. return;
  143. }
  144. floating = $('<div class="floating_parenthesis"> ) </div>');
  145. floating.draggable().appendTo("body");
  146. floating.css("position", "absolute");
  147. floating.css("left", evt.pageX + 10);
  148. floating.css("top", evt.pageY + 10);
  149. $('body').on('mousemove', function(evts) {
  150. floating.css("left", evts.pageX + 10);
  151. floating.css("top", evts.pageY + 10);
  152. });
  153. } else {
  154. floating.remove();
  155. div_to_render.off('mousemove');
  156. div_to_render.off('mouseleave');
  157. $('body').off('mouseup');
  158. setTimeout(function(){
  159. window.parentheses_activate = false;
  160. }, 50);
  161. var comando_que_esta = $(evt.target).closest('.command_container');
  162. var comando_certo = div_to_render.closest('.command_container');
  163. var is_correct = false;
  164. if (comando_que_esta.is(comando_certo)) {
  165. is_correct = true;
  166. }
  167. if (is_correct) {
  168. expression_array.splice(window.inserir_open, 0, '(');
  169. expression_array.splice(window.inserir_close, 0, ')');
  170. }
  171. window.inserir_open = -1;
  172. window.inserir_close = -1;
  173. window.open_or_close = null;
  174. renderExpression(command, function_obj, div_to_render, expression_array);
  175. }
  176. });
  177. });
  178. }
  179. window.open_parentheses = $('<div class="parentheses_ghost">(</div>');
  180. window.close_parentheses = $('<div class="parentheses_ghost">)</div>');
  181. window.inserir_open = -1;
  182. window.inserir_close = -1;
  183. function renderGhostParentheses (actual_target, command, function_obj, div_to_render, expression_array) {
  184. /*window.open_parentheses.remove();
  185. window.close_parentheses.remove();*/
  186. var index_in_array = actual_target.data('index');
  187. if ((expression_array[index_in_array] == '(') || (expression_array[index_in_array] == ')')) {
  188. return;
  189. }
  190. if (window.open_or_close == "close") {
  191. if (index_in_array < window.inserir_open) {
  192. return;
  193. }
  194. }
  195. // Tratando a situação quando é na primeira posição:
  196. if (index_in_array == 0) {
  197. if (expression_array[index_in_array].type == "var_value") {
  198. if (window.open_or_close == "open") {
  199. window.open_parentheses.insertBefore(actual_target);
  200. window.inserir_open = index_in_array;
  201. }
  202. /*if (expression_array.length == 1) {
  203. if (window.open_or_close == "close") {
  204. window.close_parentheses.insertAfter(actual_target);
  205. window.inserir_close = index_in_array + 2;
  206. }*/
  207. //} else {
  208. var count_opened = 0;
  209. var count_closed = 0;
  210. for (var i = 0; i < expression_array.length; i++) {
  211. if ((expression_array[i] == '(')) {
  212. count_opened ++;
  213. }
  214. if (expression_array[i] == ')') {
  215. count_closed ++;
  216. }
  217. if (count_opened != count_closed) {
  218. } else {
  219. if (count_opened > 0) {
  220. if (window.open_or_close == "close") {
  221. window.close_parentheses.insertAfter(div_to_render.find('.single_element_expression[data-index="'+i+'"]'));
  222. window.inserir_close = i + 2;
  223. }
  224. break;
  225. } else {
  226. if (expression_array[i].type == "var_value") {
  227. if (window.open_or_close == "close") {
  228. window.close_parentheses.insertAfter(div_to_render.find('.single_element_expression[data-index="'+i+'"]'));
  229. window.inserir_close = i + 2;
  230. }
  231. break;
  232. }
  233. }
  234. }
  235. }
  236. //}
  237. } else if (expression_array[index_in_array].type_op) {
  238. if (window.open_or_close == "open") {
  239. window.open_parentheses.insertBefore(actual_target);
  240. window.inserir_open = index_in_array;
  241. }
  242. var count_opened = 0;
  243. var count_closed = 0;
  244. for (var i = 1; i < expression_array.length; i++) {
  245. // $('.slide-link[data-slide="0"]')
  246. if ((expression_array[i] == '(')) {
  247. count_opened ++;
  248. }
  249. if (expression_array[i] == ')') {
  250. count_closed ++;
  251. }
  252. if (count_opened != count_closed) {
  253. } else {
  254. if (count_opened > 0) {
  255. if (expression_array[i].type == "var_value") {
  256. window.close_parentheses.insertAfter(div_to_render.find('.single_element_expression[data-index="'+i+'"]'));
  257. window.inserir_close = i + 2;
  258. }
  259. break;
  260. } else {
  261. if (expression_array[i].type == "var_value") {
  262. if (expression_array[i].type == "var_value") {
  263. window.close_parentheses.insertAfter(div_to_render.find('.single_element_expression[data-index="'+i+'"]'));
  264. window.inserir_close = i + 2;
  265. }
  266. break;
  267. }
  268. }
  269. }
  270. }
  271. }
  272. return;
  273. }
  274. // Tratando quando não é no índice 0:
  275. if (expression_array[index_in_array].type == "var_value") {
  276. if (window.open_or_close == "open") {
  277. window.open_parentheses.insertBefore(actual_target);
  278. window.inserir_open = index_in_array;
  279. }
  280. if (window.open_or_close == "close") {
  281. window.close_parentheses.insertAfter(actual_target);
  282. window.inserir_close = index_in_array + 2;
  283. }
  284. return;
  285. }
  286. if (expression_array[index_in_array].type_op) {
  287. // buscar para a esquerda primeiro:
  288. if (expression_array[index_in_array - 1] == '(') {
  289. if (window.open_or_close == "open") {
  290. window.open_parentheses.insertBefore(actual_target);
  291. window.inserir_open = index_in_array;
  292. }
  293. } else if (expression_array[index_in_array - 1] == ')') {
  294. // buscar a abertura
  295. var count_opened = 0;
  296. var count_closed = 0;
  297. for (var j = index_in_array - 1; j >= 0; j--) {
  298. if ((expression_array[j] == '(')) {
  299. count_opened ++;
  300. }
  301. if (expression_array[j] == ')') {
  302. count_closed ++;
  303. }
  304. if (count_opened != count_closed) {
  305. } else {
  306. if (count_closed > 0) {
  307. if (window.open_or_close == "open") {
  308. window.open_parentheses.insertBefore(div_to_render.find('.single_element_expression[data-index="'+j+'"]'));
  309. window.inserir_open = j;
  310. }
  311. break;
  312. }
  313. }
  314. }
  315. } else if (expression_array[index_in_array - 1].type == "var_value") {
  316. if (window.open_or_close == "open") {
  317. window.open_parentheses.insertBefore(div_to_render.find('.single_element_expression[data-index="'+(index_in_array - 1)+'"]'));
  318. window.inserir_open = index_in_array - 1;
  319. }
  320. }
  321. // buscar para a direita agora:
  322. if (expression_array[index_in_array + 1] == '(') {
  323. // buscar o fechamento:
  324. var count_opened = 0;
  325. var count_closed = 0;
  326. for (var j = index_in_array + 1; j < expression_array.length; j ++) {
  327. if ((expression_array[j] == '(')) {
  328. count_opened ++;
  329. }
  330. if (expression_array[j] == ')') {
  331. count_closed ++;
  332. }
  333. if (count_opened != count_closed) {
  334. } else {
  335. if (count_opened > 0) {
  336. if (window.open_or_close == "close") {
  337. window.close_parentheses.insertAfter(div_to_render.find('.single_element_expression[data-index="'+j+'"]'));
  338. window.inserir_close = j + 2;
  339. }
  340. break;
  341. }
  342. }
  343. }
  344. } else if (expression_array[index_in_array + 1].type == "var_value") {
  345. if (window.open_or_close == "close") {
  346. window.close_parentheses.insertAfter(div_to_render.find('.single_element_expression[data-index="'+(index_in_array + 1)+'"]'));
  347. window.inserir_close = index_in_array + 3;
  348. }
  349. }
  350. }
  351. }
  352. function renderParenthesis (div_to_render, expression_content, command, function_obj, position, expression_array) {
  353. var ghost_parenthesis = $('<div class="single_element_expression" data-index="'+position+'">'+expression_content+'</div>');
  354. div_to_render.append(ghost_parenthesis);
  355. }
  356. function renderStartAddOperator (div_to_render, types_included, expression_array, command, function_obj, position) {
  357. var menu_final = '<div class="ui dropdown disabled usepointer"><div class="text"> + </div><i class="dropdown icon"></i><div class="menu">';
  358. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_arithmetic) >= 0) {
  359. if (types_included.length > 1) {
  360. menu_final += '<div class="item"><i class="dropdown icon"></i>Aritméticos<div class="menu">';
  361. menu_final += getArithmeticOperators();
  362. menu_final += '</div></div>';
  363. } else {
  364. menu_final += getArithmeticOperators();
  365. }
  366. }
  367. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_logic) >= 0) {
  368. if (types_included.length > 1) {
  369. menu_final += '<div class="item"><i class="dropdown icon"></i>Lógicos<div class="menu">';
  370. menu_final += getLogicOperators();
  371. menu_final += '</div></div>';
  372. } else {
  373. menu_final += getLogicOperators();
  374. }
  375. }
  376. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_conditional) >= 0) {
  377. if (types_included.length > 1) {
  378. menu_final += '<div class="item"><i class="dropdown icon"></i>Relacionais<div class="menu">';
  379. menu_final += getRelationalOperators();
  380. menu_final += '</div></div>';
  381. } else {
  382. menu_final += getRelationalOperators();
  383. }
  384. }
  385. menu_final += '</div></div>';
  386. menu_final = $(menu_final);
  387. var div_temp = $('<div class="single_element_expression ghost_element"></div>');
  388. div_temp.append(menu_final);
  389. div_to_render.append(div_temp);
  390. menu_final.dropdown('set selected', Models.ARITHMETIC_TYPES.minus);
  391. div_temp.on('click', function() {
  392. var sera = position;
  393. console.log('será inserido em: ', sera);
  394. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_arithmetic) >= 0) {
  395. console.log('p1');
  396. expression_array.splice(sera, 0, new Models.ExpressionOperator(Models.EXPRESSION_TYPES.exp_arithmetic,Models.ARITHMETIC_TYPES.minus));
  397. } else if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_logic) >= 0) {
  398. console.log('p2');
  399. expression_array.splice(sera, 0, new Models.ExpressionOperator(Models.EXPRESSION_TYPES.exp_logic,Models.LOGIC_COMPARISON.equals_to));
  400. } else if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_conditional) >= 0) {
  401. console.log('p3');
  402. expression_array.splice(sera, 0, new Models.ExpressionOperator(Models.EXPRESSION_TYPES.exp_conditional,Models.ARITHMETIC_COMPARISON.greater_than));
  403. }
  404. renderExpression(command, function_obj, div_to_render, expression_array);
  405. });
  406. }
  407. function renderFinalAddElements (div_to_render, types_included, expression_array, command, function_obj, position) {
  408. var menu_final = '<div class="ui dropdown disabled usepointer"><div class="text"> + </div><i class="dropdown icon"></i><div class="menu">';
  409. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_arithmetic) >= 0) {
  410. if (types_included.length > 1) {
  411. menu_final += '<div class="item"><i class="dropdown icon"></i>Aritméticos<div class="menu">';
  412. menu_final += getArithmeticOperators();
  413. menu_final += '</div></div>';
  414. } else {
  415. menu_final += getArithmeticOperators();
  416. }
  417. }
  418. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_logic) >= 0) {
  419. if (types_included.length > 1) {
  420. menu_final += '<div class="item"><i class="dropdown icon"></i>Lógicos<div class="menu">';
  421. menu_final += getLogicOperators();
  422. menu_final += '</div></div>';
  423. } else {
  424. menu_final += getLogicOperators();
  425. }
  426. }
  427. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_conditional) >= 0) {
  428. if (types_included.length > 1) {
  429. menu_final += '<div class="item"><i class="dropdown icon"></i>Relacionais<div class="menu">';
  430. menu_final += getRelationalOperators();
  431. menu_final += '</div></div>';
  432. } else {
  433. menu_final += getRelationalOperators();
  434. }
  435. }
  436. menu_final += '</div></div>';
  437. menu_final = $(menu_final);
  438. var div_temp = $('<div class="single_element_expression ghost_element"></div>');
  439. div_temp.append(menu_final);
  440. div_to_render.append(div_temp);
  441. menu_final.dropdown('set selected', Models.ARITHMETIC_TYPES.plus);
  442. div_temp.on('click', function() {
  443. var sera = position;
  444. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_arithmetic) >= 0) {
  445. expression_array.splice(sera, 0, new Models.ExpressionOperator(Models.EXPRESSION_TYPES.exp_arithmetic,Models.ARITHMETIC_TYPES.plus));
  446. } else if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_logic) >= 0) {
  447. expression_array.splice(sera, 0, new Models.ExpressionOperator(Models.EXPRESSION_TYPES.exp_logic,Models.LOGIC_COMPARISON.equals_to));
  448. } else if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_conditional) >= 0) {
  449. expression_array.splice(sera, 0, new Models.ExpressionOperator(Models.EXPRESSION_TYPES.exp_conditional,Models.ARITHMETIC_COMPARISON.greater_than));
  450. }
  451. expression_array.splice(sera + 1, 0, new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true));
  452. renderExpression(command, function_obj, div_to_render, expression_array);
  453. });
  454. }
  455. function renderOperatorMenu (command, function_obj, div_to_render, expression_element, types_included, position, expression_array) {
  456. var menu_final = '<div class="ui dropdown"><div class="text"> + </div><i class="dropdown icon"></i><div class="menu">';
  457. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_arithmetic) >= 0) {
  458. if (types_included.length > 1) {
  459. menu_final += '<div class="item"><i class="dropdown icon"></i>Aritméticos<div class="menu">';
  460. menu_final += getArithmeticOperators();
  461. menu_final += '</div></div>';
  462. } else {
  463. menu_final += getArithmeticOperators();
  464. }
  465. }
  466. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_logic) >= 0) {
  467. if (types_included.length > 1) {
  468. menu_final += '<div class="item"><i class="dropdown icon"></i>Lógicos<div class="menu">';
  469. menu_final += getLogicOperators();
  470. menu_final += '</div></div>';
  471. } else {
  472. menu_final += getLogicOperators();
  473. }
  474. }
  475. if (types_included.indexOf(Models.EXPRESSION_TYPES.exp_conditional) >= 0) {
  476. if (types_included.length > 1) {
  477. menu_final += '<div class="item"><i class="dropdown icon"></i>Relacionais<div class="menu">';
  478. menu_final += getRelationalOperators();
  479. menu_final += '</div></div>';
  480. } else {
  481. menu_final += getRelationalOperators();
  482. }
  483. }
  484. menu_final += '</div></div>';
  485. menu_final = $(menu_final);
  486. var div_temp = $('<div class="single_element_expression" data-index="'+position+'"></div>');
  487. div_temp.append(menu_final);
  488. div_to_render.append(div_temp);
  489. menu_final.dropdown({
  490. onChange: function(value, text, $selectedItem) {
  491. expression_element.item = $selectedItem.data('value');
  492. expression_element.type_op = $selectedItem.data('type');
  493. }
  494. });
  495. menu_final.dropdown('set selected', expression_element.item);
  496. }
  497. function getArithmeticOperators () {
  498. var arithmetic_operators;
  499. arithmetic_operators = '<div class="item" data-type="'+Models.EXPRESSION_TYPES.exp_arithmetic+'" data-value="'+Models.ARITHMETIC_TYPES.plus+'">+</div>';
  500. arithmetic_operators += '<div class="item" data-type="'+Models.EXPRESSION_TYPES.exp_arithmetic+'" data-value="'+Models.ARITHMETIC_TYPES.minus+'">-</div>';
  501. arithmetic_operators += '<div class="item" data-type="'+Models.EXPRESSION_TYPES.exp_arithmetic+'" data-value="'+Models.ARITHMETIC_TYPES.multiplication+'">*</div>';
  502. arithmetic_operators += '<div class="item" data-type="'+Models.EXPRESSION_TYPES.exp_arithmetic+'" data-value="'+Models.ARITHMETIC_TYPES.division+'">/</div>';
  503. arithmetic_operators += '<div class="item" data-type="'+Models.EXPRESSION_TYPES.exp_arithmetic+'" data-value="'+Models.ARITHMETIC_TYPES.module+'">%</div>';
  504. return arithmetic_operators;
  505. }
  506. function getLogicOperators () {
  507. var logic_operators;
  508. logic_operators = '<div class="item" data-type="'+Models.EXPRESSION_TYPES.exp_logic+'" data-value="'+Models.LOGIC_COMPARISON.equals_to+'">==</div>';
  509. logic_operators += '<div class="item" data-type="'+Models.EXPRESSION_TYPES.exp_logic+'" data-value="'+Models.LOGIC_COMPARISON.not_equals_to+'">!=</div>';
  510. logic_operators += '<div class="item" data-type="'+Models.EXPRESSION_TYPES.exp_logic+'" data-value="'+Models.LOGIC_COMPARISON.and+'">&&</div>';
  511. logic_operators += '<div class="item" data-type="'+Models.EXPRESSION_TYPES.exp_logic+'" data-value="'+Models.LOGIC_COMPARISON.or+'">||</div>';
  512. return logic_operators;
  513. }
  514. function getRelationalOperators () {
  515. var relational_operators;
  516. relational_operators = '<div class="item" data-type="'+Models.EXPRESSION_TYPES.exp_conditional+'" data-value="'+Models.ARITHMETIC_COMPARISON.greater_than+'">></div>';
  517. relational_operators += '<div class="item" data-type="'+Models.EXPRESSION_TYPES.exp_conditional+'" data-value="'+Models.ARITHMETIC_COMPARISON.less_than+'"><</div>';
  518. relational_operators += '<div class="item" data-type="'+Models.EXPRESSION_TYPES.exp_conditional+'" data-value="'+Models.ARITHMETIC_COMPARISON.equals_to+'">==</div>';
  519. relational_operators += '<div class="item" data-type="'+Models.EXPRESSION_TYPES.exp_conditional+'" data-value="'+Models.ARITHMETIC_COMPARISON.not_equals_to+'">!=</div>';
  520. relational_operators += '<div class="item" data-type="'+Models.EXPRESSION_TYPES.exp_conditional+'" data-value="'+Models.ARITHMETIC_COMPARISON.greater_than_or_equals_to+'">>=</div>';
  521. relational_operators += '<div class="item" data-type="'+Models.EXPRESSION_TYPES.exp_conditional+'" data-value="'+Models.ARITHMETIC_COMPARISON.less_than_or_equals_to+'"><=</div>';
  522. return relational_operators;
  523. }