aboutsummaryrefslogtreecommitdiffstats
path: root/templates/wiki/page_edit.html
diff options
context:
space:
mode:
Diffstat (limited to 'templates/wiki/page_edit.html')
-rw-r--r--templates/wiki/page_edit.html27
1 files changed, 20 insertions, 7 deletions
diff --git a/templates/wiki/page_edit.html b/templates/wiki/page_edit.html
index 51ce70db..138292f9 100644
--- a/templates/wiki/page_edit.html
+++ b/templates/wiki/page_edit.html
@@ -8,7 +8,7 @@
{% block content %}
<form uk-grid class="uk-grid-small" action="{{ url_for("wiki.edit", page=page) }}" method="post">
<div class="uk-width-expand">
- <input name="title" id="title" placeholder="Page Title" value="{{ title }}" class="uk-input" />
+ <input name="title" id="title" placeholder="Page Title" value="{{ title }}" class="uk-input" required />
</div>
<div class="uk-width-auto">
<button class="uk-button uk-button-secondary" type="button" value="Preview" id="preview">Preview</button>
@@ -37,7 +37,7 @@
let csrf_token = "{{ csrf_token() }}";
- document.getElementById("preview").onclick = function(event) {
+ function do_preview() {
let oReq = new XMLHttpRequest();
oReq.addEventListener("load", function() {
@@ -63,7 +63,7 @@
let data = editor.getValue();
- if (data.replace("\s", "").length < 1) {
+ if (data.replace("\s", "").length < 1 || document.getElementById("title").value.length < 1) {
document.getElementById("submit").disabled = true;
return false;
}
@@ -76,7 +76,9 @@
oReq.send(JSON.stringify({"data": editor.getValue()}));
return false;
- };
+ }
+
+ document.getElementById("preview").onclick = do_preview;
let editor = ace.edit("editor");
let timer;
@@ -93,15 +95,26 @@
if (timer !== undefined) {
clearTimeout(timer);
}
- timer = setTimeout(function() {document.getElementById("preview").click()}, 1000);
+ timer = setTimeout(do_preview, 1000);
});
document.getElementById("title").oninput = function() {
+ if (document.getElementById("title").value.length < 1) {
+ document.getElementById("submit").disabled = true;
+ }
+
document.getElementById("preview-title").textContent = document.getElementById("title").value;
- }
+
+ document.getElementById("rst").value = editor.getValue();
+
+ if (timer !== undefined) {
+ clearTimeout(timer);
+ }
+ timer = setTimeout(do_preview, 1000);
+ };
function refreshLock(){
- console.log("Refreshing lock")
+ console.log("Refreshing lock");
let xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState === 4 && this.status === 204) {