var haste_document=function(){this.locked=!1},haste=(haste_document.prototype.htmlEscape=function(t){return t.replace(/&/g,"&").replace(/>/g,">").replace(/'+t+"");$("#messages").prepend(o),setTimeout(function(){o.slideUp("fast",function(){$(this).remove()})},3e3)},haste.prototype.lightKey=function(){this.configureKey(["new","save"])},haste.prototype.fullKey=function(){this.configureKey(["new","save","duplicate","raw"])},haste.prototype.configureKey=function(t){var e,o=0;$("#box2 .function").each(function(){for(e=$(this),o=0;o";$("#linenos").html(e)},haste.prototype.removeLineNumbers=function(){$("#linenos").html(">")},haste.prototype.loadDocument=function(t){var t=t.split(".",2),e=this;e.doc=new haste_document,e.doc.load(t[0],function(t){t?(e.$code.html(t.value),e.setTitle(t.key),e.fullKey(),e.$textarea.val("").hide(),e.$box.show().focus(),e.addLineNumbers(t.lineCount)):e.newDocument()},this.lookupTypeByExtension(t[1]))},haste.prototype.duplicateDocument=function(){var t;this.doc.locked&&(t=this.doc.data,this.newDocument(),this.$textarea.val(t))},haste.prototype.lockDocument=function(){var o=this;this.doc.save(this.$textarea.val(),function(t,e){t?o.showMessage(t.message,"error"):e&&(o.$code.html(e.value),o.setTitle(e.key),t="/"+e.key,e.language&&(t+="."+o.lookupExtensionByType(e.language)),window.history.pushState(null,o.appName+"-"+e.key,t),o.fullKey(),o.$textarea.val("").hide(),o.$box.show().focus(),o.addLineNumbers(e.lineCount))})},haste.prototype.configureButtons=function(){var e=this;this.buttons=[{$where:$("#box2 .save"),label:"Save",shortcut:function(t){return t.ctrlKey&&83===t.keyCode},shortcutDescription:"control + s",action:function(){e.doc.locked?e.duplicate():e.lockDocument()}},{$where:$("#box2 .new"),label:"New",shortcut:function(t){return t.ctrlKey&&78===t.keyCode},shortcutDescription:"control + n",action:function(){e.newDocument(!e.doc.key)}},{$where:$("#box2 .duplicate"),label:"Duplicate & Edit",shortcut:function(t){return e.doc.locked&&t.ctrlKey&&68===t.keyCode},shortcutDescription:"control + d",action:function(){e.duplicate()}},{$where:$("#box2 .raw"),label:"Just Text",shortcut:function(t){return t.ctrlKey&&t.shiftKey&&82===t.keyCode},shortcutDescription:"control + shift + r",action:function(){window.location.href="/raw/"+e.doc.key}}];for(var t=0;t