1/* vim: set expandtab sw=4 ts=4 sts=4: */ 2 3$(function () { 4 Functions.checkNumberOfFields(); 5}); 6 7/** 8 * Holds common parameters such as server, db, table, etc 9 * 10 * The content for this is normally loaded from Header.php or 11 * Response.php and executed by ajax.js 12 */ 13var CommonParams = (function () { 14 /** 15 * @var hash params An associative array of key value pairs 16 * @access private 17 */ 18 var params = {}; 19 // The returned object is the public part of the module 20 return { 21 /** 22 * Saves all the key value pair that 23 * are provided in the input array 24 * 25 * @param obj hash The input array 26 * 27 * @return void 28 */ 29 setAll: function (obj) { 30 var updateNavigation = false; 31 for (var i in obj) { 32 if (params[i] !== undefined && params[i] !== obj[i]) { 33 if (i === 'db' || i === 'table') { 34 updateNavigation = true; 35 } 36 } 37 params[i] = obj[i]; 38 } 39 if (updateNavigation && 40 $('#pma_navigation_tree').hasClass('synced') 41 ) { 42 Navigation.showCurrent(); 43 } 44 }, 45 /** 46 * Retrieves a value given its key 47 * Returns empty string for undefined values 48 * 49 * @param name string The key 50 * 51 * @return string 52 */ 53 get: function (name) { 54 return params[name]; 55 }, 56 /** 57 * Saves a single key value pair 58 * 59 * @param name string The key 60 * @param value string The value 61 * 62 * @return self For chainability 63 */ 64 set: function (name, value) { 65 var updateNavigation = false; 66 if (name === 'db' || name === 'table' && 67 params[name] !== value 68 ) { 69 updateNavigation = true; 70 } 71 params[name] = value; 72 if (updateNavigation && 73 $('#pma_navigation_tree').hasClass('synced') 74 ) { 75 Navigation.showCurrent(); 76 } 77 return this; 78 }, 79 /** 80 * Returns the url query string using the saved parameters 81 * 82 * @return string 83 */ 84 getUrlQuery: function () { 85 var common = this.get('common_query'); 86 var separator = '?'; 87 var argsep = CommonParams.get('arg_separator'); 88 if (common.length > 0) { 89 separator = argsep; 90 } 91 return Functions.sprintf( 92 '%s%sserver=%s' + argsep + 'db=%s' + argsep + 'table=%s', 93 this.get('common_query'), 94 separator, 95 encodeURIComponent(this.get('server')), 96 encodeURIComponent(this.get('db')), 97 encodeURIComponent(this.get('table')) 98 ); 99 } 100 }; 101}()); 102 103/** 104 * Holds common parameters such as server, db, table, etc 105 * 106 * The content for this is normally loaded from Header.php or 107 * Response.php and executed by ajax.js 108 */ 109// eslint-disable-next-line no-unused-vars 110var CommonActions = { 111 /** 112 * Saves the database name when it's changed 113 * and reloads the query window, if necessary 114 * 115 * @param newDb string new_db The name of the new database 116 * 117 * @return void 118 */ 119 setDb: function (newDb) { 120 if (newDb !== CommonParams.get('db')) { 121 CommonParams.setAll({ 'db': newDb, 'table': '' }); 122 } 123 }, 124 /** 125 * Opens a database in the main part of the page 126 * 127 * @param newDb string The name of the new database 128 * 129 * @return void 130 */ 131 openDb: function (newDb) { 132 CommonParams 133 .set('db', newDb) 134 .set('table', ''); 135 this.refreshMain( 136 CommonParams.get('opendb_url') 137 ); 138 }, 139 /** 140 * Refreshes the main frame 141 * 142 * @param mixed url Undefined to refresh to the same page 143 * String to go to a different page, e.g: 'index.php' 144 * 145 * @return void 146 */ 147 refreshMain: function (url, callback) { 148 var newUrl = url; 149 if (! newUrl) { 150 newUrl = $('#selflink').find('a').attr('href') || window.location.pathname; 151 newUrl = newUrl.substring(0, newUrl.indexOf('?')); 152 } 153 newUrl += CommonParams.getUrlQuery(); 154 $('<a></a>', { href: newUrl }) 155 .appendTo('body') 156 .trigger('click') 157 .remove(); 158 AJAX.callback = callback; 159 } 160};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.