From 2b6a9f02773dbaefca50a59be516c4f071925e34 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Mon, 31 Jan 2022 15:43:56 +0100 Subject: [PATCH] show agent and module name tip --- pandora_console/include/javascript/pandora.js | 19 ++++++++++++++++++- .../operation/agentes/ver_agente.php | 9 --------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js index ad70328117..e26cd5e2a8 100644 --- a/pandora_console/include/javascript/pandora.js +++ b/pandora_console/include/javascript/pandora.js @@ -88,6 +88,23 @@ function js_html_entity_decode(str) { return str2; } +function truncate_string(str, str_length, separator) { + if (str.length <= str_length) { + return str; + } + + separator = separator || "..."; + + var separator_length = separator.length, + chars_to_show = str_length - separator_length, + front_chars = Math.ceil(chars_to_show / 2), + tail_chars = Math.floor(chars_to_show / 2); + + return ( + str.substr(0, front_chars) + separator + str.substr(str.length - tail_chars) + ); +} + /** * Function to search an element in an array. * @@ -620,7 +637,7 @@ function module_changed_by_multiple_modules(event, id_module, selected) { s = js_html_entity_decode(val); $("#agents").append( $("") - .html(s) + .html(truncate_string(s, 30, "...")) .attr({ value: i, title: s }) ); $("#agents").fadeIn("normal"); diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index e97b828c9a..50ba2a7f9c 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -365,15 +365,6 @@ if (is_ajax()) { 'AW' ); - if ($truncate_agent_names === true) { - $names = array_map( - function ($name) { - return ui_print_truncate_text($name, 30); - }, - $names - ); - } - echo json_encode($names); return; }