Report offline and other AJAX errors (bug #419)
This commit is contained in:
parent
a987a2a4de
commit
37c8a3a123
|
@ -9,6 +9,10 @@
|
|||
function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
|
||||
global $LANG, $VERSION, $adminer, $drivers, $jush;
|
||||
page_headers();
|
||||
if (is_ajax() && $error) {
|
||||
page_messages($error);
|
||||
exit;
|
||||
}
|
||||
$title_all = $title . ($title2 != "" ? ": $title2" : "");
|
||||
$title_page = strip_tags($title_all . (SERVER != "" && SERVER != "localhost" ? h(" - " . SERVER) : "") . " - " . $adminer->name());
|
||||
?>
|
||||
|
@ -32,6 +36,7 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
|
|||
<body class="<?php echo lang('ltr'); ?> nojs" onkeydown="bodyKeydown(event);" onclick="bodyClick(event);"<?php echo (isset($_COOKIE["adminer_version"]) ? "" : " onload=\"verifyVersion('$VERSION');\""); ?>>
|
||||
<script type="text/javascript">
|
||||
document.body.className = document.body.className.replace(/ nojs/, ' js');
|
||||
var offlineMessage = '<?php echo js_escape(lang('You are offline.')); ?>';
|
||||
</script>
|
||||
|
||||
<div id="help" class="jush-<?php echo $jush; ?> jsonly hidden" onmouseover="helpOpen = 1;" onmouseout="helpMouseout(this, event);"></div>
|
||||
|
@ -65,6 +70,7 @@ document.body.className = document.body.className.replace(/ nojs/, ' js');
|
|||
}
|
||||
}
|
||||
echo "<h2>$title_all</h2>\n";
|
||||
echo "<div id='ajaxstatus' class='jsonly hidden'></div>\n";
|
||||
restart_session();
|
||||
page_messages($error);
|
||||
$databases = &get_session("dbs");
|
||||
|
|
|
@ -1307,7 +1307,6 @@ function edit_form($TABLE, $fields, $row, $update) {
|
|||
echo "<p class='error'>" . lang('No rows.') . "\n";
|
||||
}
|
||||
?>
|
||||
<div id="message"></div>
|
||||
<form action="" method="post" enctype="multipart/form-data" id="form">
|
||||
<?php
|
||||
if (!$fields) {
|
||||
|
|
|
@ -67,6 +67,7 @@ $translations = array(
|
|||
'Maximum allowed file size is %sB.' => 'Maximální povolená velikost souboru je %sB.',
|
||||
'Too big POST data. Reduce the data or increase the %s configuration directive.' => 'Příliš velká POST data. Zmenšete data nebo zvyšte hodnotu konfigurační direktivy %s.',
|
||||
'You can upload a big SQL file via FTP and import it from server.' => 'Velký SQL soubor můžete nahrát pomocí FTP a importovat ho ze serveru.',
|
||||
'You are offline.' => 'Jste offline.',
|
||||
|
||||
'Export' => 'Export',
|
||||
'Output' => 'Výstup',
|
||||
|
|
|
@ -67,6 +67,7 @@ $translations = array(
|
|||
'Maximum allowed file size is %sB.' => 'xx',
|
||||
'Too big POST data. Reduce the data or increase the %s configuration directive.' => 'xx',
|
||||
'You can upload a big SQL file via FTP and import it from server.' => 'xx',
|
||||
'You are offline.' => 'xx',
|
||||
|
||||
'Export' => 'xx',
|
||||
'Output' => 'xx',
|
||||
|
|
|
@ -503,11 +503,19 @@ function fieldChange(field) {
|
|||
* @param string
|
||||
* @param function (XMLHttpRequest)
|
||||
* @param [string]
|
||||
* @param [string]
|
||||
* @return XMLHttpRequest or false in case of an error
|
||||
*/
|
||||
function ajax(url, callback, data) {
|
||||
function ajax(url, callback, data, message) {
|
||||
var request = (window.XMLHttpRequest ? new XMLHttpRequest() : (window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : false));
|
||||
if (request) {
|
||||
var ajaxStatus = document.getElementById('ajaxstatus');
|
||||
if (message) {
|
||||
ajaxStatus.innerHTML = '<div class="message">' + message + '</div>';
|
||||
ajaxStatus.className = ajaxStatus.className.replace(/ hidden/g, '');
|
||||
} else {
|
||||
ajaxStatus.className += ' hidden';
|
||||
}
|
||||
request.open((data ? 'POST' : 'GET'), url);
|
||||
if (data) {
|
||||
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
|
@ -515,7 +523,12 @@ function ajax(url, callback, data) {
|
|||
request.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
||||
request.onreadystatechange = function () {
|
||||
if (request.readyState == 4) {
|
||||
callback(request);
|
||||
if (/^2/.test(request.status)) {
|
||||
callback(request);
|
||||
} else {
|
||||
ajaxStatus.innerHTML = (request.status ? request.responseText : '<div class="error">' + offlineMessage + '</div>');
|
||||
ajaxStatus.className = ajaxStatus.className.replace(/ hidden/g, '');
|
||||
}
|
||||
}
|
||||
};
|
||||
request.send(data);
|
||||
|
@ -529,11 +542,9 @@ function ajax(url, callback, data) {
|
|||
*/
|
||||
function ajaxSetHtml(url) {
|
||||
return ajax(url, function (request) {
|
||||
if (request.status) {
|
||||
var data = eval('(' + request.responseText + ')');
|
||||
for (var key in data) {
|
||||
setHtml(key, data[key]);
|
||||
}
|
||||
var data = eval('(' + request.responseText + ')');
|
||||
for (var key in data) {
|
||||
setHtml(key, data[key]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -560,18 +571,17 @@ function ajaxForm(form, message, button) {
|
|||
}
|
||||
data = data.join('&');
|
||||
|
||||
setHtml('message', '<div class="message">' + message + '</div>');
|
||||
var url = form.action;
|
||||
if (!/post/i.test(form.method)) {
|
||||
url = url.replace(/\?.*/, '') + '?' + data;
|
||||
data = '';
|
||||
}
|
||||
return ajax(url, function (request) {
|
||||
setHtml('message', request.responseText);
|
||||
setHtml('ajaxstatus', request.responseText);
|
||||
if (window.jush) {
|
||||
jush.highlight_tag(document.getElementById('message').getElementsByTagName('code'), 0);
|
||||
jush.highlight_tag(document.getElementById('ajaxstatus').getElementsByTagName('code'), 0);
|
||||
}
|
||||
}, data);
|
||||
}, data, message);
|
||||
}
|
||||
|
||||
|
||||
|
@ -629,7 +639,7 @@ function selectClick(td, event, text, warning) {
|
|||
input.focus();
|
||||
if (text == 2) { // long text
|
||||
return ajax(location.href + '&' + encodeURIComponent(td.id) + '=', function (request) {
|
||||
if (request.status && request.responseText) {
|
||||
if (request.responseText) {
|
||||
input.value = request.responseText;
|
||||
input.name = td.id;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ Fix edit by long non-utf8 string
|
|||
Specify encoding for PHP 5.6 with invalid default_charset
|
||||
Fix saving NULL value, bug since Adminer 4.0.3
|
||||
Send 403 for auth error
|
||||
Report offline and other AJAX errors (bug #419)
|
||||
MySQL: Use utf8mb4 if available
|
||||
PostgreSQL: Materialized views
|
||||
Elasticsearch: Use where in select
|
||||
|
|
Loading…
Reference in a new issue