Use dot notation for accessing array members
Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
parent
32d1759ef3
commit
d681d77263
@ -1,12 +1,12 @@
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* @fileoverview Implements the shiftkey + click remove column
|
||||
* @fileoverview Implements the shiftkey + click remove column
|
||||
* from order by clause funcationality
|
||||
* @name columndelete
|
||||
*
|
||||
* @requires jQuery
|
||||
*/
|
||||
|
||||
|
||||
function captureURL(url)
|
||||
{
|
||||
var URL = {};
|
||||
@ -14,56 +14,56 @@ function captureURL(url)
|
||||
// Exclude the url part till HTTP
|
||||
url = url.substr(url.search("sql.php"), url.length);
|
||||
// The url part between ORDER BY and &session_max_rows needs to be replaced.
|
||||
URL['head'] = url.substr(0, url.indexOf('ORDER+BY') + 9);
|
||||
URL['tail'] = url.substr(url.indexOf("&session_max_rows"), url.length);
|
||||
return URL;
|
||||
}
|
||||
URL.head = url.substr(0, url.indexOf('ORDER+BY') + 9);
|
||||
URL.tail = url.substr(url.indexOf("&session_max_rows"), url.length);
|
||||
return URL;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is for navigating to the generated URL
|
||||
*
|
||||
* @param object target HTMLAnchor element
|
||||
* @param object target HTMLAnchor element
|
||||
* @param object parent HTMLDom Object
|
||||
*/
|
||||
|
||||
function redirect(target, parent)
|
||||
{
|
||||
{
|
||||
var URL = captureURL(target);
|
||||
var begin = target.indexOf('ORDER+BY') + 8;
|
||||
var end = target.indexOf('&session_max_rows');
|
||||
// get the names of the columns involved
|
||||
var between_part = target.substr(begin, end-begin);
|
||||
var columns = between_part.split('%2C+');
|
||||
var columns = between_part.split('%2C+');
|
||||
// If the given column is not part of the order clause exit from this function
|
||||
var index = parent.find('small').length ? parent.find('small').text() : '';
|
||||
var index = parent.find('small').length ? parent.find('small').text() : '';
|
||||
if (index == ''){
|
||||
return;
|
||||
}
|
||||
// Remove the current clicked column
|
||||
columns.splice(index-1, 1);
|
||||
columns.splice(index-1, 1);
|
||||
// If all the columns have been removed dont submit a query with nothing
|
||||
// After order by clause.
|
||||
if (columns.length == 0){
|
||||
var head = URL['head'];
|
||||
head = head.slice(0,head.indexOf('ORDER+BY'));
|
||||
URL['head'] = head;
|
||||
// removing the last sort order should have priority over what
|
||||
if (columns.length == 0){
|
||||
var head = URL.head;
|
||||
head = head.slice(0,head.indexOf('ORDER+BY'));
|
||||
URL.head = head;
|
||||
// removing the last sort order should have priority over what
|
||||
// is remembered via the RememberSorting directive
|
||||
URL['tail'] += '&discard_remembered_sort=1';
|
||||
URL.tail += '&discard_remembered_sort=1';
|
||||
}
|
||||
var middle_part = columns.join('%2C+');
|
||||
url = URL['head'] + middle_part + URL['tail'];
|
||||
var middle_part = columns.join('%2C+');
|
||||
url = URL.head + middle_part + URL.tail;
|
||||
window.location.replace(url);
|
||||
}
|
||||
|
||||
|
||||
AJAX.registerOnload('keyhandler.js', function () {
|
||||
$("th.draggable.column_heading.pointer.marker a").live('click', function (event) {
|
||||
AJAX.registerOnload('keyhandler.js', function () {
|
||||
$("th.draggable.column_heading.pointer.marker a").live('click', function (event) {
|
||||
if (event.shiftKey) {
|
||||
event.preventDefault();
|
||||
redirect($(this).attr("href"), $(this).parent());
|
||||
redirect($(this).attr("href"), $(this).parent());
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
AJAX.registerTeardown('keyhandler.js', function () {
|
||||
|
||||
@ -234,7 +234,7 @@ function check_time_out(time_limit)
|
||||
clearTimeout(time_out);
|
||||
time_out = setTimeout(function(){
|
||||
$.get(href, params, function (data) {
|
||||
if (data['message'] === 'timeout') {
|
||||
if (data.message === 'timeout') {
|
||||
PMA_ajaxShowMessage(
|
||||
'<div class="error">' +
|
||||
PMA_messages.strTimeOutError +
|
||||
|
||||
@ -361,7 +361,7 @@ function confirmQuery(theForm1, sqlQuery1)
|
||||
// "is_js_confirmed" form field so the confirm test won't be
|
||||
// run on the server side and allows to submit the form
|
||||
if (is_confirmed) {
|
||||
theForm1.elements['is_js_confirmed'].value = 1;
|
||||
theForm1.elements.is_js_confirmed.value = 1;
|
||||
return true;
|
||||
}
|
||||
// statement is rejected -> do not submit the form
|
||||
@ -393,21 +393,21 @@ function checkSqlQuery(theForm)
|
||||
var sqlQuery = codemirror_editor.display.input;
|
||||
sqlQuery.value = codemirror_editor.getValue();
|
||||
} else {
|
||||
var sqlQuery = theForm.elements['sql_query'];
|
||||
var sqlQuery = theForm.elements.sql_query;
|
||||
}
|
||||
var isEmpty = 1;
|
||||
var space_re = new RegExp('\\s+');
|
||||
if (typeof(theForm.elements['sql_file']) != 'undefined' &&
|
||||
theForm.elements['sql_file'].value.replace(space_re, '') !== '') {
|
||||
if (typeof(theForm.elements.sql_file) != 'undefined' &&
|
||||
theForm.elements.sql_file.value.replace(space_re, '') !== '') {
|
||||
return true;
|
||||
}
|
||||
if (typeof(theForm.elements['sql_localfile']) != 'undefined' &&
|
||||
theForm.elements['sql_localfile'].value.replace(space_re, '') !== '') {
|
||||
if (typeof(theForm.elements.sql_localfile) != 'undefined' &&
|
||||
theForm.elements.sql_localfile.value.replace(space_re, '') !== '') {
|
||||
return true;
|
||||
}
|
||||
if (isEmpty && typeof(theForm.elements['id_bookmark']) != 'undefined' &&
|
||||
(theForm.elements['id_bookmark'].value !== null || theForm.elements['id_bookmark'].value !== '') &&
|
||||
theForm.elements['id_bookmark'].selectedIndex !== 0) {
|
||||
if (isEmpty && typeof(theForm.elements.id_bookmark) != 'undefined' &&
|
||||
(theForm.elements.id_bookmark.value !== null || theForm.elements.id_bookmark.value !== '') &&
|
||||
theForm.elements.id_bookmark.selectedIndex !== 0) {
|
||||
return true;
|
||||
}
|
||||
// Checks for "DROP/DELETE/ALTER" statements
|
||||
@ -3366,15 +3366,15 @@ AJAX.registerOnload('functions.js', function () {
|
||||
cache: false,
|
||||
type: 'POST',
|
||||
data: {
|
||||
favorite_tables: (window.localStorage['favorite_tables']
|
||||
favorite_tables: (window.localStorage.favorite_tables
|
||||
!== undefined)
|
||||
? window.localStorage['favorite_tables']
|
||||
? window.localStorage.favorite_tables
|
||||
: ''
|
||||
},
|
||||
success: function (data) {
|
||||
// Update localStorage.
|
||||
if (window.localStorage !== undefined) {
|
||||
window.localStorage['favorite_tables']
|
||||
window.localStorage.favorite_tables
|
||||
= data.favorite_tables;
|
||||
}
|
||||
$('#pma_favorite_list').html(data.list);
|
||||
@ -3797,9 +3797,9 @@ AJAX.registerOnload('functions.js', function () {
|
||||
*/
|
||||
$('a.take_theme').click(function (e) {
|
||||
var what = this.name;
|
||||
if (window.opener && window.opener.document.forms['setTheme'].elements['set_theme']) {
|
||||
window.opener.document.forms['setTheme'].elements['set_theme'].value = what;
|
||||
window.opener.document.forms['setTheme'].submit();
|
||||
if (window.opener && window.opener.document.forms.setTheme.elements.set_theme) {
|
||||
window.opener.document.forms.setTheme.elements.set_theme.value = what;
|
||||
window.opener.document.forms.setTheme.submit();
|
||||
window.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -362,9 +362,9 @@ AJAX.registerOnload('server_status_monitor.js', function () {
|
||||
|
||||
// Server is localhost => We can add cpu/memory/swap to the default chart
|
||||
if (server_db_isLocal) {
|
||||
defaultChartGrid['c3'] = presetCharts['cpu'];
|
||||
defaultChartGrid['c4'] = presetCharts['memory'];
|
||||
defaultChartGrid['c5'] = presetCharts['swap'];
|
||||
defaultChartGrid.c3 = presetCharts.cpu;
|
||||
defaultChartGrid.c4 = presetCharts.memory;
|
||||
defaultChartGrid.c5 = presetCharts.swap;
|
||||
}
|
||||
|
||||
$('a[href="#rearrangeCharts"], a[href="#endChartEditMode"]').click(function (event) {
|
||||
@ -616,8 +616,8 @@ AJAX.registerOnload('server_status_monitor.js', function () {
|
||||
|
||||
// If json ok, try applying config
|
||||
try {
|
||||
window.localStorage['monitorCharts'] = JSON.stringify(json.monitorCharts);
|
||||
window.localStorage['monitorSettings'] = JSON.stringify(json.monitorSettings);
|
||||
window.localStorage.monitorCharts = JSON.stringify(json.monitorCharts);
|
||||
window.localStorage.monitorSettings = JSON.stringify(json.monitorSettings);
|
||||
rebuildGrid();
|
||||
} catch (err) {
|
||||
alert(PMA_messages.strFailedBuildingGrid);
|
||||
@ -697,15 +697,15 @@ AJAX.registerOnload('server_status_monitor.js', function () {
|
||||
}
|
||||
var icon = PMA_getImage('s_success.png'), msg = '', str = '';
|
||||
|
||||
if (logVars['general_log'] == 'ON') {
|
||||
if (logVars['slow_query_log'] == 'ON') {
|
||||
if (logVars.general_log == 'ON') {
|
||||
if (logVars.slow_query_log == 'ON') {
|
||||
msg = PMA_messages.strBothLogOn;
|
||||
} else {
|
||||
msg = PMA_messages.strGenLogOn;
|
||||
}
|
||||
}
|
||||
|
||||
if (msg.length === 0 && logVars['slow_query_log'] == 'ON') {
|
||||
if (msg.length === 0 && logVars.slow_query_log == 'ON') {
|
||||
msg = PMA_messages.strSlowLogOn;
|
||||
}
|
||||
|
||||
@ -717,22 +717,22 @@ AJAX.registerOnload('server_status_monitor.js', function () {
|
||||
str = '<b>' + PMA_messages.strCurrentSettings + '</b><br/><div class="smallIndent">';
|
||||
str += icon + msg + '<br />';
|
||||
|
||||
if (logVars['log_output'] != 'TABLE') {
|
||||
if (logVars.log_output != 'TABLE') {
|
||||
str += PMA_getImage('s_error.png') + ' ' + PMA_messages.strLogOutNotTable + '<br />';
|
||||
} else {
|
||||
str += PMA_getImage('s_success.png') + ' ' + PMA_messages.strLogOutIsTable + '<br />';
|
||||
}
|
||||
|
||||
if (logVars['slow_query_log'] == 'ON') {
|
||||
if (logVars['long_query_time'] > 2) {
|
||||
if (logVars.slow_query_log == 'ON') {
|
||||
if (logVars.long_query_time > 2) {
|
||||
str += PMA_getImage('s_attention.png') + ' ';
|
||||
str += $.sprintf(PMA_messages.strSmallerLongQueryTimeAdvice, logVars['long_query_time']);
|
||||
str += $.sprintf(PMA_messages.strSmallerLongQueryTimeAdvice, logVars.long_query_time);
|
||||
str += '<br />';
|
||||
}
|
||||
|
||||
if (logVars['long_query_time'] < 2) {
|
||||
if (logVars.long_query_time < 2) {
|
||||
str += PMA_getImage('s_success.png') + ' ';
|
||||
str += $.sprintf(PMA_messages.strLongQueryTimeSet, logVars['long_query_time']);
|
||||
str += $.sprintf(PMA_messages.strLongQueryTimeSet, logVars.long_query_time);
|
||||
str += '<br />';
|
||||
}
|
||||
}
|
||||
@ -745,7 +745,7 @@ AJAX.registerOnload('server_status_monitor.js', function () {
|
||||
str += PMA_messages.strSettingsAppliedGlobal + '<br/>';
|
||||
|
||||
var varValue = 'TABLE';
|
||||
if (logVars['log_output'] == 'TABLE') {
|
||||
if (logVars.log_output == 'TABLE') {
|
||||
varValue = 'FILE';
|
||||
}
|
||||
|
||||
@ -753,7 +753,7 @@ AJAX.registerOnload('server_status_monitor.js', function () {
|
||||
str += $.sprintf(PMA_messages.strSetLogOutput, varValue);
|
||||
str += ' </a><br />';
|
||||
|
||||
if (logVars['general_log'] != 'ON') {
|
||||
if (logVars.general_log != 'ON') {
|
||||
str += '- <a class="set" href="#general_log-ON">';
|
||||
str += $.sprintf(PMA_messages.strEnableVar, 'general_log');
|
||||
str += ' </a><br />';
|
||||
@ -763,7 +763,7 @@ AJAX.registerOnload('server_status_monitor.js', function () {
|
||||
str += ' </a><br />';
|
||||
}
|
||||
|
||||
if (logVars['slow_query_log'] != 'ON') {
|
||||
if (logVars.slow_query_log != 'ON') {
|
||||
str += '- <a class="set" href="#slow_query_log-ON">';
|
||||
str += $.sprintf(PMA_messages.strEnableVar, 'slow_query_log');
|
||||
str += ' </a><br />';
|
||||
@ -774,7 +774,7 @@ AJAX.registerOnload('server_status_monitor.js', function () {
|
||||
}
|
||||
|
||||
varValue = 5;
|
||||
if (logVars['long_query_time'] > 2) {
|
||||
if (logVars.long_query_time > 2) {
|
||||
varValue = 1;
|
||||
}
|
||||
|
||||
@ -789,7 +789,7 @@ AJAX.registerOnload('server_status_monitor.js', function () {
|
||||
str += '</div>';
|
||||
|
||||
$dialog.find('div.monitorUse').toggle(
|
||||
logVars['log_output'] == 'TABLE' && (logVars['slow_query_log'] == 'ON' || logVars['general_log'] == 'ON')
|
||||
logVars.log_output == 'TABLE' && (logVars.slow_query_log == 'ON' || logVars.general_log == 'ON')
|
||||
);
|
||||
|
||||
$dialog.find('div.ajaxContent').html(str);
|
||||
@ -929,16 +929,16 @@ AJAX.registerOnload('server_status_monitor.js', function () {
|
||||
|
||||
/* Apply default values & config */
|
||||
if (window.localStorage) {
|
||||
if (window.localStorage['monitorCharts']) {
|
||||
runtime.charts = $.parseJSON(window.localStorage['monitorCharts']);
|
||||
if (window.localStorage.monitorCharts) {
|
||||
runtime.charts = $.parseJSON(window.localStorage.monitorCharts);
|
||||
}
|
||||
if (window.localStorage['monitorSettings']) {
|
||||
monitorSettings = $.parseJSON(window.localStorage['monitorSettings']);
|
||||
if (window.localStorage.monitorSettings) {
|
||||
monitorSettings = $.parseJSON(window.localStorage.monitorSettings);
|
||||
}
|
||||
|
||||
$('a[href="#clearMonitorConfig"]').toggle(runtime.charts !== null);
|
||||
|
||||
if (runtime.charts !== null && monitorProtocolVersion != window.localStorage['monitorVersion']) {
|
||||
if (runtime.charts !== null && monitorProtocolVersion != window.localStorage.monitorVersion) {
|
||||
$('#emptyDialog').dialog({title: PMA_messages.strIncompatibleMonitorConfig});
|
||||
$('#emptyDialog').html(PMA_messages.strIncompatibleMonitorConfigDescription);
|
||||
|
||||
@ -1417,7 +1417,7 @@ AJAX.registerOnload('server_status_monitor.js', function () {
|
||||
// update chart options
|
||||
// keep ticks number/positioning consistent while refreshrate changes
|
||||
var tickInterval = (runtime.xmax - runtime.xmin) / 5;
|
||||
elem.chart['axes']['xaxis'].ticks = [(runtime.xmax - tickInterval * 4),
|
||||
elem.chart.axes.xaxis.ticks = [(runtime.xmax - tickInterval * 4),
|
||||
(runtime.xmax - tickInterval * 3), (runtime.xmax - tickInterval * 2),
|
||||
(runtime.xmax - tickInterval), runtime.xmax];
|
||||
|
||||
@ -1426,13 +1426,13 @@ AJAX.registerOnload('server_status_monitor.js', function () {
|
||||
elem.title !== PMA_messages.strSystemMemory &&
|
||||
elem.title !== PMA_messages.strSystemSwap
|
||||
) {
|
||||
elem.chart['axes']['yaxis']['max'] = Math.ceil(elem.maxYLabel * 1.1);
|
||||
elem.chart['axes']['yaxis']['tickInterval'] = Math.ceil(elem.maxYLabel * 1.1 / 5);
|
||||
elem.chart.axes.yaxis.max = Math.ceil(elem.maxYLabel * 1.1);
|
||||
elem.chart.axes.yaxis.tickInterval = Math.ceil(elem.maxYLabel * 1.1 / 5);
|
||||
} else if (elem.title === PMA_messages.strSystemMemory ||
|
||||
elem.title === PMA_messages.strSystemSwap
|
||||
) {
|
||||
elem.chart['axes']['yaxis']['max'] = Math.ceil(total * 1.1 / 100) * 100;
|
||||
elem.chart['axes']['yaxis']['tickInterval'] = Math.ceil(total * 1.1 / 5);
|
||||
elem.chart.axes.yaxis.max = Math.ceil(total * 1.1 / 100) * 100;
|
||||
elem.chart.axes.yaxis.tickInterval = Math.ceil(total * 1.1 / 5);
|
||||
}
|
||||
i++;
|
||||
|
||||
@ -1713,10 +1713,10 @@ AJAX.registerOnload('server_status_monitor.js', function () {
|
||||
$t.next().text(rowData[sumColumnName]);
|
||||
// Restore slow log columns
|
||||
if (isSlowLog) {
|
||||
$t.parent().children('td:nth-child(3)').text(rowData['query_time']);
|
||||
$t.parent().children('td:nth-child(4)').text(rowData['lock_time']);
|
||||
$t.parent().children('td:nth-child(5)').text(rowData['rows_sent']);
|
||||
$t.parent().children('td:nth-child(6)').text(rowData['rows_examined']);
|
||||
$t.parent().children('td:nth-child(3)').text(rowData.query_time);
|
||||
$t.parent().children('td:nth-child(4)').text(rowData.lock_time);
|
||||
$t.parent().children('td:nth-child(5)').text(rowData.rows_sent);
|
||||
$t.parent().children('td:nth-child(6)').text(rowData.rows_examined);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1878,7 +1878,7 @@ AJAX.registerOnload('server_status_monitor.js', function () {
|
||||
|
||||
$('#logTable table').tablesorter({
|
||||
sortList: [[cols.length - 1, 1]],
|
||||
widgets: ['fast-zebra']
|
||||
widgets: .fast-zebra
|
||||
});
|
||||
|
||||
$('#logTable table thead th')
|
||||
@ -2076,9 +2076,9 @@ AJAX.registerOnload('server_status_monitor.js', function () {
|
||||
});
|
||||
|
||||
if (window.localStorage) {
|
||||
window.localStorage['monitorCharts'] = JSON.stringify(gridCopy);
|
||||
window.localStorage['monitorSettings'] = JSON.stringify(monitorSettings);
|
||||
window.localStorage['monitorVersion'] = monitorProtocolVersion;
|
||||
window.localStorage.monitorCharts = JSON.stringify(gridCopy);
|
||||
window.localStorage.monitorSettings = JSON.stringify(monitorSettings);
|
||||
window.localStorage.monitorVersion = monitorProtocolVersion;
|
||||
}
|
||||
|
||||
$('a[href="#clearMonitorConfig"]').show();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user