phpmyadmin/resources/js/modules/functions/refreshMainContent.ts
Maurício Meneghini Fauth 01e4a87bbd
Move resources/js/src to resources/js
Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.net>
2025-05-22 13:43:59 -03:00

28 lines
793 B
TypeScript

import $ from 'jquery';
import { CommonParams } from '../common.ts';
/**
* Refreshes the main frame
*
* @param {any} url Undefined to refresh to the same page
* String to go to a different page, e.g: 'index.php'
*/
export default function refreshMainContent (url = undefined): void {
var newUrl = url;
if (! newUrl) {
newUrl = $('#selflink').find('a').attr('href') || window.location.pathname;
newUrl = newUrl.substring(0, newUrl.indexOf('?'));
}
if (newUrl.indexOf('?') !== -1) {
newUrl += CommonParams.getUrlQuery(CommonParams.get('arg_separator'));
} else {
newUrl += CommonParams.getUrlQuery('?');
}
$('<a></a>', { href: newUrl })
.appendTo('body')
.trigger('click')
.remove();
}