trypandoc: more improvements.
This commit is contained in:
parent
3e456f46a6
commit
5092292217
2 changed files with 15 additions and 14 deletions
trypandoc
|
@ -175,7 +175,7 @@
|
||||||
<p class="version">pandoc version <span id="version"></span></p>
|
<p class="version">pandoc version <span id="version"></span></p>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script src="trypandoc.js?202208181818"></script>
|
<script src="trypandoc.js?202208182155"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -52,7 +52,7 @@ function paramsFromURL() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleErrors(response) {
|
function handleErrors(response) {
|
||||||
if (response.status == 503) {
|
if (response.status == 503 || response.status == 500) {
|
||||||
throw Error("Conversion timed out.")
|
throw Error("Conversion timed out.")
|
||||||
} else if (!response.ok) {
|
} else if (!response.ok) {
|
||||||
throw Error(response.statusText);
|
throw Error(response.statusText);
|
||||||
|
@ -70,16 +70,6 @@ function convert() {
|
||||||
citeproc: citeproc };
|
citeproc: citeproc };
|
||||||
|
|
||||||
if (text && text != "") {
|
if (text && text != "") {
|
||||||
fetch("/cgi-bin/pandoc-server.cgi/version")
|
|
||||||
.then(handleErrors)
|
|
||||||
.catch(error =>
|
|
||||||
document.getElementById("results").textContent = error )
|
|
||||||
.then(response => response.text())
|
|
||||||
.then(restext =>
|
|
||||||
document.getElementById("version").textContent = restext
|
|
||||||
);
|
|
||||||
|
|
||||||
// console.log(JSON.stringify(params));
|
|
||||||
let commandString = "pandoc"
|
let commandString = "pandoc"
|
||||||
+ " --from " + from + " --to " + to
|
+ " --from " + from + " --to " + to
|
||||||
+ (standalone ? " --standalone" : "")
|
+ (standalone ? " --standalone" : "")
|
||||||
|
@ -90,6 +80,7 @@ function convert() {
|
||||||
headers: {"Content-Type": "application/json"},
|
headers: {"Content-Type": "application/json"},
|
||||||
body: JSON.stringify(params)
|
body: JSON.stringify(params)
|
||||||
})
|
})
|
||||||
|
.then(handleErrors)
|
||||||
.then(response => response.text())
|
.then(response => response.text())
|
||||||
.then(restext => {
|
.then(restext => {
|
||||||
let binary = binaryFormats[to];
|
let binary = binaryFormats[to];
|
||||||
|
@ -102,7 +93,11 @@ function convert() {
|
||||||
document.getElementById("results").textContent = restext;
|
document.getElementById("results").textContent = restext;
|
||||||
}
|
}
|
||||||
document.getElementById("permalink").href = permalink();
|
document.getElementById("permalink").href = permalink();
|
||||||
});
|
})
|
||||||
|
.catch(error => {
|
||||||
|
document.getElementById("results").textContent = error;
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +132,6 @@ function convert() {
|
||||||
let inputtext = document.getElementById("text");
|
let inputtext = document.getElementById("text");
|
||||||
reader.onloadend = () => {
|
reader.onloadend = () => {
|
||||||
// Use a regex to remove data url part
|
// Use a regex to remove data url part
|
||||||
console.log(mimetype);
|
|
||||||
if (binary) {
|
if (binary) {
|
||||||
const base64String = reader.result
|
const base64String = reader.result
|
||||||
.replace('data:', '')
|
.replace('data:', '')
|
||||||
|
@ -154,6 +148,13 @@ function convert() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fetch("/cgi-bin/pandoc-server.cgi/version")
|
||||||
|
.then(handleErrors)
|
||||||
|
.then(response => response.text())
|
||||||
|
.then(restext =>
|
||||||
|
document.getElementById("version").textContent = restext
|
||||||
|
);
|
||||||
|
|
||||||
convert();
|
convert();
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Add table
Reference in a new issue