diff options
author | Hakim El Hattab <hakim.elhattab@gmail.com> | 2013-03-30 21:54:30 -0400 |
---|---|---|
committer | Hakim El Hattab <hakim.elhattab@gmail.com> | 2013-03-30 21:54:30 -0400 |
commit | 433c7a66cd03c2e5f52285f1bd1b42dd254ecd93 (patch) | |
tree | 05d8fb6c554b9e2a7fbeada34b60984632f58ac5 /plugin | |
parent | c2aff87379ded739ac4b6fef492cd692203a36dc (diff) | |
parent | f6487dc312539bb011434c7a8f9a80bc5b238a7c (diff) | |
download | perl-software-in-gnu-guix-433c7a66cd03c2e5f52285f1bd1b42dd254ecd93.tar perl-software-in-gnu-guix-433c7a66cd03c2e5f52285f1bd1b42dd254ecd93.tar.gz |
Merge branch 'md-error-handling' of https://github.com/jakubholynet/reveal.js into dev
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/markdown/markdown.js | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/plugin/markdown/markdown.js b/plugin/markdown/markdown.js index b6b5a9b..3e31203 100644 --- a/plugin/markdown/markdown.js +++ b/plugin/markdown/markdown.js @@ -26,11 +26,11 @@ return text; }; - + var twrap = function(el) { return '<script type="text/template">' + el + '</script>'; }; - + var slidifyMarkdown = function(markdown, separator, vertical) { separator = separator || '^\n---\n$'; @@ -101,12 +101,22 @@ xhr.onreadystatechange = function () { if( xhr.readyState === 4 ) { - section.outerHTML = slidifyMarkdown( xhr.responseText, section.getAttribute('data-separator'), section.getAttribute('data-vertical') ); + if (xhr.status >= 200 && xhr.status < 300) { + section.outerHTML = slidifyMarkdown( xhr.responseText, section.getAttribute('data-separator'), section.getAttribute('data-vertical') ); + } else { + section.outerHTML = '<section data-state="alert">ERROR: The attempt to fetch ' + url + ' failed with the HTTP status ' + xhr.status + + '. Check your browser\'s JavaScript console for more details.' + + '<p>Remember that you need to serve the presentation HTML from a HTTP server and the Markdown file must be there too.</p></section>'; + } } }; xhr.open('GET', url, false); - xhr.send(); + try { + xhr.send(); + } catch (e) { + alert('Failed to get the Markdown file ' + url + '. Make sure that the presentation and the file are served by a HTTP server and the file can be found there. ' + e); + } } else if( section.getAttribute('data-separator') ) { |