aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gn2/wqflask/templates/gn_editor.html9
-rw-r--r--gn2/wqflask/templates/gn_editor_results_page.html17
2 files changed, 18 insertions, 8 deletions
diff --git a/gn2/wqflask/templates/gn_editor.html b/gn2/wqflask/templates/gn_editor.html
index e5c649d1..d89aaf0a 100644
--- a/gn2/wqflask/templates/gn_editor.html
+++ b/gn2/wqflask/templates/gn_editor.html
@@ -157,11 +157,13 @@
let fileExt = (filePath.substring(filePath.lastIndexOf('.')+1, filePath.length) || "md").toLowerCase();
let data = {{ content|tojson }}
- localStorage.setItem("gn_editor_sha" ,hash)
+ localStorage.setItem("gn_editor_sha" ,hash)
+ htmx.on("#output", "updateDataEvent", function(event){
+ data = editor.getValue()
+ })
htmx.on("#output", "commitEvent", function(event){
htmx.ajax("POST", "/editor/commit", {target: "#output", swap:"innerHTML",values: {'msg':event.detail.payload, 'content': editor.getValue(), "hash": localStorage.getItem("gn_editor_sha"), "file_path": filePath}})
- })
-
+ })
htmx.on("#output", "diffEvent", function(event){
var fileName = "{{ file_path }}"
var diffContent = Diff.createTwoFilesPatch(fileName,fileName, data, editor.getValue())
@@ -186,7 +188,6 @@
htmx.on("#diffBtn","click",function(event){
//dispatch your event here
- console.log("Clicked diff btn here")
htmx.find("#output").dispatchEvent(
new CustomEvent("diffEvent", {
bubbles: true,
diff --git a/gn2/wqflask/templates/gn_editor_results_page.html b/gn2/wqflask/templates/gn_editor_results_page.html
index 666bd432..6eaeb941 100644
--- a/gn2/wqflask/templates/gn_editor_results_page.html
+++ b/gn2/wqflask/templates/gn_editor_results_page.html
@@ -37,10 +37,19 @@
</section>
{% block js %}
<script>
- var commitSha = "{{ commit_sha }}";
- if (commitSha !="" && commitSha!= undefined){
- localStorage.setItem("gn_editor_sha", commitSha)
- }
+ var commitSha = "{{ commit_sha }}";
+ if (commitSha !="" && commitSha!= undefined){
+ prev_commit = localStorage.getItem("gn_editor_sha")
+ localStorage.setItem("gn_editor_sha", commitSha)
+ if (prev_commit != commitSha) {
+ //update the contennt
+ htmx.find("#output").dispatchEvent(
+ new CustomEvent("updateDataEvent", {
+ bubbles: true,
+ detail: {},
+ }),
+ );
+ }}
</script>
{% endblock %}