text: /*
  
  DRKWRTR v0.2.0 — an @electricgecko joint
  http://drkwrtr.co/about
  https://github.com/electricgecko/DRKWRTR
  
  */
  
  !function(a,b){if("function"==typeof define&&define.amd)define(["exports","module"],b);else if("undefined"!=typeof exports&&"undefined"!=typeof module)b(exports,module);else{var c={exports:{}};b(c.exports,c),a.autosize=c.exports}}(this,function(a,b){"use strict";function c(a){function b(){var b=window.getComputedStyle(a,null);"vertical"===b.resize?a.style.resize="none":"both"===b.resize&&(a.style.resize="horizontal"),j="content-box"===b.boxSizing?-(parseFloat(b.paddingTop)+parseFloat(b.paddingBottom)):parseFloat(b.borderTopWidth)+parseFloat(b.borderBottomWidth),d()}function c(b){var c=a.style.width;a.style.width="0px",a.offsetWidth,a.style.width=c,k=b,i&&(a.style.overflowY=b),d()}function d(){var b=a.style.height,d=document.documentElement.scrollTop,e=document.body.scrollTop,f=a.style.height;a.style.height="auto";var g=a.scrollHeight+j;if(0===a.scrollHeight)return void(a.style.height=f);if(a.style.height=g+"px",document.documentElement.scrollTop=d,document.body.scrollTop=e,window.getComputedStyle(a,null).height!==a.style.height){if("visible"!==k)return void c("visible")}else if("hidden"!==k)return void c("hidden");if(b!==a.style.height){var h=document.createEvent("Event");h.initEvent("autosize:resized",!0,!1),a.dispatchEvent(h)}}var e=void 0===arguments[1]?{}:arguments[1],f=e.setOverflowX,g=void 0===f||f,h=e.setOverflowY,i=void 0===h||h;if(a&&a.nodeName&&"TEXTAREA"===a.nodeName&&!a.hasAttribute("data-autosize-on")){var j=null,k="hidden",l=function(b){window.removeEventListener("resize",d),a.removeEventListener("input",d),a.removeEventListener("keyup",d),a.removeAttribute("data-autosize-on"),a.removeEventListener("autosize:destroy",l),Object.keys(b).forEach(function(c){a.style[c]=b[c]})}.bind(a,{height:a.style.height,resize:a.style.resize,overflowY:a.style.overflowY,overflowX:a.style.overflowX,wordWrap:a.style.wordWrap});a.addEventListener("autosize:destroy",l),"onpropertychange"in a&&"oninput"in a&&a.addEventListener("keyup",d),window.addEventListener("resize",d),a.addEventListener("input",d),a.addEventListener("autosize:update",d),a.setAttribute("data-autosize-on",!0),i&&(a.style.overflowY="hidden"),g&&(a.style.overflowX="hidden",a.style.wordWrap="break-word"),b()}}function d(a){if(a&&a.nodeName&&"TEXTAREA"===a.nodeName){var b=document.createEvent("Event");b.initEvent("autosize:destroy",!0,!1),a.dispatchEvent(b)}}function e(a){if(a&&a.nodeName&&"TEXTAREA"===a.nodeName){var b=document.createEvent("Event");b.initEvent("autosize:update",!0,!1),a.dispatchEvent(b)}}var f=null;"undefined"==typeof window||"function"!=typeof window.getComputedStyle?(f=function(a){return a},f.destroy=function(a){return a},f.update=function(a){return a}):(f=function(a,b){return a&&Array.prototype.forEach.call(a.length?a:[a],function(a){return c(a,b)}),a},f.destroy=function(a){return a&&Array.prototype.forEach.call(a.length?a:[a],d),a},f.update=function(a){return a&&Array.prototype.forEach.call(a.length?a:[a],e),a}),b.exports=f}),function($){$.fn.markItUp=function(settings,extraSettings){var method,params,options,ctrlKey,shiftKey,altKey;ctrlKey=shiftKey=altKey=!1,"string"==typeof settings&&(method=settings,params=extraSettings),options={id:"",nameSpace:"",root:"",previewHandler:!1,previewInWindow:"",previewInElement:"#wrt",previewAutoRefresh:!1,previewPosition:"after",previewTemplatePath:"",previewParser:!1,previewParserPath:"",previewParserVar:"data",previewParserAjaxType:"GET",resizeHandle:!0,beforeInsert:"",afterInsert:"",onEnter:{},onShiftEnter:{},onCtrlEnter:{},onTab:{keepDefault:!1,openWith:"  "},markupSet:[{}]},$.extend(options,settings,extraSettings),options.root||$("script").each(function(a,b){miuScript=$(b).get(0).src.match(/(.*)jquery\.markitup(\.pack)?\.js$/),null!==miuScript&&(options.root=miuScript[1])});var uaMatch=function(a){a=a.toLowerCase();var b=/(chrome)[ \/]([\w.]+)/.exec(a)||/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||a.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},matched=uaMatch(navigator.userAgent),browser={};return matched.browser&&(browser[matched.browser]=!0,browser.version=matched.version),browser.chrome?browser.webkit=!0:browser.webkit&&(browser.safari=!0),this.each(function(){function localize(a,b){return b?a.replace(/("|')~\//g,"$1"+options.root):a.replace(/^~\//,options.root)}function init(){id="",nameSpace="",options.id?id='id="'+options.id+'"':$$.attr("id")&&(id='id="markItUp'+$$.attr("id").substr(0,1).toUpperCase()+$$.attr("id").substr(1)+'"'),options.nameSpace&&(nameSpace='class="'+options.nameSpace+'"'),$$.wrap("<div "+nameSpace+"></div>"),$$.wrap("<div "+id+' class="markItUp"></div>'),$$.wrap('<div class="markItUpContainer"></div>'),$$.addClass("markItUpEditor"),header=$('<div class="markItUpHeader"></div>').insertBefore($$),$(dropMenus(options.markupSet)).appendTo(header),footer=$('<div class="markItUpFooter"></div>').insertAfter($$),!0===options.resizeHandle&&!0!==browser.safari&&(resizeHandle=$('<div class="markItUpResizeHandle"></div>').insertAfter($$).bind("mousedown.markItUp",function(a){var b,c,d=$$.height(),e=a.clientY;b=function(a){return $$.css("height",Math.max(20,a.clientY+d-e)+"px"),!1},c=function(a){return $("html").unbind("mousemove.markItUp",b).unbind("mouseup.markItUp",c),!1},$("html").bind("mousemove.markItUp",b).bind("mouseup.markItUp",c)}),footer.append(resizeHandle)),$$.bind("keydown.markItUp",keyPressed).bind("keyup",keyPressed),$$.bind("insertion.markItUp",function(a,b){!1!==b.target&&get(),textarea===$.markItUp.focused&&markup(b)}),$$.bind("focus.markItUp",function(){$.markItUp.focused=this}),options.previewInElement}function dropMenus(markupSet){var ul=$("<ul></ul>"),i=0;return $("li:hover > ul",ul).css("display","block"),$.each(markupSet,function(){var button=this,t="",title,li,j;if(title=button.title?button.key?(button.title||"")+" [Ctrl+"+button.key+"]":button.title||"":button.key?(button.name||"")+" [Ctrl+"+button.key+"]":button.name||"",key=button.key?'accesskey="'+button.key+'"':"",button.separator)li=$('<li class="markItUpSeparator">'+(button.separator||"")+"</li>").appendTo(ul);else{for(i++,j=levels.length-1;j>=0;j--)t+=levels[j]+"-";li=$('<li class="markItUpButton markItUpButton'+t+i+" "+(button.className||"")+'"><a href="#" '+key+' title="'+title+'">'+(button.name||"")+"</a></li>").bind("contextmenu.markItUp",function(){return!1}).bind("click.markItUp",function(a){a.preventDefault()}).bind("focusin.markItUp",function(){$$.focus()}).bind("mouseup",function(e){return button.call&&eval(button.call)(e),setTimeout(function(){markup(button)},1),!1}).bind("mouseenter.markItUp",function(){$("> ul",this).show(),$(document).one("click",function(){$("ul ul",header).hide()})}).bind("mouseleave.markItUp",function(){$("> ul",this).hide()}).appendTo(ul),button.dropMenu&&(levels.push(i),$(li).addClass("markItUpDropMenu").append(dropMenus(button.dropMenu)))}}),levels.pop(),ul}function magicMarkups(a){return a?(a=a.toString(),a=a.replace(/\(\!\(([\s\S]*?)\)\!\)/g,function(a,b){var c=b.split("|!|");return!0===altKey?void 0!==c[1]?c[1]:c[0]:void 0===c[1]?"":c[0]}),a=a.replace(/\[\!\[([\s\S]*?)\]\!\]/g,function(a,b){var c=b.split(":!:");return!0!==abort&&(value=prompt(c[0],c[1]?c[1]:""),null===value&&(abort=!0),value)})):""}function prepare(a){return $.isFunction(a)&&(a=a(hash)),magicMarkups(a)}function build(a){var b=prepare(clicked.openWith),c=prepare(clicked.placeHolder),d=prepare(clicked.replaceWith),e=prepare(clicked.closeWith),f=prepare(clicked.openBlockWith),g=prepare(clicked.closeBlockWith),h=clicked.multiline;if(""!==d)block=b+d+e;else if(""===selection&&""!==c)block=b+c+e;else{a=a||selection;var i=[a],j=[];!0===h&&(i=a.split(/\r?\n/));for(var k=0;k<i.length;k++){line=i[k];var l;(l=line.match(/ *$/))?j.push(b+line.replace(/ *$/g,"")+e+l):j.push(b+line+e)}block=j.join("\n")}return block=f+block+g,{block:block,openBlockWith:f,openWith:b,replaceWith:d,placeHolder:c,closeWith:e,closeBlockWith:g}}function markup(a){var b,c,d,e;if(hash=clicked=a,get(),$.extend(hash,{line:"",root:options.root,textarea:textarea,selection:selection||"",caretPosition:caretPosition,ctrlKey:ctrlKey,shiftKey:shiftKey,altKey:altKey}),prepare(options.beforeInsert),prepare(clicked.beforeInsert),(!0===ctrlKey&&!0===shiftKey||!0===a.multiline)&&prepare(clicked.beforeMultiInsert),$.extend(hash,{line:1}),!0===ctrlKey&&!0===shiftKey){for(lines=selection.split(/\r?\n/),c=0,d=lines.length,e=0;e<d;e++)""!==$.trim(lines[e])?($.extend(hash,{line:++c,selection:lines[e]}),lines[e]=build(lines[e]).block):lines[e]="";string={block:lines.join("\n")},start=caretPosition,b=string.block.length+(browser.opera?d-1:0)}else!0===ctrlKey?(string=build(selection),start=caretPosition+string.openWith.length,b=string.block.length-string.openWith.length-string.closeWith.length,b-=string.block.match(/ $/)?1:0,b-=fixIeBug(string.block)):!0===shiftKey?(string=build(selection),start=caretPosition,b=string.block.length,b-=fixIeBug(string.block)):(string=build(selection),start=caretPosition+string.block.length,b=0,start-=fixIeBug(string.block));""===selection&&""===string.replaceWith&&(caretOffset+=fixOperaBug(string.block),start=caretPosition+string.openBlockWith.length+string.openWith.length,b=string.block.length-string.openBlockWith.length-string.openWith.length-string.closeWith.length-string.closeBlockWith.length,caretOffset=$$.val().substring(caretPosition,$$.val().length).length,caretOffset-=fixOperaBug($$.val().substring(0,caretPosition))),$.extend(hash,{caretPosition:caretPosition,scrollPosition:scrollPosition}),string.block!==selection&&!1===abort?(insert(string.block),set(start,b)):caretOffset=-1,get(),$.extend(hash,{line:"",selection:selection}),(!0===ctrlKey&&!0===shiftKey||!0===a.multiline)&&prepare(clicked.afterMultiInsert),prepare(clicked.afterInsert),prepare(options.afterInsert),previewWindow&&options.previewAutoRefresh&&refreshPreview(),shiftKey=altKey=ctrlKey=abort=!1}function fixOperaBug(a){return browser.opera?a.length-a.replace(/\n*/g,"").length:0}function fixIeBug(a){return browser.msie?a.length-a.replace(/\r*/g,"").length:0}function insert(a){if(document.selection){document.selection.createRange().text=a}else textarea.value=textarea.value.substring(0,caretPosition)+a+textarea.value.substring(caretPosition+selection.length,textarea.value.length)}function set(a,b){if(textarea.createTextRange){if(browser.opera&&browser.version>=9.5&&0==b)return!1;range=textarea.createTextRange(),range.collapse(!0),range.moveStart("character",a),range.moveEnd("character",b),range.select()}else textarea.setSelectionRange&&textarea.setSelectionRange(a,a+b);textarea.scrollTop=scrollPosition,textarea.focus()}function get(){if(textarea.focus(),scrollPosition=textarea.scrollTop,document.selection)if(selection=document.selection.createRange().text,browser.msie){var a=document.selection.createRange(),b=a.duplicate();for(b.moveToElementText(textarea),caretPosition=-1;b.inRange(a);)b.moveStart("character"),caretPosition++}else caretPosition=textarea.selectionStart;else caretPosition=textarea.selectionStart,selection=textarea.value.substring(caretPosition,textarea.selectionEnd);return selection}function preview(){"function"==typeof options.previewHandler?previewWindow=!0:options.previewInElement?previewWindow=$(options.previewInElement):!previewWindow||previewWindow.closed?options.previewInWindow?(previewWindow=window.open("","preview",options.previewInWindow),$(window).unload(function(){previewWindow.close()})):(iFrame=$('<iframe class="markItUpPreviewFrame"></iframe>'),"after"==options.previewPosition?iFrame.insertAfter(footer):iFrame.insertBefore(header),previewWindow=iFrame[iFrame.length-1].contentWindow||frame[iFrame.length-1]):!0===altKey&&(iFrame?iFrame.remove():previewWindow.close(),previewWindow=iFrame=!1),options.previewAutoRefresh||refreshPreview(),options.previewInWindow&&previewWindow.focus()}function refreshPreview(){$(textarea).hasClass("src")?(window.txt=$(textarea).val(),renderPreview(),$(textarea).toggleClass("src")):($(textarea).val(window.txt),$(textarea).toggleClass("src"))}function renderPreview(){var a=$$.val();return options.previewParser&&"function"==typeof options.previewParser&&(a=options.previewParser(a)),options.previewHandler&&"function"==typeof options.previewHandler?options.previewHandler(a):""!==options.previewParserPath?$.ajax({type:options.previewParserAjaxType,dataType:"text",global:!1,url:options.previewParserPath,data:options.previewParserVar+"="+encodeURIComponent(a),success:function(a){writeInPreview(localize(a,1))}}):template||$.ajax({url:options.previewTemplatePath,dataType:"text",global:!1,success:function(b){writeInPreview(localize(b,1).replace(/<!-- content -->/g,a))}}),!1}function writeInPreview(a){if(options.previewInElement)$(options.previewInElement).val(a);else if(previewWindow&&previewWindow.document){try{sp=previewWindow.document.documentElement.scrollTop}catch(b){sp=0}previewWindow.document.open(),previewWindow.document.write(a),previewWindow.document.close(),previewWindow.document.documentElement.scrollTop=sp}}function keyPressed(a){if(shiftKey=a.shiftKey,altKey=a.altKey,ctrlKey=(!a.altKey||!a.ctrlKey)&&(a.ctrlKey||a.metaKey),"keydown"===a.type){if(!0===altKey&&(li=$('a[accesskey="'+(13==a.keyCode?"\\n":String.fromCharCode(a.keyCode))+'"]',header).parent("li"),0!==li.length))return ctrlKey=!1,setTimeout(function(){li.triggerHandler("mouseup")},1),!1;if(13===a.keyCode||10===a.keyCode)return!0===ctrlKey?(ctrlKey=!1,markup(options.onCtrlEnter),options.onCtrlEnter.keepDefault):!0===shiftKey?(shiftKey=!1,markup(options.onShiftEnter),options.onShiftEnter.keepDefault):(markup(options.onEnter),options.onEnter.keepDefault);if(9===a.keyCode)return 1!=shiftKey&&1!=ctrlKey&&1!=altKey&&(-1!==caretOffset?(get(),caretOffset=$$.val().length-caretOffset,set(caretOffset,0),caretOffset=-1,!1):(markup(options.onTab),options.onTab.keepDefault))}}function remove(){$$.unbind(".markItUp").removeClass("markItUpEditor"),$$.parent("div").parent("div.markItUp").parent("div").replaceWith($$);var a=$$.parent("div").parent("div.markItUp").parent("div");a.length&&a.replaceWith($$),$$.data("markItUp",null)}var $$,textarea,levels,scrollPosition,caretPosition,caretOffset,clicked,hash,header,footer,previewWindow,template,iFrame,abort;if($$=$(this),textarea=this,levels=[],abort=!1,scrollPosition=caretPosition=0,caretOffset=-1,options.previewParserPath=localize(options.previewParserPath),options.previewTemplatePath=localize(options.previewTemplatePath),method)switch(method){case"remove":remove();break;case"insert":markup(params);break;default:$.error("Method "+method+" does not exist on jQuery.markItUp")}else init()})},$.fn.markItUpRemove=function(){return this.each(function(){$(this).markItUp("remove")})},$.markItUp=function(a){var b={target:!1};if($.extend(b,a),b.target)return $(b.target).each(function(){$(this).focus(),$(this).trigger("insertion",[b])});$("textarea").trigger("insertion",[b])}}(jQuery),mySettings={previewParserPath:"~/miu/parsers/markdown/parser.php",markupSet:[{name:"HTML",call:"preview",className:"HTML",key:"E"}]},miu={markminTitle:function(a,b){for(heading="",n=$.trim(a.selection||a.placeHolder).length,i=0;i<n;i++)heading+=b;return"\n"+heading}},function(a){a.idleTimer=function(b,c){var d;"object"==typeof b?(d=b,b=null):"number"==typeof b&&(d={timeout:b},b=null),c=c||document,d=a.extend({idle:!1,timeout:3e4,events:"mousemove keydown wheel DOMMouseScroll mousewheel mousedown touchstart touchmove MSPointerDown MSPointerMove"},d);var e=a(c),f=e.data("idleTimerObj")||{},g=function(b){var d=a.data(c,"idleTimerObj")||{};d.idle=!d.idle,d.olddate=+new Date;var e=a.Event((d.idle?"idle":"active")+".idleTimer");a(c).trigger(e,[c,a.extend({},d),b])},h=function(b){var d=a.data(c,"idleTimerObj")||{};if(null==d.remaining){if("mousemove"===b.type){if(b.pageX===d.pageX&&b.pageY===d.pageY)return;if(void 0===b.pageX&&void 0===b.pageY)return;if(200>+new Date-d.olddate)return}clearTimeout(d.tId),d.idle&&g(b),d.lastActive=+new Date,d.pageX=b.pageX,d.pageY=b.pageY,d.tId=setTimeout(g,d.timeout)}},i=function(){var b=a.data(c,"idleTimerObj")||{};b.idle=b.idleBackup,b.olddate=+new Date,b.lastActive=b.olddate,b.remaining=null,clearTimeout(b.tId),b.idle||(b.tId=setTimeout(g,b.timeout))},j=function(){var b=a.data(c,"idleTimerObj")||{};null==b.remaining&&(b.remaining=b.timeout-(+new Date-b.olddate),clearTimeout(b.tId))},k=function(){var b=a.data(c,"idleTimerObj")||{};null!=b.remaining&&(b.idle||(b.tId=setTimeout(g,b.remaining)),b.remaining=null)},l=function(){var b=a.data(c,"idleTimerObj")||{};clearTimeout(b.tId),e.removeData("idleTimerObj"),e.off("._idleTimer")},m=function(){var b=a.data(c,"idleTimerObj")||{};if(b.idle)return 0;if(null!=b.remaining)return b.remaining;var d=b.timeout-(+new Date-b.lastActive);return 0>d&&(d=0),d};if(null===b&&void 0!==f.idle)return i(),e;if(null===b);else{if(null!==b&&void 0===f.idle)return!1;if("destroy"===b)return l(),e;if("pause"===b)return j(),e;if("resume"===b)return k(),e;if("reset"===b)return i(),e;if("getRemainingTime"===b)return m();if("getElapsedTime"===b)return+new Date-f.olddate;if("getLastActiveTime"===b)return f.lastActive;if("isIdle"===b)return f.idle}return e.on(a.trim((d.events+" ").split(" ").join("._idleTimer ")),function(a){h(a)}),f=a.extend({},{olddate:+new Date,lastActive:+new Date,idle:d.idle,idleBackup:d.idle,timeout:d.timeout,remaining:null,tId:null,pageX:null,pageY:null}),f.idle||(f.tId=setTimeout(g,f.timeout)),a.data(c,"idleTimerObj",f),e},a.fn.idleTimer=function(b){return this[0]?a.idleTimer(b,this[0]):this}}(jQuery),$(document).ready(function(){function a(a){a?g.text("●"):g.text("○")}function b(){f.hasClass("src")?storetxt=f.val():storetxt=txt,localStorage.setItem("drkwrtr-text",storetxt),localStorage.setItem("drkwrtr-perm",k),a(!0)}function c(){$.post("cp.php",{txt:f.val()}).done(function(a){k=a,h.html('<a href="'+j+"/"+a+'.html" target="_blank">'+a+"</a>")},function(){h.fadeIn(i)})}function d(){$.post("cp.php",{txt:f.val(),uri:k}).done(function(a){console.log("● stored: "+k),h.html('<a href="'+j+"/"+k+'.html" target="_blank">'+k+"</a>")},function(){h.is(":visible")?h.fadeOut(.7*i).fadeIn(.7*i):h.fadeIn(i)})}function e(){localStorage.setItem("drkwrtr-backup",f.val()),$.ajax({url:"man.md",dataType:"text",success:function(a){f.val(a),autosize.update(f)}})}var f=$("#wrt"),g=$("#saved"),h=$("#txtid"),i=400,j="txt",k="",l=!1,m=localStorage.getItem("drkwrtr-firstrun");h.hide(),"auto"!=g.css("top")&&(l=!0),m?l?f.val(localStorage.getItem("drkwrtr-text")):(f.focus().val(localStorage.getItem("drkwrtr-text")),k=localStorage.getItem("drkwrtr-perm")):(e(),localStorage.setItem("drkwrtr-firstrun","done")),$("body").hasClass("manual")&&(console.log("man"),e()),$("body").hasClass("backup")&&(backup=localStorage.getItem("drkwrtr-backup"),""!=backup&&f.focus().val(backup)),autosize(f),f.idleTimer(800),f.keypress(function(e){174==e.keyCode&&e.altKey&&(e.preventDefault(),localStorage.setItem("drkwrtr-backup",f.val()),localStorage.setItem("drkwrtr-text",""),f.val(""),localStorage.setItem("drkwrtr-perm",""),k="",$(window).scrollTop(0)),8721==e.keyCode&&(e.preventDefault(),b(),""==k?c():d()),a(!1)}),f.on("idle.idleTimer",function(){b()}),$("#wrt").markItUp(mySettings),f.focus()});