autosave only when the content changed

This commit is contained in:
Diego Najar 2018-10-09 18:59:05 +02:00
parent c3911d7f29
commit 6a3609098f
1 changed files with 5 additions and 2 deletions

View File

@ -416,13 +416,16 @@ $(document).ready(function() {
// Autosave interval // Autosave interval
// Autosave works when the content of the page is bigger than 100 characters // Autosave works when the content of the page is bigger than 100 characters
var currentContent = editorGetContent();
setInterval(function() { setInterval(function() {
var uuid = $("#jsuuid").val(); var uuid = $("#jsuuid").val();
var title = $("#jstitle").val(); var title = $("#jstitle").val();
var content = editorGetContent(); var content = editorGetContent();
var ajax = new bluditAjax(); var ajax = new bluditAjax();
if (currentContent!=content) {
// showAlert is the function to display an alert defined in alert.php // showAlert is the function to display an alert defined in alert.php
ajax.autosave(uuid, title, content, showAlert); ajax.autosave(uuid, title, content, showAlert);
}
},1000*60*AUTOSAVE_INTERVAL); },1000*60*AUTOSAVE_INTERVAL);
// Template autocomplete // Template autocomplete