diff --git a/resources/common.js b/resources/common.js index fd5c50a..333635a 100644 --- a/resources/common.js +++ b/resources/common.js @@ -311,6 +311,21 @@ function populateCopyButton() { }); } +function register_markdown_editors() { + if (!("Markdown" in window)) { + return; + } + $('textarea.wmd-input').each(function() { + let id = this.id.substr(9); // remove prefix "wmd-input" + var $buttonBar = $(this).prevAll('div[id^="wmd-button-bar"]').first(); + if (!$buttonBar.length || !$buttonBar.html().trim()) { + let converter = new Markdown.Converter(); + let editor = new Markdown.Editor(converter, id); + editor.run(); + } + }); +} + function onWindowReady() { // http://stackoverflow.com/a/1060034/1090657 var hidden = 'hidden'; @@ -391,6 +406,7 @@ function onWindowReady() { $("[data-src]iframe").each(function() { $(this).attr("src", $(this).attr("data-src")); }) + register_markdown_editors(); }, "100"); $('form').submit(function (evt) { @@ -414,6 +430,7 @@ function onWindowReady() { $("#loading-bar").show(); $("#loading-bar").animate({ width: "100%" }, 2000, function() { + $(this).stop(true, true); $(this).hide().css({ width: 0}); }); }); diff --git a/resources/pagedown_math.js b/resources/pagedown_math.js index ba8079e..fb3f2af 100644 --- a/resources/pagedown_math.js +++ b/resources/pagedown_math.js @@ -1,6 +1,5 @@ function mathjax_pagedown($) { $.each(window.editors, function (id, editor) { - console.log(id); var preview = $('div.wmd-preview#' + id + '_wmd_preview')[0]; editor.hooks.chain('onPreviewRefresh', function () { renderKatex(preview); diff --git a/templates/three-column-content.html b/templates/three-column-content.html index 2842b1f..9f06acf 100644 --- a/templates/three-column-content.html +++ b/templates/three-column-content.html @@ -75,6 +75,7 @@ $('html, body').animate({scrollTop: 0}, 'fast'); $('.middle-right-content').html(reload_content.first().html()); $('#extra_js').html(bodyend_script.first().html()); + $("#loading-bar").stop(true, true); $("#loading-bar").hide().css({ width: 0}); if (reload_content.hasClass("wrapper")) { $('.middle-right-content').addClass("wrapper");