aboutsummaryrefslogtreecommitdiffstats
path: root/view/tpl/jot-header.tpl
diff options
context:
space:
mode:
authorAndrew Manning <tamanning@zoho.com>2018-04-08 14:18:10 -0400
committerAndrew Manning <tamanning@zoho.com>2018-04-08 14:18:10 -0400
commit43cafcc761bc12f442c30ab952164736aa18f9d8 (patch)
tree52a890ff54a9a413460c38b61833139639e6d341 /view/tpl/jot-header.tpl
parentbe6dcb5d0a96d3618c4d4d824bf94b0a6753fefc (diff)
downloadvolse-hubzilla-43cafcc761bc12f442c30ab952164736aa18f9d8.tar.gz
volse-hubzilla-43cafcc761bc12f442c30ab952164736aa18f9d8.tar.bz2
volse-hubzilla-43cafcc761bc12f442c30ab952164736aa18f9d8.zip
Auto-save post and comment entry using localStorage in browser.
Diffstat (limited to 'view/tpl/jot-header.tpl')
-rwxr-xr-xview/tpl/jot-header.tpl55
1 files changed, 55 insertions, 0 deletions
diff --git a/view/tpl/jot-header.tpl b/view/tpl/jot-header.tpl
index c1dab52d5..2b4284ade 100755
--- a/view/tpl/jot-header.tpl
+++ b/view/tpl/jot-header.tpl
@@ -560,3 +560,58 @@ $( document ).on( "click", ".wall-item-delete-link,.page-delete-link,.layout-del
}
});
</script>
+
+
+<script>
+
+ var postSaveTimer = null;
+
+ $(document).on('focusout',"#profile-jot-wrapper",function(e){
+ if(postSaveTimer)
+ clearTimeout(postSaveTimer);
+ postSaveChanges(true);
+ postSaveTimer = null;
+ });
+
+ $(document).on('focusin',"#profile-jot-wrapper",function(e){
+ postSaveTimer = setTimeout(function () {
+ postSaveChanges(false);
+ },10000);
+ });
+
+ function postSaveChanges(isFinal = false, type) {
+ localStorage.setItem("post_title", $("#jot-title").val());
+ localStorage.setItem("post_body", $("#profile-jot-text").val());
+ localStorage.setItem("post_category", $("#jot-category").val());
+ if( !isFinal) {
+ postSaveTimer = setTimeout(postSaveChanges,10000);
+ }
+
+ }
+
+ $(document).ready(function() {
+ var postTitle = localStorage.getItem("post_title");
+ var postBody = localStorage.getItem("post_body");
+ var postCategory = localStorage.getItem("post_category");
+ var openEditor = false;
+ if(postTitle) {
+ $('#jot-title').val(postTitle);
+ openEditor = true;
+ }
+ if(postBody) {
+ $('#profile-jot-text').val(postBody);
+ openEditor = true;
+ }
+ if(postCategory) {
+ var categories = postCategory.split(',');
+ categories.forEach(function(cat) {
+ $('#jot-category').tagsinput('add', cat);
+ });
+ openEditor = true;
+ }
+ if(openEditor) {
+ initEditor();
+ }
+ });
+
+</script> \ No newline at end of file