Igor 5 роки тому
батько
коміт
dec725f69f

+ 166 - 10
css/ivprog-visual-1.0.css

@@ -17,7 +17,6 @@ body {
 	height: 96%;
 	overflow: auto;
 	overflow-x: auto;
-
 }
 
 .ivprog_textual_code {
@@ -152,7 +151,7 @@ body {
 .function_name_div, .function_return_div, .function_name_parameter, .created_div_valor_var, .function_return, .var_value_menu_div, .variable_rendered, .variable_rendered div, .var_attributed,
 .expression_operand_1, .expression_operand_2, .operator, .div_comment_text, .value_rendered, .parameters_function_called, .parameters_function_called div, .expression_elements,
 .expression_element, .var_rendered, .menu_add_item, .component_element, .component_element, .conditional_expression, .variable_attribution, .attribution_expression, .var_value_expression,
-.incrementation_field, .incrementation_variable, .first_operand, .operator, .second_operand, .variable_to_switch, .variable_case, .button_remove_case, .editing_name_var {
+.incrementation_field, .incrementation_variable, .first_operand, .operator, .second_operand, .variable_to_switch, .variable_case, .button_remove_case, .editing_name_var, .parameter_div_edit {
 	display: inline;
 }
 
@@ -248,7 +247,7 @@ body {
 	display: inline;
 }
 
-.function_return, .parameter_type {
+.parameter_type {
 	margin-left: 10px;
     margin-right: 15px;
 }
@@ -304,7 +303,7 @@ div.buttons_manage_columns {
 }
 
 .global_var {
-	margin-bottom: 10px;
+	margin-bottom: 7px;
 }
 
 .list_globals, .global_const {
@@ -376,24 +375,64 @@ div.buttons_manage_columns {
 	margin: auto;
 }
 
-.global_container:hover {
+.global_container:hover, 
+.variable_container:hover {
 	border: 2px solid gray;
 	padding-left: 8px;
 	padding-right: 8px;
 	padding-top: 5px;
 	padding-bottom: 4px;
-	margin-bottom: 1px;
 }
 
-.global_container .global_type, .editing_name_var, .global_container .span_value_variable {
+.ui.label.function_name_parameter:hover {
+	border: 2px solid gray;
+	padding: 5px 6px 5px 6px;
+}
+
+.ui.label.function_name_parameter {
+	padding: 7px 8px 7px 8px;
+}
+
+.global_container:hover,  .variable_container:hover {
+	margin-bottom:  4px !important;
+}
+
+.global_container .global_type, .editing_name_var, .global_container .span_value_variable,
+.variable_container .variable_type,  .variable_container .span_value_variable,
+.ui.dropdown.function_return, div.function_name_div_updated,
+.ui.dropdown.parameter_type, .parameter_div_edit {
 	background: #cecece;
 	border-radius: 5px;
 	padding: 4px;
 	margin-left: 5px;
 	margin-right: 5px;
 }
+.parameter_div_edit {
+	padding-bottom: 2px;
+	padding-top: 2px;
+}
+.ui.dropdown.parameter_type {
+
+}
+div.function_name_div_updated {
+	padding-top: 5px;
+	padding-bottom: 5px;
+	margin-right: 10px;
+}
+.function_name_div_updated .name_function_updated {
+	padding-left: 10px;
+    padding-right: 10px;
+}
+.variable_container .variable_type {
+	padding: 5px;
+	margin-left: 0;
+	margin-right: 3px;
+}
 
-.global_container .global_type:hover, .editing_name_var:hover, .global_container .span_value_variable:hover {
+.global_container .global_type:hover, .editing_name_var:hover, .global_container .span_value_variable:hover,
+.variable_container .variable_type:hover, .variable_container .span_name_variable:hover, .variable_container .span_value_variable:hover,
+.ui.dropdown.function_return:hover, div.function_name_div_updated:hover,
+.ui.dropdown.parameter_type:hover, .parameter_div_edit:hover {
 	background: #848484;
 	color: #fff;
 	z-index: 999999;
@@ -405,7 +444,11 @@ div.buttons_manage_columns {
 	padding-bottom: 3px;
 }
 
-.global_container .global_type:active {
+.global_container .global_type:active, 
+.variable_container .variable_type:active,
+.ui.dropdown.function_return:active, 
+div.function_name_div_updated:active,
+.ui.dropdown.parameter_type:active {
 	background: #636363;
 	color: #fff;
 }
@@ -423,10 +466,18 @@ div.buttons_manage_columns {
     font-size: 150%;
 }
 
-.red.icon.times.remove_global {
+.red.icon.times.remove_global,
+.red.icon.times.remove_variable,
+.red.icon.times.remove_parameter {
 	float: right;
     margin-right: -1px;
     margin-left: 8px;
+    opacity: 0;
+}
+
+.global_container:hover > .red.icon.times.remove_global, .variable_container:hover > .red.icon.times.remove_variable,
+.function_name_parameter:hover > .red.icon.times.remove_parameter {
+	opacity: 1;
 }
 
 .tr_manage_lines {
@@ -435,6 +486,7 @@ div.buttons_manage_columns {
 
 .ui.icon.button.add-globalVar-button.add_global_button {
 	padding: 8px;
+	margin-bottom: 4px;
 }
 .all_functions {
 	margin-top: -5px;
@@ -460,3 +512,107 @@ div.buttons_manage_columns {
 .ui.container.main_title {
 	width: 85px;
 }
+.ui.label.global_container {
+	margin-bottom: 3px;
+}
+.ui.label.variable_container {
+	margin-bottom: 3px;
+}
+.created_div_valor_var {
+	display: inline-block;
+}
+.ui.dropdown.function_return {
+	padding-left: 15px;
+    padding-right: 15px;
+    margin-left: 10px;
+    margin-right: 10px;
+}
+.parethesis_function {
+	font-size: 120%;
+}
+
+.var_value_menu_div,
+.attribution .var_attributed,
+.component_element,
+.conditional_expression .expression_element,
+.menu_start_rendered,
+.attribution_expression .variable_attribution,
+.render_style_param,
+.attribution_expression .div_expression_st:not(:empty),
+.incrementation_field .incrementation_variable,
+.incrementation_field .first_operand:not(:empty),
+.incrementation_field .operator:not(:empty),
+.incrementation_field .second_operand:not(:empty) {
+	background: #e8e8e8;
+	border-radius: 5px;
+	min-width: 40px;
+	padding: 2px;
+    padding-left: 5px;
+    padding-right: 5px;
+    border: 1px solid gray;
+    box-shadow: 0 3px 3px 0 rgba(0, 0, 0, 0.2), 0 3px 3px 0 rgba(0, 0, 0, 0.19);
+    color: black;
+}
+.menu_start_rendered {
+	padding-left: 12px;
+}
+.menu_start_rendered i {
+	width: 1.5em;
+    margin-right: -1em;
+}
+.row_container:hover, .column_container:hover {
+	background: #cecece;
+}
+
+.column_container, .row_container {
+	border-radius: 4px;
+    border: 1px solid gray;
+    padding: 1px 2px 1px 2px;
+    background: #e8e8e8;
+
+    box-shadow: 0 3px 3px 0 rgba(0, 0, 0, 0.2), 0 3px 3px 0 rgba(0, 0, 0, 0.19);
+}
+
+.var_value_menu_div div i {
+	color: black;
+}
+
+.span_command_spec {
+	color: black;
+	font-weight: bold;
+	font-size: 110%;
+}
+
+.ui.comment.command_container .var_value_menu_div {
+	display: inline-block;
+	width: 93%;
+}
+
+.ui.comment.command_container .var_value_menu_div .variable_rendered,
+.ui.comment.command_container .var_value_menu_div .value_rendered {
+    width: 100%;
+    cursor: text;
+    font-style: italic;
+}
+
+.ui.comment.command_container .var_value_menu_div {
+	cursor: text;
+}
+
+.ui.comment.command_container .var_value_menu_div {
+	background: none;
+	border-radius: 0;
+    border: 0px solid gray;
+    box-shadow: none;
+    padding: 0px;
+    font-size: 110%;
+}
+.ui.comment.command_container .var_name,
+.ui.comment.command_container .value_rendered {
+	color: rgba(0,0,0,.6);
+}
+.ui.comment.command_container .var_value_menu_div input {
+    width: 100%;
+    display: inline-block;
+    font-style: italic;
+}

+ 5 - 1
i18n/en/ui.json

@@ -40,6 +40,7 @@
   "text_for":"for",
   "text_code_while":"while",
   "text_code_do":"do",
+  "text_command_do":"do",
   "text_code_switch": "switch",
   "text_code_case": "case",
   "text_logic_expression": "Logic Expression",
@@ -81,6 +82,9 @@
   "tooltip_help": "Help",
   "tooltip_add_global": "Add global variable",
   "tooltip_minimize": "Hidde function elements",
-  "tooltip_console": "Open/Close console"
+  "tooltip_console": "Open/Close console",
+  "var_menu_select_var": "Select a var",
+  "var_menu_select_all": "Select",
+  "var_menu_select_function": "Select a function"
 
 }

+ 5 - 1
i18n/es/ui.json

@@ -42,6 +42,7 @@
   "text_for":"for",
   "text_code_while":"while",
   "text_code_do":"do",
+  "text_command_do":"do",
   "text_code_switch": "switch",
   "text_code_case": "case",
   "text_logic_expression": "Logic Expression",
@@ -81,5 +82,8 @@
   "tooltip_help": "Help",
   "tooltip_add_global": "Add global variable",
   "tooltip_minimize": "Hidde function elements",
-  "tooltip_console": "Open/Close console"
+  "tooltip_console": "Open/Close console",
+  "var_menu_select_var": "Select a var",
+  "var_menu_select_all": "Select",
+  "var_menu_select_function": "Select a function"
 }

+ 6 - 2
i18n/pt/ui.json

@@ -42,7 +42,8 @@
   "text_else":"senao",
   "text_for":"para",
   "text_code_while":"enquanto",
-  "text_code_do":"faça",
+  "text_code_do":"faca",
+  "text_command_do":"faça",
   "text_code_switch": "escolha",
   "text_code_case": "caso",
   "text_logic_expression": "Expressão Lógica",
@@ -82,5 +83,8 @@
   "tooltip_help": "Ajuda",
   "tooltip_add_global": "Adicionar variável global",
   "tooltip_minimize": "Ocultar os elementos da função",
-  "tooltip_console": "Abrir/fechar o terminal"
+  "tooltip_console": "Abrir/fechar o terminal",
+  "var_menu_select_var": "Selecione uma variável",
+  "var_menu_select_all": "Selecione",
+  "var_menu_select_function": "Selecione uma função"
 }

+ 9 - 4
index.html

@@ -2,6 +2,11 @@
 <html>
   <head>
     <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+    <meta http-equiv="cache-control" content="no-cache">
+    <meta http-equiv="cache-control" content="no-store">
+    <meta http-equiv="cache-control" content="max-age=0">
+    <meta http-equiv="expires" content="-1">
+    <meta http-equiv="pragma" content="no-cache">
     <title></title>
     <link rel="stylesheet" type="text/css" href="js/semantic/semantic.min.css">
     <link rel="stylesheet" type="text/css" href="css/ivprog-visual-1.0.css">
@@ -55,22 +60,22 @@
     <div class="ui raised container segment div_to_body">
 
       <div class="ui icon menu center aligned container" style="width: 438px; margin-top: -25px;">
-        <a class="item visual_coding_button">
+        <a class="item active visual_coding_button">
           <i class="window maximize outline icon"></i>
         </a>
         <a class="item textual_coding_button">
           <i class="code icon"></i>
         </a>
-        <a class="item upload_file_button">
+        <a class="item upload_file_button disabled">
           <i class="upload icon"></i>
         </a>
-        <a class="item download_file_button">
+        <a class="item download_file_button disabled">
           <i class="download icon"></i>
         </a>
         <a class="item undo_button disabled">
           <i class="undo icon"></i>
         </a>
-        <a class="item redo_button">
+        <a class="item redo_button disabled">
           <i class="redo icon"></i>
         </a>
         <a class="item run_button">

+ 12 - 5
js/iassign-integration-functions.js

@@ -17,7 +17,7 @@ var iLMparameters = {
 
 // Set the lang parameter to the localStorage for easy access
 // and no dependency to the global scope, avoind future 'strict mode' problems
-localStorage.setItem('ivprog.lang', iLMparameters.lang);
+//localStorage.setItem('ivprog.lang', iLMparameters.lang);
 
 // Função chamada pelo iTarefa quando o professor finaliza a criação da atividade
 // ou quando o aluno finaliza a resolução do exercício
@@ -130,10 +130,12 @@ function prepareActivityToStudent (ilm_cont) {
     settingsDataTypes = content.settings_data_types;
     settingsCommands = content.settings_commands;
     settingsFunctions = content.settings_functions;
-    algorithm_in_ilm = ilm_cont.split('\n::algorithm::')[1].split('\n::logs::')[0];
-
-    window.program_obj.functions = JSON.parse(algorithm_in_ilm).functions;
-    window.program_obj.globals = JSON.parse(algorithm_in_ilm).globals;
+    if (ilm_cont.split('\n::algorithm::')[1]) {
+        algorithm_in_ilm = ilm_cont.split('\n::algorithm::')[1].split('\n::logs::')[0];
+        window.program_obj.functions = JSON.parse(algorithm_in_ilm).functions;
+        window.program_obj.globals = JSON.parse(algorithm_in_ilm).globals;
+    }
+    $('.assessment_button').removeClass('disabled');
     renderAlgorithm();
 }
 
@@ -169,6 +171,11 @@ $(document).ready(function() {
         // é para a elaboração de atividade:
         //$('.elaboracao').css("display","block");
     }
+
+    if (!testCases) {
+        $('.assessment_button').addClass('disabled');
+    }
+
 });
 
 // Função para preparar a interface para o professor criar atividade:

+ 0 - 2
js/semantic/semantic-buttons.js

@@ -34,8 +34,6 @@ var button_ready = function() {
     .dropdown()
   ;
 
-  $('.program_signature_text').text(i18n('program'));
-
   // Atualiza a tela do algoritmo
   //renderAlgorithm();
 

+ 59 - 11
js/visualUI/code_generator.js

@@ -155,7 +155,7 @@ function commandsCode (command_obj, indentation = 2) {
 	}
 }
 
-function returnsCode(command_obj, indentation) {
+function returnsCode (command_obj, indentation) {
 	var ret = '\n';
 
 	for (var i = 0; i < indentation; i++) {
@@ -173,7 +173,7 @@ function returnsCode(command_obj, indentation) {
 	return ret;
 }
 
-function breaksCode(command_obj, indentation) {
+function breaksCode (command_obj, indentation) {
 	var ret = '\n';
 
 	for (var i = 0; i < indentation; i++) {
@@ -185,7 +185,7 @@ function breaksCode(command_obj, indentation) {
 	return ret;
 }
 
-function switchsCode(command_obj, indentation) {
+function switchsCode (command_obj, indentation) {
 	var ret = '\n';
 
 	for (var i = 0; i < indentation; i++) {
@@ -213,7 +213,7 @@ function switchsCode(command_obj, indentation) {
 	return ret;
 }
 
-function switchcasesCode(switchcase, indentation) {
+function switchcasesCode (switchcase, indentation) {
 	var ret = '\n';
 
 	for (var i = 0; i < indentation; i++) {
@@ -234,7 +234,7 @@ function switchcasesCode(switchcase, indentation) {
 
 }
 
-function repeatNtimesCode(command_obj, indentation) {
+function repeatNtimesCode (command_obj, indentation) {
 	var ret = '\n';
 
 	for (var i = 0; i < indentation; i++) {
@@ -743,9 +743,11 @@ function variablesCode (variable_obj) {
 
 		switch (temp.type) {
 			case Types.INTEGER:
-			case Types.REAL:
 				ret += '= {' + temp.value + '}';
 				break;
+			case Types.REAL:
+				ret += '= {' + temp.value.toFixed(2) + '}';
+				break;
 			case Types.TEXT:
 				ret += '= {';
 				for (var j = 0; j < temp.value.length; j++) {
@@ -777,7 +779,6 @@ function variablesCode (variable_obj) {
 
 		switch (temp.type) {
 			case Types.INTEGER:
-			case Types.REAL:
 				ret += '= {';
 
 				for (var j = 0; j < temp.rows; j++) {
@@ -788,6 +789,19 @@ function variablesCode (variable_obj) {
 					}
 				}
 
+				ret += '}';
+				break;
+			case Types.REAL:
+				ret += '= {';
+
+				for (var j = 0; j < temp.rows; j++) {
+					ret += '{' + temp.value[j].toFixed(2) + '}';
+
+					if ((j + 1) < temp.rows) {
+						ret += ',';
+					}
+				}
+
 				ret += '}';
 				break;
 			case Types.TEXT:
@@ -841,9 +855,11 @@ function variablesCode (variable_obj) {
 
 		switch (temp.type) {
 			case Types.INTEGER:
-			case Types.REAL:
 				ret += '= ' + temp.value;
 				break;
+			case Types.REAL:
+				ret += '= ' + temp.value.toFixed(2);
+				break;
 			case Types.TEXT:
 				ret += '= "' + temp.value + '"';
 				break;
@@ -896,9 +912,18 @@ function globalsCode () {
 
 				switch (temp.type) {
 					case Types.INTEGER:
-					case Types.REAL:
 						ret += '= {' + temp.value + '}';
 						break;
+					case Types.REAL:
+						ret += '= {';
+						for (var j = 0; j < temp.value.length; j++) {
+							ret += temp.value[j].toFixed(2);
+							if ((j + 1) < temp.value.length) {
+								ret += ',';
+							}
+						}
+						ret += '}';
+						break;
 					case Types.TEXT:
 						ret += '= {';
 						for (var j = 0; j < temp.value.length; j++) {
@@ -930,7 +955,6 @@ function globalsCode () {
 
 				switch (temp.type) {
 					case Types.INTEGER:
-					case Types.REAL:
 						ret += '= {';
 
 						for (var j = 0; j < temp.rows; j++) {
@@ -941,6 +965,28 @@ function globalsCode () {
 							}
 						}
 
+						ret += '}';
+						break;
+					case Types.REAL:
+						ret += '= {';
+
+						for (var j = 0; j < temp.rows; j++) {
+							ret += '{';
+
+							for (var k = 0; k < temp.columns; k++) {
+								ret += temp.value[j][k].toFixed(2);
+
+								if ((k + 1) < temp.columns) {
+									ret += ',';
+								}
+							}
+
+							ret += '}';
+							if ((j + 1) < temp.rows) {
+								ret += ',';
+							}
+						}
+
 						ret += '}';
 						break;
 					case Types.TEXT:
@@ -994,9 +1040,11 @@ function globalsCode () {
 
 				switch (temp.type) {
 					case Types.INTEGER:
-					case Types.REAL:
 						ret += '= ' + temp.value;
 						break;
+					case Types.REAL:
+						ret += '= ' + temp.value.toFixed(2);
+						break;
 					case Types.TEXT:
 						ret += '= "' + temp.value + '"';
 						break;

+ 1 - 1
js/visualUI/commands/attribution.js

@@ -14,7 +14,7 @@ export function createFloatingCommand () {
 
 export function renderCommand (command, function_obj) {
 	
-	var el = $('<div class="ui attribution command_container"><i class="ui icon small arrow left command_drag"></i> <i class="ui icon times red button_remove_command"></i> <i class="ui icon redo alternate blue button_refresh_attribution"></i> <div class="var_attributed"></div> <span class="text_attr_receives">'+LocalizedStrings.getUI('text_receives')+'</span> '
+	var el = $('<div class="ui attribution command_container"><i class="ui icon small arrow left command_drag"></i> <i class="ui icon times red button_remove_command"></i> <i class="ui icon redo alternate blue button_refresh_attribution"></i> <div class="var_attributed"></div> <span class="text_attr_receives span_command_spec">'+LocalizedStrings.getUI('text_receives')+'</span> '
 		 + '<div class="expression_elements"></div> </div>');
 	el.data('command', command);
 

+ 7 - 7
js/visualUI/commands/conditional_expression.js

@@ -120,11 +120,11 @@ function renderLogicOperator (command, all_expression, expression_logic, logic_o
 
 function renderLogicExpression (command, all_expression, expression_logic, function_obj, element_to_append, initial_el_to_render) {
 
-	var exp_el_par_1 = $('<div class="expression_element"> ( </div>');
+	var exp_el_par_1 = $(' <span class="span_command_spec"> ( </span> ');
 	var exp_el_expr_el_1 = $('<div class="expression_element"></div>');
 	var exp_el_expr_operand = $('<div class="expression_element"></div>');
 	var exp_el_expr_el_2 = $('<div class="expression_element"></div>');
-	var exp_el_par_2 = $('<div class="expression_element"> ) </div>');
+	var exp_el_par_2 = $(' <span class="span_command_spec"> ) </span> ');
 
 	if (expression_logic.first_operand.type == Models.EXPRESSION_TYPES.exp_logic) {
 		renderLogicExpression(command, all_expression, expression_logic.first_operand, function_obj, exp_el_expr_el_1);
@@ -159,11 +159,11 @@ function renderLogicExpression (command, all_expression, expression_logic, funct
 
 function renderArithmeticExpression (command, all_expression, expression_arithmetic, function_obj, element_to_append) {
 
-	var exp_el_par_1 = $('<div class="expression_element"> ( </div>');
+	var exp_el_par_1 = $(' <span class="span_command_spec"> ( </span> ');
 	var exp_el_expr_el_1 = $('<div class="expression_element"></div>');
 	var exp_el_expr_operand = $('<div class="expression_element"></div>');
 	var exp_el_expr_el_2 = $('<div class="expression_element"></div>');
-	var exp_el_par_2 = $('<div class="expression_element"> ) </div>');
+	var exp_el_par_2 = $(' <span class="span_command_spec"> ) </span> ');
 
 
 	if (expression_arithmetic.first_operand.type == Models.EXPRESSION_TYPES.exp_logic) {
@@ -193,7 +193,7 @@ function renderArithmeticExpression (command, all_expression, expression_arithme
 
 function renderStartMenu (command, expression, function_obj, initial_el_to_render) {
 	var start_menu = '';
-	start_menu += '<div class="ui dropdown"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
+	start_menu += '<div class="ui dropdown menu_start_rendered"><div class="text"></div><i class="dropdown icon"></i><div class="menu">';
 	start_menu += '<div class="item" data-exp="'+Models.EXPRESSION_TYPES.exp_logic+'">'+LocalizedStrings.getUI('text_logic_expression')+'</div>';
 	start_menu += '<div class="item" data-exp="'+Models.EXPRESSION_TYPES.exp_arithmetic+'">'+LocalizedStrings.getUI('text_arithmetic_expression')+'</div>';
 	start_menu += '</div></div>';
@@ -223,9 +223,9 @@ function renderStartMenu (command, expression, function_obj, initial_el_to_rende
     	}
 	});
 
-	initial_el_to_render.append('<div class="expression_element"> ( </div>');
+	initial_el_to_render.append(' <span class="span_command_spec"> ( </span> ');
 	
 	initial_el_to_render.append(start_menu);
 
-	initial_el_to_render.append('<div class="expression_element"> ) </div>');
+	initial_el_to_render.append(' <span class="span_command_spec"> ) </span> ');
 }

+ 9 - 3
js/visualUI/commands/dowhiletrue.js

@@ -9,15 +9,15 @@ import * as ConditionalExpressionManagement from './conditional_expression';
 import * as ContextualizedMenu from './contextualized_menu';
 
 export function createFloatingCommand () {
-	return $('<div class="ui dowhiletrue created_element"> <i class="ui icon small sync"></i> <span> faça {<br>} enquanto(x < 10) </span></div>');
+	return $('<div class="ui dowhiletrue created_element"> <i class="ui icon small sync"></i> <span> '+ LocalizedStrings.getUI('text_command_do') +' {<br>} ' + LocalizedStrings.getUI('text_code_while') +'(x < 10) </span></div>');
 }
 
 export function renderCommand (command, function_obj) {
 	var ret = '';
-	ret += '<div class="ui dowhiletrue command_container"> <i class="ui icon small random command_drag"></i> <i class="ui icon times red button_remove_command"></i> <div class="ui context_menu"></div> <span> ' + LocalizedStrings.getUI('text_code_do') + ' </span>';
+	ret += '<div class="ui dowhiletrue command_container"> <i class="ui icon small random command_drag"></i> <i class="ui icon times red button_remove_command"></i> <div class="ui context_menu"></div>  <span class="span_command_spec"> ' + LocalizedStrings.getUI('text_command_do') + ' </span>';
 	ret += '<div class="ui block_commands" data-subblock="" data-idcommand="">';
 	ret += '</div>';
-	ret += '<span> ' + LocalizedStrings.getUI('text_code_while') + ' </span> <div class="conditional_expression"></div>';
+	ret += ' <span class="span_command_spec"> ' + LocalizedStrings.getUI('text_code_while') + ' </span> <div class="conditional_expression"></div>';
 	ret += '</div>';
 
 	var el = $(ret);
@@ -29,6 +29,12 @@ export function renderCommand (command, function_obj) {
 
 	ConditionalExpressionManagement.renderExpression(command, command.expression, function_obj, el.find('.conditional_expression'));
 
+	if (command.commands_block) {
+		for (var j = 0; j < command.commands_block.length; j++) {
+		    CommandsManagement.renderCommand(command.commands_block[j], $(el.find('.block_commands')[0]), 3, function_obj);
+		}
+	}
+
 	return el;
 }
 

+ 14 - 25
js/visualUI/commands/iftrue.js

@@ -14,34 +14,14 @@ export function createFloatingCommand () {
 export function renderCommand (command, function_obj) {
 	var ret = '';
 	ret += '<div class="ui iftrue command_container"><div class="ui data_block_if" data-if="true">  <i class="ui icon small random command_drag"></i> <i class="ui icon times red button_remove_command"></i> <i class="ui icon redo alternate blue button_refresh_attribution"></i>';
-	ret += '<span> ' + LocalizedStrings.getUI('text_if') + '</span>';
+	ret += '<span class="span_command_spec"> ' + LocalizedStrings.getUI('text_if') + '</span>';
 	ret += ' <div class="conditional_expression"></div>';
 	ret += '<span> </span> ';
 	ret += '<div class="ui block_commands commands_if conditional_comands_block" data-if="true">';
-
-	/*if ((writer_obj.commands_block == null)
-			|| (writer_obj.commands_block.length == 0)) {
-	} else {
-		for (ki = 0; ki < writer_obj.commands_block.length; ki ++) {
-			ret += renderElementCommandGeneric(writer_obj.commands_block[ki], function_index, ki, iftrue_index, (fullpath + ',' + ki));
-		}
-	}*/
-
-	ret += '</div></div>';
-	ret += '<div class="ui data_block_else" data-else="true"> <span> ' + LocalizedStrings.getUI('text_else') + ' </span>';
-
+ 	ret += '</div></div>';
+	ret += '<div class="ui data_block_else" data-else="true"> <span class="span_command_spec"> ' + LocalizedStrings.getUI('text_else') + ' </span>';
 	ret += '<div class="ui block_commands commands_else conditional_comands_block" data-else="true">';
-
-	/*if ((writer_obj.commands_else == null)
-			|| (writer_obj.commands_else.length == 0)) {
-	} else {
-		for (ki = 0; ki < writer_obj.commands_else.length; ki ++) {
-			ret += renderElementCommandGeneric(writer_obj.commands_else[ki], function_index, ki, iftrue_index, (fullpath + ',' + ki));
-		}
-	}*/
-
 	ret += '</div>';
-
 	ret += '<span></span></div>';
 	ret += '</div>';
 
@@ -51,8 +31,6 @@ export function renderCommand (command, function_obj) {
 	el.find('.data_block_if').data('command', command);
 	el.find('.data_block_else').data('command', command);
 
-	//data_block_if
-
 	addHandlers(command, function_obj, el);
 
 	ConditionalExpressionManagement.renderExpression(command, command.expression, function_obj, el.find('.conditional_expression'));
@@ -62,6 +40,17 @@ export function renderCommand (command, function_obj) {
 		ConditionalExpressionManagement.renderExpression(command, command.expression, function_obj, el.find('.conditional_expression'));		
 	});
 
+	if (command.commands_block) {
+		for (var j = 0; j < command.commands_block.length; j++) {
+		    CommandsManagement.renderCommand(command.commands_block[j], $(el.find('.commands_if')[0]), 3, function_obj);
+		}
+	}
+	if (command.commands_else) {
+		for (var j = 0; j < command.commands_else.length; j++) {
+		    CommandsManagement.renderCommand(command.commands_else[j], $(el.find('.commands_else')[0]), 3, function_obj);
+		}
+	}
+
 	return el;
 }
 

+ 1 - 1
js/visualUI/commands/reader.js

@@ -12,7 +12,7 @@ export function createFloatingCommand () {
 }
 
 export function renderCommand (command, function_obj) {
-	var el = '<div class="ui reader command_container"> <i class="ui icon small download command_drag"></i> <i class="ui icon times red button_remove_command"></i> <span>'+LocalizedStrings.getUI('text_command_read')+' ( </span> <div class="var_value_menu_div"></div> <span class="close_parentheses">)</span> </div>';
+	var el = '<div class="ui reader command_container"> <i class="ui icon small download command_drag"></i> <i class="ui icon times red button_remove_command"></i> <span class="span_command_spec">'+LocalizedStrings.getUI('text_command_read')+' ( </span> <div class="var_value_menu_div"></div> <span class="close_parentheses span_command_spec">)</span> </div>';
 	
 	el = $(el);
 	el.data('command', command);

Різницю між файлами не показано, бо вона завелика
+ 7 - 2
js/visualUI/commands/repeatNtimes.js


+ 1 - 1
js/visualUI/commands/return.js

@@ -12,7 +12,7 @@ export function createFloatingCommand () {
 }
 
 export function renderCommand (command, function_obj) {
-	var el = $('<div class="ui return command_container"> <i class="ui icon small reply"></i> <i class="ui icon times red button_remove_command"></i> <span> '+LocalizedStrings.getUI('text_return')+' </span>  <div class="var_value_menu_div"></div></div>');
+	var el = $('<div class="ui return command_container"> <i class="ui icon small reply"></i> <i class="ui icon times red button_remove_command"></i> <span class="span_command_spec"> '+LocalizedStrings.getUI('text_return')+' </span>  <div class="var_value_menu_div"></div></div>');
 	el.data('command', command);
 
 	addHandlers(command, function_obj, el);

+ 17 - 0
js/visualUI/commands/switch.js

@@ -46,6 +46,23 @@ export function renderCase (switchcase, command, function_obj, el) {
 
 	el.append(casediv);
 
+	if (switchcase.commands_block) {
+		for (var j = 0; j < switchcase.commands_block.length; j++) {
+		    CommandsManagement.renderCommand(switchcase.commands_block[j], $(casediv.find('.case_commands_block')[0]), 3, function_obj);
+		}
+	}
+
+	casediv.find('.button_remove_command').on('click', function() {
+		for (var i = 0; i < command.cases.length; i++) {
+			if (switchcase == command.cases[i]) {
+				delete command.cases[i];
+				command.cases.splice(i, 1);
+				casediv.remove();
+				break;
+			}
+		}
+	});
+
 }
 
 function addHandlers (command, function_obj, switch_dom) {

+ 111 - 3
js/visualUI/commands/variable_value_menu.js

@@ -73,11 +73,68 @@ export function renderMenu (command, ref_object, dom_object, function_obj, size_
     addFunctionsToMenu(function_obj, menu_var_or_value, ref_object, expression_element);
 
     if (ref_object.content || ref_object.function_called) {
-    	renderPreviousContent(function_obj, menu_var_or_value, ref_object, dom_object, command, expression_element);
+    	// Verificar se a variável ainda existe:
+    	if (isVarInProgram(ref_object.content, function_obj)) {
+    		renderPreviousContent(function_obj, menu_var_or_value, ref_object, dom_object, command, expression_element);
+    	} else {
+    		if (ref_object.content && ref_object.content.type) {
+    			ref_object.content = null;
+    			appendSelectText(ref_object, menu_var_or_value);
+    		} else {
+    			renderPreviousContent(function_obj, menu_var_or_value, ref_object, dom_object, command, expression_element);
+    		}
+    	}
+    } else {
+    	appendSelectText(ref_object, menu_var_or_value);
     }
 
 }
 
+function appendSelectText (ref_object, menu_var_or_value) {
+	switch(ref_object.variable_and_value) {
+		case VAR_OR_VALUE_TYPES.only_variable:
+			menu_var_or_value.find('.text').append('<i>'+LocalizedStrings.getUI('var_menu_select_var')+'</i>');
+			break;
+		case VAR_OR_VALUE_TYPES.all:
+			menu_var_or_value.find('.text').append('<i>'+LocalizedStrings.getUI('var_menu_select_all')+'</i>');
+			break;
+		case VAR_OR_VALUE_TYPES.variable_and_function:
+			menu_var_or_value.find('.text').append('<i>'+LocalizedStrings.getUI('var_menu_select_all')+'</i>');
+			break;
+		case VAR_OR_VALUE_TYPES.only_function:
+			menu_var_or_value.find('.text').append('<i>'+LocalizedStrings.getUI('var_menu_select_function')+'</i>');
+			break;
+	}
+}
+
+function isVarInProgram (var_obj, function_obj) {
+	// Verify in globals:
+	if (window.program_obj.globals) {
+		for (var i = 0; i < window.program_obj.globals.length; i++) {
+			if (window.program_obj.globals[i] == var_obj) {
+				return true;
+			}
+		}
+	}
+	// Verify in locals:
+	if (function_obj.variables_list) {
+		for (var i = 0; i < function_obj.variables_list.length; i++) {
+			if (function_obj.variables_list[i] == var_obj) {
+				return true;
+			}
+		}
+	}
+	// Verify in parameters:
+	if (function_obj.parameters_list) {
+		for (var i = 0; i < function_obj.parameters_list.length; i++) {
+			if (function_obj.parameters_list[i] == var_obj) {
+				return true;
+			}
+		}
+	}
+	return false;
+}
+
 export function refreshMenu (menu_var_or_value_dom) {
 	console.log('\n\n');
 	console.log(menu_var_or_value_dom);
@@ -109,6 +166,20 @@ function renderPreviousContent (function_obj, menu_var_or_value, ref_object, dom
 }
 
 function variableValueMenuCode (command, variable_obj, dom_object, function_obj, menu_var_or_value, expression_element) {
+	
+	if (variable_obj.content || variable_obj.function_called) {
+    	// Verificar se a variável ainda existe:
+    	if (isVarInProgram(variable_obj.content, function_obj)) {
+    		
+    	} else {
+    		if (variable_obj.content && variable_obj.content.type) {
+    			variable_obj.content = null;
+    			appendSelectText(variable_obj, menu_var_or_value);
+    		}
+    	}
+    } else {
+    	appendSelectText(variable_obj, menu_var_or_value);
+    }
 
 	if (variable_obj.content == null && variable_obj.function_called == null) {
 		renderMenu(command, variable_obj, dom_object, function_obj, 2, expression_element);
@@ -176,7 +247,7 @@ function variableValueMenuCode (command, variable_obj, dom_object, function_obj,
 
 			var parameters_menu = '<div class="parameters_function_called"> '+variable_obj.function_called.name+' <span> ( </span>';
 			for (var j = 0; j < variable_obj.function_called.parameters_list.length; j++) {
-				parameters_menu += '<div class="parameter_'+j+'"></div>';
+				parameters_menu += '<div class="render_style_param parameter_'+j+'"></div>';
 				if ((j + 1) != variable_obj.function_called.parameters_list.length) {
 					parameters_menu += ' , ';
 				}
@@ -289,6 +360,10 @@ function variableValueMenuCode (command, variable_obj, dom_object, function_obj,
 		      }
 			});
 
+			if (!variable_obj.column) {
+				variable_obj.column = new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.all, null, null, null, true);
+			}
+
 			variableValueMenuCode(command, variable_obj.column, $(variable_render.find('.column_container')), function_obj, menu_var_or_value, expression_element);
 
 		} else if (variable_obj.content.dimensions == 2) {
@@ -344,6 +419,13 @@ function variableValueMenuCode (command, variable_obj, dom_object, function_obj,
 		      }
 			});
 
+			if (!variable_obj.column) {
+				variable_obj.column = new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.all, null, null, null, true);
+			}
+			if (!variable_obj.row) {
+				variable_obj.row = new Models.VariableValueMenu(VAR_OR_VALUE_TYPES.all, null, null, null, true);
+			}
+
 			variableValueMenuCode(command, variable_obj.row, $(variable_render.find('.row_container')), function_obj, menu_var_or_value, expression_element);
 			variableValueMenuCode(command, variable_obj.column, $(variable_render.find('.column_container')), function_obj, menu_var_or_value, expression_element);
 
@@ -566,6 +648,19 @@ function addHandlers (command, ref_object, dom_object, menu_var_or_value, functi
 	        width: inputWidth
 	    })
 	}).trigger('input');
+
+
+	if (command.type == Models.COMMAND_TYPES.comment) {
+		dom_object.parent().on('click', function(e) {
+			dom_object.find('.value_rendered').remove();
+			dom_object.find('.value_rendered').empty();
+			dom_object.find('.value_rendered').remove();
+			dom_object.empty();
+			dom_object.append('<span class="menu_var_or_value_dom"> </span>');
+			
+			openInputToValue(command, ref_object, dom_object, menu_var_or_value, function_obj, expression_element)
+		});
+	}
 	
 }
 
@@ -582,7 +677,7 @@ function openInputToFunction (command, ref_object, dom_object, menu_var_or_value
 
 		var parameters_menu = '<div class="parameters_function_called"> '+function_selected.name+' <span> ( </span>';
 		for (var j = 0; j < function_selected.parameters_list.length; j++) {
-			parameters_menu += '<div class="parameter_'+j+'"></div>';
+			parameters_menu += '<div class="render_style_param parameter_'+j+'"></div>';
 			if ((j + 1) != function_selected.parameters_list.length) {
 				parameters_menu += ' , ';
 			}
@@ -882,6 +977,19 @@ function openInputToValue (command, ref_object, dom_object, menu_var_or_value, f
 		}
 	});
 
+	if (command.type == Models.COMMAND_TYPES.comment) {
+		rendered.parent().on('click', function(e) {
+			console.log("TTT14");
+			rendered.remove();
+			rendered.empty();
+			rendered.remove();
+			dom_object.empty();
+			dom_object.append('<span class="menu_var_or_value_dom"> </span>');
+			
+			openInputToValue(command, ref_object, dom_object, menu_var_or_value, function_obj, expression_element)
+		});
+	}
+
 	rendered.on('click', function(e) {
 		console.log("TTT2");
 		rendered.remove();

+ 7 - 1
js/visualUI/commands/whiletrue.js

@@ -14,7 +14,7 @@ export function createFloatingCommand () {
 
 export function renderCommand (command, function_obj) {
 	var ret = '';
-	ret += '<div class="ui whiletrue command_container"> <i class="ui icon small random command_drag"></i> <i class="ui icon times red button_remove_command"></i> <div class="ui context_menu"></div> <span> ' + LocalizedStrings.getUI('text_code_while') + ' </span>';
+	ret += '<div class="ui whiletrue command_container"> <i class="ui icon small random command_drag"></i> <i class="ui icon times red button_remove_command"></i> <div class="ui context_menu"></div>  <span class="span_command_spec"> ' + LocalizedStrings.getUI('text_code_while') + ' </span>';
 	ret += ' <div class="conditional_expression"></div>';
 	ret += ' </span>';
 	ret += '<div class="ui block_commands">';
@@ -31,6 +31,12 @@ export function renderCommand (command, function_obj) {
 
 	ConditionalExpressionManagement.renderExpression(command, command.expression, function_obj, el.find('.conditional_expression'));
 
+	if (command.commands_block) {
+		for (var j = 0; j < command.commands_block.length; j++) {
+		    CommandsManagement.renderCommand(command.commands_block[j], $(el.find('.block_commands')[0]), 3, function_obj);
+		}
+	}
+
 	return el;
 }
 

+ 1 - 1
js/visualUI/commands/writer.js

@@ -14,7 +14,7 @@ export function createFloatingCommand () {
 
 export function renderCommand (command, function_obj) {
 	var ret = '';
-	ret += '<div class="ui writer command_container"> <i class="ui icon small upload command_drag"></i> <i class="ui icon times red button_remove_command"></i> <span>'+LocalizedStrings.getUI('text_command_write')+' ( </span><div class="var_value_menu_div"></div> <span class="close_parentheses">)</span> </div>';
+	ret += '<div class="ui writer command_container"> <i class="ui icon small upload command_drag"></i> <i class="ui icon times red button_remove_command"></i> <span class="span_command_spec">'+LocalizedStrings.getUI('text_command_write')+' ( </span><div class="var_value_menu_div"></div> <span class="close_parentheses span_command_spec">)</span> </div>';
 
 	var el = $(ret);
 	el.data('command', command);

+ 103 - 71
js/visualUI/functions.js

@@ -32,6 +32,8 @@ const sumFunction = new Models.Function("soma", Types.INTEGER, 0, [parameter1],
 program.addFunction(sumFunction);
 */
 
+console.log('       ___           ___                    ________          \n      /   /         /   /                  /   ____/  \n     /   /         /   /                  /   /        \n    /   /         /   /  ______    ___   /   /__         \n   /   /         /   /  /      \\  /  /  /   ___/      \n  /   /______   /   /  /   /\\   \\/  /  /   /      \n /          /  /   /  /   /  \\     /  /   /____     \n/__________/  /___/  /___/    \\___/  /________/       ');
+
 const mainFunction = new Models.Function(LocalizedStrings.getUI("start"), Types.VOID, 0, [], true, false);
 mainFunction.function_comment = new Models.Comment(LocalizedStrings.getUI('text_comment_main'));
 program.addFunction(mainFunction);
@@ -88,7 +90,6 @@ function addHandlers (function_obj, function_container) {
 
   function_container.find('.ui.dropdown.function_return').dropdown({
       onChange: function(value, text, $selectedItem) {
-        $selectedItem = $($selectedItem);
         if ($selectedItem.data('dimensions')) {
           updateReturnType(function_obj, Types[$selectedItem.data('type')], $selectedItem.data('dimensions'));
         } else {
@@ -136,8 +137,6 @@ function addHandlers (function_obj, function_container) {
     function_container.find(".function_area").toggle();
     function_container.find(".add_var_top_button").toggle();
   });
-
-
 }
 
 // Essa função imprime o tipo de retorno da função e cria o menu do tipo 'select' para alteração
@@ -147,13 +146,17 @@ function renderFunctionReturn (function_obj, function_element) {
     
     if (function_obj.return_dimensions > 0) {
       ret += '<div class="text">'+ LocalizedStrings.getUI("vector") +':'+ LocalizedStrings.getUI(function_obj.return_type);
+      if (function_obj.return_dimensions == 1) {
+        ret += ' [ ] ';
+      } else {
+        ret += ' [ ] [ ] ';
+      }
       ret += '</div>';
     } else {
       ret += '<div class="text">'+LocalizedStrings.getUI(function_obj.return_type)+'</div>';
     }
 
-    ret += '<i class="dropdown icon"></i>'
-      + '<div class="menu">';
+    ret += '<div class="menu">';
 
 
     for (var tm in Types) {
@@ -215,15 +218,15 @@ export function renderFunction (function_obj) {
 
   if (function_obj.is_main) {
       appender += '<div class="function_name_div">  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' + LocalizedStrings.getUI('void') + ' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="span_name_function" >'+function_obj.name+'</span> </div> '
-        + '( <div class="ui large labels parameters_list">';
+        + ' <span class="parethesis_function">( </span> <div class="ui large labels parameters_list">';
   } else {
       appender += '<div class="ui function_return"></div>';
 
-      appender += '<div class="function_name_divunction_obj.name+'</span> <i class="icon small pencil alternate enable_edit_name_function name_function_updated"></i></div> ' 
-        + '( <i class="ui icon plus square outline add_parameter_button"></i> <div class="ui large labels parameters_list container_parameters_list">';
+      appender += '<div class="function_name_div function_name_div_updatedunction_obj.name+'</span> </div> ' 
+        + ' <span class="parethesis_function"> ( </span> <i class="ui icon plus square outline add_parameter_button"></i> <div class="ui large labels parameters_list container_parameters_list">';
   }
     
-  appender += '</div> ) </div>'
+  appender += '</div> <span class="parethesis_function"> ) </span> </div>'
     + (function_obj.is_hidden ? ' <div class="function_area" style="display: none;"> ' : ' <div class="function_area"> ')
 
     + '<div class="ui top attached segment variables_list_div">'
@@ -395,9 +398,6 @@ $( document ).ready(function() {
       hide: 0
     }
   });
-
-
-
 });
 
 function runCodeAssessment () {
@@ -424,7 +424,6 @@ function runCodeAssessment () {
   
 }
 
-
 function runCode () {
   toggleConsole(true);
 
@@ -499,12 +498,18 @@ function toggleTextualCoding () {
   $('.ivprog_textual_panel').css('display', 'block');
   $('.ivprog_textual_panel').removeClass('loading');
   $('.ivprog_textual_code').text(code);
+
+  $('.visual_coding_button').removeClass('active');
+  $('.textual_coding_button').addClass('active');
 }
 
 function toggleVisualCoding () {
   $('.ivprog_textual_panel').addClass('loading');
   $('.ivprog_textual_panel').css('display', 'none');
   $('.ivprog_visual_panel').css('display', 'block');
+
+  $('.textual_coding_button').removeClass('active');
+  $('.visual_coding_button').addClass('active');
 }
 
 function removeParameter (function_obj, parameter_obj, parameter_container) {
@@ -535,13 +540,17 @@ function renderParameter (function_obj, parameter_obj, function_container) {
 
   if (parameter_obj.dimensions > 0) {
     ret += '<div class="text">'+ LocalizedStrings.getUI('vector')+':'+LocalizedStrings.getUI(parameter_obj.type);
+    if (parameter_obj.dimensions == 1) {
+      ret += ' [ ] ';
+    } else {
+      ret += ' [ ] [ ] ';
+    }
     ret += '</div>';
   } else {
     ret += '<div class="text">'+LocalizedStrings.getUI(parameter_obj.type)+'</div>';
   }
 
-  ret += '<i class="dropdown icon"></i>'
-    + '<div class="menu">';
+  ret += '<div class="menu">';
 
   
   for (var tm in Types) {
@@ -567,7 +576,7 @@ function renderParameter (function_obj, parameter_obj, function_container) {
 
   ret += '</div></div>';
 
-  ret += '<span class="span_name_parameter label_enable_name_parameter">'+parameter_obj.name+'</span> <i class="icon small pencil alternate enable_edit_name_parameter label_enable_name_parameter"></i>';
+  ret += '<div class="parameter_div_edit"><span class="span_name_parameter label_enable_name_parameter">'+parameter_obj.name+'</span></div> ';
 
   ret += ' <i class="red icon times remove_parameter"></i></div>';
 
@@ -581,10 +590,10 @@ function renderParameter (function_obj, parameter_obj, function_container) {
   
   ret.find('.ui.dropdown.parameter_type').dropdown({
     onChange: function(value, text, $selectedItem) {
-      if ($($selectedItem).data('dimensions')) {
-        updateParameterType(parameter_obj, Types[$($selectedItem).data('type')], $($selectedItem).data('dimensions'));
+      if ($selectedItem.data('dimensions')) {
+        updateParameterType(parameter_obj, Types[$selectedItem.data('type')], $selectedItem.data('dimensions'));
       } else {
-        updateParameterType(parameter_obj, Types[$($selectedItem).data('type')]);
+        updateParameterType(parameter_obj, Types[$selectedItem.data('type')]);
       }
     }
   });
@@ -599,49 +608,55 @@ var opened_name_parameter = false;
 var opened_input_parameter = null;
 function enableNameParameterUpdate (parameter_obj, parent_node) {
   if (opened_name_parameter) {
-    $(opened_input_parameter).focus();
+    opened_input_parameter.focus();
     return;
   }
   opened_name_parameter = true;
+  parent_node = $(parent_node);
+
+  var input_field;
 
-  $(parent_node).find('.span_name_parameter').text('');
-  $( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"+parameter_obj.name+"' />" ).insertBefore($(parent_node).find('.span_name_parameter'));
+  parent_node.find('.span_name_parameter').text('');
+  input_field = $( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"+parameter_obj.name+"' />" );
+  input_field.insertBefore(parent_node.find('.span_name_parameter'));
 
-  $('.width-dynamic').on('input', function() {
-    var inputWidth = $(this).textWidth()+10;
-    opened_input_parameter = this;
-    $(this).focus();
+  input_field.on('input', function() {
+    var inputWidth = input_field.textWidth()+10;
+    opened_input_parameter = input_field;
+    input_field.focus();
 
-    var tmpStr = $(this).val();
-    $(this).val('');
-    $(this).val(tmpStr);
+    var tmpStr = input_field.val();
+    input_field.val('');
+    input_field.val(tmpStr);
 
-    $(this).css({
+    input_field.css({
         width: inputWidth
     })
   }).trigger('input');
 
-  $('.width-dynamic').focusout(function() {
+  input_field.focusout(function() {
     /// update array:
-    if ($(this).val().trim()) {
-      parameter_obj.name = $(this).val().trim();
-      $(parent_node).find('.span_name_parameter').text(parameter_obj.name);
+    if (input_field.val().trim()) {
+      parameter_obj.name = input_field.val().trim();
+      parent_node.find('.span_name_parameter').text(parameter_obj.name);
     }
-    $(this).remove();
+    input_field.off();
+    input_field.remove();
 
     /// update elements:
     opened_name_parameter = false;
     opened_input_parameter = false;
   });
 
-  $('.width-dynamic').on('keydown', function(e) {
+  input_field.on('keydown', function(e) {
     var code = e.keyCode || e.which;
     if(code == 13) {
-      if ($(this).val().trim()) {
-        parameter_obj.name = $(this).val().trim();
-        $(parent_node).find('.span_name_parameter').text(parameter_obj.name);
+      if (input_field.val().trim()) {
+        parameter_obj.name = input_field.val().trim();
+        parent_node.find('.span_name_parameter').text(parameter_obj.name);
       }
-      $(this).remove();
+      input_field.off();
+      input_field.remove();
 
       /// update elements:
       opened_name_parameter = false;
@@ -649,65 +664,79 @@ function enableNameParameterUpdate (parameter_obj, parent_node) {
 
     }
     if(code == 27) {
-      $(parent_node).find('.span_name_parameter').text(parameter_obj.name);
-
-      $(this).remove();
+      parent_node.find('.span_name_parameter').text(parameter_obj.name);
+      input_field.off();
+      input_field.remove();
 
       /// update elements:
       opened_name_parameter = false;
       opened_input_parameter = false;
     }
   });
-
+  input_field.select();
 }
 
 var opened_name_function = false;
 var opened_input = null;
-function enableNameFunctionUpdate(function_obj, parent_node) {
+var previousPadding = null;
+function enableNameFunctionUpdate (function_obj, parent_node) {
   if (opened_name_function) {
-    $(opened_input).focus();
+    opened_input.focus();
     return;
   }
+  parent_node = $(parent_node);
+  parent_node.find('.span_name_function').text('');
+  var input_field;
+  if (!previousPadding) {
+    previousPadding = parent_node.find('.span_name_function').css('padding-left');
+  }
+  parent_node.find('.span_name_function').css('padding-left', '0');
+  parent_node.find('.span_name_function').css('padding-right', '0');
+  
+  input_field = $( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"+function_obj.name+"' />" );
+  input_field.insertBefore(parent_node.find('.span_name_function'));
 
-  $(parent_node).find('.span_name_function').text('');
-  $( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"+function_obj.name+"' />" ).insertBefore($(parent_node).find('.span_name_function'));
-
-  $('.width-dynamic').on('input', function() {
-    var inputWidth = $(this).textWidth()+10;
-    opened_input = this;
-    $(this).focus();
+  input_field.on('input', function() {
+    var inputWidth = input_field.textWidth()+10;
+    opened_input = input_field;
+    input_field.focus();
 
-    var tmpStr = $(this).val();
-    $(this).val('');
-    $(this).val(tmpStr);
+    var tmpStr = input_field.val();
+    input_field.val('');
+    input_field.val(tmpStr);
 
-    $(this).css({
+    input_field.css({
         width: inputWidth
     })
   }).trigger('input');
 
-  $('.width-dynamic').focusout(function() {
+  input_field.focusout(function() {
     /// update array:
-    if ($(this).val().trim()) {
-      function_obj.name = $(this).val().trim();
+    if (input_field.val().trim()) {
+      function_obj.name = input_field.val().trim();
     }
-    $(this).remove();
-    $(parent_node).find('.span_name_function').text(function_obj.name);
+    input_field.off();
+    input_field.remove();
+    parent_node.find('.span_name_function').css('padding-left', previousPadding);
+    parent_node.find('.span_name_function').css('padding-right', previousPadding);
+    parent_node.find('.span_name_function').text(function_obj.name);
 
     /// update elements:
     opened_name_function = false;
     opened_input = false;
   });
 
-  $('.width-dynamic').on('keydown', function(e) {
+  input_field.on('keydown', function(e) {
     var code = e.keyCode || e.which;
     if(code == 13) {
-      if ($(this).val().trim()) {
-        function_obj.name = $(this).val().trim();
+      if (input_field.val().trim()) {
+        function_obj.name = input_field.val().trim();
       }
-      $(this).remove();
-
-      $(parent_node).find('.span_name_function').text(function_obj.name);
+      input_field.off();
+      input_field.remove();
+      parent_node.find('.span_name_function').css('padding-left', previousPadding);
+      parent_node.find('.span_name_function').css('padding-right', previousPadding);
+      parent_node.find('.span_name_function').text(function_obj.name);
 
       /// update elements:
       opened_name_function = false;
@@ -715,14 +744,17 @@ function enableNameFunctionUpdate(function_obj, parent_node) {
     }
     if(code == 27) {
 
-      $(this).remove();
-
-      $(parent_node).find('.span_name_function').text(function_obj.name);
+      input_field.off();
+      input_field.remove();
+      parent_node.find('.span_name_function').css('padding-left', previousPadding);
+      parent_node.find('.span_name_function').css('padding-right', previousPadding);
+      parent_node.find('.span_name_function').text(function_obj.name);
 
       /// update elements:
       opened_name_function = false;
       opened_input = false;
     }
   });
+  input_field.select();
   
 }

+ 241 - 149
js/visualUI/globals.js

@@ -47,7 +47,9 @@ function removeGlobal (global_var, global_container) {
 	if (index > -1) {
 	  window.program_obj.globals.splice(index, 1);
 	}
-	$(global_container).remove();
+	global_container.children().off();
+	global_container.off();
+	global_container.remove();
 }
 
 function updateInitialValues (global_var) {
@@ -103,12 +105,12 @@ function updateInitialValues (global_var) {
 
 function alternateBooleanGlobalValue (global_var, value_container) {
 	global_var.value = !global_var.value;
-	$(value_container).find('.span_value_variable').text(global_var.value);
+	$(value_container).find('.span_value_variable').text(LocalizedStrings.getUI(global_var.value));
 }
 
 function alternateBooleanGlobalVectorValue (global_var, index, value_container) {
 	global_var.value[index] = !global_var.value[index];
-	$(value_container).find('.span_value_variable').text(global_var.value[index]);
+	$(value_container).find('.span_value_variable').text(LocalizedStrings.getUI(global_var.value[index]));
 }
 
 function removeGlobalColumnVector (global_var) {
@@ -220,7 +222,7 @@ function addLineGlobalMatrix (global_var) {
 
 function alternateBooleanGlobalMatrixValue (global_var, row, index, value_container) {
 	global_var.value[row][index] = !global_var.value[row][index];
-	$(value_container).find('.span_value_variable').text(global_var.value[row][index]);
+	$(value_container).find('.span_value_variable').text(LocalizedStrings.getUI(global_var.value[row][index]));
 }
 
 function renderValues (global_var, global_container) {
@@ -233,7 +235,7 @@ function renderValues (global_var, global_container) {
 			ret += '<div class="created_div_valor_var"><span class="span_value_variable simple_var">'+global_var.value.toFixed(1)+'</span>  </div> ';
 		} else {
 			if (global_var.type == Types.BOOLEAN) {
-				ret += '<div class="created_div_valor_var"><span class="span_value_variable boolean_simple_type">'+global_var.value+'</span>  </div> ';
+				ret += '<div class="created_div_valor_var"><span class="span_value_variable boolean_simple_type">'+LocalizedStrings.getUI(global_var.value)+'</span>  </div> ';
 			} else {
 				ret += '<div class="created_div_valor_var"><span class="span_value_variable simple_var">'+global_var.value+'</span>  </div> ';
 			}
@@ -250,7 +252,7 @@ function renderValues (global_var, global_container) {
 			} else {
 				for (var k = 0; k < global_var.columns; k++) {
 					if (global_var.type == Types.BOOLEAN) {
-						ret += '<td><span class="span_value_variable boolean_vector_var" data-index="'+k+'">'+global_var.value[k]+'</span></td>';
+						ret += '<td><span class="span_value_variable boolean_vector_var" data-index="'+k+'">'+LocalizedStrings.getUI(global_var.value[k])+'</span></td>';
 					} else {
 						ret += '<td><span class="span_value_variable vector_var" data-index="'+k+'">'+global_var.value[k]+'</span>'+'</td>';
 					}
@@ -278,7 +280,7 @@ function renderValues (global_var, global_container) {
     				ret += '<tr>';
     				for (var k = 0; k < global_var.columns; k++) {
     					if (global_var.type == Types.BOOLEAN) { 
-    						ret += '<td><span class="span_value_variable boolean_matrix_var" data-index="'+k+'" data-row="'+l+'">'+global_var.value[l][k]+'</span></td>';
+    						ret += '<td><span class="span_value_variable boolean_matrix_var" data-index="'+k+'" data-row="'+l+'">'+LocalizedStrings.getUI(global_var.value[l][k])+'</span></td>';
     					} else {
     						ret += '<td><span class="span_value_variable matrix_var" data-index="'+k+'" data-row="'+l+'">'+global_var.value[l][k]+'</span></td>';
     					}
@@ -299,62 +301,62 @@ function renderValues (global_var, global_container) {
 		
 	}
 
-	$( global_container ).find( ".div_valor_var" ).html('');
+	global_container.find( ".div_valor_var" ).html('');
 
 	ret = $(ret);
 
-	$(ret).find('.span_value_variable').data('associatedOject', global_var);
+	ret.find('.span_value_variable').data('associatedOject', global_var);
 
-	$( ret ).find( ".boolean_simple_type" ).on('click', function(e){
+	ret.find( ".boolean_simple_type" ).on('click', function(e){
 		alternateBooleanGlobalValue(global_var, this.parentNode);
 	});
-	$( ret ).find( ".simple_var" ).on('click', function(e){
+	ret.find( ".simple_var" ).on('click', function(e){
 		enableGlobalValueUpdate(global_var, this.parentNode);
 	});
 
-	$( ret ).find( ".boolean_vector_var" ).on('click', function(e){
+	ret.find( ".boolean_vector_var" ).on('click', function(e){
 		alternateBooleanGlobalVectorValue(global_var, $(this).data('index'), this.parentNode);
 	});
-	$( ret ).find( ".vector_var" ).on('click', function(e){
+	ret.find( ".vector_var" ).on('click', function(e){
 		enableGlobalVectorValueUpdate(global_var, $(this).data('index'), this.parentNode);
 	});
-	$( ret ).find( ".remove_global_vector_column" ).on('click', function(e){
+	ret.find( ".remove_global_vector_column" ).on('click', function(e){
 		removeGlobalColumnVector(global_var);
-		$( global_container ).find( ".div_valor_var" ).html('');
+		global_container.find( ".div_valor_var" ).html('');
 		renderValues(global_var, global_container);
 	});
-	$( ret ).find( ".add_global_vector_column" ).on('click', function(e){
+	ret.find( ".add_global_vector_column" ).on('click', function(e){
 		addGlobalColumnVector(global_var);
-		$( global_container ).find( ".div_valor_var" ).html('');
+		global_container.find( ".div_valor_var" ).html('');
 		renderValues(global_var, global_container);
 	});
-	$( ret ).find( ".remove_global_matrix_column" ).on('click', function(e){
+	ret.find( ".remove_global_matrix_column" ).on('click', function(e){
 		removeColumnGlobalMatrix(global_var);
-		$( global_container ).find( ".div_valor_var" ).html('');
+		global_container.find( ".div_valor_var" ).html('');
 		renderValues(global_var, global_container);
 	});
-	$( ret ).find( ".add_global_matrix_column" ).on('click', function(e){
+	ret.find( ".add_global_matrix_column" ).on('click', function(e){
 		addColumnGlobalMatrix(global_var);
-		$( global_container ).find( ".div_valor_var" ).html('');
+		global_container.find( ".div_valor_var" ).html('');
 		renderValues(global_var, global_container);
 	});
-	$( ret ).find( ".remove_global_matrix_line" ).on('click', function(e){
+	ret.find( ".remove_global_matrix_line" ).on('click', function(e){
 		removeLineGlobalMatrix(global_var);
-		$( global_container ).find( ".div_valor_var" ).html('');
+		global_container.find( ".div_valor_var" ).html('');
 		renderValues(global_var, global_container);
 	});
-	$( ret ).find( ".add_global_matrix_line" ).on('click', function(e){
+	ret.find( ".add_global_matrix_line" ).on('click', function(e){
 		addLineGlobalMatrix(global_var);
-		$( global_container ).find( ".div_valor_var" ).html('');
+		global_container.find( ".div_valor_var" ).html('');
 		renderValues(global_var, global_container);
 	});
-	$( ret ).find( ".boolean_matrix_var" ).on('click', function(e){
+	ret.find( ".boolean_matrix_var" ).on('click', function(e){
 		alternateBooleanGlobalMatrixValue(global_var, $(this).data('row'), $(this).data('index'), this.parentNode);
 	});
-	$( ret ).find( ".matrix_var" ).on('click', function(e){
+	ret.find( ".matrix_var" ).on('click', function(e){
 		enableGlobalMatrixValueUpdate(global_var, $(this).data('row'), $(this).data('index'), this.parentNode);
 	});
-	$( global_container ).find( ".div_valor_var" ).append(ret);
+	global_container.find( ".div_valor_var" ).append(ret);
 
 
 	updateColumnsAndRowsText(global_container, global_var);
@@ -383,10 +385,10 @@ function addHandlers (global_container) {
 	// Menu to change type:
 	global_container.find('.ui.dropdown.global_type').dropdown({
 	    onChange: function(value, text, $selectedItem) {
-	    	if ($($selectedItem).data('dimensions')) {
-	    		updateType(global_var, Types[$($selectedItem).data('type')], $($selectedItem).data('dimensions'));
+	    	if ($selectedItem.data('dimensions')) {
+	    		updateType(global_var, Types[$selectedItem.data('type')], $selectedItem.data('dimensions'));
 	    	} else {
-	    		updateType(global_var, Types[$($selectedItem).data('type')]);
+	    		updateType(global_var, Types[$selectedItem.data('type')]);
 	    	}
 
 	    	renderValues(global_var, global_container);
@@ -484,76 +486,103 @@ var opened_name_value_matrix_global_v = false;
 var opened_input_value_matrix_global_v = null;
 function enableGlobalMatrixValueUpdate (global_var, row, index, parent_node) {
 	if (opened_name_value_matrix_global_v) {
-		$(opened_input_value_matrix_global_v).focus();
+		opened_input_value_matrix_global_v.focus();
 		return;
 	}
+	parent_node = $(parent_node);
 	opened_name_value_matrix_global_v = true;
 
-	$(parent_node).find('.span_value_variable').text('');
+	parent_node.find('.span_value_variable').text('');
+
+	var input_field;
 
 	if (global_var.type == Types.REAL) {
-		$( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"
-			+ global_var.value[row][index].toFixed(1) + "' />" ).insertBefore($(parent_node).find('.span_value_variable'));
+		input_field = $( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"
+			+ global_var.value[row][index].toFixed(1) + "' />" );
+		input_field.insertBefore(parent_node.find('.span_value_variable'));
 	} else {
-		$( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"
-			+ global_var.value[row][index] + "' />" ).insertBefore($(parent_node).find('.span_value_variable'));
+		input_field = $( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"
+			+ global_var.value[row][index] + "' />" );
+		input_field.insertBefore(parent_node.find('.span_value_variable'));
 	}
 
-	$('.width-dynamic').on('input', function() {
-	    var inputWidth = $(this).textWidth()+10;
-	    opened_input_value_matrix_global_v = this;
-	    $(this).focus();
+	input_field.on('input', function() {
+	    var inputWidth = input_field.textWidth()+10;
+	    opened_input_value_matrix_global_v = input_field;
+	    input_field.focus();
 
-	    var tmpStr = $(this).val();
-		$(this).val('');
-		$(this).val(tmpStr);
+	    var tmpStr = input_field.val();
+		input_field.val('');
+		input_field.val(tmpStr);
 
-	    $(this).css({
+	    input_field.css({
 	        width: inputWidth
 	    })
 	}).trigger('input');
 
-	$('.width-dynamic').focusout(function() {
+	input_field.focusout(function() {
 		/// update array:
-		if ($(this).val().trim()) {
+		if (input_field.val().trim()) {
 			if (global_var.type == Types.REAL) {
-				global_var.value[row][index] = parseFloat($(this).val().trim());
+				global_var.value[row][index] = parseFloat(input_field.val().trim());
 
-				$(parent_node).find('.span_value_variable').text(global_var.value[row][index].toFixed(1));
+				parent_node.find('.span_value_variable').text(global_var.value[row][index].toFixed(1));
 			} else {
 				if (global_var.type == Types.INTEGER) {
-					global_var.value[row][index] = parseInt($(this).val().trim());
+					global_var.value[row][index] = parseInt(input_field.val().trim());
 				} else {
-					global_var.value[row][index] = $(this).val().trim();
+					global_var.value[row][index] = input_field.val().trim();
 				}
-				$(parent_node).find('.span_value_variable').text(global_var.value[row][index]);
+				parent_node.find('.span_value_variable').text(global_var.value[row][index]);
+			}
+		} else {
+			if (global_var.type == Types.REAL) {
+				parent_node.find('.span_value_variable').text(global_var.value[row][index].toFixed(1));
+			} else {
+				parent_node.find('.span_value_variable').text(global_var.value[row][index]);
 			}
 		}
-		$(this).remove();
+		if (global_var.type == Types.TEXT) {
+			global_var.value[row][index] = input_field.val();
+			parent_node.find('.span_value_variable').text(global_var.value[row][index]);
+		}
+		input_field.off();
+		input_field.remove();
 
 		/// update elements:
 		opened_name_value_matrix_global_v = false;
 		opened_input_value_matrix_global_v = false;
 	});
 
-	$('.width-dynamic').on('keydown', function(e) {
+	input_field.on('keydown', function(e) {
 		var code = e.keyCode || e.which;
 		if(code == 13) {
-			if ($(this).val().trim()) {
+			if (input_field.val().trim()) {
 				if (global_var.type == Types.REAL) {
-					global_var.value[row][index] = parseFloat($(this).val().trim());
+					global_var.value[row][index] = parseFloat(input_field.val().trim());
 
-					$(parent_node).find('.span_value_variable').text(global_var.value[row][index].toFixed(1));
+					parent_node.find('.span_value_variable').text(global_var.value[row][index].toFixed(1));
 				} else {
 					if (global_var.type == Types.INTEGER) {
-						global_var.value[row][index] = parseInt($(this).val().trim());
+						global_var.value[row][index] = parseInt(input_field.val().trim());
 					} else {
-						global_var.value[row][index] = $(this).val().trim();
+						global_var.value[row][index] = input_field.val().trim();
 					}
-					$(parent_node).find('.span_value_variable').text(global_var.value[row][index]);
+					parent_node.find('.span_value_variable').text(global_var.value[row][index]);
 				}
+			} else {
+				if (global_var.type == Types.REAL) {
+					parent_node.find('.span_value_variable').text(global_var.value[row][index].toFixed(1));
+				} else {
+					parent_node.find('.span_value_variable').text(global_var.value[row][index]);
+				}
+			}
+			if (global_var.type == Types.TEXT) {
+				global_var.value[row][index] = input_field.val();
+				parent_node.find('.span_value_variable').text(global_var.value[row][index]);
 			}
-			$(this).remove();
+			input_field.off();
+			input_field.remove();
 
 			/// update elements:
 			opened_name_value_matrix_global_v = false;
@@ -561,69 +590,87 @@ function enableGlobalMatrixValueUpdate (global_var, row, index, parent_node) {
 		}
 		if(code == 27) {
 			if (global_var.type == Types.REAL) {
-				$(parent_node).find('.span_value_variable').text(global_var.value[row][index].toFixed(1));
+				parent_node.find('.span_value_variable').text(global_var.value[row][index].toFixed(1));
 			} else {
-				$(parent_node).find('.span_value_variable').text(global_var.value[row][index]);
+				parent_node.find('.span_value_variable').text(global_var.value[row][index]);
 			}
-
-			$(this).remove();
+			input_field.off();
+			input_field.remove();
 
 			/// update elements:
 			opened_name_value_matrix_global_v = false;
 			opened_input_value_matrix_global_v = false;
 		}
 	});
+	input_field.select();
 }
 
 var opened_name_value_global_var = false;
 var opened_input_value_global_ar = null;
 function enableGlobalValueUpdate (global_var, parent_node) {
 	if (opened_name_value_global_var) {
-		$(opened_input_value_global_ar).focus();
+		opened_input_value_global_ar.focus();
 		return;
 	}
+	parent_node = $(parent_node);
 	opened_name_value_global_var = true;
 
-	$(parent_node).find('.span_value_variable').text('');
+	parent_node.find('.span_value_variable').text('');
+
+	var input_field;
+
 	if (global_var.type == Types.REAL) {
-		$( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"
-			+ global_var.value.toFixed(1) + "' />" ).insertBefore($(parent_node).find('.span_value_variable'));
+		input_field = $( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"
+			+ global_var.value.toFixed(1) + "' />" );
+		input_field.insertBefore(parent_node.find('.span_value_variable'));
 	} else {
-		$( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"
-			+ global_var.value + "' />" ).insertBefore($(parent_node).find('.span_value_variable'));
+		input_field = $( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"
+			+ global_var.value + "' />" );
+		input_field.insertBefore(parent_node.find('.span_value_variable'));
 	}
 
-	$('.width-dynamic').on('input', function() {
-	    var inputWidth = $(this).textWidth()+10;
-	    opened_input_value_global_ar = this;
-	    $(this).focus();
+	input_field.on('input', function() {
+	    var inputWidth = input_field.textWidth()+10;
+	    opened_input_value_global_ar = input_field;
+	    input_field.focus();
 
-	    var tmpStr = $(this).val();
-		$(this).val('');
-		$(this).val(tmpStr);
+	    var tmpStr = input_field.val();
+		input_field.val('');
+		input_field.val(tmpStr);
 
-	    $(this).css({
+	    input_field.css({
 	        width: inputWidth
 	    })
 	}).trigger('input');
 
-	$('.width-dynamic').focusout(function() {
+	input_field.focusout(function() {
 		/// update array:
-		if ($(this).val().trim()) {
+		if (input_field.val().trim()) {
 			if (global_var.type == Types.REAL) {
-				global_var.value = parseFloat($(this).val().trim());
-				$(parent_node).find('.span_value_variable').text(global_var.value.toFixed(1));
+				global_var.value = parseFloat(input_field.val().trim());
+				parent_node.find('.span_value_variable').text(global_var.value.toFixed(1));
 			} else{
 				if (global_var.type == Types.INTEGER) {
-					global_var.value = parseInt($(this).val().trim());
+					global_var.value = parseInt(input_field.val().trim());
 				} else {
-					global_var.value = $(this).val().trim();
+					global_var.value = input_field.val().trim();
 				}
-				$(parent_node).find('.span_value_variable').text(global_var.value);
+				parent_node.find('.span_value_variable').text(global_var.value);
 				
 			}
+		} else {
+			if (global_var.type == Types.REAL) {
+				parent_node.find('.span_value_variable').text(global_var.value.toFixed(1));
+			} else {
+				parent_node.find('.span_value_variable').text(global_var.value);
+			}
+		}
+		if (global_var.type == Types.TEXT) {
+			global_var.value = input_field.val();
+			parent_node.find('.span_value_variable').text(global_var.value);
 		}
-		$(this).remove();
+		input_field.off();
+		input_field.remove();
 
 		/// update elements:
 		opened_name_value_global_var = false;
@@ -631,23 +678,34 @@ function enableGlobalValueUpdate (global_var, parent_node) {
 
 	});
 
-	$('.width-dynamic').on('keydown', function(e) {
+	input_field.on('keydown', function(e) {
 		var code = e.keyCode || e.which;
 		if(code == 13) {
-			if ($(this).val().trim()) {
+			if (input_field.val().trim()) {
 				if (global_var.type == Types.REAL) {
-					global_var.value = parseFloat($(this).val().trim());
-					$(parent_node).find('.span_value_variable').text(global_var.value.toFixed(1));
-				} else{
+					global_var.value = parseFloat(input_field.val().trim());
+					parent_node.find('.span_value_variable').text(global_var.value.toFixed(1));
+				} else {
 					if (global_var.type == Types.INTEGER) {
-						global_var.value = parseInt($(this).val().trim());
+						global_var.value = parseInt(input_field.val().trim());
 					} else {
-						global_var.value = $(this).val().trim();
+						global_var.value = input_field.val().trim();
 					}
-					$(parent_node).find('.span_value_variable').text(global_var.value);
+					parent_node.find('.span_value_variable').text(global_var.value);
+				}
+			} else {
+				if (global_var.type == Types.REAL) {
+					parent_node.find('.span_value_variable').text(global_var.value.toFixed(1));
+				} else {
+					parent_node.find('.span_value_variable').text(global_var.value);
 				}
 			}
-			$(this).remove();
+			if (global_var.type == Types.TEXT) {
+				global_var.value = input_field.val();
+				parent_node.find('.span_value_variable').text(global_var.value);
+			}
+			input_field.off();
+			input_field.remove();
 
 			/// update elements:
 			opened_name_value_global_var = false;
@@ -656,18 +714,20 @@ function enableGlobalValueUpdate (global_var, parent_node) {
 		}
 		if(code == 27) {
 			if (global_var.type == Types.REAL) {
-				$(parent_node).find('.span_value_variable').text(global_var.value.toFixed(1));
+				parent_node.find('.span_value_variable').text(global_var.value.toFixed(1));
 			} else{
-				$(parent_node).find('.span_value_variable').text(global_var.value);
+				parent_node.find('.span_value_variable').text(global_var.value);
 			}
-
-			$(this).remove();
+			input_field.off();
+			input_field.remove();
 
 			/// update elements:
 			opened_name_value_global_var = false;
 			opened_input_value_global_ar = false;
 		}
 	});
+
+	input_field.select();
 }
 
 
@@ -684,11 +744,12 @@ function enableNameUpdate (global_container) {
 	opened_name_global = true;
 
 	global_container.find('.span_name_variable').text('');
-	$( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"+global_var.name+"' />" ).insertBefore(global_container.find('.span_name_variable'));
+	var input_name = $( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"+global_var.name+"' />" );
+	input_name.insertBefore(global_container.find('.span_name_variable'));
 
-	$('.width-dynamic').on('input', function() {
-	    var inputWidth = $(this).textWidth()+10;
-	    opened_input_global = $(this);
+	input_name.on('input', function() {
+	    var inputWidth = input_name.textWidth()+10;
+	    opened_input_global = input_name;
 	    opened_input_global.focus();
 
 	    opened_input_global.css({
@@ -696,31 +757,33 @@ function enableNameUpdate (global_container) {
 	    })
 	}).trigger('input');
 
-	$('.width-dynamic').focusout(function() {
+	input_name.focusout(function() {
 		/// update array:
-		if ($(this).val().trim().length > 0) {
-			updateName(global_var, $(this).val().trim());
+		if (input_name.val().trim().length > 0) {
+			updateName(global_var, input_name.val().trim());
 			global_container.find('.span_name_variable').text(global_var.name);
 		} else {
 			global_container.find('.span_name_variable').text(global_var.name);
 		}
-		$(this).remove();
+		input_name.off();
+		input_name.remove();
 
 		/// update elements:
 		opened_name_global = false;
 		opened_input_global = false;
 	});
 
-	$('.width-dynamic').on('keydown', function(e) {
+	input_name.on('keydown', function(e) {
 		var code = e.keyCode || e.which;
 		if(code == 13) {
-			if ($(this).val().trim()) {
-				updateName(global_var, $(this).val().trim());
+			if (input_name.val().trim()) {
+				updateName(global_var, input_name.val().trim());
 				global_container.find('.span_name_variable').text(global_var.name);
 			} else {
 				global_container.find('.span_name_variable').text(global_var.name);
 			}
-			$(this).remove();
+			input_name.off();
+			input_name.remove();
 
 			/// update elements:
 			opened_name_global = false;
@@ -729,8 +792,8 @@ function enableNameUpdate (global_container) {
 		if(code == 27) {
 
 			global_container.find('.span_name_variable').text(global_var.name);
-
-			$(this).remove();
+			input_name.off();
+			input_name.remove();
 
 			/// update elements:
 			opened_name_global = false;
@@ -738,7 +801,7 @@ function enableNameUpdate (global_container) {
 		}
 	});
 
-	 $('.width-dynamic').select();
+	input_name.select();
 	
 }
 
@@ -747,82 +810,109 @@ var opened_name_value_vector_global_ = false;
 var opened_input_value_vector_global_ = null;
 function enableGlobalVectorValueUpdate (global_var, index, parent_node) {
 	if (opened_name_value_vector_global_) {
-		$(opened_input_value_vector_global_).focus();
+		opened_input_value_vector_global_.focus();
 		return;
 	}
+	parent_node = $(parent_node);
 	opened_name_value_vector_global_ = true;
 
-	$(parent_node).find('.span_value_variable').text('');
+	parent_node.find('.span_value_variable').text('');
+
+	var input_field;
 
 	if (global_var.type == Types.REAL) {
-		$( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"
-			+ global_var.value[index].toFixed(1) + "' />" ).insertBefore($(parent_node).find('.span_value_variable'));
+		input_field = $( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"
+			+ global_var.value[index].toFixed(1) + "' />" );
+		input_field.insertBefore(parent_node.find('.span_value_variable'));
 	} else {
-		$( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"
-			+ global_var.value[index] + "' />" ).insertBefore($(parent_node).find('.span_value_variable'));
+		input_field = $( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"
+			+ global_var.value[index] + "' />" );
+		input_field.insertBefore(parent_node.find('.span_value_variable'));
 	}
 
-	$('.width-dynamic').on('input', function() {
-	    var inputWidth = $(this).textWidth()+10;
-	    opened_input_value_vector_global_ = this;
-	    $(this).focus();
+	input_field.on('input', function() {
+	    var inputWidth = input_field.textWidth()+10;
+	    opened_input_value_vector_global_ = input_field;
+	    input_field.focus();
 
-	    var tmpStr = $(this).val();
-		$(this).val('');
-		$(this).val(tmpStr);
+	    var tmpStr = input_field.val();
+		input_field.val('');
+		input_field.val(tmpStr);
 
-	    $(this).css({
+	    input_field.css({
 	        width: inputWidth
 	    })
 	}).trigger('input');
 
-	$('.width-dynamic').focusout(function() {
+	input_field.focusout(function() {
 		/// update array:
-		if ($(this).val().trim()) {
+		if (input_field.val().trim()) {
 			if (global_var.type == Types.REAL) {
-				global_var.value[index] = parseFloat($(this).val().trim());
+				global_var.value[index] = parseFloat(input_field.val().trim());
 
-				$(parent_node).find('.span_value_variable').text(global_var.value[index].toFixed(1));
+				parent_node.find('.span_value_variable').text(global_var.value[index].toFixed(1));
 			} else {
 
 				if (global_var.type == Types.INTEGER) {
-					global_var.value[index] = parseInt($(this).val().trim());
+					global_var.value[index] = parseInt(input_field.val().trim());
 				} else {
-					global_var.value[index] = $(this).val().trim();
+					global_var.value[index] = input_field.val().trim();
 				}
 
-				$(parent_node).find('.span_value_variable').text(global_var.value[index]);
+				parent_node.find('.span_value_variable').text(global_var.value[index]);
 
 			}
+		} else {
+			if (global_var.type == Types.REAL) {
+				parent_node.find('.span_value_variable').text(global_var.value[index].toFixed(1));
+			} else {
+				parent_node.find('.span_value_variable').text(global_var.value[index]);
+			}
+		}
+		if (global_var.type == Types.TEXT) {
+			global_var.value[index] = input_field.val();
+			parent_node.find('.span_value_variable').text(global_var.value[index]);
 		}
-		$(this).remove();
+		input_field.off();
+		input_field.remove();
 
 		/// update elements:
 		opened_name_value_vector_global_ = false;
 		opened_input_value_vector_global_ = false;
 	});
 
-	$('.width-dynamic').on('keydown', function(e) {
+	input_field.on('keydown', function(e) {
 		var code = e.keyCode || e.which;
 		if(code == 13) {
-			if ($(this).val().trim()) {
+			if (input_field.val().trim()) {
 				if (global_var.type == Types.REAL) {
-					global_var.value[index] = parseFloat($(this).val().trim());
+					global_var.value[index] = parseFloat(input_field.val().trim());
 
-					$(parent_node).find('.span_value_variable').text(global_var.value[index].toFixed(1));
+					parent_node.find('.span_value_variable').text(global_var.value[index].toFixed(1));
 				} else {
 
 					if (global_var.type == Types.INTEGER) {
-						global_var.value[index] = parseInt($(this).val().trim());
+						global_var.value[index] = parseInt(input_field.val().trim());
 					} else {
-						global_var.value[index] = $(this).val().trim();
+						global_var.value[index] = input_field.val().trim();
 					}
 
-					$(parent_node).find('.span_value_variable').text(global_var.value[index]);
+					parent_node.find('.span_value_variable').text(global_var.value[index]);
 
 				}
+			} else {
+				if (global_var.type == Types.REAL) {
+					parent_node.find('.span_value_variable').text(global_var.value[index].toFixed(1));
+				} else {
+					parent_node.find('.span_value_variable').text(global_var.value[index]);
+				}
+			}
+			if (global_var.type == Types.TEXT) {
+				global_var.value[index] = input_field.val();
+				parent_node.find('.span_value_variable').text(global_var.value[index]);
 			}
-			$(this).remove();
+			input_field.off();
+			input_field.remove();
 
 			/// update elements:
 			opened_name_value_vector_global_ = false;
@@ -830,18 +920,20 @@ function enableGlobalVectorValueUpdate (global_var, index, parent_node) {
 		}
 		if(code == 27) {
 			if (global_var.type == Types.REAL) {
-				$(parent_node).find('.span_value_variable').text(global_var.value[index].toFixed(1));
+				parent_node.find('.span_value_variable').text(global_var.value[index].toFixed(1));
 			} else {
-				$(parent_node).find('.span_value_variable').text(global_var.value[index]);
+				parent_node.find('.span_value_variable').text(global_var.value[index]);
 			}
-
-			$(this).remove();
+			input_field.off();
+			input_field.remove();
 
 			/// update elements:
 			opened_name_value_vector_global_ = false;
 			opened_input_value_vector_global_ = false;
 		}
 	});
+
+	input_field.select();
 }
 
 

+ 268 - 148
js/visualUI/variables.js

@@ -28,13 +28,17 @@ function updateName (variable_obj, new_name) {
 }
 
 function removeVariable (variable_obj, variable_container) {
-	var function_associated = $(variable_container).data('associatedFunction');
+	var function_associated = variable_container.data('associatedFunction');
 
 	var index = function_associated.variables_list.indexOf(variable_obj);
 	if (index > -1) {
+	  //function_associated.variables_list[index] = null;
+	  delete function_associated.variables_list[index];
 	  function_associated.variables_list.splice(index, 1);
 	}
-	$(variable_container).remove();
+	variable_container.children().off();
+	variable_container.off();
+	variable_container.remove();
 }
 
 function updateType (variable_obj, new_type, new_dimensions = 0) {
@@ -52,25 +56,25 @@ function updateType (variable_obj, new_type, new_dimensions = 0) {
 function addHandlers (variable_obj, variable_container) {
 
 	// Manage variable name: 
-	$( variable_container ).find( ".enable_edit_name_variable" ).on('click', function(e){
+	variable_container.find( ".enable_edit_name_variable" ).on('click', function(e){
 		enableNameUpdate(variable_obj, variable_container);
 	});
 
 	// Menu to change type:
-	$( variable_container ).find('.ui.dropdown.variable_type').dropdown({
+	variable_container.find('.ui.dropdown.variable_type').dropdown({
 	    onChange: function(value, text, $selectedItem) {
-	    	if ($($selectedItem).data('dimensions')) {
-	    		updateType(variable_obj, Types[$($selectedItem).data('type')], $($selectedItem).data('dimensions'));
+	    	if ($selectedItem.data('dimensions')) {
+	    		updateType(variable_obj, Types[$selectedItem.data('type')], $selectedItem.data('dimensions'));
 	    	} else {
-	    		updateType(variable_obj, Types[$($selectedItem).data('type')]);
+	    		updateType(variable_obj, Types[$selectedItem.data('type')]);
 	    	}
 
 	    	renderValues(variable_obj, variable_container);
 	    }
 	});
 
-	// Remove global: 
-	$( variable_container ).find( ".remove_variable" ).on('click', function(e){
+	// Remove variable: 
+	variable_container.find( ".remove_variable" ).on('click', function(e){
 		removeVariable(variable_obj, variable_container);
 	});
 
@@ -106,6 +110,7 @@ export function renderVariable (function_container, new_var, function_obj) {
   			continue;
   		}
   		element += '<div class="item">'
+  			+ '<i class="dropdown icon"></i>'
 	    	+  LocalizedStrings.getUI('vector')+':'+LocalizedStrings.getUI(tm.toLowerCase())
 	      	+  '<div class="menu">'
 		        + '<div class="item" data-text="'+ LocalizedStrings.getUI('vector')+':'+LocalizedStrings.getUI(tm.toLowerCase())+' [ ] " data-type="'+tm+'" data-dimensions="1">[ ]</div>'
@@ -116,23 +121,37 @@ export function renderVariable (function_container, new_var, function_obj) {
 
     element += '</div></div> ';
 
-    element += '<span class="span_name_variable enable_edit_name_variable">'+new_var.name+'</span> ';
+    element += '<div class="editing_name_var"><span class="span_name_variable enable_edit_name_variable">'+new_var.name+'</span> </div>';
 
-	element += ' = <div class="ui div_valor_var">'+new_var.value+'</div>';    
+	element += ' <span class="character_equals"> = </span> <div class="ui div_valor_var">'+new_var.value+'</div>';    
 
 	element += ' <i class="red icon times remove_variable"></i></div>';
 
 	element = $(element);
 
-	$(element).data('associatedFunction', function_obj);
+	element.data('associatedFunction', function_obj);
 
-	$(function_container).find('.variables_list_div').append(element);
+	function_container.find('.variables_list_div').append(element);
 
 	addHandlers(new_var, element);
 
 	renderValues(new_var, element);
 }
 
+function updateColumnsAndRowsText (variable_container, variable_var) {
+	var prev = variable_container.find('.text').text().split('[');
+	if (prev.length == 2) {
+		var ff = prev[0] + '[ ' + variable_var.columns + ' ] ';
+		variable_container.find('.text').empty();
+		variable_container.find('.text').text(ff);
+	}
+	if (prev.length == 3) {
+		var ff = prev[0] + '[ ' + variable_var.columns + ' ] [ ' + variable_var.rows + ' ] ';
+		variable_container.find('.text').empty();
+		variable_container.find('.text').text(ff);
+	}
+}
+
 function renderValues (new_var, variable_container) {
 
 	var ret = "";
@@ -140,12 +159,12 @@ function renderValues (new_var, variable_container) {
 
 	if (new_var.dimensions == 0) {
 		if (new_var.type == Types.REAL) {
-			ret += '<div class="created_div_valor_var"><span class="span_value_variable simple_var">'+new_var.value.toFixed(1)+'</span> <i class="icon small pencil alternate enable_edit_name_function simple_var"></i></div> ';
+			ret += '<div class="created_div_valor_var"><span class="span_value_variable simple_var">'+new_var.value.toFixed(1)+'</span> </div> ';
 		} else {
 			if (new_var.type == Types.BOOLEAN) {
-				ret += '<div class="created_div_valor_var"><span class="span_value_variable boolean_simple_type">'+new_var.value+'</span> <i class="icon small pencil alternate enable_edit_name_function boolean_simple_type"></i></div> ';
+				ret += '<div class="created_div_valor_var"><span class="span_value_variable boolean_simple_type">'+LocalizedStrings.getUI(new_var.value)+'</span> </div> ';
 			} else {
-				ret += '<div class="created_div_valor_var"><span class="span_value_variable simple_var">'+new_var.value+'</span> <i class="icon small pencil alternate enable_edit_name_function simple_var"></i></div> ';
+				ret += '<div class="created_div_valor_var"><span class="span_value_variable simple_var">'+new_var.value+'</span> </div> ';
 			}
 		}
 	} else {
@@ -160,7 +179,7 @@ function renderValues (new_var, variable_container) {
 			} else {
 				for (var k = 0; k < new_var.columns; k++) {
 					if (new_var.type == Types.BOOLEAN) {
-						ret += '<td><span class="span_value_variable boolean_vector_var" data-index="'+k+'">'+new_var.value[k]+'</span></td>';
+						ret += '<td><span class="span_value_variable boolean_vector_var" data-index="'+k+'">'+LocalizedStrings.getUI(new_var.value[k])+'</span></td>';
 					} else {
 						ret += '<td><span class="span_value_variable vector_var" data-index="'+k+'">'+new_var.value[k]+'</span>'+'</td>';
 					}
@@ -188,7 +207,7 @@ function renderValues (new_var, variable_container) {
     				ret += '<tr>';
     				for (var k = 0; k < new_var.columns; k++) {
     					if (new_var.type == Types.BOOLEAN) { 
-    						ret += '<td><span class="span_value_variable boolean_matrix_var" data-index="'+k+'" data-row="'+l+'">'+new_var.value[l][k]+'</span></td>';
+    						ret += '<td><span class="span_value_variable boolean_matrix_var" data-index="'+k+'" data-row="'+l+'">'+LocalizedStrings.getUI(new_var.value[l][k])+'</span></td>';
     					} else {
     						ret += '<td><span class="span_value_variable matrix_var" data-index="'+k+'" data-row="'+l+'">'+new_var.value[l][k]+'</span></td>';
     					}
@@ -266,11 +285,13 @@ function renderValues (new_var, variable_container) {
 	});
 	$( variable_container ).find( ".div_valor_var" ).append(ret);
 
+	updateColumnsAndRowsText(variable_container, new_var);
+
 }
 
 function alternateBooleanMatrixValue (var_obj, row, index, value_container) {
 	var_obj.value[row][index] = !var_obj.value[row][index];
-	$(value_container).find('.span_value_variable').text(var_obj.value[row][index]);
+	$(value_container).find('.span_value_variable').text(LocalizedStrings.getUI(var_obj.value[row][index]));
 }
 
 function addLineMatrix (var_obj) {
@@ -382,12 +403,12 @@ function removeColumnVector (var_obj) {
 
 function alternateBooleanValue (var_obj, value_container) {
 	var_obj.value = !var_obj.value;
-	$(value_container).find('.span_value_variable').text(var_obj.value);
+	$(value_container).find('.span_value_variable').text(LocalizedStrings.getUI(var_obj.value));
 }
 
 function alternateBooleanVectorValue (var_obj, index, value_container) {
 	var_obj.value[index] = !var_obj.value[index];
-	$(value_container).find('.span_value_variable').text(var_obj.value[index]);
+	$(value_container).find('.span_value_variable').text(LocalizedStrings.getUI(var_obj.value[index]));
 }
 
 function updateInitialValues (variable_obj) {
@@ -445,152 +466,197 @@ var opened_name_value_vector_global_ = false;
 var opened_input_value_vector_global_ = null;
 function enableVectorValueUpdate (var_obj, index, parent_node) {
 	if (opened_name_value_vector_global_) {
-		$(opened_input_value_vector_global_).focus();
+		opened_input_value_vector_global_.focus();
 		return;
 	}
+	parent_node = $(parent_node);
 	opened_name_value_vector_global_ = true;
 
-	$(parent_node).find('.span_value_variable').text('');
+	parent_node.find('.span_value_variable').text('');
+
+	var input_field;
 
 	if (var_obj.type == Types.REAL) {
-		$( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"
-			+ var_obj.value[index].toFixed(1) + "' />" ).insertBefore($(parent_node).find('.span_value_variable'));
+		input_field = $( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"
+			+ var_obj.value[index].toFixed(1) + "' />" );
+		input_field.insertBefore(parent_node.find('.span_value_variable'));
 	} else {
-		$( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"
-			+ var_obj.value[index] + "' />" ).insertBefore($(parent_node).find('.span_value_variable'));
+		input_field = $( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"
+			+ var_obj.value[index] + "' />" );
+		input_field.insertBefore(parent_node.find('.span_value_variable'));
 	}
 
-	$('.width-dynamic').on('input', function() {
-	    var inputWidth = $(this).textWidth()+10;
-	    opened_input_value_vector_global_ = this;
-	    $(this).focus();
+	input_field.on('input', function() {
+	    var inputWidth = input_field.textWidth()+10;
+	    opened_input_value_vector_global_ = input_field;
+	    input_field.focus();
 
-	    var tmpStr = $(this).val();
-		$(this).val('');
-		$(this).val(tmpStr);
+	    var tmpStr = input_field.val();
+		input_field.val('');
+		input_field.val(tmpStr);
 
-	    $(this).css({
+	    input_field.css({
 	        width: inputWidth
 	    })
 	}).trigger('input');
 
-	$('.width-dynamic').focusout(function() {
+	input_field.focusout(function() {
 		/// update array:
-		if ($(this).val().trim()) {
+		if (input_field.val().trim()) {
 			if (var_obj.type == Types.REAL) {
-				var_obj.value[index] = parseFloat($(this).val().trim());
+				var_obj.value[index] = parseFloat(input_field.val().trim());
 
-				$(parent_node).find('.span_value_variable').text(var_obj.value[index].toFixed(1));
+				parent_node.find('.span_value_variable').text(var_obj.value[index].toFixed(1));
 			} else {
 
 				if (var_obj.type == Types.INTEGER) {
-					var_obj.value[index] = parseInt($(this).val().trim());
+					var_obj.value[index] = parseInt(input_field.val().trim());
 				} else {
-					var_obj.value[index] = $(this).val().trim();
+					var_obj.value[index] = input_field.val().trim();
 				}
 
-				$(parent_node).find('.span_value_variable').text(var_obj.value[index]);
+				parent_node.find('.span_value_variable').text(var_obj.value[index]);
 
 			}
+		} else {
+			if (var_obj.type == Types.REAL) {
+				parent_node.find('.span_value_variable').text(var_obj.value[index].toFixed(1));
+			} else {
+				parent_node.find('.span_value_variable').text(var_obj.value[index]);
+			}
 		}
-		$(this).remove();
+		if (var_obj.type == Types.TEXT) {
+			var_obj.value[index] = input_field.val();
+			parent_node.find('.span_value_variable').text(var_obj.value[index]);
+		}
+		input_field.off();
+		input_field.remove();
 
 		/// update elements:
 		opened_name_value_vector_global_ = false;
 		opened_input_value_vector_global_ = false;
 	});
 
-	$('.width-dynamic').on('keydown', function(e) {
+	input_field.on('keydown', function(e) {
 		var code = e.keyCode || e.which;
 		if(code == 13) {
-			if ($(this).val().trim()) {
+			if (input_field.val().trim()) {
 				if (var_obj.type == Types.REAL) {
-					var_obj.value[index] = parseFloat($(this).val().trim());
+					var_obj.value[index] = parseFloat(input_field.val().trim());
 
-					$(parent_node).find('.span_value_variable').text(var_obj.value[index].toFixed(1));
+					parent_node.find('.span_value_variable').text(var_obj.value[index].toFixed(1));
 				} else {
 
 					if (var_obj.type == Types.INTEGER) {
-						var_obj.value[index] = parseInt($(this).val().trim());
+						var_obj.value[index] = parseInt(input_field.val().trim());
 					} else {
-						var_obj.value[index] = $(this).val().trim();
+						var_obj.value[index] = input_field.val().trim();
 					}
 
-					$(parent_node).find('.span_value_variable').text(var_obj.value[index]);
+					parent_node.find('.span_value_variable').text(var_obj.value[index]);
 
 				}
+			} else {
+				if (var_obj.type == Types.REAL) {
+					parent_node.find('.span_value_variable').text(var_obj.value[index].toFixed(1));
+				} else {
+					parent_node.find('.span_value_variable').text(var_obj.value[index]);
+				}
 			}
-			$(this).remove();
+			if (var_obj.type == Types.TEXT) {
+				var_obj.value[index] = input_field.val();
+				parent_node.find('.span_value_variable').text(var_obj.value[index]);
+			}
+			input_field.off();
+			input_field.remove();
 
 			/// update elements:
 			opened_name_value_vector_global_ = false;
 			opened_input_value_vector_global_ = false;
 		}
 		if(code == 27) {
-			if (global_var.type == Types.REAL) {
-				$(parent_node).find('.span_value_variable').text(var_obj.value[index].toFixed(1));
+			if (var_obj.type == Types.REAL) {
+				parent_node.find('.span_value_variable').text(var_obj.value[index].toFixed(1));
 			} else {
-				$(parent_node).find('.span_value_variable').text(var_obj.value[index]);
+				parent_node.find('.span_value_variable').text(var_obj.value[index]);
 			}
-
-			$(this).remove();
+			input_field.off();
+			input_field.remove();
 
 			/// update elements:
 			opened_name_value_vector_global_ = false;
 			opened_input_value_vector_global_ = false;
 		}
 	});
+
+	input_field.select();
 }
 
 var opened_name_value_global_var = false;
 var opened_input_value_global_ar = null;
 function enableValueUpdate (var_obj, parent_node) {
 	if (opened_name_value_global_var) {
-		$(opened_input_value_global_ar).focus();
+		opened_input_value_global_ar.focus();
 		return;
 	}
+	parent_node = $(parent_node);
 	opened_name_value_global_var = true;
 
-	$(parent_node).find('.span_value_variable').text('');
+	var input_field;
+
+	parent_node.find('.span_value_variable').text('');
 	if (var_obj.type == Types.REAL) {
-		$( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"
-			+ var_obj.value.toFixed(1) + "' />" ).insertBefore($(parent_node).find('.span_value_variable'));
+		input_field = $( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"
+			+ var_obj.value.toFixed(1) + "' />" );
+		input_field.insertBefore(parent_node.find('.span_value_variable'));
 	} else {
-		$( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"
-			+ var_obj.value + "' />" ).insertBefore($(parent_node).find('.span_value_variable'));
+		input_field = $( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"
+			+ var_obj.value + "' />" );
+		input_field.insertBefore(parent_node.find('.span_value_variable'));
 	}
 
-	$('.width-dynamic').on('input', function() {
-	    var inputWidth = $(this).textWidth()+10;
-	    opened_input_value_global_ar = this;
-	    $(this).focus();
+	input_field.on('input', function() {
+	    var inputWidth = input_field.textWidth()+10;
+	    opened_input_value_global_ar = input_field;
+	    input_field.focus();
 
-	    var tmpStr = $(this).val();
-		$(this).val('');
-		$(this).val(tmpStr);
+	    var tmpStr = input_field.val();
+		input_field.val('');
+		input_field.val(tmpStr);
 
-	    $(this).css({
+	    input_field.css({
 	        width: inputWidth
 	    })
 	}).trigger('input');
 
-	$('.width-dynamic').focusout(function() {
+	input_field.focusout(function() {
 		/// update array:
-		if ($(this).val().trim()) {
+		if (input_field.val().trim()) {
 			if (var_obj.type == Types.REAL) {
-				var_obj.value = parseFloat($(this).val().trim());
-				$(parent_node).find('.span_value_variable').text(var_obj.value.toFixed(1));
+				var_obj.value = parseFloat(input_field.val().trim());
+				parent_node.find('.span_value_variable').text(var_obj.value.toFixed(1));
 			} else{
 				if (var_obj.type == Types.INTEGER) {
-					var_obj.value = parseInt($(this).val().trim());
+					var_obj.value = parseInt(input_field.val().trim());
 				} else {
-					var_obj.value = $(this).val().trim();
+					var_obj.value = input_field.val().trim();
 				}
-				$(parent_node).find('.span_value_variable').text(var_obj.value);
+				parent_node.find('.span_value_variable').text(var_obj.value);
 				
 			}
+		} else {
+			if (var_obj.type == Types.REAL) {
+				parent_node.find('.span_value_variable').text(var_obj.value.toFixed(1));
+			} else {
+				parent_node.find('.span_value_variable').text(var_obj.value);
+			}
+		}
+		if (var_obj.type == Types.TEXT) {
+			var_obj.value = input_field.val();
+			parent_node.find('.span_value_variable').text(var_obj.value);
 		}
-		$(this).remove();
+		input_field.off();
+		input_field.remove();
 
 		/// update elements:
 		opened_name_value_global_var = false;
@@ -598,23 +664,34 @@ function enableValueUpdate (var_obj, parent_node) {
 
 	});
 
-	$('.width-dynamic').on('keydown', function(e) {
+	input_field.on('keydown', function(e) {
 		var code = e.keyCode || e.which;
 		if(code == 13) {
-			if ($(this).val().trim()) {
+			if (input_field.val().trim()) {
 				if (var_obj.type == Types.REAL) {
-					var_obj.value = parseFloat($(this).val().trim());
-					$(parent_node).find('.span_value_variable').text(var_obj.value.toFixed(1));
+					var_obj.value = parseFloat(input_field.val().trim());
+					parent_node.find('.span_value_variable').text(var_obj.value.toFixed(1));
 				} else{
 					if (var_obj.type == Types.INTEGER) {
-						var_obj.value = parseInt($(this).val().trim());
+						var_obj.value = parseInt(input_field.val().trim());
 					} else {
-						var_obj.value = $(this).val().trim();
+						var_obj.value = input_field.val().trim();
 					}
-					$(parent_node).find('.span_value_variable').text(var_obj.value);
+					parent_node.find('.span_value_variable').text(var_obj.value);
 				}
+			} else {
+				if (var_obj.type == Types.REAL) {
+					parent_node.find('.span_value_variable').text(var_obj.value.toFixed(1));
+				} else {
+					parent_node.find('.span_value_variable').text(var_obj.value);
+				}
+			}
+			if (var_obj.type == Types.TEXT) {
+				var_obj.value = input_field.val();
+				parent_node.find('.span_value_variable').text(var_obj.value);
 			}
-			$(this).remove();
+			input_field.off();
+			input_field.remove();
 
 			/// update elements:
 			opened_name_value_global_var = false;
@@ -623,18 +700,20 @@ function enableValueUpdate (var_obj, parent_node) {
 		}
 		if(code == 27) {
 			if (var_obj.type == Types.REAL) {
-				$(parent_node).find('.span_value_variable').text(var_obj.value.toFixed(1));
+				parent_node.find('.span_value_variable').text(var_obj.value.toFixed(1));
 			} else{
-				$(parent_node).find('.span_value_variable').text(var_obj.value);
+				parent_node.find('.span_value_variable').text(var_obj.value);
 			}
-
-			$(this).remove();
+			input_field.off();
+			input_field.remove();
 
 			/// update elements:
 			opened_name_value_global_var = false;
 			opened_input_value_global_ar = false;
 		}
 	});
+
+	input_field.select();
 }
 
 var opened_name_global = false;
@@ -642,49 +721,59 @@ var opened_input_global = null;
 function enableNameUpdate (variable_obj, variable_container) {
 
 	if (opened_name_global) {
-		$(opened_input_global).focus();
+		opened_input_global.focus();
 		return;
 	}
 	opened_name_global = true;
 
-	$( variable_container ).find('.span_name_variable').text('');
-	$( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"+variable_obj.name+"' />" ).insertBefore($(variable_container).find('.span_name_variable'));
+	variable_container.find('.span_name_variable').text('');
+
+	var input_name;
 
-	$('.width-dynamic').on('input', function() {
-	    var inputWidth = $(this).textWidth()+10;
-	    opened_input_global = this;
-	    $(this).focus();
+	input_name = $( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"+variable_obj.name+"' />" );
+	input_name.insertBefore(variable_container.find('.span_name_variable'));
 
-	    var tmpStr = $(this).val();
-		$(this).val('');
-		$(this).val(tmpStr);
+	input_name.on('input', function() {
+	    var inputWidth = input_name.textWidth()+10;
+	    opened_input_global = input_name;
+	    input_name.focus();
 
-	    $(this).css({
+	    var tmpStr = input_name.val();
+		input_name.val('');
+		input_name.val(tmpStr);
+
+	    input_name.css({
 	        width: inputWidth
 	    })
 	}).trigger('input');
 
-	$('.width-dynamic').focusout(function() {
+	input_name.focusout(function() {
 		/// update array:
-		if ($(this).val().trim()) {
-			updateName(variable_obj, $(this).val().trim());
-			$(variable_container).find('.span_name_variable').text(variable_obj.name);
+		if (input_name.val().trim().length > 0) {
+			updateName(variable_obj, input_name.val().trim());
+			variable_container.find('.span_name_variable').text(variable_obj.name);
+		} else {
+			variable_container.find('.span_name_variable').text(variable_obj.name);
 		}
-		$(this).remove();
+		input_name.off();
+		input_name.remove();
 
 		/// update elements:
 		opened_name_global = false;
 		opened_input_global = false;
 	});
 
-	$('.width-dynamic').on('keydown', function(e) {
+	input_name.on('keydown', function(e) {
 		var code = e.keyCode || e.which;
 		if(code == 13) {
-			if ($(this).val().trim()) {
-				updateName(variable_obj, $(this).val().trim());
-				$(variable_container).find('.span_name_variable').text(variable_obj.name);
+			if (input_name.val().trim().length > 0) {
+				updateName(variable_obj, input_name.val().trim());
+				variable_container.find('.span_name_variable').text(variable_obj.name);
+			} else {
+				variable_container.find('.span_name_variable').text(variable_obj.name);
 			}
-			$(this).remove();
+			input_name.off();
+			input_name.remove();
 
 			/// update elements:
 			opened_name_global = false;
@@ -692,15 +781,17 @@ function enableNameUpdate (variable_obj, variable_container) {
 		}
 		if(code == 27) {
 
-			$(variable_container).find('.span_name_variable').text(variable_obj.name);
-
-			$(this).remove();
+			variable_container.find('.span_name_variable').text(variable_obj.name);
+			input_name.off();
+			input_name.remove();
 
 			/// update elements:
 			opened_name_global = false;
 			opened_input_global = false;
 		}
 	});
+
+	input_name.select();
 	
 }
 
@@ -709,76 +800,103 @@ var opened_name_value_matrix_global_v = false;
 var opened_input_value_matrix_global_v = null;
 function enableMatrixValueUpdate (var_obj, row, index, parent_node) {
 	if (opened_name_value_matrix_global_v) {
-		$(opened_input_value_matrix_global_v).focus();
+		opened_input_value_matrix_global_v.focus();
 		return;
 	}
+	parent_node = $(parent_node);
 	opened_name_value_matrix_global_v = true;
 
-	$(parent_node).find('.span_value_variable').text('');
+	parent_node.find('.span_value_variable').text('');
+
+	var input_field;
 
 	if (var_obj.type == Types.REAL) {
-		$( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"
-			+ var_obj.value[row][index].toFixed(1) + "' />" ).insertBefore($(parent_node).find('.span_value_variable'));
+		input_field = $( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"
+			+ var_obj.value[row][index].toFixed(1) + "' />" );
+		input_field.insertBefore(parent_node.find('.span_value_variable'));
 	} else {
-		$( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"
-			+ var_obj.value[row][index] + "' />" ).insertBefore($(parent_node).find('.span_value_variable'));
+		input_field = $( "<input type='text' class='width-dynamic input_name_function' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' value='"
+			+ var_obj.value[row][index] + "' />" );
+		input_field.insertBefore(parent_node.find('.span_value_variable'));
 	}
 
-	$('.width-dynamic').on('input', function() {
-	    var inputWidth = $(this).textWidth()+10;
-	    opened_input_value_matrix_global_v = this;
-	    $(this).focus();
+	input_field.on('input', function() {
+	    var inputWidth = input_field.textWidth()+10;
+	    opened_input_value_matrix_global_v = input_field;
+	    input_field.focus();
 
-	    var tmpStr = $(this).val();
-		$(this).val('');
-		$(this).val(tmpStr);
+	    var tmpStr = input_field.val();
+		input_field.val('');
+		input_field.val(tmpStr);
 
-	    $(this).css({
+	    input_field.css({
 	        width: inputWidth
 	    })
 	}).trigger('input');
 
-	$('.width-dynamic').focusout(function() {
+	input_field.focusout(function() {
 		/// update array:
-		if ($(this).val().trim()) {
+		if (input_field.val().trim()) {
 			if (var_obj.type == Types.REAL) {
-				var_obj.value[row][index] = parseFloat($(this).val().trim());
+				var_obj.value[row][index] = parseFloat(input_field.val().trim());
 
-				$(parent_node).find('.span_value_variable').text(var_obj.value[row][index].toFixed(1));
+				parent_node.find('.span_value_variable').text(var_obj.value[row][index].toFixed(1));
 			} else {
 				if (var_obj.type == Types.INTEGER) {
-					var_obj.value[row][index] = parseInt($(this).val().trim());
+					var_obj.value[row][index] = parseInt(input_field.val().trim());
 				} else {
-					var_obj.value[row][index] = $(this).val().trim();
+					var_obj.value[row][index] = input_field.val().trim();
 				}
-				$(parent_node).find('.span_value_variable').text(var_obj.value[row][index]);
+				parent_node.find('.span_value_variable').text(var_obj.value[row][index]);
 			}
+		} else {
+			if (var_obj.type == Types.REAL) {
+				parent_node.find('.span_value_variable').text(var_obj.value[row][index].toFixed(1));
+			} else {
+				parent_node.find('.span_value_variable').text(var_obj.value[row][index]);
+			}
+		}
+		if (var_obj.type == Types.TEXT) {
+			var_obj.value[row][index] = input_field.val();
+			parent_node.find('.span_value_variable').text(var_obj.value[row][index]);
 		}
-		$(this).remove();
+		input_field.off();
+		input_field.remove();
 
 		/// update elements:
 		opened_name_value_matrix_global_v = false;
 		opened_input_value_matrix_global_v = false;
 	});
 
-	$('.width-dynamic').on('keydown', function(e) {
+	input_field.on('keydown', function(e) {
 		var code = e.keyCode || e.which;
 		if(code == 13) {
-			if ($(this).val().trim()) {
+			if (input_field.val().trim()) {
 				if (var_obj.type == Types.REAL) {
-					var_obj.value[row][index] = parseFloat($(this).val().trim());
+					var_obj.value[row][index] = parseFloat(input_field.val().trim());
 
-					$(parent_node).find('.span_value_variable').text(var_obj.value[row][index].toFixed(1));
+					parent_node.find('.span_value_variable').text(var_obj.value[row][index].toFixed(1));
 				} else {
 					if (var_obj.type == Types.INTEGER) {
-						var_obj.value[row][index] = parseInt($(this).val().trim());
+						var_obj.value[row][index] = parseInt(input_field.val().trim());
 					} else {
-						var_obj.value[row][index] = $(this).val().trim();
+						var_obj.value[row][index] = input_field.val().trim();
 					}
-					$(parent_node).find('.span_value_variable').text(var_obj.value[row][index]);
+					parent_node.find('.span_value_variable').text(var_obj.value[row][index]);
+				}
+			} else {
+				if (var_obj.type == Types.REAL) {
+					parent_node.find('.span_value_variable').text(var_obj.value[row][index].toFixed(1));
+				} else {
+					parent_node.find('.span_value_variable').text(var_obj.value[row][index]);
 				}
 			}
-			$(this).remove();
+			if (var_obj.type == Types.TEXT) {
+				var_obj.value[row][index] = input_field.val();
+				parent_node.find('.span_value_variable').text(var_obj.value[row][index]);
+			}
+			input_field.off();
+			input_field.remove();
 
 			/// update elements:
 			opened_name_value_matrix_global_v = false;
@@ -786,16 +904,18 @@ function enableMatrixValueUpdate (var_obj, row, index, parent_node) {
 		}
 		if(code == 27) {
 			if (var_obj.type == Types.REAL) {
-				$(parent_node).find('.span_value_variable').text(var_obj.value[row][index].toFixed(1));
+				parent_node.find('.span_value_variable').text(var_obj.value[row][index].toFixed(1));
 			} else {
-				$(parent_node).find('.span_value_variable').text(var_obj.value[row][index]);
+				parent_node.find('.span_value_variable').text(var_obj.value[row][index]);
 			}
-
-			$(this).remove();
+			input_field.off();
+			input_field.remove();
 
 			/// update elements:
 			opened_name_value_matrix_global_v = false;
 			opened_input_value_matrix_global_v = false;
 		}
 	});
+
+	input_field.select();
 }