diff --git a/pandora_console/include/javascript/functions_pandora_networkmap.js b/pandora_console/include/javascript/functions_pandora_networkmap.js index b5a85ee5c3..72653abf07 100644 --- a/pandora_console/include/javascript/functions_pandora_networkmap.js +++ b/pandora_console/include/javascript/functions_pandora_networkmap.js @@ -213,7 +213,7 @@ function update_fictional_node(id_db_node) { graph.nodes[i].networkmap_id = networkmap_to_link; $("#id_node_" + i + networkmap_id + " title").html(name); - $("#id_node_" + i + networkmap_id + " tspan").html(name); + $("#id_node_" + i + networkmap_id + " tspan").html(ellipsize(name, 30)); } }); @@ -251,7 +251,7 @@ function update_node_name(id_db_node) { graph.nodes[i]['raw_text'] = data['raw_text']; $("#id_node_" + i + networkmap_id + " title").html(data['raw_text']); - $("#id_node_" + i + networkmap_id + " tspan").html(data['raw_text']); + $("#id_node_" + i + networkmap_id + " tspan").html(ellipsize(data['raw_text'], 30)); } }); @@ -773,7 +773,7 @@ function edit_node(data_node, dblClick) { $("#dialog_node_edit") .dialog("option", "title", - dialog_node_edit_title.replace("%s", node_selected['text'])); // It doesn't eval the possible XSS so it's ok + dialog_node_edit_title.replace("%s", ellipsize(node_selected['text'], 40))); // It doesn't eval the possible XSS so it's ok $("#dialog_node_edit").dialog("open"); if (node_selected.id_agent == undefined || node_selected.id_agent == -2) { @@ -3658,7 +3658,7 @@ function draw_elements_graph() { .append("tspan") .attr("style", "font-size: " + font_size + "px !important; font-family:Verdana; text-align:center; text-anchor:middle; fill:#000000") .text(function (d) { - return d.text; + return ellipsize(d.text, 30); }) .classed('dragable_node', true) //own dragable .on("click", selected_node) diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js index 8a1965268f..46e376509f 100644 --- a/pandora_console/include/javascript/pandora.js +++ b/pandora_console/include/javascript/pandora.js @@ -1562,4 +1562,11 @@ function round_with_decimals (value, multiplier = 1) { return Math.round(value * multiplier) / multiplier; } return round_with_decimals (value, multiplier * 10); -} \ No newline at end of file +} + +function ellipsize (str, max, ellipse) { + if (max == null) max = 140; + if (ellipse == null) ellipse = "…"; + + return str.trim().length > max ? str.substr(0, max).trim() + ellipse : str; +}