diff src/minified/plugins/autosave.js @ 0:4c4fc447baea

start with sceditor-3.1.1
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 04 Aug 2022 15:21:29 -0600
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/minified/plugins/autosave.js	Thu Aug 04 15:21:29 2022 -0600
@@ -0,0 +1,3 @@
+/* SCEditor v3.1.1 | (C) 2017, Sam Clarke | sceditor.com/license */
+
+!function(e){"use strict";var t="sce-autodraft-"+location.pathname+location.search;function c(e){localStorage.removeItem(e||t)}e.plugins.autosave=function(){var a,e=this,o=!1,r=t,n=864e5,s=function(e){localStorage.setItem(r,JSON.stringify(e))},i=function(){return JSON.parse(localStorage.getItem(r))};e.init=function(){var e=(a=this).opts&&a.opts.autosave||{};s=e.save||s,i=e.load||i,r=e.storageKey||r,n=e.expires||n,function(){for(var e=0;e<localStorage.length;e++){var t,a=localStorage.key(e);!/^sce\-autodraft\-/.test(a)||(t=JSON.parse(localStorage.getItem(r)))&&t.time<Date.now()-n&&c(a)}}()},e.signalReady=function(){for(var e=a.getContentAreaContainer();e;){if(/form/i.test(e.nodeName)){e.addEventListener("submit",c.bind(null,r),!0);break}e=e.parentNode}var t=i();t?(o=!0,a.sourceMode(t.sourceMode),a.val(t.value,!1),a.focus(),t.sourceMode?a.sourceEditorCaret(t.caret):a.getRangeHelper().restoreRange(),o=!1):s({caret:this.sourceEditorCaret(),sourceMode:this.sourceMode(),value:a.val(null,!1),time:Date.now()})},e.signalValuechangedEvent=function(e){o||s({caret:this.sourceEditorCaret(),sourceMode:this.sourceMode(),value:e.detail.rawValue,time:Date.now()})}},e.plugins.autosave.clear=c}(sceditor);
\ No newline at end of file