Remove Config object from the Window global object
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
5f7ab155fd
commit
83e8ed59cc
@ -5,7 +5,7 @@ import { CommonParams } from './common.js';
|
||||
/**
|
||||
* Functions used in configuration forms and on user preferences pages
|
||||
*/
|
||||
window.Config = {};
|
||||
const Config = {};
|
||||
|
||||
window.configInlineParams;
|
||||
window.configScriptLoaded;
|
||||
@ -18,7 +18,7 @@ window.configScriptLoaded;
|
||||
*
|
||||
* @return {boolean}
|
||||
*/
|
||||
window.Config.isStorageSupported = (type, warn = false) => {
|
||||
Config.isStorageSupported = (type, warn = false) => {
|
||||
try {
|
||||
window[type].setItem('PMATest', 'test');
|
||||
// Check whether key-value pair was set successfully
|
||||
@ -166,7 +166,7 @@ function getFieldValue (field, fieldType) {
|
||||
*
|
||||
* @return {object}
|
||||
*/
|
||||
window.Config.getAllValues = () => {
|
||||
Config.getAllValues = () => {
|
||||
var $elements = $('fieldset input, fieldset select, fieldset textarea');
|
||||
var values = {};
|
||||
var type;
|
||||
@ -225,7 +225,7 @@ function checkFieldDefault (field, type) {
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
window.Config.getIdPrefix = function (element) {
|
||||
Config.getIdPrefix = function (element) {
|
||||
return $(element).attr('id').replace(/[^-]+$/, '');
|
||||
};
|
||||
|
||||
@ -328,7 +328,7 @@ window.validators = {
|
||||
* @param {boolean} onKeyUp whether fire on key up
|
||||
* @param {Array} params validation function parameters
|
||||
*/
|
||||
window.Config.registerFieldValidator = (id, type, onKeyUp, params) => {
|
||||
Config.registerFieldValidator = (id, type, onKeyUp, params) => {
|
||||
if (typeof window.validators[type] === 'undefined') {
|
||||
return;
|
||||
}
|
||||
@ -378,7 +378,7 @@ function getFieldValidators (fieldId, onKeyUpOnly) {
|
||||
*
|
||||
* @param {object} errorList list of errors in the form {field id: error array}
|
||||
*/
|
||||
window.Config.displayErrors = function (errorList) {
|
||||
Config.displayErrors = function (errorList) {
|
||||
var tempIsEmpty = function (item) {
|
||||
return item !== '';
|
||||
};
|
||||
@ -442,7 +442,7 @@ function setDisplayError () {
|
||||
$('fieldset.optbox').each(function () {
|
||||
validateFieldset(this, false, errors);
|
||||
});
|
||||
window.Config.displayErrors(errors);
|
||||
Config.displayErrors(errors);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -510,10 +510,10 @@ function validateFieldAndFieldset (field, isKeyUp) {
|
||||
var errors = {};
|
||||
validateField($field, isKeyUp, errors);
|
||||
validateFieldset($field.closest('fieldset.optbox'), isKeyUp, errors);
|
||||
window.Config.displayErrors(errors);
|
||||
Config.displayErrors(errors);
|
||||
}
|
||||
|
||||
window.Config.loadInlineConfig = () => {
|
||||
Config.loadInlineConfig = () => {
|
||||
if (! Array.isArray(window.configInlineParams)) {
|
||||
return;
|
||||
}
|
||||
@ -524,11 +524,11 @@ window.Config.loadInlineConfig = () => {
|
||||
}
|
||||
};
|
||||
|
||||
window.Config.setupValidation = function () {
|
||||
Config.setupValidation = function () {
|
||||
validate = {};
|
||||
window.configScriptLoaded = true;
|
||||
if (window.configScriptLoaded && typeof window.configInlineParams !== 'undefined') {
|
||||
window.Config.loadInlineConfig();
|
||||
Config.loadInlineConfig();
|
||||
}
|
||||
// register validators and mark custom values
|
||||
var $elements = $('.optbox input[id], .optbox select[id], .optbox textarea[id]');
|
||||
@ -567,7 +567,7 @@ window.Config.setupValidation = function () {
|
||||
validateFieldset(this, false, errors);
|
||||
});
|
||||
|
||||
window.Config.displayErrors(errors);
|
||||
Config.displayErrors(errors);
|
||||
} else if ($checkPageRefresh) {
|
||||
$checkPageRefresh.val('1');
|
||||
}
|
||||
@ -606,7 +606,7 @@ function restoreField (fieldId) {
|
||||
setFieldValue($field, getFieldType($field), window.defaultValues[fieldId]);
|
||||
}
|
||||
|
||||
window.Config.setupRestoreField = function () {
|
||||
Config.setupRestoreField = function () {
|
||||
$('div.tab-content')
|
||||
.on('mouseenter', '.restore-default, .set-value', function () {
|
||||
$(this).css('opacity', 1);
|
||||
@ -693,7 +693,7 @@ function updatePrefsDate () {
|
||||
* Prepares message which informs that localStorage preferences are available and can be imported or deleted
|
||||
*/
|
||||
function offerPrefsAutoimport () {
|
||||
var hasConfig = (window.Config.isStorageSupported('localStorage')) && (window.localStorage.config || false);
|
||||
var hasConfig = (Config.isStorageSupported('localStorage')) && (window.localStorage.config || false);
|
||||
var $cnt = $('#prefs_autoload');
|
||||
if (! $cnt.length || ! hasConfig) {
|
||||
return;
|
||||
@ -726,7 +726,7 @@ function offerPrefsAutoimport () {
|
||||
/**
|
||||
* @return {function}
|
||||
*/
|
||||
window.Config.off = function () {
|
||||
Config.off = function () {
|
||||
return function () {
|
||||
$('.optbox input[id], .optbox select[id], .optbox textarea[id]').off('change').off('keyup');
|
||||
$('.optbox input[type=button][name=submit_reset]').off('click');
|
||||
@ -741,13 +741,13 @@ window.Config.off = function () {
|
||||
/**
|
||||
* @return {function}
|
||||
*/
|
||||
window.Config.on = function () {
|
||||
Config.on = function () {
|
||||
return function () {
|
||||
var $topmenuUpt = $('#user_prefs_tabs');
|
||||
$topmenuUpt.find('a.active').attr('rel', 'samepage');
|
||||
$topmenuUpt.find('a:not(.active)').attr('rel', 'newpage');
|
||||
|
||||
window.Config.setupValidation();
|
||||
Config.setupValidation();
|
||||
adjustPrefsNotification();
|
||||
|
||||
$('.optbox input[type=button][name=submit_reset]').on('click', function () {
|
||||
@ -758,7 +758,7 @@ window.Config.on = function () {
|
||||
setDisplayError();
|
||||
});
|
||||
|
||||
window.Config.setupRestoreField();
|
||||
Config.setupRestoreField();
|
||||
|
||||
offerPrefsAutoimport();
|
||||
var $radios = $('#import_local_storage, #export_local_storage');
|
||||
@ -783,7 +783,7 @@ window.Config.on = function () {
|
||||
});
|
||||
|
||||
// detect localStorage state
|
||||
var lsSupported = window.Config.isStorageSupported('localStorage', true);
|
||||
var lsSupported = Config.isStorageSupported('localStorage', true);
|
||||
var lsExists = lsSupported ? (window.localStorage.config || false) : false;
|
||||
$('div.localStorage-' + (lsSupported ? 'un' : '') + 'supported').hide();
|
||||
$('div.localStorage-' + (lsExists ? 'empty' : 'exists')).hide();
|
||||
@ -820,3 +820,7 @@ window.Config.on = function () {
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
window.Config = Config;
|
||||
|
||||
export { Config };
|
||||
|
||||
@ -4,6 +4,7 @@ import { Navigation } from './navigation.js';
|
||||
import { CommonActions, CommonParams } from './common.js';
|
||||
import { mysqlDocKeyword, mysqlDocBuiltin } from './modules/doc-links.js';
|
||||
import { Indexes } from './indexes.js';
|
||||
import { Config } from './config.js';
|
||||
|
||||
/* global ChartType, ColumnType, DataTable, JQPlotChartFactory */ // js/chart.js
|
||||
/* global DatabaseStructure */ // js/database/structure.js
|
||||
@ -934,7 +935,7 @@ Functions.onloadIdleEvent = function () {
|
||||
function UpdateIdleTime () {
|
||||
var href = 'index.php?route=/';
|
||||
var guid = 'default';
|
||||
if (window.Config.isStorageSupported('sessionStorage')) {
|
||||
if (Config.isStorageSupported('sessionStorage')) {
|
||||
guid = window.sessionStorage.guid;
|
||||
}
|
||||
var params = {
|
||||
@ -969,7 +970,7 @@ Functions.onloadIdleEvent = function () {
|
||||
updateTimeout = window.setTimeout(UpdateIdleTime, interval);
|
||||
} else { // timeout occurred
|
||||
clearInterval(incInterval);
|
||||
if (window.Config.isStorageSupported('sessionStorage')) {
|
||||
if (Config.isStorageSupported('sessionStorage')) {
|
||||
window.sessionStorage.clear();
|
||||
}
|
||||
// append the login form on the page, disable all the forms which were not disabled already, close all the open jqueryui modal boxes
|
||||
@ -997,7 +998,7 @@ Functions.onloadIdleEvent = function () {
|
||||
CommonParams.get('LoginCookieValidity'),
|
||||
CommonParams.get('session_gc_maxlifetime')
|
||||
);
|
||||
if (window.Config.isStorageSupported('sessionStorage')) {
|
||||
if (Config.isStorageSupported('sessionStorage')) {
|
||||
window.sessionStorage.setItem('guid', guid());
|
||||
}
|
||||
var interval = (sessionTimeout - 5) * 1000;
|
||||
@ -3518,7 +3519,7 @@ Functions.onloadRecentFavoriteTables = () => {
|
||||
cache: false,
|
||||
type: 'POST',
|
||||
data: {
|
||||
'favoriteTables': (window.Config.isStorageSupported('localStorage') && typeof window.localStorage.favoriteTables !== 'undefined')
|
||||
'favoriteTables': (Config.isStorageSupported('localStorage') && typeof window.localStorage.favoriteTables !== 'undefined')
|
||||
? window.localStorage.favoriteTables
|
||||
: '',
|
||||
'server': CommonParams.get('server'),
|
||||
@ -3526,7 +3527,7 @@ Functions.onloadRecentFavoriteTables = () => {
|
||||
},
|
||||
success: function (data) {
|
||||
// Update localStorage.
|
||||
if (window.Config.isStorageSupported('localStorage')) {
|
||||
if (Config.isStorageSupported('localStorage')) {
|
||||
window.localStorage.favoriteTables = data.favoriteTables;
|
||||
}
|
||||
$('#pma_favorite_list').html(data.list);
|
||||
|
||||
@ -6,6 +6,7 @@ import { Navigation } from './navigation.js';
|
||||
import { PageSettings } from './page_settings.js';
|
||||
import { crossFramingProtection } from './cross_framing_protection.js';
|
||||
import { Indexes } from './indexes.js';
|
||||
import { Config } from './config.js';
|
||||
|
||||
AJAX.registerOnload('main.js', () => AJAX.removeSubmitEvents());
|
||||
$(AJAX.loadEventHandler());
|
||||
@ -23,8 +24,8 @@ AJAX.registerOnload('main.js', KeyHandlerEvents.on());
|
||||
|
||||
crossFramingProtection();
|
||||
|
||||
AJAX.registerTeardown('config.js', window.Config.off());
|
||||
AJAX.registerOnload('config.js', window.Config.on());
|
||||
AJAX.registerTeardown('main.js', Config.off());
|
||||
AJAX.registerOnload('main.js', Config.on());
|
||||
|
||||
$.ajaxPrefilter(Functions.addNoCacheToAjaxRequests());
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import $ from 'jquery';
|
||||
import { Functions } from './functions.js';
|
||||
import { CommonParams } from './common.js';
|
||||
import { Config } from './config.js';
|
||||
|
||||
/**
|
||||
* function used in or for navigation panel
|
||||
@ -16,7 +17,7 @@ const Navigation = {};
|
||||
*/
|
||||
Navigation.treeStateUpdate = function () {
|
||||
// update if session storage is supported
|
||||
if (window.Config.isStorageSupported('sessionStorage')) {
|
||||
if (Config.isStorageSupported('sessionStorage')) {
|
||||
var storage = window.sessionStorage;
|
||||
// try catch necessary here to detect whether
|
||||
// content to be stored exceeds storage capacity
|
||||
@ -43,7 +44,7 @@ Navigation.treeStateUpdate = function () {
|
||||
* @return {void}
|
||||
*/
|
||||
Navigation.filterStateUpdate = function (filterName, filterValue) {
|
||||
if (window.Config.isStorageSupported('sessionStorage')) {
|
||||
if (Config.isStorageSupported('sessionStorage')) {
|
||||
var storage = window.sessionStorage;
|
||||
try {
|
||||
var currentFilter = $.extend({}, JSON.parse(storage.getItem('navTreeSearchFilters')));
|
||||
@ -63,7 +64,7 @@ Navigation.filterStateUpdate = function (filterName, filterValue) {
|
||||
* @return {void}
|
||||
*/
|
||||
Navigation.filterStateRestore = function () {
|
||||
if (window.Config.isStorageSupported('sessionStorage')
|
||||
if (Config.isStorageSupported('sessionStorage')
|
||||
&& typeof window.sessionStorage.navTreeSearchFilters !== 'undefined'
|
||||
) {
|
||||
var searchClauses = JSON.parse(window.sessionStorage.navTreeSearchFilters);
|
||||
@ -531,7 +532,7 @@ Navigation.onload = () => function () {
|
||||
}
|
||||
}
|
||||
|
||||
var hasLocalStorage = window.Config.isStorageSupported('localStorage') &&
|
||||
var hasLocalStorage = Config.isStorageSupported('localStorage') &&
|
||||
typeof window.localStorage.favoriteTables !== 'undefined';
|
||||
$.ajax({
|
||||
url: $self.attr('href'),
|
||||
@ -551,7 +552,7 @@ Navigation.onload = () => function () {
|
||||
$('#' + anchorId).attr('title')
|
||||
);
|
||||
// Update localStorage.
|
||||
if (window.Config.isStorageSupported('localStorage')) {
|
||||
if (Config.isStorageSupported('localStorage')) {
|
||||
window.localStorage.favoriteTables = data.favoriteTables;
|
||||
}
|
||||
} else {
|
||||
@ -561,7 +562,7 @@ Navigation.onload = () => function () {
|
||||
});
|
||||
});
|
||||
// Check if session storage is supported
|
||||
if (window.Config.isStorageSupported('sessionStorage')) {
|
||||
if (Config.isStorageSupported('sessionStorage')) {
|
||||
var storage = window.sessionStorage;
|
||||
// remove tree from storage if Navi_panel config form is submitted
|
||||
$(document).on('submit', 'form.config-form', function () {
|
||||
@ -903,8 +904,8 @@ Navigation.ensureSettings = function (selflink) {
|
||||
$.post('index.php?route=/navigation&ajax_request=1', params, function (data) {
|
||||
if (typeof data !== 'undefined' && data.success) {
|
||||
$('#pma_navi_settings_container').html(data.message);
|
||||
window.Config.setupRestoreField();
|
||||
window.Config.setupValidation();
|
||||
Config.setupRestoreField();
|
||||
Config.setupValidation();
|
||||
$('#pma_navigation_settings').find('form').attr('action', selflink);
|
||||
} else {
|
||||
Functions.ajaxShowMessage(data.error);
|
||||
|
||||
@ -2,6 +2,7 @@ import $ from 'jquery';
|
||||
import { AJAX } from '../../ajax.js';
|
||||
import { Functions } from '../../functions.js';
|
||||
import { CommonParams } from '../../common.js';
|
||||
import { Config } from '../../config.js';
|
||||
|
||||
/**
|
||||
* @fileoverview Javascript functions used in server status monitor page
|
||||
@ -700,7 +701,7 @@ AJAX.registerOnload('server/status/monitor.js', function () {
|
||||
|
||||
// If json ok, try applying config
|
||||
try {
|
||||
if (window.Config.isStorageSupported('localStorage')) {
|
||||
if (Config.isStorageSupported('localStorage')) {
|
||||
window.localStorage.monitorCharts = JSON.stringify(json.monitorCharts);
|
||||
window.localStorage.monitorSettings = JSON.stringify(json.monitorSettings);
|
||||
}
|
||||
@ -708,7 +709,7 @@ AJAX.registerOnload('server/status/monitor.js', function () {
|
||||
} catch (err) {
|
||||
alert(window.Messages.strFailedBuildingGrid);
|
||||
// If an exception is thrown, load default again
|
||||
if (window.Config.isStorageSupported('localStorage')) {
|
||||
if (Config.isStorageSupported('localStorage')) {
|
||||
window.localStorage.removeItem('monitorCharts');
|
||||
window.localStorage.removeItem('monitorSettings');
|
||||
}
|
||||
@ -736,7 +737,7 @@ AJAX.registerOnload('server/status/monitor.js', function () {
|
||||
|
||||
$('a[href="#clearMonitorConfig"]').on('click', function (event) {
|
||||
event.preventDefault();
|
||||
if (window.Config.isStorageSupported('localStorage')) {
|
||||
if (Config.isStorageSupported('localStorage')) {
|
||||
window.localStorage.removeItem('monitorCharts');
|
||||
window.localStorage.removeItem('monitorSettings');
|
||||
window.localStorage.removeItem('monitorVersion');
|
||||
@ -1031,7 +1032,7 @@ AJAX.registerOnload('server/status/monitor.js', function () {
|
||||
var i;
|
||||
|
||||
/* Apply default values & config */
|
||||
if (window.Config.isStorageSupported('localStorage')) {
|
||||
if (Config.isStorageSupported('localStorage')) {
|
||||
if (typeof window.localStorage.monitorCharts !== 'undefined') {
|
||||
runtime.charts = JSON.parse(window.localStorage.monitorCharts);
|
||||
}
|
||||
@ -2310,7 +2311,7 @@ AJAX.registerOnload('server/status/monitor.js', function () {
|
||||
gridCopy[key].maxYLabel = elem.maxYLabel;
|
||||
});
|
||||
|
||||
if (window.Config.isStorageSupported('localStorage')) {
|
||||
if (Config.isStorageSupported('localStorage')) {
|
||||
window.localStorage.monitorCharts = JSON.stringify(gridCopy);
|
||||
window.localStorage.monitorSettings = JSON.stringify(monitorSettings);
|
||||
window.localStorage.monitorVersion = monitorProtocolVersion;
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
import $ from 'jquery';
|
||||
|
||||
/* eslint-disable no-unused-vars */
|
||||
/**
|
||||
* Dummy implementation of the ajax page loader
|
||||
*/
|
||||
window.AJAX = {
|
||||
registerOnload: function (idx, func) {
|
||||
$(func);
|
||||
},
|
||||
registerTeardown: function (idx, func) {
|
||||
}
|
||||
};
|
||||
@ -1,4 +1,5 @@
|
||||
import $ from 'jquery';
|
||||
import { Config } from '../config.js';
|
||||
|
||||
/**
|
||||
* Functions used in Setup configuration forms
|
||||
@ -107,7 +108,7 @@ function ajaxValidate (parent, id, values) {
|
||||
error[key] = Array.isArray(value) ? value : [value];
|
||||
}
|
||||
}
|
||||
window.Config.displayErrors(error);
|
||||
Config.displayErrors(error);
|
||||
},
|
||||
complete: function () {
|
||||
$parent.removeData('ajax');
|
||||
@ -169,7 +170,7 @@ $.extend(true, window.validators, {
|
||||
*/
|
||||
Server: function (isKeyUp) {
|
||||
if (!isKeyUp) {
|
||||
ajaxValidate(this, 'Server', window.Config.getAllValues());
|
||||
ajaxValidate(this, 'Server', Config.getAllValues());
|
||||
}
|
||||
return true;
|
||||
},
|
||||
@ -195,9 +196,9 @@ $.extend(true, window.validators, {
|
||||
return true;
|
||||
}
|
||||
|
||||
var prefix = window.Config.getIdPrefix($(this).find('input'));
|
||||
var prefix = Config.getIdPrefix($(this).find('input'));
|
||||
if ($('#' + prefix + 'pmadb').val() !== '') {
|
||||
ajaxValidate(this, 'Server_pmadb', window.Config.getAllValues());
|
||||
ajaxValidate(this, 'Server_pmadb', Config.getAllValues());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -3,6 +3,7 @@ import { AJAX } from './ajax.js';
|
||||
import { Functions } from './functions.js';
|
||||
import { Navigation } from './navigation.js';
|
||||
import { CommonActions, CommonParams } from './common.js';
|
||||
import { Config } from './config.js';
|
||||
|
||||
/**
|
||||
* @fileoverview functions used wherever an sql query form is used
|
||||
@ -48,7 +49,7 @@ Sql.urlEncode = function (str) {
|
||||
Sql.autoSave = function (query) {
|
||||
if (query) {
|
||||
var key = Sql.getAutoSavedKey();
|
||||
if (window.Config.isStorageSupported('localStorage')) {
|
||||
if (Config.isStorageSupported('localStorage')) {
|
||||
window.localStorage.setItem(key, query);
|
||||
} else {
|
||||
window.Cookies.set(key, query, { path: CommonParams.get('rootPath') });
|
||||
@ -70,7 +71,7 @@ Sql.showThisQuery = function (db, table, query) {
|
||||
'table': table,
|
||||
'query': query
|
||||
};
|
||||
if (window.Config.isStorageSupported('localStorage')) {
|
||||
if (Config.isStorageSupported('localStorage')) {
|
||||
window.localStorage.showThisQuery = 1;
|
||||
window.localStorage.showThisQueryObject = JSON.stringify(showThisQueryObject);
|
||||
} else {
|
||||
@ -86,7 +87,7 @@ Sql.showThisQuery = function (db, table, query) {
|
||||
Sql.setShowThisQuery = function () {
|
||||
var db = $('input[name="db"]').val();
|
||||
var table = $('input[name="table"]').val();
|
||||
if (window.Config.isStorageSupported('localStorage')) {
|
||||
if (Config.isStorageSupported('localStorage')) {
|
||||
if (window.localStorage.showThisQueryObject !== undefined) {
|
||||
var storedDb = JSON.parse(window.localStorage.showThisQueryObject).db;
|
||||
var storedTable = JSON.parse(window.localStorage.showThisQueryObject).table;
|
||||
@ -116,7 +117,7 @@ Sql.setShowThisQuery = function () {
|
||||
*/
|
||||
Sql.autoSaveWithSort = function (query) {
|
||||
if (query) {
|
||||
if (window.Config.isStorageSupported('localStorage')) {
|
||||
if (Config.isStorageSupported('localStorage')) {
|
||||
window.localStorage.setItem('autoSavedSqlSort', query);
|
||||
} else {
|
||||
window.Cookies.set('autoSavedSqlSort', query, { path: CommonParams.get('rootPath') });
|
||||
@ -130,7 +131,7 @@ Sql.autoSaveWithSort = function (query) {
|
||||
* @return {void}
|
||||
*/
|
||||
Sql.clearAutoSavedSort = function () {
|
||||
if (window.Config.isStorageSupported('localStorage')) {
|
||||
if (Config.isStorageSupported('localStorage')) {
|
||||
window.localStorage.removeItem('autoSavedSqlSort');
|
||||
} else {
|
||||
window.Cookies.set('autoSavedSqlSort', '', { path: CommonParams.get('rootPath') });
|
||||
@ -303,7 +304,7 @@ const insertQuery = function (queryType) {
|
||||
key += '.' + table;
|
||||
}
|
||||
key = 'autoSavedSql_' + key;
|
||||
if (window.Config.isStorageSupported('localStorage') &&
|
||||
if (Config.isStorageSupported('localStorage') &&
|
||||
typeof window.localStorage.getItem(key) === 'string') {
|
||||
setQuery(window.localStorage.getItem(key));
|
||||
} else if (window.Cookies.get(key, { path: CommonParams.get('rootPath') })) {
|
||||
@ -465,7 +466,7 @@ AJAX.registerOnload('sql.js', function () {
|
||||
$('#sqlquery').on('input propertychange', function () {
|
||||
Sql.autoSave($('#sqlquery').val());
|
||||
});
|
||||
var useLocalStorageValue = window.Config.isStorageSupported('localStorage') && typeof window.localStorage.autoSavedSqlSort !== 'undefined';
|
||||
var useLocalStorageValue = Config.isStorageSupported('localStorage') && typeof window.localStorage.autoSavedSqlSort !== 'undefined';
|
||||
// Save sql query with sort
|
||||
if ($('#RememberSorting') !== undefined && $('#RememberSorting').is(':checked')) {
|
||||
$('select[name="sql_query"]').on('change', function () {
|
||||
@ -1209,7 +1210,7 @@ Sql.getAutoSavedKey = function () {
|
||||
Sql.checkSavedQuery = function () {
|
||||
var key = Sql.getAutoSavedKey();
|
||||
|
||||
if (window.Config.isStorageSupported('localStorage') &&
|
||||
if (Config.isStorageSupported('localStorage') &&
|
||||
typeof window.localStorage.getItem(key) === 'string') {
|
||||
Functions.ajaxShowMessage(window.Messages.strPreviousSaveQuery);
|
||||
} else if (window.Cookies.get(key, { path: CommonParams.get('rootPath') })) {
|
||||
|
||||
@ -85,8 +85,6 @@ class ExportController extends AbstractController
|
||||
$GLOBALS['error'] = $result;
|
||||
}
|
||||
|
||||
$this->addScriptFiles(['config.js']);
|
||||
|
||||
$relationParameters = $this->relation->getRelationParameters();
|
||||
|
||||
$this->render('preferences/header', [
|
||||
|
||||
@ -85,8 +85,6 @@ class FeaturesController extends AbstractController
|
||||
$GLOBALS['error'] = $result;
|
||||
}
|
||||
|
||||
$this->addScriptFiles(['config.js']);
|
||||
|
||||
$relationParameters = $this->relation->getRelationParameters();
|
||||
|
||||
$this->render('preferences/header', [
|
||||
|
||||
@ -85,8 +85,6 @@ class ImportController extends AbstractController
|
||||
$GLOBALS['error'] = $result;
|
||||
}
|
||||
|
||||
$this->addScriptFiles(['config.js']);
|
||||
|
||||
$relationParameters = $this->relation->getRelationParameters();
|
||||
|
||||
$this->render('preferences/header', [
|
||||
|
||||
@ -85,8 +85,6 @@ class MainPanelController extends AbstractController
|
||||
$GLOBALS['error'] = $result;
|
||||
}
|
||||
|
||||
$this->addScriptFiles(['config.js']);
|
||||
|
||||
$relationParameters = $this->relation->getRelationParameters();
|
||||
|
||||
$this->render('preferences/header', [
|
||||
|
||||
@ -262,8 +262,6 @@ class ManageController extends AbstractController
|
||||
return;
|
||||
}
|
||||
|
||||
$this->addScriptFiles(['config.js']);
|
||||
|
||||
$relationParameters = $this->relation->getRelationParameters();
|
||||
|
||||
echo $this->template->render('preferences/header', [
|
||||
|
||||
@ -85,8 +85,6 @@ class NavigationController extends AbstractController
|
||||
$GLOBALS['error'] = $result;
|
||||
}
|
||||
|
||||
$this->addScriptFiles(['config.js']);
|
||||
|
||||
$relationParameters = $this->relation->getRelationParameters();
|
||||
|
||||
$this->render('preferences/header', [
|
||||
|
||||
@ -85,8 +85,6 @@ class SqlController extends AbstractController
|
||||
$GLOBALS['error'] = $result;
|
||||
}
|
||||
|
||||
$this->addScriptFiles(['config.js']);
|
||||
|
||||
$relationParameters = $this->relation->getRelationParameters();
|
||||
|
||||
$this->render('preferences/header', [
|
||||
|
||||
@ -141,7 +141,6 @@ class Header
|
||||
$this->scripts->addFile('index.php', ['route' => '/messages', 'l' => $GLOBALS['lang']]);
|
||||
$this->scripts->addFile('shared.js');
|
||||
$this->scripts->addFile('menu_resizer.js');
|
||||
$this->scripts->addFile('config.js');
|
||||
$this->scripts->addFile('main.js');
|
||||
|
||||
$this->scripts->addCode($this->getJsParamsCode());
|
||||
@ -336,21 +335,6 @@ class Header
|
||||
$this->scripts->addCode('ConsoleEnterExecutes=' . ($GLOBALS['cfg']['ConsoleEnterExecutes'] ? 'true' : 'false'));
|
||||
$this->scripts->addFiles($this->console->getScripts());
|
||||
|
||||
// if database storage for user preferences is transient,
|
||||
// offer to load exported settings from localStorage
|
||||
// (detection will be done in JavaScript)
|
||||
$userprefsOfferImport = false;
|
||||
if (
|
||||
$GLOBALS['config']->get('user_preferences') === 'session'
|
||||
&& ! isset($_SESSION['userprefs_autoload'])
|
||||
) {
|
||||
$userprefsOfferImport = true;
|
||||
}
|
||||
|
||||
if ($userprefsOfferImport) {
|
||||
$this->scripts->addFile('config.js');
|
||||
}
|
||||
|
||||
if ($this->menuEnabled && $GLOBALS['server'] > 0) {
|
||||
$nav = new Navigation(
|
||||
$this->template,
|
||||
@ -363,7 +347,10 @@ class Header
|
||||
$customHeader = Config::renderHeader();
|
||||
|
||||
// offer to load user preferences from localStorage
|
||||
if ($userprefsOfferImport) {
|
||||
if (
|
||||
$GLOBALS['config']->get('user_preferences') === 'session'
|
||||
&& ! isset($_SESSION['userprefs_autoload'])
|
||||
) {
|
||||
$loadUserPreferences = $this->userPreferences->autoloadGetHeader();
|
||||
}
|
||||
|
||||
|
||||
@ -10,10 +10,9 @@
|
||||
<script type="text/javascript" src="../js/vendor/jquery/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="../js/vendor/jquery/jquery-ui.min.js"></script>
|
||||
<script type="text/javascript" src="../js/vendor/bootstrap/bootstrap.bundle.min.js"></script>
|
||||
<script type="text/javascript" src="../js/dist/setup/ajax.js"></script>
|
||||
<script type="text/javascript" src="../js/dist/config.js"></script>
|
||||
<script type="text/javascript" src="../js/dist/setup/scripts.js"></script>
|
||||
<script type="text/javascript" src="../{{ url('/messages') }}"></script>
|
||||
<script type="text/javascript" src="../js/dist/shared.js"></script>
|
||||
<script type="text/javascript" src="../js/dist/setup/scripts.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@ -263,7 +263,6 @@ class HeaderTest extends AbstractTestCase
|
||||
['name' => 'index.php', 'fire' => 0],
|
||||
['name' => 'shared.js', 'fire' => 0],
|
||||
['name' => 'menu_resizer.js', 'fire' => 1],
|
||||
['name' => 'config.js', 'fire' => 1],
|
||||
['name' => 'main.js', 'fire' => 1],
|
||||
];
|
||||
$this->assertSame($expected, $scripts->getFiles());
|
||||
|
||||
@ -13,7 +13,6 @@ module.exports = [
|
||||
entry: {
|
||||
'chart': './js/src/chart.js',
|
||||
'codemirror/addon/lint/sql-lint': './js/src/codemirror/addon/lint/sql-lint.js',
|
||||
'config': './js/src/config.js',
|
||||
'console': { import: './js/src/console.js', library: { name: 'Console', type: 'window', export: 'Console' } },
|
||||
'datetimepicker': './js/src/datetimepicker.js',
|
||||
'database/central_columns': './js/src/database/central_columns.js',
|
||||
@ -59,7 +58,6 @@ module.exports = [
|
||||
'server/status/variables': './js/src/server/status/variables.js',
|
||||
'server/user_groups': './js/src/server/user_groups.js',
|
||||
'server/variables': './js/src/server/variables.js',
|
||||
'setup/ajax': './js/src/setup/ajax.js',
|
||||
'setup/scripts': './js/src/setup/scripts.js',
|
||||
'shortcuts_handler': './js/src/shortcuts_handler.js',
|
||||
'sql': './js/src/sql.js',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user