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 return Functions.sprintf(
90 '%s%sserver=%s' + argsep + 'db=%s' + argsep + 'table=%s',
93 encodeURIComponent(this.get('server')),
94 encodeURIComponent(this.get('db')),
95 encodeURIComponent(this.get('table'))
102 * Holds common parameters such as server, db, table, etc
104 * The content for this is normally loaded from Header.php or
105 * Response.php and executed by ajax.js
107 // eslint-disable-next-line no-unused-vars
108 var CommonActions = {
110 * Saves the database name when it's changed
111 * and reloads the query window, if necessary
113 * @param newDb string new_db The name of the new database
117 setDb: function (newDb) {
118 if (newDb !== CommonParams.get('db')) {
119 CommonParams.setAll({ 'db': newDb, 'table': '' });
123 * Opens a database in the main part of the page
125 * @param newDb string The name of the new database
129 openDb: function (newDb) {
134 CommonParams.get('opendb_url')
138 * Refreshes the main frame
140 * @param mixed url Undefined to refresh to the same page
141 * String to go to a different page, e.g: 'index.php'
145 refreshMain: function (url, callback) {
148 newUrl = $('#selflink').find('a').attr('href') || window.location.pathname;
149 newUrl = newUrl.substring(0, newUrl.indexOf('?'));
151 if (newUrl.indexOf('?') !== -1) {
152 newUrl += CommonParams.getUrlQuery(CommonParams.get('arg_separator'));
154 newUrl += CommonParams.getUrlQuery('?');
156 $('<a></a>', { href: newUrl })
160 AJAX.callback = callback;