summaryrefslogtreecommitdiff
path: root/data/templates/recipe.html
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2023-01-14 18:07:47 +0100
committerxengineering <me@xengineering.eu>2023-02-08 20:44:02 +0100
commit9005de11ef8b7cf32cc8503e8b5f134eca47b4fb (patch)
treec6a445bd55790c9677d9217de72b8d968c33ce2d /data/templates/recipe.html
parent1f8b5c2bbe20c4c6b7b334b00ae5e6622dcd51f7 (diff)
downloadceres-9005de11ef8b7cf32cc8503e8b5f134eca47b4fb.tar
ceres-9005de11ef8b7cf32cc8503e8b5f134eca47b4fb.tar.zst
ceres-9005de11ef8b7cf32cc8503e8b5f134eca47b4fb.zip
Add new recipe edit page
Recipes should be completely editable and removable. Thus this edit page was added.
Diffstat (limited to 'data/templates/recipe.html')
-rw-r--r--data/templates/recipe.html42
1 files changed, 2 insertions, 40 deletions
diff --git a/data/templates/recipe.html b/data/templates/recipe.html
index 536cac9..a35cc49 100644
--- a/data/templates/recipe.html
+++ b/data/templates/recipe.html
@@ -25,51 +25,13 @@
<main>
<img src="./recipe/image?id={{.Id}}" alt="Recipe image">
<h2>Recipe description</h2>
- <button id="editbtn" style="display:block" onclick=startEditMode()>edit</button>
- <button id="cancelbtn" style="display:none" onclick=cancelEditMode()>abort</button>
- <button id="savebtn" style="display:none" onclick=saveDescriptionMarkdown()>save</button>
- <pre id="description_md" style="display:none;" contenteditable="true">{{.DescriptionMarkdown}}</pre>
- <div id="rendered_description_md" style="display:block;">
- {{.RenderedDescriptionMarkdown}}
- </div>
+ <a href="./recipe/edit?id={{.Id}}"><button>edit</button></a>
+ {{.RenderedDescriptionMarkdown}}
<footer>
<hr>
<p>The <a href="https://xengineering.eu/git/ceres">Ceres</a> recipe server is licensed under <a href="https://www.gnu.org/licenses/agpl-3.0.en.html">AGPL v3</a> and developed with <a href="https://simplecss.org/">simple.css</a>.</p>
</footer>
</main>
-
- <script>
- var editbtn = document.getElementById("editbtn");
- var cancelbtn = document.getElementById("cancelbtn");
- var savebtn = document.getElementById("savebtn");
- var description_md = document.getElementById("description_md");
- var rendered_description_md = document.getElementById("rendered_description_md");
-
- function startEditMode() {
- editbtn.style.display = "none";
- rendered_description_md.style.display = "none";
- cancelbtn.style.display = "block";
- savebtn.style.display = "block";
- description_md.style.display = "block";
- }
-
- function cancelEditMode() {
- window.location.reload(true);
- }
-
- function saveDescriptionMarkdown() {
- var xhttp = new XMLHttpRequest();
- xhttp.onreadystatechange = function() {
- if (this.readyState == 4) {
- window.location.reload(true);
- }
- }
- xhttp.open("POST", window.location.href, true);
- xhttp.send(description_md.innerHTML.replaceAll("<br>", "\n"));
- }
- </script>
-
</body>
-
</html>