Store query data in data attribute instead of HTML

Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
Michal Čihař 2017-01-18 09:35:54 +01:00
parent 9b4642af62
commit 9503e0f6aa
3 changed files with 5 additions and 7 deletions

View File

@ -16,10 +16,9 @@ AJAX.registerOnload('server_status_queries.js', function () {
// Build query statistics chart
var cdata = [];
try {
$.each(JSON.parse($('#serverstatusquerieschart').text()), function (key, value) {
$.each(JSON.parse($('#serverstatusquerieschart').data('chart'))), function (key, value) {
cdata.push([key, parseInt(value, 10)]);
});
$('#serverstatusquerieschart').empty();
$('#serverstatusquerieschart').data(
'queryPieChart',
PMA_createProfilingChart(

View File

@ -134,13 +134,12 @@ function PMA_getHtmlForServerStatusQueriesDetails($ServerStatusData)
$retval .= '</tbody>';
$retval .= '</table>';
$retval .= '<div id="serverstatusquerieschart">';
$retval .= '<div id="serverstatusquerieschart" data-chart="';
if ($other_sum > 0) {
$chart_json[__('Other')] = $other_sum;
}
$retval .= htmlspecialchars(json_encode($chart_json));
$retval .= '</div>';
$retval .= htmlspecialchars(json_encode($chart_json), ENT_QUOTES);
$retval .= '"></div>';
return $retval;
}

View File

@ -219,7 +219,7 @@ class PMA_ServerStatusQueries_Test extends PHPUnit_Framework_TestCase
//validate 3:serverstatusquerieschart
$this->assertContains(
'<div id="serverstatusquerieschart">',
'<div id="serverstatusquerieschart" data-chart="',
$html
);