|
@@ -47,8 +47,6 @@ export function removeCommand (command, function_obj, dom_obj) {
|
|
|
} catch (err) {}
|
|
|
|
|
|
if (dom_obj.parent().data('switchcase')) {
|
|
|
- console.log("o que encontrei: ");
|
|
|
- console.log(dom_obj.parent().data('switchcase'));
|
|
|
dom_obj.parent().data('switchcase').commands_block.splice(dom_obj.parent().data('switchcase').commands_block.indexOf(command), 1);
|
|
|
return true;
|
|
|
}
|
|
@@ -125,8 +123,6 @@ export function createFloatingCommand (function_obj, function_container, command
|
|
|
function_container = $(mouse_event.originalEvent.srcElement.closest('.function_div'));
|
|
|
}
|
|
|
|
|
|
- console.log('function_container', function_container);
|
|
|
-
|
|
|
function_container_active = function_container;
|
|
|
|
|
|
function_container.find('.commands_list_div').on('mousemove', function(evt) {
|
|
@@ -173,18 +169,18 @@ function addGhostToEmptyBlock (element, evt) {
|
|
|
|
|
|
if (window.active_container != null) {
|
|
|
if (window.active_container.is(container)) {
|
|
|
- console.log('é o mesmo, não mudou!');
|
|
|
+ //console.log('é o mesmo, não mudou!');
|
|
|
} else {
|
|
|
if (container.length < 1) {
|
|
|
container = element.closest('.commands_list_div');
|
|
|
if (window.active_container.is(container)) {
|
|
|
- console.log('é o mesmo command list');
|
|
|
+ //console.log('é o mesmo command list');
|
|
|
} else {
|
|
|
- console.log('mudou para um command list');
|
|
|
+ //console.log('mudou para um command list');
|
|
|
window.active_container = container;
|
|
|
}
|
|
|
} else {
|
|
|
- console.log('mudou para um outro container?');
|
|
|
+ //console.log('mudou para um outro container?');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -236,7 +232,6 @@ function addGhostToNotEmptyBlock (element, evt) {
|
|
|
|
|
|
// quem está mais próximo? // Essa regra se aplica somente quando o over está sobre um comando
|
|
|
var allfilhos;
|
|
|
- console.log('olha o container: ', container);
|
|
|
if (container.hasClass('iftrue')) {
|
|
|
|
|
|
if ($(evt.target).closest('.data_block_if').length > 0) {
|
|
@@ -276,8 +271,6 @@ function addGhostToNotEmptyBlock (element, evt) {
|
|
|
bottomDistances.push(botD);
|
|
|
}
|
|
|
|
|
|
- console.log('topDistances\n', topDistances, '\nbottomDistances\n', bottomDistances)
|
|
|
-
|
|
|
var menorTop = Math.min.apply(null, topDistances);
|
|
|
var indiceTop = topDistances.indexOf(menorTop);
|
|
|
|
|
@@ -289,8 +282,6 @@ function addGhostToNotEmptyBlock (element, evt) {
|
|
|
} else {
|
|
|
window.ghostDiv.insertAfter($(allfilhos.get(indiceBot)));
|
|
|
}
|
|
|
-
|
|
|
- console.log('distancias: menorTop ', menorTop, ' menorBot ', menorBot);
|
|
|
}
|
|
|
|
|
|
function addGhostToFunctionArea (undermouse, evt) {
|
|
@@ -549,8 +540,6 @@ function findSingleElement (searching, query) {
|
|
|
searching.commands_else = [];
|
|
|
}
|
|
|
|
|
|
- console.log('\n\nveja onde: ', searching.commands_block, ' \n\nquery: ', query);
|
|
|
-
|
|
|
if (searching.commands_block.indexOf(query) >= 0) {
|
|
|
return 'if[' + searching.commands_block.indexOf(query) + ']';
|
|
|
} else {
|
|
@@ -573,9 +562,6 @@ function findPathRecursive (starter_index, hierarquia_bottom_up, function_obj, i
|
|
|
var full_path = '';
|
|
|
|
|
|
for (var i = 0; i <= hierarquia_bottom_up.length; i ++) {
|
|
|
-
|
|
|
- console.log('\n\n:: ', i, ':\n', hierarquia_bottom_up[i]);
|
|
|
-
|
|
|
full_path += findSingleElement(hierarquia_bottom_up[i], hierarquia_bottom_up[i + 1]) + '-';
|
|
|
}
|
|
|
|
|
@@ -593,11 +579,6 @@ function manageCommand (function_obj, function_container, event, command_type) {
|
|
|
if (el.hasClass('ghost_div')) {
|
|
|
if (el.closest('.command_container').length < 1) {
|
|
|
|
|
|
-
|
|
|
- console.log('\n\nvou tentar!!!!');
|
|
|
-
|
|
|
- console.log(el.closest('.commands_list_div'), '\n\n');
|
|
|
-
|
|
|
el.closest('.commands_list_div').css('height', el.closest('.commands_list_div').css('height') + 30);
|
|
|
|
|
|
//$('.ghost_div').remove();
|
|
@@ -606,10 +587,6 @@ function manageCommand (function_obj, function_container, event, command_type) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- console.log('soltou no: ');
|
|
|
- console.log(el);
|
|
|
- console.log(el.data('fun'));
|
|
|
-
|
|
|
// Primeiro verificar se ele soltou no espaço da função correta:
|
|
|
var hier = el.parentsUntil(".all_functions");
|
|
|
var esta_correto = false;
|
|
@@ -642,7 +619,6 @@ function manageCommand (function_obj, function_container, event, command_type) {
|
|
|
}
|
|
|
var hierarquia_bottom_up = null;
|
|
|
// Agora é descobrir qual o escopo para adicionar o comando:
|
|
|
- console.log('ev0');
|
|
|
// Se o elemento clicado possuir o atributo "fun", então, é direto na div dos comandos:
|
|
|
if (typeof el.data('fun') !== 'undefined') {
|
|
|
|
|
@@ -665,7 +641,6 @@ function manageCommand (function_obj, function_container, event, command_type) {
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
- console.log("soltou em um comando");
|
|
|
// descobrir em qual comando ele soltou:
|
|
|
var hier_find = el.parentsUntil(".commands_list_div");
|
|
|
hierarquia_bottom_up = [];
|
|
@@ -677,13 +652,7 @@ function manageCommand (function_obj, function_container, event, command_type) {
|
|
|
hierarquia_bottom_up.push($(hier_find[i]).data('command'));
|
|
|
}
|
|
|
}
|
|
|
- console.log("comando em que soltou: ");
|
|
|
- console.log(hierarquia_bottom_up[0]);
|
|
|
- console.log("hierarquia de baixo para cima na árvore, de onde ele soltou: ");
|
|
|
- for (var i = 0; i < hierarquia_bottom_up.length; i++) {
|
|
|
- console.log(hierarquia_bottom_up[i]);
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
// Se for do tipo break, verificar se está no contexto correto:
|
|
|
// Caso não esteja no contexto, apenas retorna sem dar continuidade:
|
|
|
var is_correct_context = false;
|
|
@@ -707,33 +676,25 @@ function manageCommand (function_obj, function_container, event, command_type) {
|
|
|
|
|
|
// se a hierarquia possuir apenas um elemento, então está na raiz dos comandos:
|
|
|
if (hierarquia_bottom_up.length == 1) {
|
|
|
- console.log('QQ1');
|
|
|
var sub_elemento = false;
|
|
|
for (var i = 0; i < hier_find.length; i++) {
|
|
|
if (typeof $(hier_find[i]).data('command') !== 'undefined') {
|
|
|
- console.log('QQ2');
|
|
|
findBeforeOrAfterCommandToAdd(hier_find[i], event, function_obj, command_type);
|
|
|
sub_elemento = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (!sub_elemento) {
|
|
|
- console.log('QQ3');
|
|
|
findBeforeOrAfterCommandToAdd(el[0], event, function_obj, command_type);
|
|
|
}
|
|
|
} else {
|
|
|
- console.log('QQ4');
|
|
|
// caso exista mais de um elemento na hierarquia:
|
|
|
if (typeof $(el).data('command') !== 'undefined') {
|
|
|
- console.log('QQ5');
|
|
|
- console.log("PPP1");
|
|
|
insertCommandInBlockHierar(el[0], event, function_obj, command_type, hier_find, hierarquia_bottom_up);
|
|
|
} else {
|
|
|
- console.log('QQ6');
|
|
|
var sub_elemento = false;
|
|
|
for (var i = 0; i < hier_find.length; i++) {
|
|
|
if (typeof $(hier_find[i]).data('command') !== 'undefined') {
|
|
|
- console.log('QQ7');
|
|
|
insertCommandInBlockHierar(hier_find[i], event, function_obj, command_type, hier_find, hierarquia_bottom_up);
|
|
|
sub_elemento = true;
|
|
|
break;
|
|
@@ -748,13 +709,10 @@ function manageCommand (function_obj, function_container, event, command_type) {
|
|
|
// which_element_is_draged = null;
|
|
|
|
|
|
if (hierarquia_bottom_up) {
|
|
|
- console.log('\n\n:::índices::\n\n');
|
|
|
var i = hierarquia_bottom_up.length - 1;
|
|
|
var starter_index = window.program_obj.functions[window.program_obj.functions.indexOf(function_obj)].commands.indexOf(hierarquia_bottom_up[i]);
|
|
|
var all_str_path = starter_index + '-' + findPathRecursive(starter_index, hierarquia_bottom_up, function_obj);
|
|
|
registerUserEvent(function_obj.name, ActionTypes.INSERT_COMMAND, command_type, '/' , all_str_path);
|
|
|
- console.log('\n\nfull path: \n\n', all_str_path);
|
|
|
- console.log('fim dos índices');
|
|
|
}
|
|
|
|
|
|
renderAlgorithm();
|
|
@@ -769,14 +727,10 @@ function insertCommandInBlockHierar (el, event, function_obj, command_type, hier
|
|
|
(el_jq.data('command').type == Models.COMMAND_TYPES.dowhiletrue) ||
|
|
|
(el_jq.data('command').type == Models.COMMAND_TYPES.switch) ) {
|
|
|
|
|
|
- console.log('QQ17');
|
|
|
-
|
|
|
if ((el_jq.data('command').type == Models.COMMAND_TYPES.repeatNtimes) ||
|
|
|
(el_jq.data('command').type == Models.COMMAND_TYPES.whiletrue) ||
|
|
|
(el_jq.data('command').type == Models.COMMAND_TYPES.dowhiletrue) ) {
|
|
|
|
|
|
- console.log('QQ18');
|
|
|
-
|
|
|
// Se não tiver outro comando ainda no bloco, só adiciona:
|
|
|
if (command_parent.commands_block == null || command_parent.commands_block.length == 0) {
|
|
|
command_parent.commands_block = [];
|
|
@@ -796,7 +750,6 @@ function insertCommandInBlockHierar (el, event, function_obj, command_type, hier
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
- console.log('QQ19');
|
|
|
// entra neste bloco, se soltou o comando sobre outro comando dentro de um subbloco:
|
|
|
findBeforeOrAfterCommandToAddInsertBlock(el, event, function_obj, command_type);
|
|
|
}
|
|
@@ -804,8 +757,6 @@ function insertCommandInBlockHierar (el, event, function_obj, command_type, hier
|
|
|
|
|
|
function findNearbyCommandToAddInBlockScope (el, event, node_list_commands, function_obj, command_type, command_parent) {
|
|
|
|
|
|
- console.log("\n\n\n::COMANDOS:\n\n", el, event, node_list_commands, function_obj, command_type, command_parent);
|
|
|
-
|
|
|
var all_sub = $(node_list_commands).find('div.command_container');
|
|
|
|
|
|
var menor_distancia = 999999999;
|
|
@@ -900,12 +851,9 @@ function findBeforeOrAfterCommandToAddInsertBlock (el, event, function_obj, comm
|
|
|
|
|
|
if ((command_parent.type != Models.COMMAND_TYPES.iftrue) && (command_parent.type != Models.COMMAND_TYPES.switch)) {
|
|
|
var hier = temp_parent.parentsUntil(".all_cases_div");
|
|
|
- console.log("vou procurar!!");
|
|
|
for (var i = 0; i < hier.length; i++) {
|
|
|
- console.log("estou vasculhando...");
|
|
|
var temp = $(hier[i]);
|
|
|
if (typeof temp.data('switchcase') !== 'undefined') {
|
|
|
- console.log("encontrei");
|
|
|
command_parent = temp.data('switchcase');
|
|
|
is_in_else = false;
|
|
|
break;
|
|
@@ -913,14 +861,6 @@ function findBeforeOrAfterCommandToAddInsertBlock (el, event, function_obj, comm
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- console.log('debugging:');
|
|
|
- console.log('el_jq');
|
|
|
- console.log(el_jq);
|
|
|
- console.log('command_parent');
|
|
|
- console.log(command_parent);
|
|
|
- console.log('command_target');
|
|
|
- console.log(command_target);
|
|
|
-
|
|
|
var menor_distancia = 999999999;
|
|
|
var antes = true;
|
|
|
|
|
@@ -939,14 +879,9 @@ function findBeforeOrAfterCommandToAddInsertBlock (el, event, function_obj, comm
|
|
|
|
|
|
var recentComand = genericCreateCommand(command_type);
|
|
|
|
|
|
- console.log('MMM1');
|
|
|
-
|
|
|
if (is_in_else) {
|
|
|
|
|
|
- console.log('MMM2');
|
|
|
-
|
|
|
if (command_parent == command_target) {
|
|
|
- console.log('MMM3');
|
|
|
if (command_parent.commands_else == null || command_parent.commands_else.length == 0) {
|
|
|
command_parent.commands_else = [];
|
|
|
|
|
@@ -959,7 +894,6 @@ function findBeforeOrAfterCommandToAddInsertBlock (el, event, function_obj, comm
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
- console.log('MMM7');
|
|
|
var index = command_parent.commands_else.indexOf(command_target);
|
|
|
|
|
|
if (index > -1) {
|
|
@@ -968,25 +902,20 @@ function findBeforeOrAfterCommandToAddInsertBlock (el, event, function_obj, comm
|
|
|
|
|
|
renderCommand(recentComand, el, 1, function_obj);
|
|
|
} else {
|
|
|
- console.log('MMM4');
|
|
|
if (command_parent == command_target) {
|
|
|
- console.log('Nxxxx5');
|
|
|
if (command_parent.commands_block == null || command_parent.commands_block.length == 0) {
|
|
|
command_parent.commands_block = [];
|
|
|
- console.log('SSS4');
|
|
|
var recentComand = genericCreateCommand(command_type);
|
|
|
command_parent.commands_block.push(recentComand);
|
|
|
|
|
|
renderCommand(recentComand, el_jq, 3, function_obj);
|
|
|
} else {
|
|
|
- console.log('SSS5');
|
|
|
findInBlockCorrectPlace(el_jq, event, function_obj, command_type);
|
|
|
}
|
|
|
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
- console.log('MMM6');
|
|
|
|
|
|
var index = command_parent.commands_block.indexOf(command_target);
|
|
|
|
|
@@ -1000,28 +929,23 @@ function findBeforeOrAfterCommandToAddInsertBlock (el, event, function_obj, comm
|
|
|
|
|
|
|
|
|
} else {
|
|
|
- console.log('XXX1');
|
|
|
var recentComand = genericCreateCommand(command_type);
|
|
|
|
|
|
if (is_in_else) {
|
|
|
|
|
|
if (command_parent == command_target) {
|
|
|
- console.log('MMM3');
|
|
|
if (command_parent.commands_else == null || command_parent.commands_else.length == 0) {
|
|
|
command_parent.commands_else = [];
|
|
|
- console.log('SSS1');
|
|
|
var recentComand = genericCreateCommand(command_type);
|
|
|
command_parent.commands_else.push(recentComand);
|
|
|
|
|
|
renderCommand(recentComand, el_jq, 3, function_obj);
|
|
|
} else { // Se já tem algum comando no bloco:
|
|
|
- console.log('SSS2');
|
|
|
findInBlockCorrectPlace(el_jq, event, function_obj, command_type, true);
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- console.log('XXX2');
|
|
|
var index = command_parent.commands_else.indexOf(command_target);
|
|
|
|
|
|
if (index > -1) {
|
|
@@ -1033,16 +957,13 @@ function findBeforeOrAfterCommandToAddInsertBlock (el, event, function_obj, comm
|
|
|
} else {
|
|
|
|
|
|
if (command_parent == command_target) {
|
|
|
- console.log('Nxxxx78');
|
|
|
if (command_parent.commands_block == null || command_parent.commands_block.length == 0) {
|
|
|
command_parent.commands_block = [];
|
|
|
|
|
|
var recentComand = genericCreateCommand(command_type);
|
|
|
command_parent.commands_block.push(recentComand);
|
|
|
- console.log('SSS6');
|
|
|
renderCommand(recentComand, el_jq, 3, function_obj);
|
|
|
} else {
|
|
|
- console.log('SSS7');
|
|
|
findInBlockCorrectPlace(el_jq, event, function_obj, command_type);
|
|
|
}
|
|
|
|
|
@@ -1050,7 +971,6 @@ function findBeforeOrAfterCommandToAddInsertBlock (el, event, function_obj, comm
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- console.log('XXX3');
|
|
|
var index = command_parent.commands_block.indexOf(command_target);
|
|
|
|
|
|
if (index > -1) {
|
|
@@ -1086,8 +1006,6 @@ function insertCommandInBlock (el, event, function_obj, command_type) {
|
|
|
|
|
|
} else if (el_jq.data('command').type == Models.COMMAND_TYPES.iftrue) {
|
|
|
|
|
|
- console.log('QQ9');
|
|
|
-
|
|
|
// no if ou no else?
|
|
|
var correct_div = $(document.elementFromPoint(event.pageX, event.pageY));
|
|
|
var is_in_if = true;
|
|
@@ -1137,7 +1055,6 @@ function insertCommandInBlock (el, event, function_obj, command_type) {
|
|
|
}
|
|
|
|
|
|
} else { // é do tipo switch
|
|
|
- console.log("está tentando inserir em um switch que está na raiz!");
|
|
|
addCommandToSwitchCase(event, function_obj, command_type);
|
|
|
}
|
|
|
}
|
|
@@ -1245,31 +1162,20 @@ function findInBlockCorrectPlace (el, event, function_obj, command_type, is_in_e
|
|
|
}
|
|
|
|
|
|
var borda_inferior = elemento_menor_distancia.parentNode.getBoundingClientRect().top + elemento_menor_distancia.parentNode.getBoundingClientRect().height;
|
|
|
-
|
|
|
- console.log("menor_distancia: ");
|
|
|
- console.log(elemento_menor_distancia);
|
|
|
|
|
|
// Está mais próximo da borda de baixo, ou seja.. inserir por último:
|
|
|
if ((borda_inferior - event.clientY) < menor_distancia) {
|
|
|
|
|
|
- console.log('QQ11');
|
|
|
-
|
|
|
var recentComand = genericCreateCommand(command_type);
|
|
|
|
|
|
var command_parent = el_jq.data('command');
|
|
|
|
|
|
if (is_in_else) {
|
|
|
- console.log('QQ15');
|
|
|
command_parent.commands_else.push(recentComand);
|
|
|
- console.log('el_jq');
|
|
|
- console.log(el_jq);
|
|
|
- console.log("$(el_jq.find('.commands_else')[0]):: ");
|
|
|
- console.log($(el_jq.find('.commands_else')[0]));
|
|
|
|
|
|
renderCommand(recentComand, el_jq, 3, function_obj);
|
|
|
|
|
|
} else {
|
|
|
- console.log('QQ16');
|
|
|
command_parent.commands_block.push(recentComand);
|
|
|
|
|
|
renderCommand(recentComand, $(el_jq.find('.block_commands')[0]), 3, function_obj);
|
|
@@ -1277,8 +1183,6 @@ function findInBlockCorrectPlace (el, event, function_obj, command_type, is_in_e
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- console.log('QQ12');
|
|
|
-
|
|
|
var recentComand = genericCreateCommand(command_type);
|
|
|
|
|
|
var command_parent = el_jq.data('command');
|