Skip to content
Browse files

Remove versioned minified js.

Add new built js.
Update demo.
  • Loading branch information...
1 parent cf0c166 commit a72c09ada2b713ed5de7dcce314c10d372094ae1 @amasad amasad committed Oct 28, 2012
Showing with 6 additions and 6 deletions.
  1. +1 −1 demo/index.html
  2. +0 −5 jqconsole-2.7.min.js
  3. +5 −0 jqconsole.min.js
View
2 demo/index.html
@@ -4,7 +4,7 @@
<head>
<link rel="stylesheet" href="../ansi.css" type="text/css" media="all" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript" charset="utf-8"></script>
- <script src="../jqconsole-2.7.min.js"></script>
+ <script src="../jqconsole.min.js"></script>
<style>
html, body {
background-color: #333;
View
5 jqconsole-2.7.min.js
@@ -1,5 +0,0 @@
-/*
-Copyrights 2011, the repl.it project.
-Licensed under the MIT license
-*/
-(function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L=function(a,b){return function(){return a.apply(b,arguments)}},M=Array.prototype.slice;a=jQuery,H=0,I=1,J=2,y=13,E=9,v=46,u=8,A=37,D=39,F=38,w=40,z=36,x=35,C=33,B=34,i="jqconsole-",e=""+i+"cursor",f=""+i+"header",j=""+i+"prompt",h=""+i+"old-prompt",g=""+i+"input",d=""+i+"blurred",s="keypress",p="<span/>",n="<div/>",o=":empty",G="\n",m=">>> ",l="... ",k=2,c=""+i+"ansi-",q="",r=/\[(\d*)(?:;(\d*))*m/,b=function(){function a(){this.stylize=L(this.stylize,this),this._closeSpan=L(this._closeSpan,this),this._openSpan=L(this._openSpan,this),this.getClasses=L(this.getClasses,this),this._style=L(this._style,this),this._color=L(this._color,this),this._remove=L(this._remove,this),this._append=L(this._append,this),this.klasses=[]}return a.prototype.COLORS=["black","red","green","yellow","blue","magenta","cyan","white"],a.prototype._append=function(a){a=""+c+a;if(this.klasses.indexOf(a)===-1)return this.klasses.push(a)},a.prototype._remove=function(){var a,b,d,e,f,g;d=1<=arguments.length?M.call(arguments,0):[],g=[];for(e=0,f=d.length;e<f;e++)b=d[e],b==="fonts"||b==="color"||b==="background-color"?g.push(this.klasses=function(){var d,e,f,g;f=this.klasses,g=[];for(d=0,e=f.length;d<e;d++)a=f[d],a.indexOf(b)!==c.length&&g.push(a);return g}.call(this)):(b=""+c+b,g.push(this.klasses=function(){var c,d,e,f;e=this.klasses,f=[];for(c=0,d=e.length;c<d;c++)a=e[c],a!==b&&f.push(a);return f}.call(this)));return g},a.prototype._color=function(a){return this.COLORS[a]},a.prototype._style=function(a){a===""&&(a=0),a=parseInt(a);if(isNaN(a))return;switch(a){case 0:return this.klasses=[];case 1:return this._append("bold");case 2:return this._append("lighter");case 3:return this._append("italic");case 4:return this._append("underline");case 5:return this._append("blink");case 6:return this._append("blink-rapid");case 8:return this._append("hidden");case 9:return this._append("line-through");case 10:return this._remove("fonts");case 11:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:return this._append("fonts-"+(a-10));case 20:return this._append("fraktur");case 21:return this._remove("bold","lighter");case 22:return this._remove("bold","lighter");case 23:return this._remove("italic","fraktur");case 24:return this._remove("underline");case 25:return this._remove("blink","blink-rapid");case 28:return this._remove("hidden");case 29:return this._remove("line-through");case 30:case 31:case 32:case 33:case 34:case 35:case 36:case 37:return this._append("color-"+this._color(a-30));case 39:return this._remove("color");case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:return this._append("background-color-"+this._color(a-40));case 49:return this._remove("background-color");case 51:return this._append("framed");case 53:return this._append("overline");case 54:return this._remove("framed");case 55:return this._remove("overline")}},a.prototype.getClasses=function(){return this.klasses.join(" ")},a.prototype._openSpan=function(a){return'<span class="'+this.getClasses()+'">'+a},a.prototype._closeSpan=function(a){return""+a+"</span>"},a.prototype.stylize=function(a){var b,c,d,e,f,g;a=this._openSpan(a),d=0;while((d=a.indexOf(q,d))&&d!==-1)if(c=a.slice(d).match(r)){g=c.slice(1);for(e=0,f=g.length;e<f;e++)b=g[e],this._style(b);a=this._closeSpan(a.slice(0,d))+this._openSpan(a.slice(d+1+c[0].length))}else d++;return this._closeSpan(a)},a}(),K=function(a,b){return'<span class="'+a+'">'+(b||"")+"</span>"},t=function(){function c(c,d,e,g){this.container=c,this._HideComposition=L(this._HideComposition,this),this._ShowComposition=L(this._ShowComposition,this),this._UpdateComposition=L(this._UpdateComposition,this),this._EndComposition=L(this._EndComposition,this),this._StartComposition=L(this._StartComposition,this),this._CheckComposition=L(this._CheckComposition,this),this._ProcessMatch=L(this._ProcessMatch,this),this._HandleKey=L(this._HandleKey,this),this._HandleChar=L(this._HandleChar,this),this.isMobile=!!navigator.userAgent.match(/iPhone|iPad|iPod|Android/i),this.isIos=!!navigator.userAgent.match(/iPhone|iPad|iPod/i),this.isAndroid=!!navigator.userAgent.match(/Android/i),this.$window=a(window),this.header=d||"",this.prompt_label_main=e||m,this.prompt_label_continue=" \n"+(g||l),this.indent_width=k,this.state=I,this.input_queue=[],this.input_callback=null,this.multiline_callback=null,this.history=[],this.history_index=0,this.history_new="",this.history_active=!1,this.shortcuts={},this.$console=a('<pre class="jqconsole"/>').appendTo(this.container),this.$console.css({position:"absolute",top:0,bottom:0,right:0,left:0,margin:0,overflow:"auto"}),this.$console_focused=!0,this.$input_container=a(n).appendTo(this.container),this.$input_container.css({position:"relative",width:1,height:0,overflow:"hidden"}),this.$input_source=a("<textarea/>"),this.$input_source.attr("wrap","off").css({position:"absolute",width:2}),this.$input_source.appendTo(this.$input_container),this.$composition=a(n),this.$composition.addClass(""+i+"composition"),this.$composition.css({display:"inline",position:"relative"}),this.matchings={openings:{},closings:{},clss:[]},this.ansi=new b,this._InitPrompt(),this._SetupEvents(),this.Write(this.header,f),a(this.container).data("jqconsole",this)}return c.prototype.ResetHistory=function(){return this.history=[],this.history_index=0,this.history_current=""},c.prototype.ResetShortcuts=function(){return this.shortcuts={}},c.prototype.ResetMatchings=function(){return this.matchings={openings:{},closings:{},clss:[]}},c.prototype.Reset=function(){this.state!==I&&this.ClearPromptText(!0),this.state=I,this.input_queue=[],this.input_callback=null,this.multiline_callback=null,this.ResetHistory(),this.ResetShortcuts(),this.ResetMatchings(),this.$prompt.detach(),this.$input_container.detach(),this.$console.html(""),this.$prompt.appendTo(this.$console),this.$input_container.appendTo(this.container),this.Write(this.header,f)},c.prototype._CheckKeyCode=function(a){isNaN(a)?a=a.charCodeAt(0):a=parseInt(a,10);if(0<a&&a<256&&!isNaN(a))return a;throw new Error("Key code must be a number between 0 and 256 exclusive.")},c.prototype._LetterCaseHelper=function(a,b){b(a),65<=a&&a<=90&&b(a+32);if(97<=a&&a<=122)return b(a-32)},c.prototype.RegisterShortcut=function(a,b){var c,d=this;a=this._CheckKeyCode(a);if(!b instanceof Function)throw new Error("Callback must be a function, not "+b+".");c=function(a){return a in d.shortcuts||(d.shortcuts[a]=[]),d.shortcuts[a].push(b)},this._LetterCaseHelper(a,c)},c.prototype.UnRegisterShortcut=function(a,b){var c,d=this;a=this._CheckKeyCode(a),c=function(a){if(a in d.shortcuts)return b?d.shortcuts[a].splice(d.shortcuts[a].indexOf(b),1):delete d.shortcuts[a]},this._LetterCaseHelper(a,c)},c.prototype.GetColumn=function(){var a;return this.$prompt_cursor.text(""),a=this.$console.text().split(G),this.$prompt_cursor.html("&nbsp;"),a[a.length-1].length},c.prototype.GetLine=function(){return this.$console.text().split(G).length-1},c.prototype.ClearPromptText=function(a){if(this.state===I)throw new Error("ClearPromptText() is not allowed in output state.");this.$prompt_before.html(""),this.$prompt_after.html(""),this.$prompt_label.text(a?"":this._SelectPromptLabel(!1)),this.$prompt_left.text(""),this.$prompt_right.text("")},c.prototype.GetPromptText=function(b){var c,d,e,f,g;if(this.state===I)throw new Error("GetPromptText() is not allowed in output state.");return b?(this.$prompt_cursor.text(""),g=this.$prompt.text(),this.$prompt_cursor.html("&nbsp;"),g):(f=function(b){var c;return c=[],b.children().each(function(){return c.push(a(this).children().last().text())}),c.join(G)},d=f(this.$prompt_before),d&&(d+=G),e=this.$prompt_left.text()+this.$prompt_right.text(),c=f(this.$prompt_after),c&&(c=G+c),d+e+c)},c.prototype.SetPromptText=function(a){if(this.state===I)throw new Error("SetPromptText() is not allowed in output state.");this.ClearPromptText(!1),this._AppendPromptText(a),this._ScrollToEnd()},c.prototype.Write=function(b,c,d){var e;d==null&&(d=!0),d&&(b=this.ansi.stylize(a(p).text(b).html())),e=a(p).html(b),c!=null&&e.addClass(c),e.insertBefore(this.$prompt),this._ScrollToEnd(),this.$prompt_cursor.detach().insertAfter(this.$prompt_left)},c.prototype.Input=function(a){var b,c,d,e,f=this;if(this.state===J)d=this.input_callback,e=this.multiline_callback,c=this.history_active,b=this.async_multiline,this.AbortPrompt(),this.input_queue.unshift(function(){return f.Prompt(c,d,e,b)});else if(this.state!==I){this.input_queue.push(function(){return f.Input(a)});return}this.history_active=!1,this.input_callback=a,this.multiline_callback=null,this.state=H,this.$prompt.attr("class",g),this.$prompt_label.text(this._SelectPromptLabel(!1)),this.Focus(),this._ScrollToEnd()},c.prototype.Prompt=function(a,b,c,d){var e=this;if(this.state!==I){this.input_queue.push(function(){return e.Prompt(a,b,c,d)});return}this.history_active=a,this.input_callback=b,this.multiline_callback=c,this.async_multiline=d,this.state=J,this.$prompt.attr("class",j+" "+this.ansi.getClasses()),this.$prompt_label.text(this._SelectPromptLabel(!1)),this.Focus(),this._ScrollToEnd()},c.prototype.AbortPrompt=function(){if(this.state!==J)throw new Error("Cannot abort prompt when not in prompt state.");this.Write(this.GetPromptText(!0)+G,h),this.ClearPromptText(!0),this.state=I,this.input_callback=this.multiline_callback=null,this._CheckInputQueue()},c.prototype.Focus=function(){this.IsDisabled()||this.$input_source.focus()},c.prototype.SetIndentWidth=function(a){return this.indent_width=a},c.prototype.GetIndentWidth=function(){return this.indent_width},c.prototype.RegisterMatching=function(a,b,c){var d;return d={opening_char:a,closing_char:b,cls:c},this.matchings.clss.push(c),this.matchings.openings[a]=d,this.matchings.closings[b]=d},c.prototype.UnRegisterMatching=function(a,b){var c;return c=this.matchings.openings[a].cls,delete this.matchings.openings[a],delete this.matchings.closings[b],this.matchings.clss.splice(this.matchings.clss.indexOf(c),1)},c.prototype.Dump=function(){var b,c;return b=this.$console.find("."+f).nextUntil("."+j),function(){var d,e,f;f=[];for(d=0,e=b.length;d<e;d++)c=b[d],a(c).is("."+h)?f.push(a(c).text().replace(/^\s+/,">>> ")):f.push(a(c).text());return f}().join(" ")},c.prototype.GetState=function(){return this.state===H?"input":this.state===I?"output":"prompt"},c.prototype.Disable=function(){return this.$input_source.attr("disabled",!0),this.$input_source.blur()},c.prototype.Enable=function(){return this.$input_source.attr("disabled",!1)},c.prototype.IsDisabled=function(){return Boolean(this.$input_source.attr("disabled"))},c.prototype.MoveToStart=function(a){this._MoveTo(a,!0)},c.prototype.MoveToEnd=function(a){this._MoveTo(a,!1)},c.prototype._CheckInputQueue=function(){if(this.input_queue.length)return this.input_queue.shift()()},c.prototype._InitPrompt=function(){this.$prompt=a(K(g)).appendTo(this.$console),this.$prompt_before=a(p).appendTo(this.$prompt),this.$prompt_current=a(p).appendTo(this.$prompt),this.$prompt_after=a(p).appendTo(this.$prompt),this.$prompt_label=a(p).appendTo(this.$prompt_current),this.$prompt_left=a(p).appendTo(this.$prompt_current),this.$prompt_right=a(p).appendTo(this.$prompt_current),this.$prompt_right.css({position:"relative"}),this.$prompt_cursor=a(K(e,"&nbsp;")),this.$prompt_cursor.insertBefore(this.$prompt_right),this.$prompt_cursor.css({color:"transparent",display:"inline",zIndex:0});if(!this.isMobile)return this.$prompt_cursor.css("position","absolute")},c.prototype._SetupEvents=function(){var b,c,e,f=this;this.isMobile?this.$console.click(function(a){return a.preventDefault(),f.Focus()}):this.$console.mouseup(function(a){var b;return b=function(){if(!window.getSelection().toString())return a.preventDefault(),f.Focus()},setTimeout(b,0)}),this.$input_source.focus(function(){var a,b;return f._ScrollToEnd(),f.$console_focused=!0,f.$console.removeClass(d),b=function(){if(f.$console_focused)return f.$console.removeClass(d)},setTimeout(b,100),a=function(){if(f.isIos&&f.$console_focuseded)return f.$input_source.hide()},setTimeout(a,500)}),this.$input_source.blur(function(){var a;return f.$console_focused=!1,f.isIos&&f.$input_source.show(),a=function(){if(!f.$console_focused)return f.$console.addClass(d)},setTimeout(a,100)}),e=a.browser.opera?"input":"paste",this.$input_source.bind(e,function(){var a;return a=function(){if(f.in_composition)return;return f._AppendPromptText(f.$input_source.val()),f.$input_source.val(""),f.Focus()},setTimeout(a,0)}),this.$input_source.keypress(this._HandleChar),c=a.browser.mozilla||a.browser.opera?s:"keydown",this.$input_source[c](this._HandleKey),this.$input_source.keydown(this._CheckComposition),a.browser.mozilla!=null&&(this.$input_source.bind("compositionstart",this._StartComposition),this.$input_source.bind("compositionend",this._EndCommposition),this.$input_source.bind("text",this._UpdateComposition));if(a.browser.opera!=null)return b=function(){if(f.in_composition)return;if(f.$input_source.val().length)return f._StartComposition()},setInterval(b,200)},c.prototype._HandleChar=function(b){var c;if(this.state===I||b.metaKey||b.ctrlKey)return!0;c=b.which;if(c===8||c===9||c===13)return!1;if(a.browser.mozilla)if(b.keyCode||b.altKey)return!0;return a.browser.opera&&b.altKey?!0:(this.$prompt_left.text(this.$prompt_left.text()+String.fromCharCode(c)),this._ScrollToEnd(),!1)},c.prototype._HandleKey=function(b){var c;if(this.state===I)return!0;c=b.keyCode||b.which,setTimeout(a.proxy(this._CheckMatchings,this),0);if(b.altKey)return!0;if(b.ctrlKey||b.metaKey)return this._HandleCtrlShortcut(c);if(b.shiftKey){switch(c){case y:this._HandleEnter(!0);break;case E:this._Unindent();break;case F:this._MoveUp();break;case w:this._MoveDown();break;case C:this._ScrollUp();break;case B:this._ScrollDown();break;default:return!0}return!1}switch(c){case y:this._HandleEnter(!1);break;case E:this._Indent();break;case v:this._Delete(!1);break;case u:this._Backspace(!1);break;case A:this._MoveLeft(!1);break;case D:this._MoveRight(!1);break;case F:this._HistoryPrevious();break;case w:this._HistoryNext();break;case z:this.MoveToStart(!1);break;case x:this.MoveToEnd(!1);break;case C:this._ScrollUp();break;case B:this._ScrollDown();break;default:return!0}return!1},c.prototype._HandleCtrlShortcut=function(a){var b,c,d,e;switch(a){case v:this._Delete(!0);break;case u:this._Backspace(!0);break;case A:this._MoveLeft(!0);break;case D:this._MoveRight(!0);break;case F:this._MoveUp();break;case w:this._MoveDown();break;case x:this.MoveToEnd(!0);break;case z:this.MoveToStart(!0);break;default:if(a in this.shortcuts){e=this.shortcuts[a];for(c=0,d=e.length;c<d;c++)b=e[c],b.call(this);return!1}return!0}return!1},c.prototype._HandleEnter=function(a){var b,c,d=this;return a?this._InsertNewLine(!0):(c=this.GetPromptText(),b=function(a){var b,e,f,g,h;if(a!==!1){d.MoveToEnd(!0),d._InsertNewLine(!0),h=[];for(f=0,g=Math.abs(a);0<=g?f<g:f>g;0<=g?f++:f--)a>0?h.push(d._Indent()):h.push(d._Unindent());return h}return e=d.state===H?"input":"prompt",d.Write(d.GetPromptText(!0)+G,""+i+"old-"+e),d.ClearPromptText(!0),d.history_active&&((!d.history.length||d.history[d.history.length-1]!==c)&&d.history.push(c),d.history_index=d.history.length),d.state=I,b=d.input_callback,d.input_callback=null,b&&b(c),d._CheckInputQueue()},this.multiline_callback?this.async_multiline?this.multiline_callback(c,b):b(this.multiline_callback(c)):b(!1))},c.prototype._GetDirectionals=function(b){var c,d,e,f,g,h,i,j;return f=b?this.$prompt_left:this.$prompt_right,c=b?this.$prompt_right:this.$prompt_left,e=b?this.$prompt_before:this.$prompt_after,d=b?this.$prompt_after:this.$prompt_before,h=b?a.proxy(this.MoveToStart,this):a.proxy(this.MoveToEnd,this),g=b?a.proxy(this._MoveLeft,this):a.proxy(this._MoveRight,this),j=b?"last":"first",i=b?"prependTo":"appendTo",{$prompt_which:f,$prompt_opposite:c,$prompt_relative:e,$prompt_rel_opposite:d,MoveToLimit:h,MoveDirection:g,which_end:j,where_append:i}},c.prototype._VerticalMove=function(a){var b,c,d,e,f,g,h,i;i=this._GetDirectionals(a),d=i.$prompt_which,b=i.$prompt_opposite,c=i.$prompt_relative,f=i.MoveToLimit,e=i.MoveDirection;if(c.is(o))return;return g=this.$prompt_left.text().length,f(),e(),h=d.text(),b.text(a?h.slice(g):h.slice(0,g)),d.text(a?h.slice(0,g):h.slice(g))},c.prototype._MoveUp=function(){return this._VerticalMove(!0)},c.prototype._MoveDown=function(){return this._VerticalMove()},c.prototype._HorizontalMove=function(b,c){var d,e,f,g,h,i,j,k,l,m,n,q,r,s;s=this._GetDirectionals(c),h=s.$prompt_which,e=s.$prompt_opposite,g=s.$prompt_relative,f=s.$prompt_rel_opposite,q=s.which_end,n=s.where_append,k=c?/\w*\W*$/:/^\w*\W*/,l=h.text();if(l){if(b){r=l.match(k);if(!r)return;return r=r[0],m=e.text(),e.text(c?r+m:m+r),j=r.length,h.text(c?l.slice(0,-j):l.slice(j))}return m=e.text(),e.text(c?l.slice(-1)+m:m+l[0]),h.text(c?l.slice(0,-1):l.slice(1))}if(!g.is(o))return i=a(p)[n](f),i.append(a(p).text(this.$prompt_label.text())),i.append(a(p).text(e.text())),d=g.children()[q]().detach(),this.$prompt_label.text(d.children().first().text()),h.text(d.children().last().text()),e.text("")},c.prototype._MoveLeft=function(a){return this._HorizontalMove(a,!0)},c.prototype._MoveRight=function(a){return this._HorizontalMove(a)},c.prototype._MoveTo=function(a,b){var c,d,e,f,g,h,i;h=this._GetDirectionals(b),e=h.$prompt_which,c=h.$prompt_opposite,d=h.$prompt_relative,g=h.MoveToLimit,f=h.MoveDirection;if(a){i=[];while(!d.is(o)||e.text()!=="")g(!1),i.push(f(!1));return i}return c.text(this.$prompt_left.text()+this.$prompt_right.text()),e.text("")},c.prototype._Delete=function(a){var b,c,d;c=this.$prompt_right.text();if(c){if(a){d=c.match(/^\w*\W*/);if(!d)return;return d=d[0],this.$prompt_right.text(c.slice(d.length))}return this.$prompt_right.text(c.slice(1))}if(!this.$prompt_after.is(o))return b=this.$prompt_after.children().first().detach(),this.$prompt_right.text(b.children().last().text())},c.prototype._Backspace=function(b){var c,d,e;setTimeout(a.proxy(this._ScrollToEnd,this),0),d=this.$prompt_left.text();if(d){if(b){e=d.match(/\w*\W*$/);if(!e)return;return e=e[0],this.$prompt_left.text(d.slice(0,-e.length))}return this.$prompt_left.text(d.slice(0,-1))}if(!this.$prompt_before.is(o))return c=this.$prompt_before.children().last().detach(),this.$prompt_label.text(c.children().first().text()),this.$prompt_left.text(c.children().last().text())},c.prototype._Indent=function(){var a;return this.$prompt_left.prepend(function(){var b,c;c=[];for(a=1,b=this.indent_width;1<=b?a<=b:a>=b;1<=b?a++:a--)c.push(" ");return c}.call(this).join(""))},c.prototype._Unindent=function(){var a,b,c,d;a=this.$prompt_left.text()+this.$prompt_right.text(),d=[];for(b=1,c=this.indent_width;1<=c?b<=c:b>=c;1<=c?b++:b--){if(!/^ /.test(a))break;this.$prompt_left.text()?this.$prompt_left.text(this.$prompt_left.text().slice(1)):this.$prompt_right.text(this.$prompt_right.text().slice(1)),d.push(a=a.slice(1))}return d},c.prototype._InsertNewLine=function(b){var c,d,e;return b==null&&(b=!1),e=this._SelectPromptLabel(!this.$prompt_before.is(o)),c=a(p).appendTo(this.$prompt_before),c.append(a(p).text(e)),c.append(a(p).text(this.$prompt_left.text())),this.$prompt_label.text(this._SelectPromptLabel(!0)),b&&(d=this.$prompt_left.text().match(/^\s+/))?this.$prompt_left.text(d[0]):this.$prompt_left.text(""),this._ScrollToEnd()},c.prototype._AppendPromptText=function(a){var b,c,d,e,f,g;c=a.split(G),this.$prompt_left.text(this.$prompt_left.text()+c[0]),f=c.slice(1),g=[];for(d=0,e=f.length;d<e;d++)b=f[d],this._InsertNewLine(),g.push(this.$prompt_left.text(b));return g},c.prototype._ScrollUp=function(){var a;return a=this.$console[0].scrollTop-this.$console.height(),this.$console.stop().animate({scrollTop:a},"fast")},c.prototype._ScrollDown=function(){var a;return a=this.$console[0].scrollTop+this.$console.height(),this.$console.stop().animate({scrollTop:a},"fast")},c.prototype._ScrollToEnd=function(){var a,b=this;return this.$console.scrollTop(this.$console[0].scrollHeight),a=function(){var a,c,d,e,f,g,h;c=b.$prompt_cursor.height(),h=b.$window.scrollTop(),g=b.$window.scrollLeft(),a=document.documentElement.clientHeight,e=b.$prompt_cursor.offset(),f=b.$prompt_cursor.position(),b.$input_container.css({left:f.left,top:f.top}),d=e.top-2*c;if(b.isMobile&&typeof orientation!="undefined"&&orientation!==null){if(h<e.top||h>e.top)return b.$window.scrollTop(d)}else{if(h+a<e.top)return b.$window.scrollTop(e.top-a+c);if(h>d)return b.$window.scrollTop(e.top)}},setTimeout(a,0)},c.prototype._SelectPromptLabel=function(a){return this.state===J?a?this.prompt_label_continue:this.prompt_label_main:a?"\n ":" "},c.prototype._outerHTML=function(b){return document.body.outerHTML?b.get(0).outerHTML:a(n).append(b.eq(0).clone()).html()},c.prototype._Wrap=function(a,b,c){var d,e;return e=a.html(),d=e.slice(0,b)+K(c,e[b])+e.slice(b+1),a.html(d)},c.prototype._WalkCharacters=function(a,b,c,d,e){var f,g,h;g=e?a.length:0,a=a.split(""),h=function(){var b,c,d,f;return e?(d=a,a=2<=d.length?M.call(d,0,c=d.length-1):(c=0,[]),b=d[c++]):(f=a,b=f[0],a=2<=f.length?M.call(f,1):[]),b&&(g+=e?-1:1),b};while(f=h()){f===b?d++:f===c&&d--;if(d===0)return{index:g,current_count:d}}return{index:-1,current_count:d}},c.prototype._ProcessMatch=function(b,c,d){var e,f,g,h,i,j,k,l,m,n,o,p,q=this;return n=c?[b.closing_char,b.opening_char]:[b.opening_char,b.closing_char],h=n[0],l=n[1],o=this._GetDirectionals(c),g=o.$prompt_which,f=o.$prompt_relative,i=1,j=!1,m=g.html(),c||(m=m.slice(1)),d&&c&&(m=m.slice(0,-1)),p=this._WalkCharacters(m,h,l,i,c),k=p.index,i=p.current_count,k>-1?(this._Wrap(g,k,b.cls),j=!0):(e=f.children(),e=c?Array.prototype.reverse.call(e):e,e.each(function(d,e){var f,g;f=a(e).children().last(),m=f.html(),g=q._WalkCharacters(m,h,l,i,c),k=g.index,i=g.current_count;if(k>-1)return c||k--,q._Wrap(f,k,b.cls),j=!0,!1})),j},c.prototype._CheckMatchings=function(b){var c,d,e,f,g,h,i;e=b?this.$prompt_left.text().slice(this.$prompt_left.text().length-1):this.$prompt_right.text()[0],i=this.matchings.clss;for(g=0,h=i.length;g<h;g++)c=i[g],a("."+c,this.$console).contents().unwrap();(d=this.matchings.closings[e])?f=this._ProcessMatch(d,!0,b):(d=this.matchings.openings[e])?f=this._ProcessMatch(d,!1,b):b||this._CheckMatchings(!0);if(b){if(f)return this._Wrap(this.$prompt_left,this.$prompt_left.html().length-1,d.cls)}else if(f)return this._Wrap(this.$prompt_right,0,d.cls)},c.prototype._HistoryPrevious=function(){if(!this.history_active)return;if(this.history_index<=0)return;return this.history_index===this.history.length&&(this.history_new=this.GetPromptText()),this.SetPromptText(this.history[--this.history_index])},c.prototype._HistoryNext=function(){if(!this.history_active)return;if(this.history_index>=this.history.length)return;return this.history_index===this.history.length-1?(this.history_index++,this.SetPromptText(this.history_new)):this.SetPromptText(this.history[++this.history_index])},c.prototype._CheckComposition=function(b){var c;c=b.keyCode||b.which,a.browser.opera!=null&&this.in_composition&&this._UpdateComposition();if(c===229)return this.in_composition?this._UpdateComposition():this._StartComposition()},c.prototype._StartComposition=function(){return this.$input_source.bind(s,this._EndComposition),this.in_composition=!0,this._ShowComposition(),setTimeout(this._UpdateComposition,0)},c.prototype._EndComposition=function(){return this.$input_source.unbind(s,this._EndComposition),this.in_composition=!1,this._HideComposition(),this.$input_source.val("")},c.prototype._UpdateComposition=function(a){var b,c=this;return b=function(){if(!c.in_composition)return;return c.$composition.text(c.$input_source.val())},setTimeout(b,0)},c.prototype._ShowComposition=function(){return this.$composition.css("height",this.$prompt_cursor.height()),this.$composition.empty(),this.$composition.appendTo(this.$prompt_left)},c.prototype._HideComposition=function(){return this.$composition.detach()},c}(),a.fn.jqconsole=function(a,b,c){return new t(this,a,b,c)}}).call(this)
View
5 jqconsole.min.js
@@ -0,0 +1,5 @@
+/*
+Copyrights 2011, the repl.it project.
+Licensed under the MIT license
+*/
+(function(){var e,t,n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S,x,T,N,C,k,L,A,O,M,_,D,P,H,B,j=function(e,t){return function(){return e.apply(t,arguments)}},F=[].slice;e=jQuery,D=0,P=1,H=2,T=13,O=9,E=46,w=8,C=37,A=39,M=38,S=40,N=36,x=35,L=33,k=34,a="jqconsole-",i=""+a+"cursor",s=""+a+"header",f=""+a+"prompt",u=""+a+"old-prompt",o=""+a+"input",r=""+a+"blurred",y="keypress",v="<span/>",p="<div/>",d=":empty",_="\n",h=">>> ",c="... ",l=2,n=""+a+"ansi-",m="",g=/\[(\d*)(?:;(\d*))*m/,t=function(){function e(){this.stylize=j(this.stylize,this),this._closeSpan=j(this._closeSpan,this),this._openSpan=j(this._openSpan,this),this.getClasses=j(this.getClasses,this),this._style=j(this._style,this),this._color=j(this._color,this),this._remove=j(this._remove,this),this._append=j(this._append,this),this.klasses=[]}return e.prototype.COLORS=["black","red","green","yellow","blue","magenta","cyan","white"],e.prototype._append=function(e){e=""+n+e;if(this.klasses.indexOf(e)===-1)return this.klasses.push(e)},e.prototype._remove=function(){var e,t,r,i,s,o;r=1<=arguments.length?F.call(arguments,0):[],o=[];for(i=0,s=r.length;i<s;i++)t=r[i],t==="fonts"||t==="color"||t==="background-color"?o.push(this.klasses=function(){var r,i,s,o;s=this.klasses,o=[];for(r=0,i=s.length;r<i;r++)e=s[r],e.indexOf(t)!==n.length&&o.push(e);return o}.call(this)):(t=""+n+t,o.push(this.klasses=function(){var n,r,i,s;i=this.klasses,s=[];for(n=0,r=i.length;n<r;n++)e=i[n],e!==t&&s.push(e);return s}.call(this)));return o},e.prototype._color=function(e){return this.COLORS[e]},e.prototype._style=function(e){e===""&&(e=0),e=parseInt(e);if(isNaN(e))return;switch(e){case 0:return this.klasses=[];case 1:return this._append("bold");case 2:return this._append("lighter");case 3:return this._append("italic");case 4:return this._append("underline");case 5:return this._append("blink");case 6:return this._append("blink-rapid");case 8:return this._append("hidden");case 9:return this._append("line-through");case 10:return this._remove("fonts");case 11:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:return this._append("fonts-"+(e-10));case 20:return this._append("fraktur");case 21:return this._remove("bold","lighter");case 22:return this._remove("bold","lighter");case 23:return this._remove("italic","fraktur");case 24:return this._remove("underline");case 25:return this._remove("blink","blink-rapid");case 28:return this._remove("hidden");case 29:return this._remove("line-through");case 30:case 31:case 32:case 33:case 34:case 35:case 36:case 37:return this._append("color-"+this._color(e-30));case 39:return this._remove("color");case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:return this._append("background-color-"+this._color(e-40));case 49:return this._remove("background-color");case 51:return this._append("framed");case 53:return this._append("overline");case 54:return this._remove("framed");case 55:return this._remove("overline")}},e.prototype.getClasses=function(){return this.klasses.join(" ")},e.prototype._openSpan=function(e){return'<span class="'+this.getClasses()+'">'+e},e.prototype._closeSpan=function(e){return""+e+"</span>"},e.prototype.stylize=function(e){var t,n,r,i,s,o;e=this._openSpan(e),r=0;while((r=e.indexOf(m,r))&&r!==-1)if(n=e.slice(r).match(g)){o=n.slice(1);for(i=0,s=o.length;i<s;i++)t=o[i],this._style(t);e=this._closeSpan(e.slice(0,r))+this._openSpan(e.slice(r+1+n[0].length))}else r++;return this._closeSpan(e)},e}(),B=function(e,t){return'<span class="'+e+'">'+(t||"")+"</span>"},b=function(){function n(n,r,i,o){this.container=n,this._HideComposition=j(this._HideComposition,this),this._ShowComposition=j(this._ShowComposition,this),this._UpdateComposition=j(this._UpdateComposition,this),this._EndComposition=j(this._EndComposition,this),this._StartComposition=j(this._StartComposition,this),this._CheckComposition=j(this._CheckComposition,this),this._ProcessMatch=j(this._ProcessMatch,this),this._HandleKey=j(this._HandleKey,this),this._HandleChar=j(this._HandleChar,this),this.isMobile=!!navigator.userAgent.match(/iPhone|iPad|iPod|Android/i),this.isIos=!!navigator.userAgent.match(/iPhone|iPad|iPod/i),this.isAndroid=!!navigator.userAgent.match(/Android/i),this.$window=e(window),this.header=r||"",this.prompt_label_main=i||h,this.prompt_label_continue=" \n"+(o||c),this.indent_width=l,this.state=P,this.input_queue=[],this.input_callback=null,this.multiline_callback=null,this.history=[],this.history_index=0,this.history_new="",this.history_active=!1,this.shortcuts={},this.$console=e('<pre class="jqconsole"/>').appendTo(this.container),this.$console.css({position:"absolute",top:0,bottom:0,right:0,left:0,margin:0,overflow:"auto"}),this.$console_focused=!0,this.$input_container=e(p).appendTo(this.container),this.$input_container.css({position:"relative",width:1,height:0,overflow:"hidden"}),this.$input_source=e("<textarea/>"),this.$input_source.attr("wrap","off").css({position:"absolute",width:2}),this.$input_source.appendTo(this.$input_container),this.$composition=e(p),this.$composition.addClass(""+a+"composition"),this.$composition.css({display:"inline",position:"relative"}),this.matchings={openings:{},closings:{},clss:[]},this.ansi=new t,this._InitPrompt(),this._SetupEvents(),this.Write(this.header,s),e(this.container).data("jqconsole",this)}return n.prototype.ResetHistory=function(){return this.SetHistory([])},n.prototype.ResetShortcuts=function(){return this.shortcuts={}},n.prototype.ResetMatchings=function(){return this.matchings={openings:{},closings:{},clss:[]}},n.prototype.Reset=function(){return this.state!==P&&this.ClearPromptText(!0),this.state=P,this.input_queue=[],this.input_callback=null,this.multiline_callback=null,this.ResetHistory(),this.ResetShortcuts(),this.ResetMatchings(),this.$prompt.detach(),this.$input_container.detach(),this.$console.html(""),this.$prompt.appendTo(this.$console),this.$input_container.appendTo(this.container),this.Write(this.header,s),void 0},n.prototype.GetHistory=function(){return this.history},n.prototype.SetHistory=function(e){return this.history=e.slice(),this.history_index=this.history.length},n.prototype._CheckKeyCode=function(e){isNaN(e)?e=e.charCodeAt(0):e=parseInt(e,10);if(0<e&&e<256&&!isNaN(e))return e;throw new Error("Key code must be a number between 0 and 256 exclusive.")},n.prototype._LetterCaseHelper=function(e,t){t(e),65<=e&&e<=90&&t(e+32);if(97<=e&&e<=122)return t(e-32)},n.prototype.RegisterShortcut=function(e,t){var n,r=this;e=this._CheckKeyCode(e);if(!t instanceof Function)throw new Error("Callback must be a function, not "+t+".");return n=function(e){return e in r.shortcuts||(r.shortcuts[e]=[]),r.shortcuts[e].push(t)},this._LetterCaseHelper(e,n),void 0},n.prototype.UnRegisterShortcut=function(e,t){var n,r=this;return e=this._CheckKeyCode(e),n=function(e){if(e in r.shortcuts)return t?r.shortcuts[e].splice(r.shortcuts[e].indexOf(t),1):delete r.shortcuts[e]},this._LetterCaseHelper(e,n),void 0},n.prototype.GetColumn=function(){var e;return this.$prompt_cursor.text(""),e=this.$console.text().split(_),this.$prompt_cursor.html("&nbsp;"),e[e.length-1].length},n.prototype.GetLine=function(){return this.$console.text().split(_).length-1},n.prototype.ClearPromptText=function(e){if(this.state===P)throw new Error("ClearPromptText() is not allowed in output state.");return this.$prompt_before.html(""),this.$prompt_after.html(""),this.$prompt_label.text(e?"":this._SelectPromptLabel(!1)),this.$prompt_left.text(""),this.$prompt_right.text(""),void 0},n.prototype.GetPromptText=function(t){var n,r,i,s,o;if(this.state===P)throw new Error("GetPromptText() is not allowed in output state.");return t?(this.$prompt_cursor.text(""),o=this.$prompt.text(),this.$prompt_cursor.html("&nbsp;"),o):(s=function(t){var n;return n=[],t.children().each(function(){return n.push(e(this).children().last().text())}),n.join(_)},r=s(this.$prompt_before),r&&(r+=_),i=this.$prompt_left.text()+this.$prompt_right.text(),n=s(this.$prompt_after),n&&(n=_+n),r+i+n)},n.prototype.SetPromptText=function(e){if(this.state===P)throw new Error("SetPromptText() is not allowed in output state.");return this.ClearPromptText(!1),this._AppendPromptText(e),this._ScrollToEnd(),void 0},n.prototype.Write=function(t,n,r){var i;return r==null&&(r=!0),r&&(t=this.ansi.stylize(e(v).text(t).html())),i=e(v).html(t),n!=null&&i.addClass(n),this.Append(i)},n.prototype.Append=function(t){var n;return n=e(t).insertBefore(this.$prompt),this._ScrollToEnd(),this.$prompt_cursor.detach().insertAfter(this.$prompt_left),n},n.prototype.Input=function(e){var t,n,r,i,s=this;if(this.state===H)r=this.input_callback,i=this.multiline_callback,n=this.history_active,t=this.async_multiline,this.AbortPrompt(),this.input_queue.unshift(function(){return s.Prompt(n,r,i,t)});else if(this.state!==P){this.input_queue.push(function(){return s.Input(e)});return}return this.history_active=!1,this.input_callback=e,this.multiline_callback=null,this.state=D,this.$prompt.attr("class",o),this.$prompt_label.text(this._SelectPromptLabel(!1)),this.Focus(),this._ScrollToEnd(),void 0},n.prototype.Prompt=function(e,t,n,r){var i=this;if(this.state!==P){this.input_queue.push(function(){return i.Prompt(e,t,n,r)});return}return this.history_active=e,this.input_callback=t,this.multiline_callback=n,this.async_multiline=r,this.state=H,this.$prompt.attr("class",f+" "+this.ansi.getClasses()),this.$prompt_label.text(this._SelectPromptLabel(!1)),this.Focus(),this._ScrollToEnd(),void 0},n.prototype.AbortPrompt=function(){if(this.state!==H)throw new Error("Cannot abort prompt when not in prompt state.");return this.Write(this.GetPromptText(!0)+_,u),this.ClearPromptText(!0),this.state=P,this.input_callback=this.multiline_callback=null,this._CheckInputQueue(),void 0},n.prototype.Focus=function(){return this.IsDisabled()||this.$input_source.focus(),void 0},n.prototype.SetIndentWidth=function(e){return this.indent_width=e},n.prototype.GetIndentWidth=function(){return this.indent_width},n.prototype.RegisterMatching=function(e,t,n){var r;return r={opening_char:e,closing_char:t,cls:n},this.matchings.clss.push(n),this.matchings.openings[e]=r,this.matchings.closings[t]=r},n.prototype.UnRegisterMatching=function(e,t){var n;return n=this.matchings.openings[e].cls,delete this.matchings.openings[e],delete this.matchings.closings[t],this.matchings.clss.splice(this.matchings.clss.indexOf(n),1)},n.prototype.Dump=function(){var t,n;return t=this.$console.find("."+s).nextUntil("."+f),function(){var r,i,s;s=[];for(r=0,i=t.length;r<i;r++)n=t[r],e(n).is("."+u)?s.push(e(n).text().replace(/^\s+/,">>> ")):s.push(e(n).text());return s}().join(" ")},n.prototype.GetState=function(){return this.state===D?"input":this.state===P?"output":"prompt"},n.prototype.Disable=function(){return this.$input_source.attr("disabled",!0),this.$input_source.blur()},n.prototype.Enable=function(){return this.$input_source.attr("disabled",!1)},n.prototype.IsDisabled=function(){return Boolean(this.$input_source.attr("disabled"))},n.prototype.MoveToStart=function(e){return this._MoveTo(e,!0),void 0},n.prototype.MoveToEnd=function(e){return this._MoveTo(e,!1),void 0},n.prototype._CheckInputQueue=function(){if(this.input_queue.length)return this.input_queue.shift()()},n.prototype._InitPrompt=function(){this.$prompt=e(B(o)).appendTo(this.$console),this.$prompt_before=e(v).appendTo(this.$prompt),this.$prompt_current=e(v).appendTo(this.$prompt),this.$prompt_after=e(v).appendTo(this.$prompt),this.$prompt_label=e(v).appendTo(this.$prompt_current),this.$prompt_left=e(v).appendTo(this.$prompt_current),this.$prompt_right=e(v).appendTo(this.$prompt_current),this.$prompt_right.css({position:"relative"}),this.$prompt_cursor=e(B(i,"&nbsp;")),this.$prompt_cursor.insertBefore(this.$prompt_right),this.$prompt_cursor.css({color:"transparent",display:"inline",zIndex:0});if(!this.isMobile)return this.$prompt_cursor.css("position","absolute")},n.prototype._SetupEvents=function(){var t,n,i,s=this;this.isMobile?this.$console.click(function(e){return e.preventDefault(),s.Focus()}):this.$console.mouseup(function(e){var t;return t=function(){if(!window.getSelection().toString())return e.preventDefault(),s.Focus()},setTimeout(t,0)}),this.$input_source.focus(function(){var e,t;return s._ScrollToEnd(),s.$console_focused=!0,s.$console.removeClass(r),t=function(){if(s.$console_focused)return s.$console.removeClass(r)},setTimeout(t,100),e=function(){if(s.isIos&&s.$console_focused)return s.$input_source.hide()},setTimeout(e,500)}),this.$input_source.blur(function(){var e;return s.$console_focused=!1,s.isIos&&s.$input_source.show(),e=function(){if(!s.$console_focused)return s.$console.addClass(r)},setTimeout(e,100)}),i=e.browser.opera?"input":"paste",this.$input_source.bind(i,function(){var e;return e=function(){if(s.in_composition)return;return s._AppendPromptText(s.$input_source.val()),s.$input_source.val(""),s.Focus()},setTimeout(e,0)}),this.$input_source.keypress(this._HandleChar),n=e.browser.mozilla||e.browser.opera?y:"keydown",this.$input_source[n](this._HandleKey),this.$input_source.keydown(this._CheckComposition),e.browser.mozilla!=null&&(this.$input_source.bind("compositionstart",this._StartComposition),this.$input_source.bind("compositionend",this._EndCommposition),this.$input_source.bind("text",this._UpdateComposition));if(e.browser.opera!=null)return t=function(){if(s.in_composition)return;if(s.$input_source.val().length)return s._StartComposition()},setInterval(t,200)},n.prototype._HandleChar=function(t){var n;if(this.state===P||t.metaKey||t.ctrlKey)return!0;n=t.which;if(n===8||n===9||n===13)return!1;if(e.browser.mozilla)if(t.keyCode||t.altKey)return!0;return e.browser.opera&&t.altKey?!0:(this.$prompt_left.text(this.$prompt_left.text()+String.fromCharCode(n)),this._ScrollToEnd(),!1)},n.prototype._HandleKey=function(t){var n;if(this.state===P)return!0;n=t.keyCode||t.which,setTimeout(e.proxy(this._CheckMatchings,this),0);if(t.altKey)return!0;if(t.ctrlKey||t.metaKey)return this._HandleCtrlShortcut(n);if(t.shiftKey){switch(n){case T:this._HandleEnter(!0);break;case O:this._Unindent();break;case M:this._MoveUp();break;case S:this._MoveDown();break;case L:this._ScrollUp();break;case k:this._ScrollDown();break;default:return!0}return!1}switch(n){case T:this._HandleEnter(!1);break;case O:this._Indent();break;case E:this._Delete(!1);break;case w:this._Backspace(!1);break;case C:this._MoveLeft(!1);break;case A:this._MoveRight(!1);break;case M:this._HistoryPrevious();break;case S:this._HistoryNext();break;case N:this.MoveToStart(!1);break;case x:this.MoveToEnd(!1);break;case L:this._ScrollUp();break;case k:this._ScrollDown();break;default:return!0}return!1},n.prototype._HandleCtrlShortcut=function(e){var t,n,r,i;switch(e){case E:this._Delete(!0);break;case w:this._Backspace(!0);break;case C:this._MoveLeft(!0);break;case A:this._MoveRight(!0);break;case M:this._MoveUp();break;case S:this._MoveDown();break;case x:this.MoveToEnd(!0);break;case N:this.MoveToStart(!0);break;default:if(e in this.shortcuts){i=this.shortcuts[e];for(n=0,r=i.length;n<r;n++)t=i[n],t.call(this);return!1}return!0}return!1},n.prototype._HandleEnter=function(e){var t,n,r=this;return e?this._InsertNewLine(!0):(n=this.GetPromptText(),t=function(e){var t,i,s,o,u,f;if(e!==!1){r.MoveToEnd(!0),r._InsertNewLine(!0),f=[];for(s=o=0,u=Math.abs(e);0<=u?o<u:o>u;s=0<=u?++o:--o)e>0?f.push(r._Indent()):f.push(r._Unindent());return f}return i=r.state===D?"input":"prompt",r.Write(r.GetPromptText(!0)+_,""+a+"old-"+i),r.ClearPromptText(!0),r.history_active&&((!r.history.length||r.history[r.history.length-1]!==n)&&r.history.push(n),r.history_index=r.history.length),r.state=P,t=r.input_callback,r.input_callback=null,t&&t(n),r._CheckInputQueue()},this.multiline_callback?this.async_multiline?this.multiline_callback(n,t):t(this.multiline_callback(n)):t(!1))},n.prototype._GetDirectionals=function(t){var n,r,i,s,o,u,a,f;return s=t?this.$prompt_left:this.$prompt_right,n=t?this.$prompt_right:this.$prompt_left,i=t?this.$prompt_before:this.$prompt_after,r=t?this.$prompt_after:this.$prompt_before,u=t?e.proxy(this.MoveToStart,this):e.proxy(this.MoveToEnd,this),o=t?e.proxy(this._MoveLeft,this):e.proxy(this._MoveRight,this),f=t?"last":"first",a=t?"prependTo":"appendTo",{$prompt_which:s,$prompt_opposite:n,$prompt_relative:i,$prompt_rel_opposite:r,MoveToLimit:u,MoveDirection:o,which_end:f,where_append:a}},n.prototype._VerticalMove=function(e){var t,n,r,i,s,o,u,a;a=this._GetDirectionals(e),r=a.$prompt_which,t=a.$prompt_opposite,n=a.$prompt_relative,s=a.MoveToLimit,i=a.MoveDirection;if(n.is(d))return;return o=this.$prompt_left.text().length,s(),i(),u=r.text(),t.text(e?u.slice(o):u.slice(0,o)),r.text(e?u.slice(0,o):u.slice(o))},n.prototype._MoveUp=function(){return this._VerticalMove(!0)},n.prototype._MoveDown=function(){return this._VerticalMove()},n.prototype._HorizontalMove=function(t,n){var r,i,s,o,u,a,f,l,c,h,p,m,g,y;y=this._GetDirectionals(n),u=y.$prompt_which,i=y.$prompt_opposite,o=y.$prompt_relative,s=y.$prompt_rel_opposite,m=y.which_end,p=y.where_append,l=n?/\w*\W*$/:/^\w*\W*/,c=u.text();if(c){if(t){g=c.match(l);if(!g)return;return g=g[0],h=i.text(),i.text(n?g+h:h+g),f=g.length,u.text(n?c.slice(0,-f):c.slice(f))}return h=i.text(),i.text(n?c.slice(-1)+h:h+c[0]),u.text(n?c.slice(0,-1):c.slice(1))}if(!o.is(d))return a=e(v)[p](s),a.append(e(v).text(this.$prompt_label.text())),a.append(e(v).text(i.text())),r=o.children()[m]().detach(),this.$prompt_label.text(r.children().first().text()),u.text(r.children().last().text()),i.text("")},n.prototype._MoveLeft=function(e){return this._HorizontalMove(e,!0)},n.prototype._MoveRight=function(e){return this._HorizontalMove(e)},n.prototype._MoveTo=function(e,t){var n,r,i,s,o,u,a;u=this._GetDirectionals(t),i=u.$prompt_which,n=u.$prompt_opposite,r=u.$prompt_relative,o=u.MoveToLimit,s=u.MoveDirection;if(e){a=[];while(!r.is(d)||i.text()!=="")o(!1),a.push(s(!1));return a}return n.text(this.$prompt_left.text()+this.$prompt_right.text()),i.text("")},n.prototype._Delete=function(e){var t,n,r;n=this.$prompt_right.text();if(n){if(e){r=n.match(/^\w*\W*/);if(!r)return;return r=r[0],this.$prompt_right.text(n.slice(r.length))}return this.$prompt_right.text(n.slice(1))}if(!this.$prompt_after.is(d))return t=this.$prompt_after.children().first().detach(),this.$prompt_right.text(t.children().last().text())},n.prototype._Backspace=function(t){var n,r,i;setTimeout(e.proxy(this._ScrollToEnd,this),0),r=this.$prompt_left.text();if(r){if(t){i=r.match(/\w*\W*$/);if(!i)return;return i=i[0],this.$prompt_left.text(r.slice(0,-i.length))}return this.$prompt_left.text(r.slice(0,-1))}if(!this.$prompt_before.is(d))return n=this.$prompt_before.children().last().detach(),this.$prompt_label.text(n.children().first().text()),this.$prompt_left.text(n.children().last().text())},n.prototype._Indent=function(){var e;return this.$prompt_left.prepend(function(){var t,n,r;r=[];for(e=t=1,n=this.indent_width;1<=n?t<=n:t>=n;e=1<=n?++t:--t)r.push(" ");return r}.call(this).join(""))},n.prototype._Unindent=function(){var e,t,n,r,i;e=this.$prompt_left.text()+this.$prompt_right.text(),i=[];for(t=n=1,r=this.indent_width;1<=r?n<=r:n>=r;t=1<=r?++n:--n){if(!/^ /.test(e))break;this.$prompt_left.text()?this.$prompt_left.text(this.$prompt_left.text().slice(1)):this.$prompt_right.text(this.$prompt_right.text().slice(1)),i.push(e=e.slice(1))}return i},n.prototype._InsertNewLine=function(t){var n,r,i;return t==null&&(t=!1),i=this._SelectPromptLabel(!this.$prompt_before.is(d)),n=e(v).appendTo(this.$prompt_before),n.append(e(v).text(i)),n.append(e(v).text(this.$prompt_left.text())),this.$prompt_label.text(this._SelectPromptLabel(!0)),t&&(r=this.$prompt_left.text().match(/^\s+/))?this.$prompt_left.text(r[0]):this.$prompt_left.text(""),this._ScrollToEnd()},n.prototype._AppendPromptText=function(e){var t,n,r,i,s,o;n=e.split(_),this.$prompt_left.text(this.$prompt_left.text()+n[0]),s=n.slice(1),o=[];for(r=0,i=s.length;r<i;r++)t=s[r],this._InsertNewLine(),o.push(this.$prompt_left.text(t));return o},n.prototype._ScrollUp=function(){var e;return e=this.$console[0].scrollTop-this.$console.height(),this.$console.stop().animate({scrollTop:e},"fast")},n.prototype._ScrollDown=function(){var e;return e=this.$console[0].scrollTop+this.$console.height(),this.$console.stop().animate({scrollTop:e},"fast")},n.prototype._ScrollToEnd=function(){var e,t=this;return this.$console.scrollTop(this.$console[0].scrollHeight),e=function(){var e,n,r,i,s,o,u;n=t.$prompt_cursor.height(),u=t.$window.scrollTop(),o=t.$window.scrollLeft(),e=document.documentElement.clientHeight,i=t.$prompt_cursor.offset(),s=t.$prompt_cursor.position(),t.$input_container.css({left:s.left,top:s.top}),r=i.top-2*n;if(t.isMobile&&typeof orientation!="undefined"&&orientation!==null){if(u<i.top||u>i.top)return t.$window.scrollTop(r)}else{if(u+e<i.top)return t.$window.scrollTop(i.top-e+n);if(u>r)return t.$window.scrollTop(i.top)}},setTimeout(e,0)},n.prototype._SelectPromptLabel=function(e){return this.state===H?e?this.prompt_label_continue:this.prompt_label_main:e?"\n ":" "},n.prototype._outerHTML=function(t){return document.body.outerHTML?t.get(0).outerHTML:e(p).append(t.eq(0).clone()).html()},n.prototype._Wrap=function(e,t,n){var r,i;return i=e.html(),r=i.slice(0,t)+B(n,i[t])+i.slice(t+1),e.html(r)},n.prototype._WalkCharacters=function(e,t,n,r,i){var s,o,u;o=i?e.length:0,e=e.split(""),u=function(){var t,n,r,s;return i?(r=e,e=2<=r.length?F.call(r,0,n=r.length-1):(n=0,[]),t=r[n++]):(s=e,t=s[0],e=2<=s.length?F.call(s,1):[]),t&&(o+=i?-1:1),t};while(s=u()){s===t?r++:s===n&&r--;if(r===0)return{index:o,current_count:r}}return{index:-1,current_count:r}},n.prototype._ProcessMatch=function(t,n,r){var i,s,o,u,a,f,l,c,h,p,d,v,m=this;return p=n?[t.closing_char,t.opening_char]:[t.opening_char,t.closing_char],u=p[0],c=p[1],d=this._GetDirectionals(n),o=d.$prompt_which,s=d.$prompt_relative,a=1,f=!1,h=o.html(),n||(h=h.slice(1)),r&&n&&(h=h.slice(0,-1)),v=this._WalkCharacters(h,u,c,a,n),l=v.index,a=v.current_count,l>-1?(this._Wrap(o,l,t.cls),f=!0):(i=s.children(),i=n?Array.prototype.reverse.call(i):i,i.each(function(r,i){var s,o;s=e(i).children().last(),h=s.html(),o=m._WalkCharacters(h,u,c,a,n),l=o.index,a=o.current_count;if(l>-1)return n||l--,m._Wrap(s,l,t.cls),f=!0,!1})),f},n.prototype._CheckMatchings=function(t){var n,r,i,s,o,u,a;i=t?this.$prompt_left.text().slice(this.$prompt_left.text().length-1):this.$prompt_right.text()[0],a=this.matchings.clss;for(o=0,u=a.length;o<u;o++)n=a[o],e("."+n,this.$console).contents().unwrap();(r=this.matchings.closings[i])?s=this._ProcessMatch(r,!0,t):(r=this.matchings.openings[i])?s=this._ProcessMatch(r,!1,t):t||this._CheckMatchings(!0);if(t){if(s)return this._Wrap(this.$prompt_left,this.$prompt_left.html().length-1,r.cls)}else if(s)return this._Wrap(this.$prompt_right,0,r.cls)},n.prototype._HistoryPrevious=function(){if(!this.history_active)return;if(this.history_index<=0)return;return this.history_index===this.history.length&&(this.history_new=this.GetPromptText()),this.SetPromptText(this.history[--this.history_index])},n.prototype._HistoryNext=function(){if(!this.history_active)return;if(this.history_index>=this.history.length)return;return this.history_index===this.history.length-1?(this.history_index++,this.SetPromptText(this.history_new)):this.SetPromptText(this.history[++this.history_index])},n.prototype._CheckComposition=function(t){var n;n=t.keyCode||t.which,e.browser.opera!=null&&this.in_composition&&this._UpdateComposition();if(n===229)return this.in_composition?this._UpdateComposition():this._StartComposition()},n.prototype._StartComposition=function(){return this.$input_source.bind(y,this._EndComposition),this.in_composition=!0,this._ShowComposition(),setTimeout(this._UpdateComposition,0)},n.prototype._EndComposition=function(){return this.$input_source.unbind(y,this._EndComposition),this.in_composition=!1,this._HideComposition(),this.$input_source.val("")},n.prototype._UpdateComposition=function(e){var t,n=this;return t=function(){if(!n.in_composition)return;return n.$composition.text(n.$input_source.val())},setTimeout(t,0)},n.prototype._ShowComposition=function(){return this.$composition.css("height",this.$prompt_cursor.height()),this.$composition.empty(),this.$composition.appendTo(this.$prompt_left)},n.prototype._HideComposition=function(){return this.$composition.detach()},n}(),e.fn.jqconsole=function(e,t,n){return new b(this,e,t,n)}}).call(this);

0 comments on commit a72c09a

Please sign in to comment.
Something went wrong with that request. Please try again.