3 Functions.checkNumberOfFields();
7 * Holds common parameters such as server, db, table, etc
9 * The content for this is normally loaded from Header.php or
10 * Response.php and executed by ajax.js
12 var CommonParams = (function () {
14 * @var hash params An associative array of key value pairs
18 // The returned object is the public part of the module
21 * Saves all the key value pair that
22 * are provided in the input array
24 * @param obj hash The input array
28 setAll: function (obj) {
29 var updateNavigation = false;
31 if (params[i] !== undefined && params[i] !== obj[i]) {
32 if (i === 'db' || i === 'table') {
33 updateNavigation = true;
38 if (updateNavigation &&
39 $('#pma_navigation_tree').hasClass('synced')
41 Navigation.showCurrent();
45 * Retrieves a value given its key
46 * Returns empty string for undefined values
48 * @param name string The key
52 get: function (name) {
56 * Saves a single key value pair
58 * @param name string The key
59 * @param value string The value
61 * @return self For chainability
63 set: function (name, value) {
64 var updateNavigation = false;
65 if (name === 'db' || name === 'table' &&
66 params[name] !== value
68 updateNavigation = true;
71 if (updateNavigation &&
72 $('#pma_navigation_tree').hasClass('synced')
74 Navigation.showCurrent();
79 * Returns the url query string using the saved parameters
81 * @param {string} separator New separator
85 getUrlQuery: function (separator) {
86 var sep = (typeof separator !== 'undefined') ? separator : '?';
87 var common = this.get('common_query');
88 var argsep = CommonParams.get('arg_separator');
89 if (common.length > 0) {
92 return Functions.sprintf(
93 '%s%sserver=%s' + argsep + 'db=%s' + argsep + 'table=%s',
94 this.get('common_query'),
96 encodeURIComponent(this.get('server')),
97 encodeURIComponent(this.get('db')),
98 encodeURIComponent(this.get('table'))
105 * Holds common parameters such as server, db, table, etc
107 * The content for this is normally loaded from Header.php or
108 * Response.php and executed by ajax.js
110 // eslint-disable-next-line no-unused-vars
111 var CommonActions = {
113 * Saves the database name when it's changed
114 * and reloads the query window, if necessary
116 * @param newDb string new_db The name of the new database
120 setDb: function (newDb) {
121 if (newDb !== CommonParams.get('db')) {
122 CommonParams.setAll({ 'db': newDb, 'table': '' });
126 * Opens a database in the main part of the page
128 * @param newDb string The name of the new database
132 openDb: function (newDb) {
137 CommonParams.get('opendb_url')
141 * Refreshes the main frame
143 * @param mixed url Undefined to refresh to the same page
144 * String to go to a different page, e.g: 'index.php'
148 refreshMain: function (url, callback) {
151 newUrl = $('#selflink').find('a').attr('href') || window.location.pathname;
152 newUrl = newUrl.substring(0, newUrl.indexOf('?'));
154 if (newUrl.indexOf('?') !== -1) {
155 newUrl += CommonParams.getUrlQuery('&');
157 newUrl += CommonParams.getUrlQuery();
159 $('<a></a>', { href: newUrl })
163 AJAX.callback = callback;