|
@@ -26,6 +26,7 @@ window.studentGrade = null;
|
|
|
const program = new Models.Program();
|
|
|
|
|
|
window.system_functions = [];
|
|
|
+
|
|
|
window.system_functions.push(new Models.SystemFunction('$sin', Types.REAL, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)],
|
|
|
null, Models.SYSTEM_FUNCTIONS_CATEGORIES.math));
|
|
|
window.system_functions.push(new Models.SystemFunction('$cos', Types.REAL, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)],
|
|
@@ -48,6 +49,40 @@ window.system_functions.push(new Models.SystemFunction('$max', Types.REAL, 0, [n
|
|
|
null, Models.SYSTEM_FUNCTIONS_CATEGORIES.math));
|
|
|
window.system_functions.push(new Models.SystemFunction('$min', Types.REAL, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)],
|
|
|
null, Models.SYSTEM_FUNCTIONS_CATEGORIES.math));
|
|
|
+
|
|
|
+window.system_functions.push(new Models.SystemFunction('$substring', Types.TEXT, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true),
|
|
|
+new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true), new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)],
|
|
|
+ null, Models.SYSTEM_FUNCTIONS_CATEGORIES.text));
|
|
|
+window.system_functions.push(new Models.SystemFunction('$length', Types.INTEGER, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)],
|
|
|
+ null, Models.SYSTEM_FUNCTIONS_CATEGORIES.text));
|
|
|
+window.system_functions.push(new Models.SystemFunction('$uppercase', Types.TEXT, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)],
|
|
|
+ null, Models.SYSTEM_FUNCTIONS_CATEGORIES.text));
|
|
|
+window.system_functions.push(new Models.SystemFunction('$lowercase', Types.TEXT, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)],
|
|
|
+ null, Models.SYSTEM_FUNCTIONS_CATEGORIES.text));
|
|
|
+window.system_functions.push(new Models.SystemFunction('$charAt', Types.TEXT, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true), new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)],
|
|
|
+ null, Models.SYSTEM_FUNCTIONS_CATEGORIES.text));
|
|
|
+
|
|
|
+window.system_functions.push(new Models.SystemFunction('$numElements', Types.INTEGER, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)],
|
|
|
+ null, Models.SYSTEM_FUNCTIONS_CATEGORIES.arrangement));
|
|
|
+window.system_functions.push(new Models.SystemFunction('$matrixLines', Types.INTEGER, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)],
|
|
|
+ null, Models.SYSTEM_FUNCTIONS_CATEGORIES.arrangement));
|
|
|
+window.system_functions.push(new Models.SystemFunction('$matrixColumns', Types.INTEGER, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)],
|
|
|
+ null, Models.SYSTEM_FUNCTIONS_CATEGORIES.arrangement));
|
|
|
+
|
|
|
+window.system_functions.push(new Models.SystemFunction('$isReal', Types.BOOLEAN, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)],
|
|
|
+ null, Models.SYSTEM_FUNCTIONS_CATEGORIES.conversion));
|
|
|
+window.system_functions.push(new Models.SystemFunction('$isInt', Types.BOOLEAN, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)],
|
|
|
+ null, Models.SYSTEM_FUNCTIONS_CATEGORIES.conversion));
|
|
|
+window.system_functions.push(new Models.SystemFunction('$isBool', Types.BOOLEAN, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)],
|
|
|
+ null, Models.SYSTEM_FUNCTIONS_CATEGORIES.conversion));
|
|
|
+window.system_functions.push(new Models.SystemFunction('$castReal', Types.REAL, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)],
|
|
|
+ null, Models.SYSTEM_FUNCTIONS_CATEGORIES.conversion));
|
|
|
+window.system_functions.push(new Models.SystemFunction('$castInt', Types.INTEGER, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)],
|
|
|
+ null, Models.SYSTEM_FUNCTIONS_CATEGORIES.conversion));
|
|
|
+window.system_functions.push(new Models.SystemFunction('$castBool', Types.BOOLEAN, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)],
|
|
|
+ null, Models.SYSTEM_FUNCTIONS_CATEGORIES.conversion));
|
|
|
+window.system_functions.push(new Models.SystemFunction('$castString', Types.TEXT, 0, [new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.all, null, null, null, true)],
|
|
|
+ null, Models.SYSTEM_FUNCTIONS_CATEGORIES.conversion));
|
|
|
|
|
|
const parameter1 = new Models.Variable(Types.INTEGER, "par_1", 1);
|
|
|
const command1 = new Models.Comment(new Models.VariableValueMenu(VariableValueMenu.VAR_OR_VALUE_TYPES.only_value, "Testing rendering commands"));
|
|
@@ -69,74 +104,100 @@ window.program_obj = program;
|
|
|
window.generator = CodeManagement.generate;
|
|
|
window.runCodeAssessment = runCodeAssessment;
|
|
|
window.renderAlgorithm = AlgorithmManagement.renderAlgorithm;
|
|
|
+window.insertContext = false;
|
|
|
+window.watchW = WatchJS;
|
|
|
|
|
|
-WatchJS.watch(program.globals, function(){
|
|
|
- AlgorithmManagement.renderAlgorithm();
|
|
|
+WatchJS.watch(window.program_obj.globals, function () {
|
|
|
+ if (window.insertContext) {
|
|
|
+ setTimeout(function () { AlgorithmManagement.renderAlgorithm(); }, 300);
|
|
|
+ window.insertContext = false;
|
|
|
+ } else {
|
|
|
+ AlgorithmManagement.renderAlgorithm();
|
|
|
+ }
|
|
|
+}, 1);
|
|
|
+
|
|
|
+WatchJS.watch(window.program_obj.functions, function () {
|
|
|
+ if (window.insertContext) {
|
|
|
+ setTimeout(function () { AlgorithmManagement.renderAlgorithm(); }, 300);
|
|
|
+ window.insertContext = false;
|
|
|
+ } else {
|
|
|
+ AlgorithmManagement.renderAlgorithm();
|
|
|
+ }
|
|
|
}, 1);
|
|
|
|
|
|
-function addFunctionHandler () {
|
|
|
+function addFunctionHandler() {
|
|
|
|
|
|
- var new_function = new Models.Function(LocalizedStrings.getUI("new_function") + "_" + counter_new_functions, Types.VOID, 0, [], false, false, [], new Models.Comment(LocalizedStrings.getUI('text_comment_start')));
|
|
|
- program.addFunction(new_function);
|
|
|
+ var new_function = new Models.Function(LocalizedStrings.getUI("new_function") + "_" + counter_new_functions, Types.VOID, 0, [], false, false, [], new Models.Comment(LocalizedStrings.getUI('text_comment_start')));
|
|
|
+ program.addFunction(new_function);
|
|
|
|
|
|
- counter_new_functions ++;
|
|
|
+ counter_new_functions++;
|
|
|
|
|
|
- renderFunction(new_function);
|
|
|
+ window.insertContext = true;
|
|
|
+
|
|
|
+ var newe = renderFunction(new_function);
|
|
|
+
|
|
|
+ newe.css('display', 'none');
|
|
|
+ newe.fadeIn();
|
|
|
}
|
|
|
|
|
|
-function addParameter (function_obj, function_container) {
|
|
|
+function addParameter(function_obj, function_container, is_from_click = false) {
|
|
|
if (function_obj.parameters_list == null) {
|
|
|
function_obj.parameters_list = [];
|
|
|
}
|
|
|
var new_parameter = new Models.Variable(Types.INTEGER, LocalizedStrings.getUI("new_parameter") + "_" + counter_new_parameters);
|
|
|
function_obj.parameters_list.push(new_parameter);
|
|
|
- counter_new_parameters ++;
|
|
|
+ counter_new_parameters++;
|
|
|
+
|
|
|
+ var newe = renderParameter(function_obj, new_parameter, function_container);
|
|
|
|
|
|
- renderParameter(function_obj, new_parameter, function_container);
|
|
|
+ if (is_from_click) {
|
|
|
+ newe.css('display', 'none');
|
|
|
+ newe.fadeIn();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-function updateReturnType (function_obj, new_type, new_dimensions = 0) {
|
|
|
+function updateReturnType(function_obj, new_type, new_dimensions = 0) {
|
|
|
function_obj.return_type = new_type;
|
|
|
function_obj.return_dimensions = new_dimensions;
|
|
|
}
|
|
|
|
|
|
-function removeFunction (function_obj) {
|
|
|
-
|
|
|
+function removeFunction(function_obj) {
|
|
|
var index = program.functions.indexOf(function_obj);
|
|
|
if (index > -1) {
|
|
|
program.functions.splice(index, 1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function minimizeFunction (function_obj) {
|
|
|
+function minimizeFunction(function_obj) {
|
|
|
function_obj.is_hidden = !function_obj.is_hidden;
|
|
|
}
|
|
|
|
|
|
-function addHandlers (function_obj, function_container) {
|
|
|
+function addHandlers(function_obj, function_container) {
|
|
|
|
|
|
function_container.find('.ui.dropdown.function_return').dropdown({
|
|
|
- onChange: function(value, text, $selectedItem) {
|
|
|
- if ($selectedItem.data('dimensions')) {
|
|
|
- updateReturnType(function_obj, Types[$selectedItem.data('type')], $selectedItem.data('dimensions'));
|
|
|
- } else {
|
|
|
- updateReturnType(function_obj, Types[$selectedItem.data('type')]);
|
|
|
- }
|
|
|
+ onChange: function (value, text, $selectedItem) {
|
|
|
+ if ($selectedItem.data('dimensions')) {
|
|
|
+ updateReturnType(function_obj, Types[$selectedItem.data('type')], $selectedItem.data('dimensions'));
|
|
|
+ } else {
|
|
|
+ updateReturnType(function_obj, Types[$selectedItem.data('type')]);
|
|
|
}
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
- function_container.find( ".name_function_updated" ).on('click', function(e){
|
|
|
+ function_container.find(".name_function_updated").on('click', function (e) {
|
|
|
enableNameFunctionUpdate(function_obj, function_container);
|
|
|
});
|
|
|
|
|
|
- function_container.find( ".add_parameter_button" ).on('click', function(e){
|
|
|
- addParameter(function_obj, function_container);
|
|
|
+ function_container.find(".add_parameter_button").on('click', function (e) {
|
|
|
+ window.insertContext = true;
|
|
|
+ addParameter(function_obj, function_container, true);
|
|
|
});
|
|
|
|
|
|
function_container.find('.menu_commands').dropdown({
|
|
|
- on: 'hover'
|
|
|
- });
|
|
|
+ on: 'hover'
|
|
|
+ });
|
|
|
|
|
|
- function_container.find('.menu_commands a').on('click', function(evt){
|
|
|
+ function_container.find('.menu_commands a').on('click', function (evt) {
|
|
|
if (function_obj.commands == null || function_obj.commands.length == 0) {
|
|
|
function_obj.commands = [];
|
|
|
var new_cmd = CommandsManagement.genericCreateCommand($(this).data('command'));
|
|
@@ -149,122 +210,127 @@ function addHandlers (function_obj, function_container) {
|
|
|
|
|
|
});
|
|
|
|
|
|
- function_container.find('.add_var_button_function').on('click', function(e){
|
|
|
- VariablesManagement.addVariable(function_obj, function_container);
|
|
|
+ function_container.find('.add_var_button_function').on('click', function (e) {
|
|
|
+ window.insertContext = true;
|
|
|
+ VariablesManagement.addVariable(function_obj, function_container, true);
|
|
|
});
|
|
|
|
|
|
- function_container.find('.remove_function_button').on('click', function(e){
|
|
|
+ function_container.find('.remove_function_button').on('click', function (e) {
|
|
|
removeFunction(function_obj);
|
|
|
- function_container.slideUp(400);
|
|
|
+ function_container.fadeOut();
|
|
|
});
|
|
|
|
|
|
- function_container.find('.minimize_function_button').on('click', function(e){
|
|
|
+ function_container.find('.minimize_function_button').on('click', function (e) {
|
|
|
minimizeFunction(function_obj);
|
|
|
- function_container.find(".function_area").toggle();
|
|
|
- function_container.find(".add_var_top_button").toggle();
|
|
|
+ if (function_obj.is_hidden) {
|
|
|
+ function_container.find(".add_var_button_function").toggle();
|
|
|
+ function_container.find(".inline_add_command").toggle();
|
|
|
+ function_container.find(".function_area").slideToggle();
|
|
|
+ } else {
|
|
|
+ function_container.find(".function_area").slideToggle(function () {
|
|
|
+ function_container.find(".add_var_button_function").toggle();
|
|
|
+ function_container.find(".inline_add_command").toggle();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
});
|
|
|
}
|
|
|
|
|
|
|
|
|
-function renderFunctionReturn (function_obj, function_element) {
|
|
|
+function renderFunctionReturn(function_obj, function_element) {
|
|
|
|
|
|
var ret = '<div class="ui dropdown function_return">';
|
|
|
-
|
|
|
- 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>';
|
|
|
+
|
|
|
+ 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 += '<div class="text">'+LocalizedStrings.getUI(function_obj.return_type)+'</div>';
|
|
|
+ ret += ' [ ] [ ] ';
|
|
|
}
|
|
|
+ ret += '</div>';
|
|
|
+ } else {
|
|
|
+ ret += '<div class="text">' + LocalizedStrings.getUI(function_obj.return_type) + '</div>';
|
|
|
+ }
|
|
|
|
|
|
- ret += '<div class="menu">';
|
|
|
+ ret += '<div class="menu">';
|
|
|
|
|
|
|
|
|
- for (var tm in Types) {
|
|
|
- ret += '<div class="item ' + (function_obj.return_type == tm.toLowerCase() && function_obj.return_dimensions < 1 ? ' selected ' : '') + '" data-type="'+tm+'" >'+LocalizedStrings.getUI(tm.toLowerCase())+'</div>';
|
|
|
- }
|
|
|
+ for (var tm in Types) {
|
|
|
+ ret += '<div class="item ' + (function_obj.return_type == tm.toLowerCase() && function_obj.return_dimensions < 1 ? ' selected ' : '') + '" data-type="' + tm + '" >' + LocalizedStrings.getUI(tm.toLowerCase()) + '</div>';
|
|
|
+ }
|
|
|
|
|
|
- for (var tm in Types) {
|
|
|
- if (tm == Types.VOID.toUpperCase()) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- ret += '<div class="item">'
|
|
|
- + '<i class="dropdown icon"></i>'
|
|
|
- + LocalizedStrings.getUI('vector')+':'+LocalizedStrings.getUI(tm.toLowerCase())
|
|
|
- + '<div class="menu">'
|
|
|
- + '<div class="item '+(function_obj.return_type == tm.toLowerCase() && function_obj.return_dimensions > 0 ? ' selected ' : '')+'" data-text="'+ LocalizedStrings.getUI('vector')+':'+LocalizedStrings.getUI(tm.toLowerCase())+' [ ] " data-type="'+tm+'" data-dimensions="1">[ ]</div>'
|
|
|
- + '<div class="item '+(function_obj.return_type == tm.toLowerCase() && function_obj.return_dimensions > 0 ? ' selected ' : '')+'" data-text="'+ LocalizedStrings.getUI('vector')+':'+LocalizedStrings.getUI(tm.toLowerCase())+' [ ] [ ] " data-type="'+tm+'" data-dimensions="2">[ ] [ ] </div>'
|
|
|
- + '</div>'
|
|
|
- + '</div>';
|
|
|
+ for (var tm in Types) {
|
|
|
+ if (tm == Types.VOID.toUpperCase()) {
|
|
|
+ continue;
|
|
|
}
|
|
|
+ ret += '<div class="item">'
|
|
|
+ + '<i class="dropdown icon"></i>'
|
|
|
+ + LocalizedStrings.getUI('vector') + ':' + LocalizedStrings.getUI(tm.toLowerCase())
|
|
|
+ + '<div class="menu">'
|
|
|
+ + '<div class="item ' + (function_obj.return_type == tm.toLowerCase() && function_obj.return_dimensions > 0 ? ' selected ' : '') + '" data-text="' + LocalizedStrings.getUI('vector') + ':' + LocalizedStrings.getUI(tm.toLowerCase()) + ' [ ] " data-type="' + tm + '" data-dimensions="1">[ ]</div>'
|
|
|
+ + '<div class="item ' + (function_obj.return_type == tm.toLowerCase() && function_obj.return_dimensions > 0 ? ' selected ' : '') + '" data-text="' + LocalizedStrings.getUI('vector') + ':' + LocalizedStrings.getUI(tm.toLowerCase()) + ' [ ] [ ] " data-type="' + tm + '" data-dimensions="2">[ ] [ ] </div>'
|
|
|
+ + '</div>'
|
|
|
+ + '</div>';
|
|
|
+ }
|
|
|
|
|
|
- ret += '</div></div>';
|
|
|
+ ret += '</div></div>';
|
|
|
+
|
|
|
+ ret = $(ret);
|
|
|
|
|
|
- ret = $(ret);
|
|
|
-
|
|
|
- function_element.find('.function_return').append(ret);
|
|
|
+ function_element.find('.function_return').append(ret);
|
|
|
}
|
|
|
|
|
|
|
|
|
-export function renderFunction (function_obj) {
|
|
|
+export function renderFunction(function_obj) {
|
|
|
|
|
|
var appender = '<div class="ui secondary segment function_div list-group-item">';
|
|
|
|
|
|
if (function_obj.function_comment) {
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
appender += '<span class="glyphicon glyphicon-move move_function" aria-hidden="true"><i class="icon sort alternate vertical"></i></span>';
|
|
|
|
|
|
appender += (function_obj.is_main ? '<div class="div_start_minimize_v"> </div>' : '<button class="ui icon button large remove_function_button"><i class="red icon times"></i></button>')
|
|
|
+ '<button class="ui icon button tiny minimize_function_button"><i class="icon window minimize"></i></button>';
|
|
|
|
|
|
- appender += '<div class="ui small icon buttons add_var_top_button"><div class="ui icon button add_var_button_function"><i class="icon superscript"></i></div>';
|
|
|
-
|
|
|
- appender += '<div class="ui icon button dropdown menu_commands" ><i class="icon code"></i> <div class="menu"> ';
|
|
|
- appender += '<a class="item" data-command="'+Models.COMMAND_TYPES.reader+'"><i class="download icon"></i> ' +LocalizedStrings.getUI('text_read_var')+ '</a>'
|
|
|
- + '<a class="item" data-command="'+Models.COMMAND_TYPES.writer+'"><i class="upload icon"></i> '+LocalizedStrings.getUI('text_write_var')+'</a>'
|
|
|
- + '<a class="item" data-command="'+Models.COMMAND_TYPES.comment+'"><i class="quote left icon"></i> '+LocalizedStrings.getUI('text_comment')+'</a>'
|
|
|
- + '<a class="item" data-command="'+Models.COMMAND_TYPES.attribution+'"><i class="arrow left icon"></i> '+LocalizedStrings.getUI('text_attribution')+'</a>'
|
|
|
- + '<a class="item" data-command="'+Models.COMMAND_TYPES.functioncall+'"><i class="hand point right icon"></i> '+LocalizedStrings.getUI('text_functioncall')+'</a>'
|
|
|
- + '<a class="item" data-command="'+Models.COMMAND_TYPES.iftrue+'" ><i class="random icon"></i> '+LocalizedStrings.getUI('text_iftrue')+'</a>'
|
|
|
- + '<a class="item" data-command="'+Models.COMMAND_TYPES.repeatNtimes+'"><i class="sync icon"></i> '+LocalizedStrings.getUI('text_repeatNtimes')+'</a>'
|
|
|
- + '<a class="item" data-command="'+Models.COMMAND_TYPES.whiletrue+'"><i class="sync icon"></i> '+LocalizedStrings.getUI('text_whiletrue')+'</a>'
|
|
|
- + '<a class="item" data-command="'+Models.COMMAND_TYPES.dowhiletrue+'"><i class="sync icon"></i> '+LocalizedStrings.getUI('text_dowhiletrue')+'</a>'
|
|
|
- + '<a class="item" data-command="'+Models.COMMAND_TYPES.switch+'"><i class="list icon"></i> '+LocalizedStrings.getUI('text_switch')+'</a>'
|
|
|
- + '<a class="item" data-command="'+Models.COMMAND_TYPES.return+'"><i class="reply icon"></i> '+LocalizedStrings.getUI('text_btn_return')+'</a>'
|
|
|
- + '</div></div></div>';
|
|
|
-
|
|
|
- appender += '<div class="function_signature_div">'+LocalizedStrings.getUI("function")+' ';
|
|
|
+ appender += '<div class="function_signature_div">' + LocalizedStrings.getUI("function") + ' ';
|
|
|
|
|
|
if (function_obj.is_main) {
|
|
|
- appender += '<div class="function_name_div"> ' + LocalizedStrings.getUI('void') + ' <span class="span_name_function" >'+function_obj.name+'</span> </div> '
|
|
|
- + ' <span class="parethesis_function">( </span> <div class="ui large labels parameters_list">';
|
|
|
+ appender += '<div class="function_name_div"> ' + LocalizedStrings.getUI('void') + ' <span class="span_name_function" >' + function_obj.name + '</span> </div> '
|
|
|
+ + ' <span class="parethesis_function">( </span> <div class="ui large labels parameters_list">';
|
|
|
} else {
|
|
|
- appender += '<div class="ui function_return"></div>';
|
|
|
+ appender += '<div class="ui function_return"></div>';
|
|
|
|
|
|
- appender += '<div class="function_name_div function_name_div_updated"><span class="span_name_function name_function_updated">'+function_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 class="function_name_div function_name_div_updated"><span class="span_name_function name_function_updated">' + function_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> <span class="parethesis_function"> ) </span> </div>'
|
|
|
- + (function_obj.is_hidden ? ' <div class="function_area" style="display: none;"> ' : ' <div class="function_area"> ')
|
|
|
+ + (function_obj.is_hidden ? ' <div class="function_area" style="display: none;"> ' : ' <div class="function_area"> ');
|
|
|
+
|
|
|
+ appender += '<div class="ui add_var_context add_var_button_function" style="float: left;"><i class="icon plus circle purple"></i><i class="icon circle white back"></i><div class="ui icon button purple"><i class="icon superscript"></i></div></div>';
|
|
|
|
|
|
- + '<div class="ui top attached segment variables_list_div">'
|
|
|
- + '</div>'
|
|
|
+ appender += '<div class="ui top attached segment variables_list_div"></div>';
|
|
|
|
|
|
- + '<div class="ui bottom attached segment commands_list_div" id="function_drag_cmd_">';
|
|
|
+ appender += '<div class="ui inline_add_command"><i class="icon plus circle purple"></i><i class="icon circle white back"></i><div class="ui icon button dropdown menu_commands orange" style="float: left;" ><i class="icon code"></i> <div class="menu"> ';
|
|
|
+ appender += '<a class="item" data-command="' + Models.COMMAND_TYPES.reader + '"><i class="download icon"></i> ' + LocalizedStrings.getUI('text_read_var') + '</a>'
|
|
|
+ + '<a class="item" data-command="' + Models.COMMAND_TYPES.writer + '"><i class="upload icon"></i> ' + LocalizedStrings.getUI('text_write_var') + '</a>'
|
|
|
+ + '<a class="item" data-command="' + Models.COMMAND_TYPES.comment + '"><i class="quote left icon"></i> ' + LocalizedStrings.getUI('text_comment') + '</a>'
|
|
|
+ + '<a class="item" data-command="' + Models.COMMAND_TYPES.attribution + '"><i class="arrow left icon"></i> ' + LocalizedStrings.getUI('text_attribution') + '</a>'
|
|
|
+ + '<a class="item" data-command="' + Models.COMMAND_TYPES.functioncall + '"><i class="hand point right icon"></i> ' + LocalizedStrings.getUI('text_functioncall') + '</a>'
|
|
|
+ + '<a class="item" data-command="' + Models.COMMAND_TYPES.iftrue + '" ><i class="random icon"></i> ' + LocalizedStrings.getUI('text_iftrue') + '</a>'
|
|
|
+ + '<a class="item" data-command="' + Models.COMMAND_TYPES.repeatNtimes + '"><i class="sync icon"></i> ' + LocalizedStrings.getUI('text_repeatNtimes') + '</a>'
|
|
|
+ + '<a class="item" data-command="' + Models.COMMAND_TYPES.whiletrue + '"><i class="sync icon"></i> ' + LocalizedStrings.getUI('text_whiletrue') + '</a>'
|
|
|
+ + '<a class="item" data-command="' + Models.COMMAND_TYPES.dowhiletrue + '"><i class="sync icon"></i> ' + LocalizedStrings.getUI('text_dowhiletrue') + '</a>'
|
|
|
+ + '<a class="item" data-command="' + Models.COMMAND_TYPES.switch + '"><i class="list icon"></i> ' + LocalizedStrings.getUI('text_switch') + '</a>'
|
|
|
+ + '<a class="item" data-command="' + Models.COMMAND_TYPES.return + '"><i class="reply icon"></i> ' + LocalizedStrings.getUI('text_btn_return') + '</a>'
|
|
|
+ + '</div></div></div>';
|
|
|
|
|
|
- appender += '</div>';
|
|
|
+ appender += '<div class="ui bottom attached segment commands_list_div"></div>';
|
|
|
|
|
|
- appender += '<div class="function_close_div"></div>'
|
|
|
- + '</div>'
|
|
|
- + '</div>';
|
|
|
+ appender += '</div></div>';
|
|
|
|
|
|
appender = $(appender);
|
|
|
|
|
@@ -277,7 +343,6 @@ export function renderFunction (function_obj) {
|
|
|
|
|
|
addHandlers(function_obj, appender);
|
|
|
|
|
|
-
|
|
|
|
|
|
for (var j = 0; j < function_obj.parameters_list.length; j++) {
|
|
|
renderParameter(function_obj, function_obj.parameters_list[j], appender);
|
|
@@ -287,24 +352,53 @@ export function renderFunction (function_obj) {
|
|
|
for (var j = 0; j < function_obj.variables_list.length; j++) {
|
|
|
VariablesManagement.renderVariable(appender, function_obj.variables_list[j], function_obj);
|
|
|
}
|
|
|
-
|
|
|
|
|
|
for (var j = 0; j < function_obj.commands.length; j++) {
|
|
|
CommandsManagement.renderCommand(function_obj.commands[j], $(appender.find('.commands_list_div')[0]), 3, function_obj);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
$('.minimize_function_button').popup({
|
|
|
- content : LocalizedStrings.getUI("tooltip_minimize"),
|
|
|
+ content: LocalizedStrings.getUI("tooltip_minimize"),
|
|
|
delay: {
|
|
|
show: 750,
|
|
|
hide: 0
|
|
|
}
|
|
|
});
|
|
|
-}
|
|
|
|
|
|
+ Sortable.create(appender.find(".variables_list_div")[0], {
|
|
|
+ handle: '.ellipsis',
|
|
|
+ animation: 100,
|
|
|
+ ghostClass: 'ghost',
|
|
|
+ group: 'local_vars_drag_' + program.functions.indexOf(function_obj),
|
|
|
+ onEnd: function (evt) {
|
|
|
+ updateSequenceLocals(evt.oldIndex, evt.newIndex, function_obj);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ Sortable.create(appender.find(".commands_list_div")[0], {
|
|
|
+ handle: '.command_drag',
|
|
|
+ animation: 100,
|
|
|
+ ghostClass: 'ghost',
|
|
|
+ group: 'commands_drag_' + program.functions.indexOf(function_obj),
|
|
|
+ onEnd: function (evt) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ if (!function_obj.is_main) {
|
|
|
+ Sortable.create(appender.find(".container_parameters_list")[0], {
|
|
|
+ handle: '.ellipsis',
|
|
|
+ animation: 100,
|
|
|
+ ghostClass: 'ghost',
|
|
|
+ group: 'parameters_drag_' + program.functions.indexOf(function_obj),
|
|
|
+ onEnd: function (evt) {
|
|
|
+ updateSequenceParameters(evt.oldIndex, evt.newIndex, function_obj);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return appender;
|
|
|
+}
|
|
|
|
|
|
-export function initVisualUI () {
|
|
|
+export function initVisualUI() {
|
|
|
|
|
|
const mainDiv = $('#visual-main-div');
|
|
|
|
|
@@ -313,7 +407,8 @@ export function initVisualUI () {
|
|
|
addFunctionHandler();
|
|
|
});
|
|
|
$('.add_global_button').on('click', () => {
|
|
|
- GlobalsManagement.addGlobal(program);
|
|
|
+ window.insertContext = true;
|
|
|
+ GlobalsManagement.addGlobal(program, true);
|
|
|
});
|
|
|
|
|
|
$('.run_button').on('click', () => {
|
|
@@ -336,11 +431,14 @@ export function initVisualUI () {
|
|
|
$('.div_toggle_console').on('click', () => {
|
|
|
toggleConsole();
|
|
|
});
|
|
|
+ $('.expand_button').on('click', () => {
|
|
|
+ full_screen();
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
var is_iassign = false;
|
|
|
|
|
|
-$( document ).ready(function() {
|
|
|
+$(document).ready(function () {
|
|
|
|
|
|
for (var i = 0; i < program.functions.length; i++) {
|
|
|
renderFunction(program.functions[i]);
|
|
@@ -348,77 +446,77 @@ $( document ).ready(function() {
|
|
|
|
|
|
var time_show = 750;
|
|
|
$('.visual_coding_button').popup({
|
|
|
- content : LocalizedStrings.getUI("tooltip_visual"),
|
|
|
+ content: LocalizedStrings.getUI("tooltip_visual"),
|
|
|
delay: {
|
|
|
show: time_show,
|
|
|
hide: 0
|
|
|
}
|
|
|
});
|
|
|
$('.textual_coding_button').popup({
|
|
|
- content : LocalizedStrings.getUI("tooltip_textual"),
|
|
|
+ content: LocalizedStrings.getUI("tooltip_textual"),
|
|
|
delay: {
|
|
|
show: time_show,
|
|
|
hide: 0
|
|
|
}
|
|
|
});
|
|
|
$('.upload_file_button').popup({
|
|
|
- content : LocalizedStrings.getUI("tooltip_upload"),
|
|
|
+ content: LocalizedStrings.getUI("tooltip_upload"),
|
|
|
delay: {
|
|
|
show: time_show,
|
|
|
hide: 0
|
|
|
}
|
|
|
});
|
|
|
$('.download_file_button').popup({
|
|
|
- content : LocalizedStrings.getUI("tooltip_download"),
|
|
|
+ content: LocalizedStrings.getUI("tooltip_download"),
|
|
|
delay: {
|
|
|
show: time_show,
|
|
|
hide: 0
|
|
|
}
|
|
|
});
|
|
|
$('.undo_button').popup({
|
|
|
- content : LocalizedStrings.getUI("tooltip_undo"),
|
|
|
+ content: LocalizedStrings.getUI("tooltip_undo"),
|
|
|
delay: {
|
|
|
show: time_show,
|
|
|
hide: 0
|
|
|
}
|
|
|
});
|
|
|
$('.redo_button').popup({
|
|
|
- content : LocalizedStrings.getUI("tooltip_redo"),
|
|
|
+ content: LocalizedStrings.getUI("tooltip_redo"),
|
|
|
delay: {
|
|
|
show: time_show,
|
|
|
hide: 0
|
|
|
}
|
|
|
});
|
|
|
$('.run_button').popup({
|
|
|
- content : LocalizedStrings.getUI("tooltip_run"),
|
|
|
+ content: LocalizedStrings.getUI("tooltip_run"),
|
|
|
delay: {
|
|
|
show: time_show,
|
|
|
hide: 0
|
|
|
}
|
|
|
});
|
|
|
$('.assessment_button').popup({
|
|
|
- content : LocalizedStrings.getUI("tooltip_evaluate"),
|
|
|
+ content: LocalizedStrings.getUI("tooltip_evaluate"),
|
|
|
delay: {
|
|
|
show: time_show,
|
|
|
hide: 0
|
|
|
}
|
|
|
});
|
|
|
$('.help_button').popup({
|
|
|
- content : LocalizedStrings.getUI("tooltip_help"),
|
|
|
+ content: LocalizedStrings.getUI("tooltip_help"),
|
|
|
delay: {
|
|
|
show: time_show,
|
|
|
hide: 0
|
|
|
}
|
|
|
});
|
|
|
$('.add_global_button').popup({
|
|
|
- content : LocalizedStrings.getUI("tooltip_add_global"),
|
|
|
+ content: LocalizedStrings.getUI("tooltip_add_global"),
|
|
|
delay: {
|
|
|
show: time_show,
|
|
|
hide: 0
|
|
|
}
|
|
|
});
|
|
|
$('.div_toggle_console').popup({
|
|
|
- content : LocalizedStrings.getUI("tooltip_console"),
|
|
|
+ content: LocalizedStrings.getUI("tooltip_console"),
|
|
|
delay: {
|
|
|
show: time_show,
|
|
|
hide: 0
|
|
@@ -431,17 +529,40 @@ $( document ).ready(function() {
|
|
|
ghostClass: 'ghost',
|
|
|
group: 'functions_divs_drag',
|
|
|
onEnd: function (evt) {
|
|
|
- updateSequenceFunction(evt.oldIndex, evt.newIndex);
|
|
|
+ updateSequenceFunction(evt.oldIndex, evt.newIndex);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ var listGlobalsHandle = document.getElementById("listGlobalsHandle");
|
|
|
+ Sortable.create(listGlobalsHandle, {
|
|
|
+ handle: '.ellipsis',
|
|
|
+ animation: 100,
|
|
|
+ ghostClass: 'ghost',
|
|
|
+ group: 'globals_divs_drag',
|
|
|
+ onEnd: function (evt) {
|
|
|
+ updateSequenceGlobals(evt.oldIndex, evt.newIndex);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
-function updateSequenceFunction (oldIndex, newIndex) {
|
|
|
+function updateSequenceParameters(oldIndex, newIndex, function_obj) {
|
|
|
+ function_obj.parameters_list.splice(newIndex, 0, function_obj.parameters_list.splice(oldIndex, 1)[0]);
|
|
|
+}
|
|
|
+
|
|
|
+function updateSequenceLocals(oldIndex, newIndex, function_obj) {
|
|
|
+ function_obj.variables_list.splice(newIndex, 0, function_obj.variables_list.splice(oldIndex, 1)[0]);
|
|
|
+}
|
|
|
+
|
|
|
+function updateSequenceGlobals(oldIndex, newIndex) {
|
|
|
+ program_obj.globals.splice(newIndex, 0, program_obj.globals.splice(oldIndex, 1)[0]);
|
|
|
+}
|
|
|
+
|
|
|
+function updateSequenceFunction(oldIndex, newIndex) {
|
|
|
program_obj.functions.splice(newIndex, 0, program_obj.functions.splice(oldIndex, 1)[0]);
|
|
|
}
|
|
|
|
|
|
-function runCodeAssessment () {
|
|
|
+function runCodeAssessment() {
|
|
|
toggleConsole(true);
|
|
|
|
|
|
window.studentGrade = null;
|
|
@@ -450,7 +571,7 @@ function runCodeAssessment () {
|
|
|
if (strCode == null) {
|
|
|
return;
|
|
|
}
|
|
|
- if(domConsole == null)
|
|
|
+ if (domConsole == null)
|
|
|
domConsole = new DOMConsole("#ivprog-term");
|
|
|
$("#ivprog-term").slideDown(500);
|
|
|
const runner = new IVProgAssessment(strCode, testCases, domConsole);
|
|
@@ -461,18 +582,18 @@ function runCodeAssessment () {
|
|
|
} else {
|
|
|
is_iassign = false;
|
|
|
}
|
|
|
- }).catch( err => domConsole.err(err.message));
|
|
|
-
|
|
|
+ }).catch(err => domConsole.err(err.message));
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-function runCode () {
|
|
|
+function runCode() {
|
|
|
toggleConsole(true);
|
|
|
|
|
|
const strCode = CodeManagement.generate();
|
|
|
if (strCode == null) {
|
|
|
return;
|
|
|
}
|
|
|
- if(domConsole == null)
|
|
|
+ if (domConsole == null)
|
|
|
domConsole = new DOMConsole("#ivprog-term");
|
|
|
$("#ivprog-term").slideDown(500);
|
|
|
try {
|
|
@@ -484,21 +605,21 @@ function runCode () {
|
|
|
proc.registerOutput(domConsole);
|
|
|
$("#ivprog-term").addClass('ivprog-term-active');
|
|
|
|
|
|
- proc.interpretAST().then( _ => {
|
|
|
+ proc.interpretAST().then(_ => {
|
|
|
domConsole.info("Programa executado com sucesso!");
|
|
|
$("#ivprog-term").removeClass('ivprog-term-active');
|
|
|
}).catch(err => {
|
|
|
domConsole.err(err.message);
|
|
|
$("#ivprog-term").removeClass('ivprog-term-active');
|
|
|
- })
|
|
|
+ })
|
|
|
} catch (error) {
|
|
|
domConsole.err(error.message);
|
|
|
console.log(error);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-function toggleConsole (is_running) {
|
|
|
+function toggleConsole(is_running) {
|
|
|
|
|
|
if (is_running) {
|
|
|
$('.ivprog-term-div').css('display', 'block');
|
|
@@ -521,19 +642,19 @@ function toggleConsole (is_running) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function waitToCloseConsole () {
|
|
|
+function waitToCloseConsole() {
|
|
|
domConsole.info("Aperte qualquer tecla para fechar...");
|
|
|
const p = new Promise((resolve, _) => {
|
|
|
domConsole.requestInput(resolve, true);
|
|
|
});
|
|
|
- p.then( _ => {
|
|
|
+ p.then(_ => {
|
|
|
domConsole.dispose();
|
|
|
domConsole = null;
|
|
|
$("#ivprog-term").hide();
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-function toggleTextualCoding () {
|
|
|
+function toggleTextualCoding() {
|
|
|
var code = CodeManagement.generate();
|
|
|
$('.ivprog_visual_panel').css('display', 'none');
|
|
|
$('.ivprog_textual_panel').css('display', 'block');
|
|
@@ -544,7 +665,7 @@ function toggleTextualCoding () {
|
|
|
$('.textual_coding_button').addClass('active');
|
|
|
}
|
|
|
|
|
|
-function toggleVisualCoding () {
|
|
|
+function toggleVisualCoding() {
|
|
|
$('.ivprog_textual_panel').addClass('loading');
|
|
|
$('.ivprog_textual_panel').css('display', 'none');
|
|
|
$('.ivprog_visual_panel').css('display', 'block');
|
|
@@ -553,12 +674,13 @@ function toggleVisualCoding () {
|
|
|
$('.visual_coding_button').addClass('active');
|
|
|
}
|
|
|
|
|
|
-function removeParameter (function_obj, parameter_obj, parameter_container) {
|
|
|
+function removeParameter(function_obj, parameter_obj, parameter_container) {
|
|
|
var index = function_obj.parameters_list.indexOf(parameter_obj);
|
|
|
if (index > -1) {
|
|
|
+ window.insertContext = true;
|
|
|
function_obj.parameters_list.splice(index, 1);
|
|
|
}
|
|
|
- $(parameter_container).remove();
|
|
|
+ $(parameter_container).fadeOut();
|
|
|
}
|
|
|
|
|
|
function updateParameterType(parameter_obj, new_type, new_dimensions = 0) {
|
|
@@ -572,15 +694,15 @@ function updateParameterType(parameter_obj, new_type, new_dimensions = 0) {
|
|
|
|
|
|
}
|
|
|
|
|
|
-function renderParameter (function_obj, parameter_obj, function_container) {
|
|
|
+function renderParameter(function_obj, parameter_obj, function_container) {
|
|
|
var ret = "";
|
|
|
|
|
|
- ret += '<div class="ui label function_name_parameter">';
|
|
|
+ ret += '<div class="ui label function_name_parameter pink"><i class="ui icon ellipsis vertical inverted"></i>';
|
|
|
|
|
|
ret += '<div class="ui dropdown parameter_type">';
|
|
|
|
|
|
if (parameter_obj.dimensions > 0) {
|
|
|
- ret += '<div class="text">'+ LocalizedStrings.getUI('vector')+':'+LocalizedStrings.getUI(parameter_obj.type);
|
|
|
+ ret += '<div class="text">' + LocalizedStrings.getUI('vector') + ':' + LocalizedStrings.getUI(parameter_obj.type);
|
|
|
if (parameter_obj.dimensions == 1) {
|
|
|
ret += ' [ ] ';
|
|
|
} else {
|
|
@@ -588,17 +710,17 @@ function renderParameter (function_obj, parameter_obj, function_container) {
|
|
|
}
|
|
|
ret += '</div>';
|
|
|
} else {
|
|
|
- ret += '<div class="text">'+LocalizedStrings.getUI(parameter_obj.type)+'</div>';
|
|
|
+ ret += '<div class="text">' + LocalizedStrings.getUI(parameter_obj.type) + '</div>';
|
|
|
}
|
|
|
|
|
|
ret += '<div class="menu">';
|
|
|
|
|
|
-
|
|
|
+
|
|
|
for (var tm in Types) {
|
|
|
- if (tm == Types.VOID.toUpperCase()) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- ret += '<div class="item ' + (parameter_obj.type == tm.toLowerCase() ? ' selected ' : '') + '" data-type="'+tm+'" >'+LocalizedStrings.getUI(tm.toLowerCase())+'</div>';
|
|
|
+ if (tm == Types.VOID.toUpperCase()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ ret += '<div class="item ' + (parameter_obj.type == tm.toLowerCase() ? ' selected ' : '') + '" data-type="' + tm + '" >' + LocalizedStrings.getUI(tm.toLowerCase()) + '</div>';
|
|
|
}
|
|
|
|
|
|
for (var tm in Types) {
|
|
@@ -607,30 +729,30 @@ function renderParameter (function_obj, parameter_obj, function_container) {
|
|
|
}
|
|
|
ret += '<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>'
|
|
|
- + '<div class="item" data-text="'+ LocalizedStrings.getUI('vector')+':'+LocalizedStrings.getUI(tm.toLowerCase())+' [ ] [ ] " data-type="'+tm+'" data-dimensions="2">[ ] [ ] </div>'
|
|
|
- + '</div>'
|
|
|
- + '</div>';
|
|
|
+ + 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>'
|
|
|
+ + '<div class="item" data-text="' + LocalizedStrings.getUI('vector') + ':' + LocalizedStrings.getUI(tm.toLowerCase()) + ' [ ] [ ] " data-type="' + tm + '" data-dimensions="2">[ ] [ ] </div>'
|
|
|
+ + '</div>'
|
|
|
+ + '</div>';
|
|
|
}
|
|
|
|
|
|
ret += '</div></div>';
|
|
|
|
|
|
- ret += '<div class="parameter_div_edit"><span class="span_name_parameter label_enable_name_parameter">'+parameter_obj.name+'</span></div> ';
|
|
|
+ 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>';
|
|
|
+ ret += ' <i class="yellow inverted icon times remove_parameter"></i></div>';
|
|
|
|
|
|
ret = $(ret);
|
|
|
-
|
|
|
+
|
|
|
function_container.find('.container_parameters_list').append(ret);
|
|
|
|
|
|
- ret.find('.remove_parameter').on('click', function(e){
|
|
|
+ ret.find('.remove_parameter').on('click', function (e) {
|
|
|
removeParameter(function_obj, parameter_obj, ret);
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
ret.find('.ui.dropdown.parameter_type').dropdown({
|
|
|
- onChange: function(value, text, $selectedItem) {
|
|
|
+ onChange: function (value, text, $selectedItem) {
|
|
|
if ($selectedItem.data('dimensions')) {
|
|
|
updateParameterType(parameter_obj, Types[$selectedItem.data('type')], $selectedItem.data('dimensions'));
|
|
|
} else {
|
|
@@ -639,15 +761,16 @@ function renderParameter (function_obj, parameter_obj, function_container) {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- ret.find('.label_enable_name_parameter').on('click', function(e){
|
|
|
+ ret.find('.label_enable_name_parameter').on('click', function (e) {
|
|
|
enableNameParameterUpdate(parameter_obj, ret);
|
|
|
});
|
|
|
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
var opened_name_parameter = false;
|
|
|
var opened_input_parameter = null;
|
|
|
-function enableNameParameterUpdate (parameter_obj, parent_node) {
|
|
|
+function enableNameParameterUpdate(parameter_obj, parent_node) {
|
|
|
if (opened_name_parameter) {
|
|
|
opened_input_parameter.focus();
|
|
|
return;
|
|
@@ -658,11 +781,11 @@ function enableNameParameterUpdate (parameter_obj, parent_node) {
|
|
|
var input_field;
|
|
|
|
|
|
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 = $("<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'));
|
|
|
|
|
|
- input_field.on('input', function() {
|
|
|
- var inputWidth = input_field.textWidth()+10;
|
|
|
+ input_field.on('input', function () {
|
|
|
+ var inputWidth = input_field.textWidth() + 10;
|
|
|
opened_input_parameter = input_field;
|
|
|
input_field.focus();
|
|
|
|
|
@@ -671,11 +794,11 @@ function enableNameParameterUpdate (parameter_obj, parent_node) {
|
|
|
input_field.val(tmpStr);
|
|
|
|
|
|
input_field.css({
|
|
|
- width: inputWidth
|
|
|
+ width: inputWidth
|
|
|
})
|
|
|
}).trigger('input');
|
|
|
|
|
|
- input_field.focusout(function() {
|
|
|
+ input_field.focusout(function () {
|
|
|
|
|
|
if (input_field.val().trim()) {
|
|
|
parameter_obj.name = input_field.val().trim();
|
|
@@ -689,9 +812,9 @@ function enableNameParameterUpdate (parameter_obj, parent_node) {
|
|
|
opened_input_parameter = false;
|
|
|
});
|
|
|
|
|
|
- input_field.on('keydown', function(e) {
|
|
|
+ input_field.on('keydown', function (e) {
|
|
|
var code = e.keyCode || e.which;
|
|
|
- if(code == 13) {
|
|
|
+ if (code == 13) {
|
|
|
if (input_field.val().trim()) {
|
|
|
parameter_obj.name = input_field.val().trim();
|
|
|
parent_node.find('.span_name_parameter').text(parameter_obj.name);
|
|
@@ -704,7 +827,7 @@ function enableNameParameterUpdate (parameter_obj, parent_node) {
|
|
|
opened_input_parameter = false;
|
|
|
|
|
|
}
|
|
|
- if(code == 27) {
|
|
|
+ if (code == 27) {
|
|
|
parent_node.find('.span_name_parameter').text(parameter_obj.name);
|
|
|
input_field.off();
|
|
|
input_field.remove();
|
|
@@ -720,7 +843,7 @@ function enableNameParameterUpdate (parameter_obj, parent_node) {
|
|
|
var opened_name_function = false;
|
|
|
var opened_input = null;
|
|
|
var previousPadding = null;
|
|
|
-function enableNameFunctionUpdate (function_obj, parent_node) {
|
|
|
+function enableNameFunctionUpdate(function_obj, parent_node) {
|
|
|
if (opened_name_function) {
|
|
|
opened_input.focus();
|
|
|
return;
|
|
@@ -733,12 +856,12 @@ function enableNameFunctionUpdate (function_obj, parent_node) {
|
|
|
}
|
|
|
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 = $("<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'));
|
|
|
|
|
|
- input_field.on('input', function() {
|
|
|
- var inputWidth = input_field.textWidth()+10;
|
|
|
+ input_field.on('input', function () {
|
|
|
+ var inputWidth = input_field.textWidth() + 10;
|
|
|
opened_input = input_field;
|
|
|
input_field.focus();
|
|
|
|
|
@@ -747,11 +870,11 @@ function enableNameFunctionUpdate (function_obj, parent_node) {
|
|
|
input_field.val(tmpStr);
|
|
|
|
|
|
input_field.css({
|
|
|
- width: inputWidth
|
|
|
+ width: inputWidth
|
|
|
})
|
|
|
}).trigger('input');
|
|
|
|
|
|
- input_field.focusout(function() {
|
|
|
+ input_field.focusout(function () {
|
|
|
|
|
|
if (input_field.val().trim()) {
|
|
|
function_obj.name = input_field.val().trim();
|
|
@@ -767,9 +890,9 @@ function enableNameFunctionUpdate (function_obj, parent_node) {
|
|
|
opened_input = false;
|
|
|
});
|
|
|
|
|
|
- input_field.on('keydown', function(e) {
|
|
|
+ input_field.on('keydown', function (e) {
|
|
|
var code = e.keyCode || e.which;
|
|
|
- if(code == 13) {
|
|
|
+ if (code == 13) {
|
|
|
if (input_field.val().trim()) {
|
|
|
function_obj.name = input_field.val().trim();
|
|
|
}
|
|
@@ -783,7 +906,7 @@ function enableNameFunctionUpdate (function_obj, parent_node) {
|
|
|
opened_name_function = false;
|
|
|
opened_input = false;
|
|
|
}
|
|
|
- if(code == 27) {
|
|
|
+ if (code == 27) {
|
|
|
|
|
|
input_field.off();
|
|
|
input_field.remove();
|
|
@@ -797,5 +920,5 @@ function enableNameFunctionUpdate (function_obj, parent_node) {
|
|
|
}
|
|
|
});
|
|
|
input_field.select();
|
|
|
-
|
|
|
+
|
|
|
}
|