aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2022-08-23 21:47:12 -0700
committerJohn MacFarlane <[email protected]>2022-08-23 21:47:12 -0700
commitaa53a700d9d4ba2bdaf94a64290b3be87e83d78e (patch)
tree84e6969baa459c1702b94eba4e3c7ff6cc100ce6
parent1a07b6613e113cff492b7efa0c9627094e1bf81c (diff)
trypandoc: Add clear button to text.
-rw-r--r--trypandoc/index.html1
-rw-r--r--trypandoc/trypandoc.js57
2 files changed, 31 insertions, 27 deletions
diff --git a/trypandoc/index.html b/trypandoc/index.html
index e8e55bbc7..57dba70bc 100644
--- a/trypandoc/index.html
+++ b/trypandoc/index.html
@@ -87,6 +87,7 @@
<option value="twiki">TWiki</option>
<option value="vimwiki">Vimwiki</option>
</select><br/>
+ <button onclick="clearText()">clear</button>
<label for="loadfile">Input</label>
<input id="loadfile" type="file" />
<!-- <label for="supportfile">+ Support</label>
diff --git a/trypandoc/trypandoc.js b/trypandoc/trypandoc.js
index d63cf97a3..6f91c9326 100644
--- a/trypandoc/trypandoc.js
+++ b/trypandoc/trypandoc.js
@@ -157,6 +157,11 @@ supported by {#1} and {#2}!}
}
+function clearText() {
+ params.text = '';
+ document.getElementById("text").value = '';
+}
+
function permalink() {
let href = window.location.href;
const URLparams = new URLSearchParams(Object.entries(params));
@@ -215,33 +220,31 @@ function convert() {
errs.textContent = "";
console.log(params);
- if (params.text && params.text != "") {
- let commandString = "pandoc"
- + " --from " + params.from + " --to " + params.to
- + (params.standalone ? " --standalone" : "")
- + (params.citeproc ? " --citeproc" : "") ;
- document.getElementById("command").textContent = commandString;
- fetch("/cgi-bin/pandoc-server.cgi", {
- method: "POST",
- headers: {"Content-Type": "application/json"},
- body: JSON.stringify(params)
- })
- .then(handleErrors)
- .then(response => response.text())
- .then(restext => {
- let binary = binaryFormats[params.to];
- if (binary &&
- document.getElementById("errors").style.display == "none") {
- document.getElementById("results").innerHTML +=
- '<a download="trypandoc.' + binary.extension +
- '" href="data:' + binary.mime + ';base64,' + restext +
- '">click to download trypandoc.' + binary.extension + '</a>';
- } else {
- document.getElementById("results").textContent += restext;
- }
- document.getElementById("permalink").href = permalink();
- });
- };
+ let commandString = "pandoc"
+ + " --from " + params.from + " --to " + params.to
+ + (params.standalone ? " --standalone" : "")
+ + (params.citeproc ? " --citeproc" : "") ;
+ document.getElementById("command").textContent = commandString;
+ fetch("/cgi-bin/pandoc-server.cgi", {
+ method: "POST",
+ headers: {"Content-Type": "application/json"},
+ body: JSON.stringify(params)
+ })
+ .then(handleErrors)
+ .then(response => response.text())
+ .then(restext => {
+ let binary = binaryFormats[params.to];
+ if (binary &&
+ document.getElementById("errors").style.display == "none") {
+ document.getElementById("results").innerHTML +=
+ '<a download="trypandoc.' + binary.extension +
+ '" href="data:' + binary.mime + ';base64,' + restext +
+ '">click to download trypandoc.' + binary.extension + '</a>';
+ } else {
+ document.getElementById("results").textContent += restext;
+ }
+ document.getElementById("permalink").href = permalink();
+ });
}
function setFormFromParams() {