Bug fix for token mismatch error on server_databases.php page.

Signed-Off-By: Piyush Vijay <piyushvijay.1997@gmail.com>
This commit is contained in:
Piyush Vijay 2018-07-25 20:17:46 +05:30
parent 177e101379
commit d5eb59bb62
2 changed files with 56 additions and 0 deletions

1
.gitignore vendored
View File

@ -55,3 +55,4 @@ composer.lock
/vendor/
# NPM
/node_modules/
yarn.lock

View File

@ -11,6 +11,19 @@ import { methods } from './menu_resizer';
// import { GlobalVariables, timePicker, validations } from '../variables/export_variables';
import { PMA_Messages as PMA_messages } from '../variables/export_variables';
/**
* Make sure that ajax requests will not be cached
* by appending a random variable to their parameters
*/
$.ajaxPrefilter(function (options, originalOptions, jqXHR) {
var nocache = new Date().getTime() + '' + Math.floor(Math.random() * 1000000);
if (typeof options.data === 'string') {
options.data += '&_nocache=' + nocache + '&token=' + encodeURIComponent(PMA_commonParams.get('token'));
} else if (typeof options.data === 'object') {
options.data = $.extend(originalOptions.data, { '_nocache' : nocache, 'token': PMA_commonParams.get('token') });
}
});
/**
* Comes from menu_resizer.js
*/
@ -134,6 +147,48 @@ $.fn.PMA_confirm = function (question, url, callbackFn, openCallback) {
});
};
/**
* jQuery function to sort a table's body after a new row has been appended to it.
*
* @param string text_selector string to select the sortKey's text
*
* @return jQuery Object for chaining purposes
*/
$.fn.PMA_sort_table = function (text_selector) {
return this.each(function () {
/**
* @var table_body Object referring to the table's <tbody> element
*/
var table_body = $(this);
/**
* @var rows Object referring to the collection of rows in {@link table_body}
*/
var rows = $(this).find('tr').get();
// get the text of the field that we will sort by
$.each(rows, function (index, row) {
row.sortKey = $.trim($(row).find(text_selector).text().toLowerCase());
});
// get the sorted order
rows.sort(function (a, b) {
if (a.sortKey < b.sortKey) {
return -1;
}
if (a.sortKey > b.sortKey) {
return 1;
}
return 0;
});
// pull out each row from the table and then append it according to it's order
$.each(rows, function (index, row) {
$(table_body).append(row);
row.sortKey = null;
});
});
};
/**
* Return POST data as stored by Util::linkOrButton
*/