|
@@ -18,6 +18,7 @@ import VersionInfo from './../../.ima_version.json';
|
|
|
import * as TextEditor from "./text_editor";
|
|
|
import { isValidIdentifier } from "./../util/utils";
|
|
|
import { Modes } from '../processor/modes';
|
|
|
+import { Config } from '../util/config';
|
|
|
|
|
|
var counter_new_functions = 0;
|
|
|
var counter_new_parameters = 0;
|
|
@@ -246,7 +247,7 @@ function addHandlers (function_obj, function_container) {
|
|
|
function_container.find(".inline_add_command").toggle();
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -254,7 +255,7 @@ function addHandlers (function_obj, function_container) {
|
|
|
function renderFunctionReturn (function_obj, function_element) {
|
|
|
|
|
|
var ret = '<div class="ui dropdown function_return">';
|
|
|
-
|
|
|
+
|
|
|
if (function_obj.return_dimensions == 1) {
|
|
|
ret += '<div class="text">'+ LocalizedStrings.getUI("vector") +': '+ LocalizedStrings.getUI(`type_${function_obj.return_type.toLowerCase()}`);
|
|
|
ret += ' [ ] </div>';
|
|
@@ -301,20 +302,20 @@ function renderFunctionReturn (function_obj, function_element) {
|
|
|
ret += '</div></div>';
|
|
|
|
|
|
ret = $(ret);
|
|
|
-
|
|
|
+
|
|
|
function_element.find('.function_return').append(ret);
|
|
|
}
|
|
|
|
|
|
var cont = 0;
|
|
|
|
|
|
export function renderFunction (function_obj) {
|
|
|
-
|
|
|
+
|
|
|
var appender = '<div class="ui secondary segment function_div list-group-item function_cont_'+cont+'">';
|
|
|
|
|
|
if (function_obj.function_comment) {
|
|
|
//appender += renderComment(function_obj.function_comment, sequence, true, -1);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
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>')
|
|
@@ -328,10 +329,10 @@ export function renderFunction (function_obj) {
|
|
|
} else {
|
|
|
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> '
|
|
|
+ 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"> ');
|
|
|
|
|
@@ -380,7 +381,7 @@ export function renderFunction (function_obj) {
|
|
|
|
|
|
addHandlers(function_obj, appender);
|
|
|
|
|
|
- // Rendering parameters:
|
|
|
+ // Rendering parameters:
|
|
|
for (var j = 0; j < function_obj.parameters_list.length; j++) {
|
|
|
renderParameter(function_obj, function_obj.parameters_list[j], appender);
|
|
|
}
|
|
@@ -436,7 +437,7 @@ export function renderFunction (function_obj) {
|
|
|
offset: 40,
|
|
|
onStick: function (evt) {
|
|
|
$(teste).css('top', '20px', 'important');
|
|
|
- },
|
|
|
+ },
|
|
|
onBottom: function (evt) {
|
|
|
$(teste).css('top', '20px', 'important');
|
|
|
},
|
|
@@ -457,7 +458,7 @@ export function renderFunction (function_obj) {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
cont ++;
|
|
|
|
|
|
return appender;
|
|
@@ -578,7 +579,7 @@ function updateProgramObjDrag () {
|
|
|
|
|
|
// agora tem que alocar o comando na árvore, mas considerar as quatro situações:
|
|
|
// (1) se está em um else ou (2) se está em switch ou (3) será um caso padrão ou (4) se será na raiz.
|
|
|
-
|
|
|
+
|
|
|
if (path_target.length == 0) { // soltou na raiz:
|
|
|
window.program_obj.functions[function_index].commands.splice(evento_drag.newIndex - 1, 0, command_in_drag);
|
|
|
} else if (is_in_else) {
|
|
@@ -603,7 +604,7 @@ function updateProgramObjDrag () {
|
|
|
|
|
|
window.draging = false;
|
|
|
renderAlgorithm();
|
|
|
-
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
@@ -647,7 +648,7 @@ function prepareDragHandler (evt) {
|
|
|
var command_in_drag;
|
|
|
|
|
|
function addSortableHandler (element, id_function) {
|
|
|
-
|
|
|
+
|
|
|
var n_group = 'commands_drag_' + id_function;
|
|
|
Sortable.create(element, {
|
|
|
handle: '.command_drag',
|
|
@@ -720,7 +721,7 @@ function addSortableHandler (element, id_function) {
|
|
|
addSortableHandler($(this).find(".case_commands_block")[0], id_function);
|
|
|
});
|
|
|
|
|
|
- });
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
export function initVisualUI () {
|
|
@@ -881,7 +882,7 @@ export function setTestCases (testCases) {
|
|
|
|
|
|
export function getTestCases () {
|
|
|
// Deep clone of test cases to avoid unauthorized modification
|
|
|
- // TODO: It may be not possible to use this once custom test are fully implemented
|
|
|
+ // TODO: It may be not possible to use this once custom test are fully implemented
|
|
|
return JSON.parse(JSON.stringify(_testCases));
|
|
|
}
|
|
|
|
|
@@ -908,12 +909,12 @@ function runCodeAssessment () {
|
|
|
// cannot run assessment or it's already running
|
|
|
return -1;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
let strCode = null;
|
|
|
|
|
|
window.studentGrade = null;
|
|
|
|
|
|
- if (settingsProgrammingTypes == "textual") {
|
|
|
+ if (Config.programming_type == "textual") {
|
|
|
strCode = TextEditor.getCode();
|
|
|
} else {
|
|
|
strCode = CodeManagement.generate();
|
|
@@ -960,7 +961,7 @@ function runCode () {
|
|
|
}
|
|
|
let strCode = null;
|
|
|
|
|
|
- if (settingsProgrammingTypes == "textual") {
|
|
|
+ if (Config.programming_type == "textual") {
|
|
|
strCode = TextEditor.getCode();
|
|
|
} else {
|
|
|
strCode = CodeManagement.generate();
|
|
@@ -969,7 +970,7 @@ function runCode () {
|
|
|
if (strCode == null) {
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
toggleConsole(true);
|
|
|
|
|
|
// if(domConsole == null)
|
|
@@ -986,7 +987,7 @@ function runCode () {
|
|
|
scheduleCall(() => {
|
|
|
if(domConsole.pending_writes.length == 0) {
|
|
|
if(proc.mode === Modes.ABORT) {
|
|
|
- domConsole.info(LocalizedStrings.getMessage("aborted_execution"));
|
|
|
+ domConsole.info(LocalizedStrings.getMessage("aborted_execution"));
|
|
|
} else {
|
|
|
domConsole.info(LocalizedStrings.getMessage("success_execution"));
|
|
|
}
|
|
@@ -1014,7 +1015,7 @@ function runCode () {
|
|
|
}
|
|
|
return false;
|
|
|
},100);
|
|
|
- })
|
|
|
+ })
|
|
|
} catch (error) {
|
|
|
scheduleCall(() => {
|
|
|
if(domConsole.pending_writes.length == 0) {
|
|
@@ -1028,7 +1029,7 @@ function runCode () {
|
|
|
return false;
|
|
|
},100);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
function toggleConsole (is_running) {
|
|
@@ -1073,7 +1074,7 @@ function toggleConsole (is_running) {
|
|
|
|
|
|
function toggleTextualCoding () {
|
|
|
let code = null;
|
|
|
- if (settingsProgrammingTypes != "textual") {
|
|
|
+ if (Config.programming_type == "textual") {
|
|
|
code = CodeManagement.generate();
|
|
|
if (code == null) {
|
|
|
return;
|
|
@@ -1145,7 +1146,7 @@ function renderParameter (function_obj, parameter_obj, function_container) {
|
|
|
|
|
|
ret += '<div class="menu">';
|
|
|
|
|
|
-
|
|
|
+
|
|
|
for (const tm in Types) {
|
|
|
if (tm == Types.VOID.toUpperCase()) {
|
|
|
continue;
|
|
@@ -1188,13 +1189,13 @@ function renderParameter (function_obj, parameter_obj, function_container) {
|
|
|
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){
|
|
|
removeParameter(function_obj, parameter_obj, ret);
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
ret.find('.ui.dropdown.parameter_type').dropdown({
|
|
|
onChange: function(_, __, $selectedItem) {
|
|
|
if ($selectedItem.data('dimensions')) {
|
|
@@ -1215,7 +1216,7 @@ function renderParameter (function_obj, parameter_obj, function_container) {
|
|
|
}
|
|
|
|
|
|
function updateParameterName (parameter_var, new_name, parameter_obj_dom, function_obj) {
|
|
|
-
|
|
|
+
|
|
|
if (parameter_var.name == new_name) {
|
|
|
return;
|
|
|
}
|
|
@@ -1254,11 +1255,11 @@ function variableNameAlreadyExists (name_var, function_obj) {
|
|
|
}
|
|
|
|
|
|
function updateFunctionName (function_var, new_name, function_obj_dom) {
|
|
|
-
|
|
|
+
|
|
|
if (function_var.name == new_name) {
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (isValidIdentifier(new_name)) {
|
|
|
if (functionNameAlreadyExists(new_name)) {
|
|
|
Utils.renderErrorMessage(function_obj_dom.find('.function_name_div'), LocalizedStrings.getError('inform_valid_function_duplicated', [new_name]));
|
|
@@ -1368,7 +1369,7 @@ 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.insertBefore(parent_node.find('.span_name_function'));
|
|
|
|
|
@@ -1432,7 +1433,7 @@ function enableNameFunctionUpdate (function_obj, parent_node) {
|
|
|
}
|
|
|
});
|
|
|
input_field.select();
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
export function addFunctionChangeListener (callback) {
|
|
@@ -1481,4 +1482,4 @@ function stopExecution () {
|
|
|
return;
|
|
|
}
|
|
|
proc.mode = Modes.ABORT;
|
|
|
-}
|
|
|
+}
|