aboutsummaryrefslogtreecommitdiffstats
path: root/view/tpl/wiki.tpl
diff options
context:
space:
mode:
authorAndrew Manning <tamanning@zoho.com>2016-06-07 20:58:14 -0400
committerAndrew Manning <tamanning@zoho.com>2016-06-07 20:58:14 -0400
commite86e666c22dd37d715c51c53e4267bd25230f48e (patch)
tree56baa9d3d5925330efbe977455f236c24935d564 /view/tpl/wiki.tpl
parentcf180f614207e6cdae44d1e3649a469b8982ade0 (diff)
downloadvolse-hubzilla-e86e666c22dd37d715c51c53e4267bd25230f48e.tar.gz
volse-hubzilla-e86e666c22dd37d715c51c53e4267bd25230f48e.tar.bz2
volse-hubzilla-e86e666c22dd37d715c51c53e4267bd25230f48e.zip
Javascript only allows saving a page if the content has changed.
Diffstat (limited to 'view/tpl/wiki.tpl')
-rw-r--r--view/tpl/wiki.tpl13
1 files changed, 11 insertions, 2 deletions
diff --git a/view/tpl/wiki.tpl b/view/tpl/wiki.tpl
index 05604778d..1312f8518 100644
--- a/view/tpl/wiki.tpl
+++ b/view/tpl/wiki.tpl
@@ -111,6 +111,8 @@
<script>
window.wiki_resource_id = '{{$resource_id}}';
window.wiki_page_name = '{{$page}}';
+ window.wiki_page_content = {{$content}};
+
if (window.wiki_page_name === 'Home') {
$('#delete-page').hide();
}
@@ -123,7 +125,7 @@
var editor = ace.edit("ace-editor");
editor.setTheme("ace/theme/github");
editor.getSession().setMode("ace/mode/markdown");
- editor.getSession().setValue({{$content}});
+ editor.getSession().setValue(window.wiki_page_content);
$('#wiki-get-preview').click(function (ev) {
$.post("wiki/{{$channel}}/preview", {content: editor.getValue()}, function (data) {
@@ -203,8 +205,14 @@ function wiki_delete_wiki(wikiHtmlName, resource_id) {
ev.preventDefault();
return false;
}
+ var currentContent = editor.getValue();
+ if (window.wiki_page_content === currentContent) {
+ window.console.log('No edits to save.');
+ ev.preventDefault();
+ return false;
+ }
$.post("wiki/{{$channel}}/save/page",
- { content: editor.getValue(),
+ { content: currentContent,
commitMsg: $('#id_commitMsg').val(),
name: window.wiki_page_name,
resource_id: window.wiki_resource_id
@@ -212,6 +220,7 @@ function wiki_delete_wiki(wikiHtmlName, resource_id) {
function (data) {
if (data.success) {
window.console.log('Page saved successfully.');
+ window.wiki_page_content = currentContent;
$('#id_commitMsg').val(''); // Clear the commit message box
} else {
alert('Error saving page.'); // TODO: Replace alerts with auto-timeout popups