From 7988ca18d136e9f5cf310941ef0dccc35753e034 Mon Sep 17 00:00:00 2001 From: Martin Monperrus Date: Sat, 19 Mar 2011 10:53:05 +0100 Subject: [PATCH] improved the robustness of javascript progressive enhancement --- bibtexbrowser.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bibtexbrowser.php b/bibtexbrowser.php index dcb98db..a19e689 100755 --- a/bibtexbrowser.php +++ b/bibtexbrowser.php @@ -1739,13 +1739,13 @@ $('a.biburl').each(function(item) { // for each url "[bib]" var bibtexEntryUrl = $(this).attr('href'); $.ajax({url: bibtexEntryUrl, dataType: 'xml', success: function (data) { // we download it var elem = $('
'); // the element containing bibtex entry, creating a new element is required for Chrome and IE
-        elem.text($('.purebibtex', data).text()); // both text() is required for IE
+        elem.text($('.purebibtex', data).text()); // both text() are required for IE
         // we add a link so that users clearly see that even with AJAX
         // there is still one URL per paper (which is important for crawlers and metadata)
         elem.append(
            $('
%% Bibtex entry URL: '+bibtexEntryUrl+'
') ).appendTo(biburl.parent()); - }}); + }, error: function() {window.location.href = biburl.attr('href');}}); } else {biburl.nextAll('pre').toggle();} // we toggle the view }); }); @@ -2074,12 +2074,14 @@ class BibEntryDisplay extends BibtexBrowserDisplay { function display() { + // we encapsulate everything so that the output of display() is still valid XHTML + echo '
'; echo $this->bib->toCoins(); echo $this->formatedHeader(); echo $this->bib->toEntryUnformatted(); //echo $this->bib->getUrlLink(); - echo $this->poweredby(); + echo '
'; } /** Creates metadata for Google Scholar @@ -2590,9 +2592,10 @@ echo "\n".' -->'; } -/** is used to switch between HTML wrapper and NoWrapper */ +/** NoWrapper calls method display() on the content. */ class NoWrapper { function NoWrapper(&$content) { + header('Content-type: text/html; charset='.ENCODING); echo $content->display(); } }