From 0e29a6a7837f3e06ab7125eede02e8440abe965e Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Mon, 22 Nov 2010 18:13:07 +0100 Subject: [PATCH] AJAX title --- adminer/include/design.inc.php | 7 +++++-- adminer/static/functions.js | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/adminer/include/design.inc.php b/adminer/include/design.inc.php index 8f948064..4d273cca 100644 --- a/adminer/include/design.inc.php +++ b/adminer/include/design.inc.php @@ -11,7 +11,10 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") { header("Content-Type: text/html; charset=utf-8"); $adminer->headers(); $title_all = $title . ($title2 != "" ? ": " . h($title2) : ""); - if (!is_ajax()) { + $title_page = $title_all . (SERVER != "" && SERVER != "localhost" ? h(" - " . SERVER) : "") . " - " . $adminer->name(); + if (is_ajax()) { + header("X-AJAX-Title: " . rawurlencode($title_page)); + } else { $protocol = ($HTTPS ? "https" : "http"); ?> @@ -19,7 +22,7 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") { -<?php echo $title_all . (SERVER != "" && SERVER != "localhost" ? h(" - " . SERVER) : "") . " - " . $adminer->name(); ?> +<?php echo $title_page; ?> diff --git a/adminer/static/functions.js b/adminer/static/functions.js index 4edba2e9..0faae95f 100644 --- a/adminer/static/functions.js +++ b/adminer/static/functions.js @@ -197,6 +197,10 @@ function ajax(url, callback, data) { if (redirect && history.replaceState) { history.replaceState(null, '', redirect); } + var title = xmlhttp.getResponseHeader('X-AJAX-Title'); + if (title) { + document.title = decodeURIComponent(title); + } callback(xmlhttp.responseText); } };