From 6b38ca71f78dd18ea57a0c065b2fff35ee542a77 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Mon, 8 Mar 2010 12:49:49 +0000 Subject: [PATCH] 2010-03-08 Miguel de Dios * include/javascript/pandora.js: change the code into function "html_entity_decode" for fix the decode in IE6 and rename the function to "js_html_entity_decode" for clean source code. * include/javascript/jquery.pandora.controls.js, include/javascript/pandora_modules.js, godmode/alerts/alert_list.php, godmode/alerts/configure_alert_action.php, godmode/reporting/reporting_builder.php, godmode/reporting/map_builder.php, godmode/reporting/graph_builder.php: use the rewrite new function javascript js_html_entity_decode. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2483 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 13 ++++++++++ pandora_console/godmode/alerts/alert_list.php | 2 +- .../godmode/alerts/configure_alert_action.php | 2 +- .../godmode/reporting/graph_builder.php | 4 ++-- .../godmode/reporting/map_builder.php | 4 ++-- .../godmode/reporting/reporting_builder.php | 4 ++-- .../javascript/jquery.pandora.controls.js | 6 ++--- pandora_console/include/javascript/pandora.js | 19 ++++++++------- .../include/javascript/pandora_modules.js | 24 +++++++++---------- 9 files changed, 46 insertions(+), 32 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 6241809aae..2680b3f078 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,16 @@ +2010-03-08 Miguel de Dios + + * include/javascript/pandora.js: change the code into function + "html_entity_decode" for fix the decode in IE6 and rename the function to + "js_html_entity_decode" for clean source code. + + * include/javascript/jquery.pandora.controls.js, + include/javascript/pandora_modules.js, godmode/alerts/alert_list.php, + godmode/alerts/configure_alert_action.php, + godmode/reporting/reporting_builder.php, godmode/reporting/map_builder.php, + godmode/reporting/graph_builder.php: use the rewrite new function javascript + js_html_entity_decode. + 2010-03-06 SAncho Lerena * install.php: Fixed width of textarea, too small. diff --git a/pandora_console/godmode/alerts/alert_list.php b/pandora_console/godmode/alerts/alert_list.php index 3cbecee911..fe2ffd1e1e 100644 --- a/pandora_console/godmode/alerts/alert_list.php +++ b/pandora_console/godmode/alerts/alert_list.php @@ -663,7 +663,7 @@ $(document).ready (function () { success: function (data) { $('#id_agent_module').append ($('').attr ('value', 0).text ("--")); jQuery.each (data, function (i, val) { - s = html_entity_decode (val['nombre']); + s = js_html_entity_decode (val['nombre']); $('#id_agent_module').append ($('').attr ('value', val['id_agente_modulo']).text (s)); }); $('#id_agent_module').enable(); diff --git a/pandora_console/godmode/alerts/configure_alert_action.php b/pandora_console/godmode/alerts/configure_alert_action.php index 9a697c3d22..1ccb0fbfab 100644 --- a/pandora_console/godmode/alerts/configure_alert_action.php +++ b/pandora_console/godmode/alerts/configure_alert_action.php @@ -113,7 +113,7 @@ $(document).ready (function () { jQuery.get ("ajax.php", values, function (data, status) { - original_command = html_entity_decode (data["command"]); + original_command = js_html_entity_decode (data["command"]); render_command_preview (original_command); }, "json" diff --git a/pandora_console/godmode/reporting/graph_builder.php b/pandora_console/godmode/reporting/graph_builder.php index 8bfa25fb1b..cf0e72a4bb 100644 --- a/pandora_console/godmode/reporting/graph_builder.php +++ b/pandora_console/godmode/reporting/graph_builder.php @@ -678,7 +678,7 @@ function agent_changed () { success: function (data) { $('#id_module').append ($('').attr ('value', 0).text ("--")); jQuery.each (data, function (i, val) { - s = html_entity_decode (val['nombre']); + s = js_html_entity_decode (val['nombre']); $('#id_module').append ($('').attr ('value', val['id_agente_modulo']).text (s)); }); $('#id_module').fadeIn ('normal'); @@ -735,7 +735,7 @@ $(document).ready (function () { success: function (data) { $('#id_module').append ($('').attr ('value', 0).text ("--")); jQuery.each (data, function (i, val) { - s = html_entity_decode (val['nombre']); + s = js_html_entity_decode (val['nombre']); $('#id_module').append ($('').attr ('value', val['id_agente_modulo']).text (s)); }); $('#id_module').fadeIn ('normal'); diff --git a/pandora_console/godmode/reporting/map_builder.php b/pandora_console/godmode/reporting/map_builder.php index 618a0d208e..2f8d606042 100644 --- a/pandora_console/godmode/reporting/map_builder.php +++ b/pandora_console/godmode/reporting/map_builder.php @@ -597,7 +597,7 @@ $(document).ready (function () { success: function (data) { $('#module').append ($('').attr ('value', 0).text ("--")); jQuery.each (data, function (i, val) { - s = html_entity_decode (val['nombre']); + s = js_html_entity_decode (val['nombre']); $('#module').append ($('').attr ('value', val['id_agente_modulo']).text (s)); }); $('#module').fadeIn ('normal'); @@ -724,7 +724,7 @@ $(document).ready (function () { $('#module').append ($('').attr ('value', 0).text ("--")); jQuery.each (data, function (i, val) { var val_id_agente_modulo = parseInt(val['id_agente_modulo']); - s = html_entity_decode (val['nombre']); + s = js_html_entity_decode (val['nombre']); option = $(""); option.attr ('value', val['id_agente_modulo']).text (s); diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index c36395df17..bc111021f5 100644 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -605,7 +605,7 @@ function refresh_table () { // success: function (data) { // $('#id_module').append ($('').attr ('value', 0).text ("--")); // jQuery.each (data, function (i, val) { -// s = html_entity_decode (val['nombre']); +// s = js_html_entity_decode (val['nombre']); // $('#id_module').append ($('').attr ('value', val['id_agente_modulo']).text (s.toLowerCase())); // }); // $('#id_module').fadeIn ('normal'); @@ -705,7 +705,7 @@ $(document).ready (function () { success: function (data) { $('#id_module').append ($('').attr ('value', 0).text ("--")); jQuery.each (data, function (i, val) { - s = html_entity_decode (val['nombre']); + s = js_html_entity_decode (val['nombre']); $('#id_module').append ($('').attr ('value', val['id_agente_modulo']).text (s.toLowerCase())); }); $('#id_module').fadeIn ('normal'); diff --git a/pandora_console/include/javascript/jquery.pandora.controls.js b/pandora_console/include/javascript/jquery.pandora.controls.js index 954b01b2df..db1d178dbd 100644 --- a/pandora_console/include/javascript/jquery.pandora.controls.js +++ b/pandora_console/include/javascript/jquery.pandora.controls.js @@ -97,7 +97,7 @@ config.callbackPre (); option = $("") .attr ("value", value['id_agente_modulo']) - .html (html_entity_decode (value['nombre'])); + .html (js_html_entity_decode (value['nombre'])); config.callbackPost (i, value, option); $(config.moduleSelect).append (option); }); @@ -151,8 +151,8 @@ config.callbackPre (); option = $("") .attr ("value", value['id']) - .html (html_entity_decode (value['template']['name'])) - .append (" ("+html_entity_decode (value['module_name'])+")"); + .html (js_html_entity_decode (value['template']['name'])) + .append (" ("+js_html_entity_decode (value['module_name'])+")"); config.callbackPost (i, value, option); $(config.alertSelect).append (option); }); diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js index d694ddcb12..d69f56b3f8 100644 --- a/pandora_console/include/javascript/pandora.js +++ b/pandora_console/include/javascript/pandora.js @@ -26,16 +26,17 @@ function open_help (help_id) { * * @retval str with entities decoded */ -function html_entity_decode (str) { +function js_html_entity_decode (str) { if (! str) return ""; - var ta = document.createElement ("textarea"); - ta.innerHTML = str.replace (//g,">").replace(/</g,'<').replace(/>/g,'>') - .replace(/\/g,'\\').replace(/"/g,'\"').replace(/'/g,'\'') - .replace(/&/g,'&'); - - return ta.value; + + str2 = str.replace (//g,">").replace(/</g,'<').replace(/>/g,'>') + .replace(/\/g,'\\').replace(/"/g,'\"').replace(/'/g,'\'') + .replace(/&/g,'&') + .replace(/ /g, '\r').replace(/ /g, '\n'); + + return str2; } /** @@ -77,7 +78,7 @@ function agent_changed (event, id_agent, selected) { $('#module').empty (); $('#module').append ($('').html ("").attr ("value", 0)); jQuery.each (data, function (i, val) { - s = html_entity_decode (val['nombre']); + s = js_html_entity_decode (val['nombre']); $('#module').append ($('').html (s).attr ("value", val['id_agente_modulo'])); $('#module').fadeIn ('normal'); }); diff --git a/pandora_console/include/javascript/pandora_modules.js b/pandora_console/include/javascript/pandora_modules.js index 3333848f3b..bdfcbe16d0 100644 --- a/pandora_console/include/javascript/pandora_modules.js +++ b/pandora_console/include/javascript/pandora_modules.js @@ -68,10 +68,10 @@ function configure_modules_form () { "id_module_component" : this.value }, function (data, status) { - configuration_data = html_entity_decode (data['data']); + configuration_data = js_html_entity_decode (data['data']); - $("#text-name").attr ("value", html_entity_decode (data["name"])); - $("#textarea_description").attr ("value", html_entity_decode (data["description"])); + $("#text-name").attr ("value", js_html_entity_decode (data["name"])); + $("#textarea_description").attr ("value", js_html_entity_decode (data["description"])); $("#textarea_configuration_data").attr ("value", configuration_data); $("#component_loading").hide (); @@ -126,24 +126,24 @@ function configure_modules_form () { "id_module_component" : this.value }, function (data, status) { - $("#text-name").attr ("value", html_entity_decode (data["name"])); - $("#textarea_description").attr ("value", html_entity_decode (data["description"])); + $("#text-name").attr ("value", js_html_entity_decode (data["name"])); + $("#textarea_description").attr ("value", js_html_entity_decode (data["description"])); $("#id_module_type option[value="+data["type"]+"]").select (1); $("#text-max").attr ("value", data["max"]); $("#text-min").attr ("value", data["min"]); $("#text-module_interval").attr ("value", data["module_interval"]); $("#text-tcp_port").attr ("value", data["tcp_port"]); - $("#textarea_tcp_send").attr ("value", html_entity_decode (data["tcp_send"])); - $("#textarea_tcp_rcv").attr ("value", html_entity_decode (data["tcp_rcv"])); - $("#text-snmp_community").attr ("value", html_entity_decode (data["snmp_community"])); - $("#text-snmp_oid").attr ("value", html_entity_decode (data["snmp_oid"])).show (); + $("#textarea_tcp_send").attr ("value", js_html_entity_decode (data["tcp_send"])); + $("#textarea_tcp_rcv").attr ("value", js_html_entity_decode (data["tcp_rcv"])); + $("#text-snmp_community").attr ("value", js_html_entity_decode (data["snmp_community"])); + $("#text-snmp_oid").attr ("value", js_html_entity_decode (data["snmp_oid"])).show (); $("#oid, img#edit_oid").hide (); $("#id_module_group option["+data["id_group"]+"]").select (1); $("#max_timeout").attr ("value", data["max_timeout"]); $("#id_plugin option[value="+data["id_plugin"]+"]").select (1); - $("#text-plugin_user").attr ("value", html_entity_decode (data["plugin_user"])); - $("#password-plugin_pass").attr ("value", html_entity_decode (data["plugin_pass"])); - $("#text-plugin_parameter").attr ("value", html_entity_decode (data["plugin_parameter"])); + $("#text-plugin_user").attr ("value", js_html_entity_decode (data["plugin_user"])); + $("#password-plugin_pass").attr ("value", js_html_entity_decode (data["plugin_pass"])); + $("#text-plugin_parameter").attr ("value", js_html_entity_decode (data["plugin_parameter"])); if (data["history_data"]) $("#checkbox-history_data").check (); else