Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/files_markdown.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'js/editor.js')
-rw-r--r--js/editor.js40
1 files changed, 39 insertions, 1 deletions
diff --git a/js/editor.js b/js/editor.js
index 48e3c38..2a4e4e1 100644
--- a/js/editor.js
+++ b/js/editor.js
@@ -45,7 +45,15 @@ $(document).ready(function () {
editor.width(halfWidth - 10);
preview.height(editor.height());
});
- })
+ });
+ $.get(OC.filePath('files_markdown', 'ajax', 'checkconvert.php')).then(function (result) {
+ if (result) {
+ var downloadButton = $('<button/>');
+ downloadButton.click(downloadPDF);
+ downloadButton.text(t('files_markdown', 'Download PDF'));
+ $('#editorcontrols').append(downloadButton);
+ }
+ });
});
});
FileActions.setDefault('text/markdown', 'Edit');
@@ -72,4 +80,34 @@ $(document).ready(function () {
}
});
+function downloadPDF() {
+ var html = $('#preview').html(),
+ form = $('<form/>'),
+ textfield = $('<textarea/>'),
+ input = $('<input/>');
+
+ form.attr('action', OC.filePath('files_markdown', 'ajax', 'download.php')).attr('method', 'post');
+ input.attr('name', 'name');
+ input.val($('div.crumb.last').text())
+ form.append(input);
+
+ textfield.attr('name', 'html');
+ textfield.val(html);
+ form.append(textfield);
+
+ input = $('<input/>')
+ input.attr('name', 'requesttoken');
+ input.val(oc_requesttoken);
+ form.append(input);
+
+ input = $('<input/>')
+ input.attr('name', 'mathjaxcss');//we need the css mathjax inserts for fonts and such
+ input.val($('head style').last().text());
+ form.append(input);
+
+ form.hide();
+ $('body').append(form);
+ form.submit();
+}
+
var mathJaxLoaded = false;