Explorar el Código

Update 'js/visualUI/commands/comment.js'

Fixes to solve problem to read 'ivph' file with comments (contribution of Edilson Cuambe/Gleyce Santos).
leo hace 1 semana
padre
commit
ecbec83b5f
Se han modificado 1 ficheros con 53 adiciones y 19 borrados
  1. 53 19
      js/visualUI/commands/comment.js

+ 53 - 19
js/visualUI/commands/comment.js

@@ -1,33 +1,67 @@
+// iVProg - www.usp.br/line/ivprog
+// LInE - Free Education, Private Data
+
 import { LocalizedStrings } from '../../services/localizedStringsService';
 import { LocalizedStrings } from '../../services/localizedStringsService';
 import * as VariableValueMenu from './variable_value_menu';
 import * as VariableValueMenu from './variable_value_menu';
 import * as CommandsManagement from '../commands';
 import * as CommandsManagement from '../commands';
 
 
 export function createFloatingCommand () {
 export function createFloatingCommand () {
-	return $('<div class="ui comment created_element"> <i class="ui icon small quote left"></i> <span class="span_comment_text" "> '+LocalizedStrings.getUI('text_comment')+' </span></div>');
-}
+  return $(
+    '<div class="ui comment created_element"> <i class="ui icon small quote left"></i> <span class="span_comment_text" "> ' +
+    LocalizedStrings.getUI("text_comment") +
+    ' </span></div>'
+    );
+  }
 
 
 export function renderCommand (command, function_obj) {
 export function renderCommand (command, function_obj) {
-	var el = $('<div class="ui comment command_container"> <i class="ui icon small quote left command_drag"></i> <i class="ui icon times red button_remove_command"></i> <div class="var_value_menu_div"></div> <div class="div_comment_text">'+'</div> </div>');
-	el.data('command', command);
+  var el = $(
+    '<div class="ui comment command_container"> ' +
+    '<i class="ui icon small quote left command_drag"></i> ' +
+    '<i class="ui icon times red button_remove_command"></i> ' +
+    '<div class="var_value_menu_div"></div> <div class="div_comment_text">' +
+    '</div> </div>' + "\n";
+    );
+  el.data('command', command);
+
+  addHandlers(command, function_obj, el);
 
 
-	addHandlers(command, function_obj, el);
+  renderTextComment(command, function_obj, el);
 
 
-	renderTextComment(command, function_obj, el);
+  return el;
+  }
 
 
-	return el;
-}
 
 
 function renderTextComment (command, function_obj, el) {
 function renderTextComment (command, function_obj, el) {
-	VariableValueMenu.renderMenu(command, command.comment_text, el.find('.var_value_menu_div'), function_obj, 20);
-}
+  //x VariableValueMenu.renderMenu(command, command.comment_text, el.find('.var_value_menu_div'), function_obj, 20);
+  let commentText = "";
 
 
-function addHandlers (command, function_obj, comment_dom) {
+  if (command.comment_text) {
+    if (typeof command.comment_text === "object") {
+      commentText = command.comment_text.content || command.comment_text.value || "";
+    } else if (typeof command.comment_text === "string") {
+      commentText = command.comment_text;
+      }
+    }
 
 
-	comment_dom.find('.button_remove_command').on('click', function() {
-		if (CommandsManagement.removeCommand(command, function_obj, comment_dom)) {
-			comment_dom.fadeOut(400, function() {
-				comment_dom.remove();
-			});
-		}
-	});
-}
+  if (!commentText) {
+    commentText = command.value || command.comment || command._text || "";
+    }
+
+  if (commentText) {
+    el.find(".var_value_menu_div").hide();
+    el.find(".div_comment_text").text(commentText).show();
+  } else {
+    el.find(".var_value_menu_div").hide();
+    el.find(".div_comment_text").text(LocalizedStrings.getUI("text_comment")).show();
+    }
+  }
+
+function addHandlers (command, function_obj, comment_dom) {
+  comment_dom.find('.button_remove_command').on('click', function() {
+    if (CommandsManagement.removeCommand(command, function_obj, comment_dom)) {
+      comment_dom.fadeOut(400, function() {
+      	comment_dom.remove();
+        });
+      }
+    });
+  }