/* SCEditor v2.1.2 | (C) 2017, Sam Clarke | sceditor.com/license */

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