Display AJAX loader together with page

This commit is contained in:
Jakub Vrana 2011-03-11 16:47:37 +01:00
parent 1a0369adc0
commit 6fee8048e0
2 changed files with 7 additions and 9 deletions

View file

@ -35,9 +35,10 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
<div id="content">
<?php
}
echo '<p id="breadcrumb">';
if (isset($breadcrumb)) {
$link = substr(preg_replace('~(username|db|ns)=[^&]*&~', '', ME), 0, -1);
echo '<p id="breadcrumb"><a href="' . ($link ? h($link) : ".") . '">' . $drivers[DRIVER] . '</a> &raquo; ';
echo '<a href="' . ($link ? h($link) : ".") . '">' . $drivers[DRIVER] . '</a> &raquo; ';
$link = substr(preg_replace('~(db|ns)=[^&]*&~', '', ME), 0, -1);
$server = (SERVER != "" ? h(SERVER) : lang('Server'));
if ($breadcrumb === false) {
@ -61,6 +62,7 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
echo "$title\n";
}
}
echo "<span id='loader'></span>\n";
echo "<h2>$title_all</h2>\n";
restart_session();
$uri = preg_replace('~^[^?]*~', '', $_SERVER["REQUEST_URI"]);

View file

@ -270,23 +270,19 @@ function ajaxSetHtml(url) {
});
}
var ajaxState = 0, ajaxTimeout;
var ajaxState = 0;
/** Safely load content to #content
* @param string
* @param [string]
* @param [boolean]
* @return XMLHttpRequest or false in case of an error
*/
function ajaxSend(url, data) {
function ajaxSend(url, data, popState) {
var currentState = ++ajaxState;
clearTimeout(ajaxTimeout);
ajaxTimeout = setTimeout(function () {
scrollTo(0, 0);
setHtml('content', '<img src="../adminer/static/loader.gif" alt="">');
}, 500); // defer displaying loader
setHtml('loader', '<img src="../adminer/static/loader.gif" alt="">');
return ajax(url, function (text) {
if (currentState == ajaxState) {
clearTimeout(ajaxTimeout);
scrollTo(0, 0);
setHtml('content', text);
var content = document.getElementById('content');