/* SCEditor v3.2.0 | (C) 2017, Sam Clarke | sceditor.com/license */
!function(e){"use strict";var t="sce-autodraft-"+location.pathname+location.search;function u(e){localStorage.removeItem(e||t)}e.plugins.autosave=function(){var r,e=this,a=!1,n=t,s=864e5,i=function(e){localStorage.setItem(n,JSON.stringify(e))},c=function(){return JSON.parse(localStorage.getItem(n))};e.init=function(){var e=(r=this).opts&&r.opts.autosave||{};i=e.save||i,c=e.load||c,n=e.storageKey||n,s=e.expires||s;for(var t=0;t<localStorage.length;t++){var a,o=localStorage.key(t);!/^sce\-autodraft\-/.test(o)||(a=JSON.parse(localStorage.getItem(n)))&&a.time<Date.now()-s&&u(o)}},e.signalReady=function(){for(var e=r.getContentAreaContainer();e;){if(/form/i.test(e.nodeName)){e.addEventListener("submit",u.bind(null,n),!0);break}e=e.parentNode}var t=c();t?(a=!0,r.sourceMode(t.sourceMode),r.val(t.value,!1),r.focus(),t.sourceMode?r.sourceEditorCaret(t.caret):r.getRangeHelper().restoreRange(),a=!1):i({caret:this.sourceEditorCaret(),sourceMode:this.sourceMode(),value:r.val(null,!1),time:Date.now()})},e.signalValuechangedEvent=function(e){a||i({caret:this.sourceEditorCaret(),sourceMode:this.sourceMode(),value:e.detail.rawValue,time:Date.now()})}},e.plugins.autosave.clear=u}(sceditor);