/*

 |       __ _____                     ________                              __
 |      / // _  /__ __ _____ ___ __ _/__  ___/__ ___ ______ __ __  __ ___  / /
 |  __ / // // // // // _  // _// // / / // _  // _//     // //  \/ // _ \/ /
 | /  / // // // // // ___// / / // / / // ___// / / / / // // /\  // // / /__
 | \___//____ \\___//____//_/ _\_  / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/
 |           \/              /____/                              version 0.7.12
 http://terminal.jcubic.pl

 Licensed under GNU LGPL Version 3 license
 Copyright (c) 2011-2013 Jakub Jankiewicz <http://jcubic.pl>

 Includes:

 Storage plugin Distributed under the MIT License
 Copyright (c) 2010 Dave Schindler

 jQuery Timers licenced with the WTFPL
 <http://jquery.offput.ca/every/>

 Cross-Browser Split 1.1.1
 Copyright 2007-2012 Steven Levithan <stevenlevithan.com>
 Available under the MIT License

 Date: Tue, 17 Dec 2013 16:24:17 +0000
*/
(function(d,R){function wa(c,e){var i;if(typeof c==="string"&&typeof e==="string"){localStorage[c]=e;return true}else if(typeof c==="object"&&typeof e==="undefined"){for(i in c)if(c.hasOwnProperty(i))localStorage[i]=c[i];return true}return false}function la(c,e){var i,g;i=new Date;i.setTime(i.getTime()+31536E6);i="; expires="+i.toGMTString();if(typeof c==="string"&&typeof e==="string"){document.cookie=c+"="+e+i+"; path=/";return true}else if(typeof c==="object"&&typeof e==="undefined"){for(g in c)if(c.hasOwnProperty(g))document.cookie=
g+"="+c[g]+i+"; path=/";return true}return false}function xa(c){return localStorage[c]}function ya(c){var e,i,g;c+="=";e=document.cookie.split(";");for(i=0;i<e.length;i++){for(g=e[i];g.charAt(0)===" ";)g=g.substring(1,g.length);if(g.indexOf(c)===0)return g.substring(c.length,g.length)}return null}function za(c){return delete localStorage[c]}function Aa(c){return la(c,"",-1)}function ja(c,e){var i=[],g=c.length;if(g<e)return[c];for(var l=0;l<g;l+=e)i.push(c.substring(l,l+e));return i}function Ba(c){var e=
c?[c]:[];d.extend(this,{size:function(){return e.length},pop:function(){if(e.length===0)return null;else{var i=e[e.length-1];e=e.slice(0,e.length-1);return i}},push:function(i){e=e.concat([i]);return i},top:function(){return e.length>0?e[e.length-1]:null}})}function Ca(c,e){var i=true;if(typeof c==="string"&&c!=="")c+="_";var g=d.Storage.get(c+"commands");g=g?(new Function("return "+g+";"))():[];var l=g.length-1;d.extend(this,{append:function(o){if(i)if(g[g.length-1]!==o){g.push(o);if(e&&g.length>
e)g=g.slice(-e);l=g.length-1;d.Storage.set(c+"commands",d.json_stringify(g))}},data:function(){return g},reset:function(){l=g.length-1},last:function(){return g[length-1]},end:function(){return l===g.length-1},position:function(){return l},current:function(){return g[l]},next:function(){l<g.length-1&&++l;if(l!==-1)return g[l]},previous:function(){var o=l;l>0&&--l;if(o!==-1)return g[l]},clear:function(){g=[];this.purge()},enabled:function(){return i},enable:function(){i=true},purge:function(){d.Storage.remove(c+
"commands")},disable:function(){i=false}})}function ma(c){return c.replace(/([\^\$\[\]\(\)\+\*\.\|])/g,"\\$1")}function ka(c,e){var i=c.split(/(\s+)/);return{name:i[0],args:e(i.slice(2).join("")),rest:c.replace(RegExp("^"+ma(i[0])+" "),"")}}function na(c){var e=d('<div class="terminal"><span>&nbsp;</span></div>').appendTo("body"),i=e.find("span").width();e.remove();e=Math.floor(c.width()/i);if(ha(c)){c=c.innerWidth()-c.width();e-=Math.ceil((20-c/2)/(i-1))}return e}function ha(c){return c.get(0).scrollHeight>
c.innerHeight()}d.omap=function(c,e){var i={};d.each(c,function(g,l){i[g]=e.call(c,g,l)});return i};var da=typeof window.localStorage!=="undefined";d.extend({Storage:{set:da?wa:la,get:da?xa:ya,remove:da?za:Aa}});jQuery.fn.extend({everyTime:function(c,e,i,g,l){return this.each(function(){jQuery.timer.add(this,c,e,i,g,l)})},oneTime:function(c,e,i){return this.each(function(){jQuery.timer.add(this,c,e,i,1)})},stopTime:function(c,e){return this.each(function(){jQuery.timer.remove(this,c,e)})}});jQuery.extend({timer:{guid:1,
global:{},regex:/^([0-9]+)\s*(.*s)?$/,powers:{ms:1,cs:10,ds:100,s:1E3,das:1E4,hs:1E5,ks:1E6},timeParse:function(c){if(c===R||c===null)return null;var e=this.regex.exec(jQuery.trim(c.toString()));return e[2]?parseInt(e[1],10)*(this.powers[e[2]]||1):c},add:function(c,e,i,g,l,o){var A=0;if(jQuery.isFunction(i)){l||(l=g);g=i;i=e}e=jQuery.timer.timeParse(e);if(!(typeof e!=="number"||isNaN(e)||e<=0)){if(l&&l.constructor!==Number){o=!!l;l=0}l=l||0;o=o||false;if(!c.$timers)c.$timers={};c.$timers[i]||(c.$timers[i]=
{});g.$timerID=g.$timerID||this.guid++;var k=function(){if(!(o&&k.inProgress)){k.inProgress=true;if(++A>l&&l!==0||g.call(c,A)===false)jQuery.timer.remove(c,i,g);k.inProgress=false}};k.$timerID=g.$timerID;c.$timers[i][g.$timerID]||(c.$timers[i][g.$timerID]=window.setInterval(k,e));this.global[i]||(this.global[i]=[]);this.global[i].push(c)}},remove:function(c,e,i){var g=c.$timers,l;if(g){if(e){if(g[e]){if(i){if(i.$timerID){window.clearInterval(g[e][i.$timerID]);delete g[e][i.$timerID]}}else for(var o in g[e])if(g[e].hasOwnProperty(o)){window.clearInterval(g[e][o]);
delete g[e][o]}for(l in g[e])if(g[e].hasOwnProperty(l))break;if(!l){l=null;delete g[e]}}}else for(var A in g)g.hasOwnProperty(A)&&this.remove(c,A,i);for(l in g)if(g.hasOwnProperty(l))break;if(!l)c.$timers=null}}}});if(jQuery.browser&&jQuery.browser.msie||/(msie) ([\w.]+)/.exec(navigator.userAgent.toLowerCase()))jQuery(window).one("unload",function(){var c=jQuery.timer.global,e;for(e in c)if(c.hasOwnProperty(e))for(var i=c[e],g=i.length;--g;)jQuery.timer.remove(i[g],e)});(function(c){if(String.prototype.split.toString().match(/\[native/)){var e=
String.prototype.split,i=/()??/.exec("")[1]===c,g;g=function(l,o,A){if(Object.prototype.toString.call(o)!=="[object RegExp]")return e.call(l,o,A);var k=[],x=(o.ignoreCase?"i":"")+(o.multiline?"m":"")+(o.extended?"x":"")+(o.sticky?"y":""),B=0,D,v,y;o=RegExp(o.source,x+"g");l+="";i||(D=RegExp("^"+o.source+"$(?!\\s)",x));for(A=A===c?4294967295:A>>>0;v=o.exec(l);){x=v.index+v[0].length;if(x>B){k.push(l.slice(B,v.index));!i&&v.length>1&&v[0].replace(D,function(){for(var E=1;E<arguments.length-2;E++)if(arguments[E]===
c)v[E]=c});v.length>1&&v.index<l.length&&Array.prototype.push.apply(k,v.slice(1));y=v[0].length;B=x;if(k.length>=A)break}o.lastIndex===v.index&&o.lastIndex++}if(B===l.length){if(y||!o.test(""))k.push("")}else k.push(l.slice(B));return k.length>A?k.slice(0,A):k};String.prototype.split=function(l,o){return g(this,l,o)};return g}})();d.json_stringify=function(c,e){var i="",g;e=e===R?1:e;switch(typeof c){case "function":i+=c;break;case "boolean":i+=c?"true":"false";break;case "object":if(c===null)i+=
"null";else if(c instanceof Array){i+="[";var l=c.length;for(g=0;g<l-1;++g)i+=d.json_stringify(c[g],e+1);i+=d.json_stringify(c[l-1],e+1)+"]"}else{i+="{";for(l in c)if(c.hasOwnProperty(l))i+='"'+l+'":'+d.json_stringify(c[l],e+1);i+="}"}break;case "string":l=c;var o={"\\\\":"\\\\",'"':'\\"',"/":"\\/","\\n":"\\n","\\r":"\\r","\\t":"\\t"};for(g in o)if(o.hasOwnProperty(g))l=l.replace(RegExp(g,"g"),o[g]);i+='"'+l+'"';break;case "number":i+=String(c)}i+=e>1?",":"";if(e===1)i=i.replace(/,([\]}])/g,"$1");
return i.replace(/([\[{]),/g,"$1")};d.fn.cmd=function(c){function e(){b.toggleClass("inverted")}function i(){L="(reverse-i-search)`"+E+"': ";Z()}function g(f){var t=M.data(),I,W=t.length;if(f&&G>0)W-=G;if(E.length>0)for(f=E.length;f>0;f--){I=E.substring(0,f).replace(/([.*+{}\[\]?])/g,"\\$1");I=RegExp(I);for(var Y=W;Y--;)if(I.test(t[Y])){G=t.length-Y;r=0;k.set(t[Y],true);J();if(E.length!==f){E=E.substring(0,f);i()}return}}E=""}function l(f){var t=f.substring(0,D-v);f=f.substring(D-v);return[t].concat(ja(f,
D))}function o(){B.focus();k.oneTime(1,function(){k.insert(B.val());B.blur().val("")})}function A(f){var t;if(typeof c.keydown=="function"){t=c.keydown(f);if(t!==R)return t}if(S){if(f.which!==38&&!(f.which===80&&f.ctrlKey))ba=true;if(y&&(f.which===35||f.which===36||f.which===37||f.which===38||f.which===39||f.which===40||f.which===13||f.which===27)){L=H;y=false;G=null;E="";Z();if(f.which===27)n="";J();A.call(this,f)}else if(f.altKey){if(f.which===68){k.set(n.slice(0,r)+n.slice(r).replace(/[^ ]+ |[^ ]+$/,
""),true);return false}return true}else if(f.keyCode===13){if(M&&n&&(c.historyFilter&&c.historyFilter(n)||!c.historyFilter))M.append(n);f=n;M.reset();k.set("");c.commands&&c.commands(f);typeof L==="function"&&Z()}else if(f.which===8)if(y){E=E.slice(0,-1);i()}else{if(n!==""&&r>0){n=n.slice(0,r-1)+n.slice(r,n.length);--r;J()}}else if(f.which===9&&!(f.ctrlKey||f.altKey))k.insert("\t");else if(f.which===46){if(n!==""&&r<n.length){n=n.slice(0,r)+n.slice(r+1,n.length);J()}return true}else if(M&&f.which===
38||f.which===80&&f.ctrlKey){if(ba){Q=n;k.set(M.current())}else k.set(M.previous());ba=false}else if(M&&f.which===40||f.which===78&&f.ctrlKey)k.set(M.end()?Q:M.next());else if(f.which===37||f.which===66&&f.ctrlKey)if(f.ctrlKey&&f.which!==66){t=r-1;f=0;for(n[t]===" "&&--t;t>0;--t)if(n[t]===" "&&n[t+1]!==" "){f=t+1;break}else if(n[t]==="\n"&&n[t+1]!=="\n"){f=t;break}k.position(f)}else{if(r>0){--r;J()}}else if(f.which===82&&f.ctrlKey)if(y)g(true);else{H=L;i();Q=n;n="";J();y=true}else if(f.which==71&&
f.ctrlKey){if(y){L=H;Z();n=Q;J();y=false;E=""}}else if(f.which===39||f.which===70&&f.ctrlKey)if(f.ctrlKey&&f.which!==70){n[r]===" "&&++r;f=n.slice(r).match(/\S[\n\s]{2,}|[\n\s]+\S?/);if(!f||f[0].match(/^\s+$/))r=n.length;else if(f[0][0]!==" ")r+=f.index+1;else{r+=f.index+f[0].length-1;f[0][f[0].length-1]!==" "&&--r}J()}else{if(r<n.length){++r;J()}}else if(f.which===123)return true;else if(f.which===36)k.position(0);else if(f.which===35)k.position(n.length);else if(f.shiftKey&&f.which==45){o();return true}else if(f.ctrlKey||
f.metaKey){if(f.which===192)return true;if(f.metaKey)if(f.which===82)return true;else if(f.which===76)return true;if(f.shiftKey){if(f.which===84)return true}else if(f.which===87){if(n!==""){f=n.slice(0,r);t=n.slice(r+1);var I=f.match(/([^ ]+ *$)/);r=f.length-I[0].length;n=f.slice(0,r)+t;J()}}else if(f.which===72){if(n!==""&&r>0){n=n.slice(0,--r);if(r<n.length-1)n+=n.slice(r);J()}}else if(f.which===65)k.position(0);else if(f.which===69)k.position(n.length);else if(f.which===88||f.which===67||f.which===
84)return true;else if(f.which===86){o();return true}else if(f.which===75)if(r===0)k.set("");else r!==n.length&&k.set(n.slice(0,r));else if(f.which===85){k.set(n.slice(r,n.length));k.position(0)}}else return true;return false}}var k=this,x=k.data("cmd");if(x)return x;k.addClass("cmd");k.append('<span class="prompt"></span><span></span><span class="cursor">&nbsp;</span><span></span>');var B=d("<textarea/>").addClass("clipboard").appendTo(k);c.width&&k.width(c.width);var D,v,y=false,E="",G=null,H,N=
c.mask||false,n="",r=0,L,S=c.enabled,ea=c.historySize||60,O,M,b=k.find(".cursor"),J=function(f){function t(z,C){if(C===z.length){X.html(d.terminal.encode(z,true));b.html("&nbsp;");m.html("")}else if(C===0){X.html("");b.html(d.terminal.encode(z.slice(0,1),true));m.html(d.terminal.encode(z.slice(1),true))}else{var F=d.terminal.encode(z.slice(0,C),true);X.html(F);F=z.slice(C,C+1);b.html(F===" "?"&nbsp;":d.terminal.encode(F,true));C===z.length-1?m.html(""):m.html(d.terminal.encode(z.slice(C+1),true))}}
function I(z){return"<div>"+d.terminal.encode(z,true)+"</div>"}function W(z){var C=m;d.each(z,function(F,s){C=d(I(s)).insertAfter(C).addClass("clear")})}function Y(z){d.each(z,function(C,F){X.before(I(F))})}var X=b.prev(),m=b.next();return function(){var z=N?n.replace(/./g,"*"):n,C,F;f.find("div").remove();X.html("");if(z.length>D-v-1||z.match(/\n/)){var s,u=z.match(/\t/g),a=u?u.length*3:0;if(u)z=z.replace(/\t/g,"\u0000\u0000\u0000\u0000");if(z.match(/\n/)){var h=z.split("\n");F=D-v-1;for(C=0;C<h.length-
1;++C)h[C]+=" ";if(h[0].length>F){s=[h[0].substring(0,F)];s=s.concat(ja(h[0].substring(F),D))}else s=[h[0]];for(C=1;C<h.length;++C)if(h[C].length>D)s=s.concat(ja(h[C],D));else s.push(h[C])}else s=l(z);if(u)s=d.map(s,function(p){return p.replace(/\x00\x00\x00\x00/g,"\t")});F=s[0].length;if(!(F===0&&s.length===1))if(r<F){t(s[0],r);W(s.slice(1))}else if(r===F){X.before(I(s[0]));t(s[1],0);W(s.slice(2))}else{C=s.length;if(r<F){t(s[0],r);W(s.slice(1))}else if(r===F){X.before(I(s[0]));t(s[1],0);W(s.slice(2))}else{u=
s.slice(-1)[0];h=z.length-r;var j=u.length;z=0;if(h<=j){Y(s.slice(0,-1));t(u,(j===h?0:j-h)+a)}else if(C===3){X.before("<div>"+d.terminal.encode(s[0],true)+"</div>");t(s[1],r-F-1);m.after('<div class="clear">'+d.terminal.encode(s[2],true)+"</div>")}else{z=r;for(C=0;C<s.length;++C){F=s[C].length;if(z>F)z-=F;else break}F=s[C];a=C;if(z===F.length){z=0;F=s[++a]}t(F,z);Y(s.slice(0,a));W(s.slice(a+1))}}}}else if(z===""){X.html("");b.html("&nbsp;");m.html("")}else t(z,r)}}(k),Q,Z=function(){function f(I){v=
d("<div>"+d.terminal.strip(I)+"</div>").text().length;t.html(d.terminal.format(d.terminal.encode(I)))}var t=k.find(".prompt");return function(){switch(typeof L){case "string":f(L);break;case "function":L(f)}}}(),ba=true,K=[];d.extend(k,{name:function(f){if(f!==R){O=f;M=new Ca(f,ea);(f=K.length)&&!K[f-1].enabled()&&M.disable();K.push(M);return k}else return O},purge:function(){for(var f=K.length;f--;)K[f].purge();K=[];return k},history:function(){return M},set:function(f,t){if(f!==R){n=f;if(!t)r=n.length;
J();if(typeof c.onCommandChange==="function")c.onCommandChange(n)}return k},insert:function(f,t){if(r===n.length)n+=f;else n=r===0?f+n:n.slice(0,r)+f+n.slice(r);t||(r+=f.length);J();if(typeof c.onCommandChange==="function")c.onCommandChange(n);return k},get:function(){return n},commands:function(f){if(f){c.commands=f;return k}else return f},destroy:function(){d(document.documentElement||window).unbind(".cmd");k.stopTime("blink",e);k.find(".cursor").next().remove().end().prev().remove().end().remove();
k.find(".prompt, .clipboard").remove();k.removeClass("cmd").removeData("cmd");return k},prompt:function(f){if(f===R)return L;else{if(typeof f==="string"||typeof f==="function")L=f;else throw"prompt must be a function or string";Z();J();return k}},position:function(f){if(typeof f==="number"){r=f<0?0:f>n.length?n.length:f;J();return k}else return r},visible:function(){var f=k.visible;return function(){f.apply(k,[]);J();Z()}}(),show:function(){var f=k.show;return function(){f.apply(k,[]);J();Z()}}(),
resize:function(f){if(f)D=f;else{f=k.width();var t=b.innerWidth();D=Math.floor(f/t)}J();return k},enable:function(){if(!S){b.addClass("inverted");k.everyTime(500,"blink",e);S=true}return k},isenabled:function(){return S},disable:function(){if(S){k.stopTime("blink",e);b.removeClass("inverted");S=false}return k},mask:function(f){if(typeof f==="boolean"){N=f;J();return k}else return N}});k.name(c.name||c.prompt||"");L=c.prompt||"> ";Z();if(c.enabled===R||c.enabled===true)k.enable();d(document.documentElement||
window).bind("keypress.cmd",function(f){var t;if(f.ctrlKey&&f.which===99)return true;if(!y&&typeof c.keypress==="function")t=c.keypress(f);if(t===R||t){if(S)if(d.inArray(f.which,[38,13,0,8])>-1&&f.keyCode!==123&&!(f.which===38&&f.shiftKey))return false;else if(!f.ctrlKey&&!(f.altKey&&f.which===100)||f.altKey){if(y){E+=String.fromCharCode(f.which);g();i()}else k.insert(String.fromCharCode(f.which));return false}}else return t}).bind("keydown.cmd",A);k.data("cmd",k);return k};var Da=/(\[\[[gbiuso]*;[^;]*;[^\]]*\](?:[^\]]*\\\][^\]]*|[^\]]*|[^\[]*\[[^\]]*)\]?)/,
oa=/\[\[([gbiuso]*);([^;]*);([^;\]]*);?([^;\]]*);?([^\]]*)\]([^\]]*\\\][^\]]*|[^\]]*|[^\[]*\[[^\]]*)\]?/g,pa=/\[\[([gbiuso]*;[^;\]]*;[^;\]]*(?:;|[^\]()]*);?[^\]]*)\]([^\]]*\\\][^\]]*|[^\]]*|[^\[]*\[[^\]]*)\]?/gi,qa=/#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})/,Ea=/https?:\/\/(?:(?!&[^;]+;)[^\s:"'<>)])+/g,Fa=/((([^<>('")[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,})))/g,ra=/('[^']*'|"(\\"|[^"])*"|\/(\\\/|[^\/])*\/|(\\ |[^ ])+|[\w-]+)/g,
sa=/(\[\[[gbiuso]*;[^;]*;[^\]]*\])/,ta=/\[\[[gbiuso]*;[^;]*;[^\]]*\]?$/;d.terminal={split_equal:function(c,e){for(var i=false,g=false,l="",o=[],A=c.replace(pa,function(N,n,r){N=n.match(/;/g).length;return"[["+n+(N==2?";;":N==3?";":"")+r.replace(/\\\]/g,"&#93;").replace(/\n/g,"\\n")+"]"+r+"]"}).split(/\n/g),k=0,x=A.length;k<x;++k)if(A[k]==="")o.push("");else for(var B=A[k],D=0,v=0,y=0,E=B.length;y<E;++y){if(B[y]==="["&&B[y+1]==="[")i=true;else if(i&&B[y]==="]")if(g)g=i=false;else g=true;else if(i&&
g||!i)if(B[y]==="&"){var G=B.substring(y).match(/^(&[^;]+;)/);if(!G)throw"Unclosed html entity in line "+(k+1)+" at char "+(y+1);y+=G[1].length-2;y===E-1&&o.push(H+G[1]);continue}else if(B[y]==="]"&&B[y-1]==="\\")--v;else++v;if(v===e||y===E-1){var H=B.substring(D,y+1);if(l){H=l+H;if(H.match("]"))l=""}D=y+1;v=0;if(G=H.match(pa)){G=G[G.length-1];if(G[G.length-1]!=="]"){l=G.match(sa)[1];H+="]"}else if(H.match(ta)){H=H.replace(ta,"");l=G.match(sa)[1]}}o.push(H)}}return o},encode:function(c,e){c=e?c.replace(/&(?![^=]+=)/g,
"&amp;"):c.replace(/&(?!#[0-9]+;|[a-zA-Z]+;|[^= "]+=[^=])/g,"&amp;");return c.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g,"&nbsp;").replace(/\t/g,"&nbsp;&nbsp;&nbsp;&nbsp;")},format:function(c,e){var i=d.extend({},{linksNoReferrer:false},e||{});if(typeof c==="string"){var g=c.split(Da);if(g&&g.length>1)c=d.map(g,function(l){return l===""?l:l.substring(0,1)==="["?l.replace(oa,function(o,A,k,x,B,D,v){if(v==="")return"";v=v.replace(/\\]/g,"]");o="";if(A.indexOf("b")!==-1)o+="font-weight:bold;";
var y=[];A.indexOf("u")!==-1&&y.push("underline");A.indexOf("s")!==-1&&y.push("line-through");A.indexOf("o")!==-1&&y.push("overline");if(y.length)o+="text-decoration:"+y.join(" ")+";";if(A.indexOf("i")!==-1)o+="font-style:italic;";if(k.match(qa)){o+="color:"+k+";";if(A.indexOf("g")!==-1)o+="text-shadow:0 0 5px "+k+";"}if(x.match(qa))o+="background-color:"+x;return'<span style="'+o+'"'+(B!==""?' class="'+B+'"':"")+' data-text="'+(D===""?v:D.replace(/&#93;/g,"]")).replace('"',"&quote;")+'">'+v+"</span>"}):
"<span>"+l+"</span>"}).join("");return d.map(c.split(/(<\/?span[^>]*>)/g),function(l){return l.match(/span/)?l:l.replace(Ea,function(o){var A=o.match(/\.$/);o=o.replace(/\.$/,"");return'<a target="_blank" '+(i.linksNoReferer?' rel="noreferrer" ':"")+'href="'+o+'">'+o+"</a>"+(A?".":"")}).replace(Fa,'<a href="mailto:$1">$1</a>')}).join("").replace(/<span><br\/?><\/span>/g,"<br/>")}else return""},escape_brackets:function(c){return c.replace(/\[/g,"&#91;").replace(/\]/g,"&#93;")},strip:function(c){return c.replace(oa,
"$6")},active:function(){return $.front()},from_ntroff:function(c){return c.replace(/((?:_\x08.|.\x08_)+)/g,function(e){return"[[u;;]"+e.replace(/_x08|\x08_|_\u0008|\u0008_/g,"")+"]"}).replace(/((?:.\x08.)+)/g,function(e){return"[[b;#fff;]"+e.replace(/(.)(?:\x08|\u0008)(.)/g,function(i,g,l){return l})+"]"})},ansi_colors:{normal:{black:"#000",red:"#A00",green:"#008400",yellow:"#A50",blue:"#00A",magenta:"#A0A",cyan:"#0AA",white:"#AAA"},faited:{black:"#000",red:"#640000",green:"#006100",yellow:"#737300",
blue:"#000087",magenta:"#650065",cyan:"#008787",white:"#818181"},bold:{black:"#000",red:"#F55",green:"#44D544",yellow:"#FF5",blue:"#55F",magenta:"#F5F",cyan:"#5FF",white:"#FFF"},palette:["#000000","#AA0000","#00AA00","#AA5500","#0000AA","#AA00AA","#00AAAA","#AAAAAA","#555555","#FF5555","#55FF55","#FFFF55","#5555FF","#FF55FF","#55FFFF","#FFFFFF","#000000","#00005F","#000087","#0000AF","#0000D7","#0000FF","#005F00","#005F5F","#005F87","#005FAF","#005FD7","#005FFF","#008700","#00875F","#008787","#0087AF",
"#0087D7","#00AF00","#00AF5F","#00AF87","#00AFAF","#00AFD7","#00AFFF","#00D700","#00D75F","#00D787","#00D7AF","#00D7D7","#00D7FF","#00FF00","#00FF5F","#00FF87","#00FFAF","#00FFD7","#00FFFF","#5F0000","#5F005F","#5F0087","#5F00AF","#5F00D7","#5F00FF","#5F5F00","#5F5F5F","#5F5F87","#5F5FAF","#5F5FD7","#5F5FFF","#5F8700","#5F875F","#5F8787","#5F87AF","#5F87D7","#5F87FF","#5FAF00","#5FAF5F","#5FAF87","#5FAFAF","#5FAFD7","#5FAFFF","#5FD700","#5FD75F","#5FD787","#5FD7AF","#5FD7D7","#5FD7FF","#5FFF00","#5FFF5F",
"#5FFF87","#5FFFAF","#5FFFD7","#5FFFFF","#870000","#87005F","#870087","#8700AF","#8700D7","#8700FF","#875F00","#875F5F","#875F87","#875FAF","#875FD7","#875FFF","#878700","#87875F","#878787","#8787AF","#8787D7","#8787FF","#87AF00","#87AF5F","#87AF87","#87AFAF","#87AFD7","#87AFFF","#87D700","#87D75F","#87D787","#87D7AF","#87D7D7","#87D7FF","#87FF00","#87FF5F","#87FF87","#87FFAF","#87FFD7","#87FFFF","#AF0000","#AF005F","#AF0087","#AF00AF","#AF00D7","#AF00FF","#AF5F00","#AF5F5F","#AF5F87","#AF5FAF","#AF5FD7",
"#AF5FFF","#AF8700","#AF875F","#AF8787","#AF87AF","#AF87D7","#AF87FF","#AFAF00","#AFAF5F","#AFAF87","#AFAFAF","#AFAFD7","#AFAFFF","#AFD700","#AFD75F","#AFD787","#AFD7AF","#AFD7D7","#AFD7FF","#AFFF00","#AFFF5F","#AFFF87","#AFFFAF","#AFFFD7","#AFFFFF","#D70000","#D7005F","#D70087","#D700AF","#D700D7","#D700FF","#D75F00","#D75F5F","#D75F87","#D75FAF","#D75FD7","#D75FFF","#D78700","#D7875F","#D78787","#D787AF","#D787D7","#D787FF","#D7AF00","#D7AF5F","#D7AF87","#D7AFAF","#D7AFD7","#D7AFFF","#D7D700","#D7D75F",
"#D7D787","#D7D7AF","#D7D7D7","#D7D7FF","#D7FF00","#D7FF5F","#D7FF87","#D7FFAF","#D7FFD7","#D7FFFF","#FF0000","#FF005F","#FF0087","#FF00AF","#FF00D7","#FF00FF","#FF5F00","#FF5F5F","#FF5F87","#FF5FAF","#FF5FD7","#FF5FFF","#FF8700","#FF875F","#FF8787","#FF87AF","#FF87D7","#FF87FF","#FFAF00","#FFAF5F","#FFAF87","#FFAFAF","#FFAFD7","#FFAFFF","#FFD700","#FFD75F","#FFD787","#FFD7AF","#FFD7D7","#FFD7FF","#FFFF00","#FFFF5F","#FFFF87","#FFFFAF","#FFFFD7","#FFFFFF","#080808","#121212","#1C1C1C","#262626","#303030",
"#3A3A3A","#444444","#4E4E4E","#585858","#626262","#6C6C6C","#767676","#808080","#8A8A8A","#949494","#9E9E9E","#A8A8A8","#B2B2B2","#BCBCBC","#C6C6C6","#D0D0D0","#DADADA","#E4E4E4","#EEEEEE"]},from_ansi:function(){var c={30:"black",31:"red",32:"green",33:"yellow",34:"blue",35:"magenta",36:"cyan",37:"white",39:"white"},e={40:"black",41:"red",42:"green",43:"yellow",44:"blue",45:"magenta",46:"cyan",47:"white",49:"black"};return function(i){var g=i.split(/(\x1B\[[0-9;]*[A-Za-z])/g);if(g.length==1)return i;
i=[];if(g.length>3&&g.slice(0,3).join("")=="[0m")g=g.slice(3);for(var l=false,o,A,k,x,B=0;B<g.length;++B)if(x=g[B].match(/^\x1B\[([0-9;]*)([A-Za-z])$/))switch(x[2]){case "m":if(x[1]==="")continue;if(x[1]!=="0"){var D=x[1].split(";"),v=void 0,y=k=false,E=false,G=[],H="",N="",n=false,r=false,L=false,S=d.terminal.ansi_colors.palette,ea=void 0;for(ea in D){v=parseInt(D[ea],10);switch(v){case 1:G.push("b");E=true;k=false;break;case 4:G.push("u");break;case 3:G.push("i");break;case 5:L=true;break;case 38:n=
true;break;case 48:r=true;break;case 2:k=true;E=false;break;case 7:y=true;break;default:if(n&&L&&S[v-1])H=S[v-1];else if(c[v])H=c[v];if(r&&L&&S[v-1])N=S[v-1];else if(e[v])N=e[v]}if(v!==5)L=false}if(y)if(H&&N){D=N;N=H;H=D}else{H="black";N="white"}D=void 0;v=void 0;D=E?v=d.terminal.ansi_colors.bold:k?v=d.terminal.ansi_colors.faited:v=d.terminal.ansi_colors.normal;k=[G.join(""),n?H:D[H],r?N:v[N]]}else k=["",""];if(l){i.push("]");if(x[1]=="0"){l=false;o=A=""}else{k[1]=k[1]||o;k[2]=k[2]||A;i.push("[["+
k.join(";")+"]");if(k[1])o=k[1];if(k[2])A=k[2]}}else{l=true;i.push("[["+k.join(";")+"]");if(k[1])o=k[1];if(k[2])A=k[2]}}else i.push(g[B]);l&&i.push("]");return i.join("")}}(),parseArguments:function(c){return d.map(c.match(ra)||[],function(e){if(e[0]==="'"&&e[e.length-1]==="'")return e.replace(/^'|'$/g,"");else if(e[0]==='"'&&e[e.length-1]==='"'){e=e.replace(/^"|"$/g,"").replace(/\\([" ])/g,"$1");return e.replace(/\\\\|\\t|\\n/g,function(i){return i[1]==="t"?"\t":i[1]==="n"?"\n":"\\"}).replace(/\\x([0-9a-f]+)/gi,
function(i,g){return String.fromCharCode(parseInt(g,16))}).replace(/\\0([0-7]+)/g,function(i,g){return String.fromCharCode(parseInt(g,8))})}else return e[0]==="/"&&e[e.length-1]=="/"?RegExp(e.replace(/^\/|\/$/g,"")):e.match(/^-?[0-9]+$/)?parseInt(e,10):e.match(/^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/)?parseFloat(e):e.replace(/\\ /g," ")})},splitArguments:function(c){return d.map(c.match(ra)||[],function(e){return e[0]==="'"&&e[e.length-1]==="'"?e.replace(/^'|'$/g,""):e[0]==='"'&&e[e.length-1]===
'"'?e.replace(/^"|"$/g,"").replace(/\\([" ])/g,"$1"):e[0]==="/"&&e[e.length-1]=="/"?e:e.replace(/\\ /g," ")})},parseCommand:function(c){return ka(c,d.terminal.parseArguments)},splitCommand:function(c){return ka(c,d.terminal.splitArguments)},test:function(){function c(x,B){e.echo(B+" &#91;"+(x?"[[b;#44D544;]PASS]":"[[b;#FF5555;]FAIL]")+"&#93;")}var e=d.terminal.active();if(!e){e=d("body").terminal(d.noop).css("margin",0);e.outerHeight();e.height();d(window).resize(function(){e.css("height",d(window).height()-
20)}).resize()}e.echo("Testing...");var i='name "foo bar" baz /^asd [x]/ str\\ str 10 1e10',g=d.terminal.splitCommand(i);c(g.name==="name"&&g.args[0]==="foo bar"&&g.args[1]==="baz"&&g.args[2]==="/^asd [x]/"&&g.args[3]==="str str"&&g.args[4]==="10"&&g.args[5]==="1e10","$.terminal.splitCommand");g=d.terminal.parseCommand(i);c(g.name==="name"&&g.args[0]==="foo bar"&&g.args[1]==="baz"&&d.type(g.args[2])==="regexp"&&g.args[2].source==="^asd [x]"&&g.args[3]==="str str"&&g.args[4]===10&&g.args[5]===1E10,
"$.terminal.parseCommand");c(d.terminal.from_ansi("\u001b[2;31;46mFoo\u001b[1;3;4;32;45mBar\u001b[0m\u001b[7mBaz")==="[[;#640000;#008787]Foo][[biu;#44D544;#F5F]Bar][[;#000;#AAA]Baz]","$.terminal.from_ansi");i="[[biugs;#fff;#000]Foo][[i;;;foo]Bar][[ous;;]Baz]";e.echo("$.terminal.format");c(d.terminal.format(i)==='<span style="font-weight:bold;text-decoration:underline line-through;font-style:italic;color:#fff;text-shadow:0 0 5px #fff;background-color:#000" data-text="Foo">Foo</span><span style="font-style:italic;" class="foo" data-text="Bar">Bar</span><span style="text-decoration:underline line-through overline;" data-text="Baz">Baz</span>',
"\tformatting");c(d.terminal.format("http://terminal.jcubic.pl/examples.php https://www.google.com/?q=jquery%20terminal")==='<a target="_blank" href="http://terminal.jcubic.pl/examples.php">http://terminal.jcubic.pl/examples.php</a> <a target="_blank" href="https://www.google.com/?q=jquery%20terminal">https://www.google.com/?q=jquery%20terminal</a>',"\turls");c(d.terminal.format("foo@bar.com baz.quux@example.com")==='<a href="mailto:foo@bar.com">foo@bar.com</a> <a href="mailto:baz.quux@example.com">baz.quux@example.com</a>',
"\temails");c(d.terminal.strip("-_-[[biugs;#fff;#000]Foo]-_-[[i;;;foo]Bar]-_-[[ous;;]Baz]-_-")==="-_-Foo-_-Bar-_-Baz-_-","$.terminal.strip");i="[[bui;#fff;]Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sed dolor nisl, in suscipit justo. Donec a enim et est porttitor semper at vitae augue. Proin at nulla at dui mattis mattis. Nam a volutpat ante. Aliquam consequat dui eu sem convallis ullamcorper. Nulla suscipit, massa vitae suscipit ornare, tellus] est [[b;;#f00]consequat nunc, quis blandit elit odio eu arcu. Nam a urna nec nisl varius sodales. Mauris iaculis tincidunt orci id commodo. Aliquam] non magna quis [[i;;]tortor malesuada aliquam] eget ut lacus. Nam ut vestibulum est. Praesent volutpat tellus in eros dapibus elementum. Nam laoreet risus non nulla mollis ac luctus [[ub;#fff;]felis dapibus. Pellentesque mattis elementum augue non sollicitudin. Nullam lobortis fermentum elit ac mollis. Nam ac varius risus. Cras faucibus euismod nulla, ac auctor diam rutrum sit amet. Nulla vel odio erat], ac mattis enim.";
e.echo("$.terminal.split_equal");g=[10,40,60,400];for(var l=g.length;l--;){for(var o=d.terminal.split_equal(i,g[l]),A=true,k=0;k<o.length;++k)if(d.terminal.strip(o[k]).length>g[l]){A=false;break}c(A,"\tsplit "+g[l])}}};d.fn.visible=function(){return this.css("visibility","visible")};d.fn.hidden=function(){return this.css("visibility","hidden")};var Ga=0;d.jrpc=function(c,e,i,g,l){e=d.json_stringify({jsonrpc:"2.0",method:e,params:i,id:++Ga});return d.ajax({url:c,data:e,success:g,error:l,contentType:"application/json",
dataType:"json",async:true,cache:false,type:"POST"})};var ia=(da=!"0.7.12".match(/^\{\{/))?" version 0.7.12":" ",ua=RegExp(" {"+ia.length+"}$"),Ha=[["jQuery Terminal","(c) 2011-2013 jcubic"],["jQuery Terminal Emulator"+(da?" v. 0.7.12":""),"Copyright (c) 2011-2013 Jakub Jankiewicz <http://jcubic.pl>".replace(/ *<.*>/,"")],["jQuery Terminal Emulator"+(da?ia:""),"Copyright (c) 2011-2013 Jakub Jankiewicz <http://jcubic.pl>".replace(/^Copyright /,"")],["      _______                 ________                        __",
"     / / _  /_ ____________ _/__  ___/______________  _____  / /"," __ / / // / // / _  / _/ // / / / _  / _/     / /  \\/ / _ \\/ /","/  / / // / // / ___/ // // / / / ___/ // / / / / /\\  / // / /__","\\___/____ \\\\__/____/_/ \\__ / /_/____/_//_/ /_/ /_/  \\/\\__\\_\\___/","         \\/          /____/                                   ".replace(ua," ")+ia,"Copyright (c) 2011-2013 Jakub Jankiewicz <http://jcubic.pl>"],["      __ _____                     ________                              __",
"     / // _  /__ __ _____ ___ __ _/__  ___/__ ___ ______ __ __  __ ___  / /"," __ / // // // // // _  // _// // / / // _  // _//     // //  \\/ // _ \\/ /","/  / // // // // // ___// / / // / / // ___// / / / / // // /\\  // // / /__","\\___//____ \\\\___//____//_/ _\\_  / /_//____//_/ /_/ /_//_//_/ /_/ \\__\\_\\___/","          \\/              /____/                                          ".replace(ua,"")+ia,"Copyright (c) 2011-2013 Jakub Jankiewicz <http://jcubic.pl>"]];d.terminal.defaults=
{prompt:"> ",history:true,exit:true,clear:true,enabled:true,historySize:60,checkArity:true,displayExceptions:true,cancelableAjax:true,processArguments:true,linksNoReferrer:false,login:null,outputLimit:-1,tabcompletion:null,historyFilter:null,onInit:d.noop,onClear:d.noop,onBlur:d.noop,onFocus:d.noop,onTerminalChange:d.noop,onExit:d.noop,keypress:d.noop,keydown:d.noop};var fa=[],$=new function(c){var e=c?[c]:[],i=0;d.extend(this,{get:function(){return e},rotate:function(){if(e.length===1)return e[0];
else{if(i===e.length-1)i=0;else++i;return e[i]}},length:function(){return e.length},set:function(g){for(var l=e.length;l--;)if(e[l]===g){i=l;return}this.append(g)},front:function(){return e[i]},append:function(g){e.push(g)}})};d.fn.terminal=function(c,e){function i(a){return typeof m.processArguments==="function"?ka(a,m.processArguments):m.processArguments?d.terminal.parseCommand(a):d.terminal.splitCommand(a)}function g(a){if(typeof a==="string")b.echo(a);else if(a instanceof Array)b.echo(d.map(a,
function(h){return d.json_stringify(h)}).join(" "));else typeof a==="object"?b.echo(d.json_stringify(a)):b.echo(a)}function l(a){var h=function(j,p){b.pause();d.jrpc(a,j,p,function(q){q.error?b.error("&#91;RPC&#93; "+q.error.message):g(q.result);b.resume()},function(q,w){w!=="abort"&&b.error("&#91;AJAX&#93; "+w+" - Server reponse is: \n"+q.responseText);b.resume()})};return function(j,p){if(j!==""){j=i(j);if(!m.login||j.name==="help")h(j.name,j.args);else{var q=p.token();q?h(j.name,[q].concat(j.args)):
p.error("&#91;AUTH&#93; Access denied (no token)")}}}}function o(a,h){return function(j,p){if(j!==""){j=i(j);var q=a[j.name],w=d.type(q);if(w==="function")if(h&&q.length!==j.args.length)b.error("&#91;Arity&#93; wrong number of arguments. Function '"+j.name+"' expect "+q.length+" got "+j.args.length);else return q.apply(b,j.args);else if(w==="object"||w==="string"){var T=[];if(w==="object"){for(var U in q)q.hasOwnProperty(U)&&T.push(U);q=o(q,h)}p.push(q,{prompt:j.name+"> ",name:j.name,completion:w===
"object"?function(P,aa,V){V(T)}:R})}else p.error("Command '"+j.name+"' Not Found")}}}function A(a,h){h=h||d.noop;var j=d.type(a),p={};if(j==="string"){b.pause();d.jrpc(a,"system.describe",[],function(T){var U=[];if(T.procs){var P={};d.each(T.procs,function(aa,V){U.push(V.name);P[V.name]=function(){var ca=Array.prototype.slice.call(arguments);if(m.checkArity&&V.params&&V.params.length!==ca.length)b.error("&#91;Arity&#93; wrong number of arguments.Function '"+V.name+"' expect "+V.params.length+" got "+
ca.length);else{b.pause();d.jrpc(a,V.name,ca,function(ga){ga.error?b.error("&#91;RPC&#93; "+ga.error.message):g(ga.result);b.resume()},function(ga,va){va!=="abort"&&b.error("&#91;AJAX&#93; "+va+" - Server reponse is: \n"+ga.responseText);b.resume()})}}});p.interpreter=o(P,false);p.completion=function(aa,V,ca){ca(U)}}else{p.interpreter=l(a);p.completion=m.completion}b.resume();h(p)},function(){p.completion=m.completion;p.interpreter=l(a);h(p)})}else if(j==="object"){var q=[],w;for(w in a)q.push(w);
p.interpreter=o(a,true);p.completion=function(T,U,P){P(q)};h(p)}else{if(j==="undefined")a=d.noop;else if(j!=="function")throw j+" is invalid interpreter value";h({interpreter:a,completion:m.completion})}}function k(a){return typeof a==="string"?a:typeof a.fileName==="string"?a.fileName+": "+a.message:a.message}function x(a,h){if(m.displayExceptions){var j=k(a);b.error("&#91;"+h+"&#93;: "+j);if(typeof a.fileName==="string"){b.pause();d.get(a.fileName,function(p){b.resume();var q=a.lineNumber-1;(p=
p.split("\n")[q])&&b.error("&#91;"+a.lineNumber+"&#93;: "+p)})}a.stack&&b.error(a.stack)}}function B(){var a=Q.prop?Q.prop("scrollHeight"):Q.attr("scrollHeight");Q.scrollTop(a)}function D(a,h){try{if(typeof h==="function")h(function(){});else if(typeof h!=="string")throw a+" must be string or function";}catch(j){x(j,a.toUpperCase());return false}return true}function v(a,h){try{var j=d.extend({raw:false,finalize:d.noop},h||{});a=d.type(a)==="function"?a():a;a=d.type(a)==="string"?a:String(a);var p,
q;j.raw||(a=d.terminal.encode(a));a=d.terminal.from_ntroff(a);a=d.terminal.from_ansi(a);O.push(M);if(!j.raw&&(a.length>I||a.match(/\n/))){var w=d.terminal.split_equal(a,I);p=0;for(q=w.length;p<q;++p)if(w[p]===""||w[p]==="\r")O.push("&nbsp");else j.raw?O.push(w[p]):O.push(d.terminal.format(w[p],{linksNoReferer:m.linksNoReferer}))}else{j.raw||(a=d.terminal.format(a,{linksNoReferer:m.linksNoReferer}));O.push(a)}O.push(j.finalize)}catch(T){O=[];alert("Internal Exception(draw_line):"+k(T)+"\n"+T.stack)}}
function y(){try{var a;if(m.outputLimit>=0){var h=b.rows(),j=m.outputLimit===0?h:m.outputLimit;h=0;for(var p,q=d("<div/>"),w=O.length;w--;)if(typeof O[w]==="function"){p=O[w];a=d("<div/>")}else if(O[w]===M){a.prependTo(q);try{p(a)}catch(T){x(T,"USER:echo(finalize)")}}else{a.prepend("<div>"+O[w]+"</div>");if(++h===j){if(O[w-1]!==M)try{p(a)}catch(U){x(U,"USER:echo(finalize)")}break}}q.children().appendTo(f)}else d.each(O,function(aa,V){if(V===M)a=d("<div></div>");else if(typeof V==="function"){a.appendTo(f);
try{V(a)}catch(ca){x(ca,"USER:echo(finalize)")}}else d("<div/>").html(V).appendTo(a).width("100%")});B();O=[]}catch(P){alert("flush "+k(P)+"\n"+P.stack)}}function E(){if(m.greetings===R)b.echo(b.signature);else m.greetings&&b.echo(m.greetings)}function G(a){a=d.terminal.escape_brackets(d.terminal.encode(a,true));var h=u.prompt();if(u.mask())a=a.replace(/./g,"*");typeof h==="function"?h(function(j){b.echo(j+a)}):b.echo(h+a)}function H(a,h){try{Z=a;var j=s.top();if(a==="exit"&&m.exit)if(s.size()===
1)if(m.login)n();else{h||G(a);b.echo("You can't exit from main interpeter")}else b.pop("exit");else{h||G(a);var p=K.length-1;if(a==="clear"&&m.clear)b.clear();else{var q=j.interpreter(a,b);if(q!==R){if(p===K.length-1){K.pop();q!==false&&b.echo(q)}else K=q===false?K.slice(0,p).concat(K.slice(p+1)):K.slice(0,p).concat([q]).concat(K.slice(p+1));b.resize()}}}}catch(w){x(w,"USER");b.resume();throw w;}}function N(){var a=null;u.prompt("login: ");m.history&&u.history().disable();u.commands(function(h){try{G(h);
if(a){u.mask(false);b.pause();if(typeof m.login!=="function")throw"Value of login property must be a function";m.login(a,h,function(p){if(p){var q=m.name;q=(q?q+"_":"")+t+"_";d.Storage.set(q+"token",p);d.Storage.set(q+"login",a);u.commands(H);S()}else{b.error("Wrong password try again");u.prompt("login: ");a=null}b.resume()},b)}else{a=h;u.prompt("password: ");u.mask(true)}}catch(j){x(j,"LOGIN",b);throw j;}})}function n(){if(typeof m.onBeforelogout==="function")try{if(m.onBeforelogout(b)===false)return}catch(a){x(a,
"onBeforelogout");throw a;}var h=(m.name?m.name+"_":"")+t+"_";d.Storage.remove(h+"token");d.Storage.remove(h+"login");m.history&&u.history().disable();N();if(typeof m.onAfterlogout==="function")try{m.onAfterlogout(b)}catch(j){x(j,"onAfterlogout");throw j;}}function r(a){var h=(m.name?m.name+"_":"")+t+"_interpreters",j=d.Storage.get(h);j=j?(new Function("return "+j+";"))():[];if(d.inArray(a,j)==-1){j.push(a);d.Storage.set(h,d.json_stringify(j))}}function L(){var a=s.top(),h=(m.name?m.name+"_":"")+
t+(J.length?"_"+J.join("_"):"");r(h);u.name(h);typeof a.prompt=="function"?u.prompt(function(j){a.prompt(j,b)}):u.prompt(a.prompt);u.set("");if(typeof a.onStart==="function")a.onStart(b)}function S(){L();m.history&&u.history().enable();E();if(typeof m.onInit==="function")try{m.onInit(b)}catch(a){x(a,"OnInit");throw a;}}function ea(a){var h,j;h=s.top();if(d.type(h.keydown)==="function"){h=h.keydown(a,b);if(h!==R)return h}b.oneTime(10,function(){C()});if(d.type(m.keydown)==="function"){h=m.keydown(a,
b);if(h!==R)return h}if(b.paused()){if(a.which===68&&a.ctrlKey){if(fa.length){for(j=fa.length;j--;){a=fa[j];if(4!==a.readyState)try{a.abort()}catch(p){b.error("error in aborting ajax")}}fa=[];b.resume()}return false}}else{if(a.which!==9)ba=0;if(a.which===68&&a.ctrlKey){if(u.get()==="")if(s.size()>1||m.login!==R)b.pop("");else{b.resume();b.echo("")}else b.set_command("");return false}else if(m.tabcompletion&&a.which===9){++ba;var q=u.get().substring(0,u.position());a=q.split(" ");var w;if(a.length==
1)w=a[0];else{w=a[a.length-1];for(j=a.length-1;j>0;j--)if(a[j-1][a[j-1].length-1]=="\\")w=a[j-1]+" "+w;else break}var T=RegExp("^"+ma(w));s.top().completion(b,w,function(U){if(u.get().substring(0,u.position())===q){var P=[];for(j=U.length;j--;)T.test(U[j])&&P.push(U[j]);if(P.length===1)b.insert(P[0].replace(T,""));else if(P.length>1)if(ba>=2){G(q);b.echo(P.join("\t"));ba=0}else{U=false;var aa=w.length;a:for(;aa<P[0].length;++aa){for(j=1;j<P.length;++j)if(P[0].charAt(aa)!==P[j].charAt(aa))break a;
U=true}U&&b.insert(P[0].slice(0,aa).replace(T,""))}}});return false}else if(a.which===86&&a.ctrlKey)b.oneTime(1,function(){B()});else if(a.which===9&&a.ctrlKey){if($.length()>1){b.focus(false);return false}}else if(a.which===34)b.scroll(b.height());else a.which===33?b.scroll(-b.height()):b.attr({scrollTop:b.attr("scrollHeight")})}}var O=[],M=1,b=this;if(this.length>1)return this.each(function(){d.fn.terminal.call(d(this),c,d.extend({name:b.selector},e))});else{if(b.data("terminal"))return b.data("terminal");
if(b.length===0)throw'Sorry, but terminal said that "'+b.selector+'" is not valid selector!';var J=[],Q,Z,ba=0,K=[],f,t=$.length(),I,W,Y,X=[],m=d.extend({},d.terminal.defaults,{name:b.selector},e||{}),z=!m.enabled;d.extend(b,d.omap({clear:function(){f.html("");u.set("");K=[];try{m.onClear(b)}catch(a){x(a,"onClear");throw a;}b.attr({scrollTop:0});return b},export_view:function(){return{prompt:b.get_prompt(),command:b.get_command(),position:u.position(),lines:K.slice(0)}},import_view:function(a){b.set_prompt(a.prompt);
b.set_command(a.command);u.position(a.position);K=a.lines;b.resize();return b},exec:function(a,h){z?X.push([a,h]):H(a,h);return b},commands:function(){return s.top().interpreter},greetings:function(){E();return b},paused:function(){return z},pause:function(){if(u){z=true;b.disable();u.hidden()}return b},resume:function(){if(u){b.enable();var a=X;for(X=[];a.length;){var h=a.shift();b.exec.apply(b,h)}u.visible();B()}return b},cols:function(){return I},rows:function(){var a=d('<div class="terminal"><span>&nbsp;</span></div>').appendTo("body"),
h=Math.floor(b.height()/a.height());a.remove();return h},history:function(){return u.history()},next:function(){if($.length()===1)return b;else{var a=b.offset().top;b.height();b.scrollTop();var h=b,j=d(window).scrollTop(),p=j+d(window).height(),q=d(h).offset().top;if(q+d(h).height()>=j&&q<=p){$.front().disable();a=$.rotate().enable();h=a.offset().top-50;d("html,body").animate({scrollTop:h},500);try{m.onTerminalChange(a)}catch(w){x(w,"onTerminalChange");throw w;}return a}else{b.enable();d("html,body").animate({scrollTop:a-
50},500);return b}}},focus:function(a,h){b.oneTime(1,function(){if($.length()===1)if(a===false)try{!h&&m.onBlur(b)!==false&&b.disable()}catch(j){x(j,"onBlur");throw j;}else try{!h&&m.onFocus(b)!==false&&b.enable()}catch(p){x(p,"onFocus");throw p;}else if(a===false)b.next();else{var q=$.front();if(q!=b){q.disable();if(!h)try{m.onTerminalChange(b)}catch(w){x(w,"onTerminalChange");throw w;}}$.set(b);b.enable()}});return b},enable:function(){I===R&&b.resize();if(z)if(u){u.enable();z=false}return b},disable:function(){if(u){z=
true;u.disable()}return b},enabled:function(){return z},signature:function(){var a=b.cols();a=a<15?null:a<35?0:a<55?1:a<64?2:a<75?3:4;return a!==null?Ha[a].join("\n")+"\n":""},version:function(){return"0.7.12"},get_command:function(){return u.get()},insert:function(a){if(typeof a==="string"){u.insert(a);return b}else throw"insert function argument is not a string";},set_prompt:function(a){if(D("prompt",a)){typeof a=="function"?u.prompt(function(h){a(h,b)}):u.prompt(a);s.top().prompt=a}return b},get_prompt:function(){return s.top().prompt},
set_command:function(a){u.set(a);return b},set_mask:function(a){u.mask(a);return b},get_output:function(a){return a?K:d.map(K,function(h){return typeof h[0]=="function"?h[0]():h[0]}).join("\n")},resize:function(a,h){if(a&&h){b.width(a);b.height(h)}a=b.width();h=b.height();var j=na(b);if(j!==I){I=j;u.resize(I);j=f.empty().detach();d.each(K,function(p,q){v.apply(null,q)});u.before(j);y();if(typeof m.onResize==="function"&&(Y!==h||W!==a))m.onResize(b);if(Y!==h||W!==a){Y=h;W=a}}return b},flush:function(){y()},
echo:function(a,h){try{a=a||"";var j=d.extend({flush:true,raw:false,finalize:d.noop},h||{});O=[];v(a,j);j.flush&&y();K.push([a,j]);if(j.outputLimit>=0){var p=j.outputLimit===0?b.rows():j.outputLimit,q=f.find("div div");q.length>p&&q.slice(0,K.length-p+1).remove()}C()}catch(w){alert("terminal.echo "+k(w)+"\n"+w.stack)}return b},error:function(a,h){return b.echo("[[;#f00;]"+d.terminal.escape_brackets(a).replace(/\\$/,"&#92;")+"]",h)},scroll:function(a){var h;a=Math.round(a);if(Q.prop){a>Q.prop("scrollTop")&&
a>0&&Q.prop("scrollTop",0);h=Q.prop("scrollTop")}else{a>Q.attr("scrollTop")&&a>0&&Q.attr("scrollTop",0);h=Q.attr("scrollTop")}Q.scrollTop(h+a);return b},logout:m.login?function(){for(;s.size()>1;)s.pop();n();return b}:function(){throw"You don't have login function";},token:m.login?function(){var a=m.name;return d.Storage.get((a?a+"_":"")+t+"_token")}:d.noop,login_name:m.login?function(){var a=m.name;return d.Storage.get((a?a+"_":"")+t+"_login")}:d.noop,name:function(){return s.top().name},push:function(a,
h){if(h&&(!h.prompt||D("prompt",h.prompt))||!h){h=h||{};h.name=h.name||Z;h.prompt=h.prompt||h.name+" ";J.push(h.name);var j=s.top();if(j)j.mask=u.mask();A(a,function(p){s.push(d.extend({},p,h));L()})}return b},pop:function(a){a!==R&&G(a);J.pop();if(s.top().name===m.name){if(m.login){n();if(d.type(m.onExit)==="function")try{m.onExit(b)}catch(h){x(h,"onExit");throw h;}}}else{a=s.pop();L();if(d.type(a.onExit)==="function")try{a.onExit(b)}catch(j){x(j,"onExit");throw j;}b.set_mask(s.top().mask)}return b},
level:function(){return s.size()},reset:function(){for(b.clear();s.size()>1;)s.pop();S();return b},purge:function(){var a=(m.name?m.name+"_":"")+t+"_",h=d.Storage.get(a+"interpreters");d.each((new Function("return "+h+";"))(),function(j,p){d.Storage.remove(p+"_commands")});d.Storage.remove(a+"interpreters");d.Storage.remove(a+"token");d.Storage.remove(a+"login");return b},destroy:function(){u.destroy().remove();f.remove();d(document).unbind(".terminal");d(window).unbind(".terminal");b.unbind("click, mousewheel");
b.removeData("terminal").removeClass("terminal");m.width&&b.css("width","");m.height&&b.css("height","");return b}},function(a,h){return function(){try{return h.apply(this,Array.prototype.slice.apply(arguments))}catch(j){a!=="exec"&&x(j,"TERMINAL");throw j;}}}));var C=function(){var a=ha(b);return function(){if(a!==ha(b)){b.resize();a=ha(b)}}}();m.width&&b.width(m.width);m.height&&b.height(m.height);Q=!navigator.userAgent.toLowerCase().match(/(webkit)[ \/]([\w.]+)/)&&b[0].tagName.toLowerCase()=="body"?
d("html"):b;d(document).bind("ajaxSend.terminal",function(a,h){fa.push(h)});f=d("<div>").addClass("terminal-output").appendTo(b);b.addClass("terminal");if("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch){b.click(function(){b.find("textarea").focus()});b.find("textarea").focus()}if(m.login&&typeof m.onBeforeLogin==="function")try{m.onBeforeLogin(b)}catch(F){x(F,"onBeforeLogin");throw F;}if(typeof c==="string"&&(typeof m.login==="string"||m.login))m.login=function(a){return function(h,
j,p){b.pause();d.jrpc(c,a,[h,j],function(q){b.resume();!q.error&&q.result?p(q.result):p(null)},function(q,w){b.resume();b.error("&#91;AJAX&#92; Response: "+w+"\n"+q.responseText)})}}(d.type(m.login)==="boolean"?"login":m.login);$.append(b);if(D("prompt",m.prompt)){var s,u;A(c,function(a){s=new Ba(d.extend({name:m.name,prompt:m.prompt,greetings:m.greetings},a));u=d("<div/>").appendTo(b).cmd({prompt:m.prompt,history:m.history,historyFilter:m.historyFilter,historySize:m.historySize,width:"100%",keydown:ea,
keypress:m.keypress?function(h){return m.keypress(h,b)}:null,onCommandChange:function(h){if(d.type(m.onCommandChange)==="function")try{m.onCommandChange(h,b)}catch(j){x(j,"onCommandChange");throw j;}B()},commands:H});m.enabled===true?b.focus(R,true):b.disable();d(document).bind("click.terminal",function(h){!d(h.target).parents().hasClass("terminal")&&m.onBlur(b)!==false&&b.disable()});b.click(function(){b.focus()});m.login&&b.token&&!b.token()&&b.login_name&&!b.login_name()?N():S();if(b.is(":visible")){I=
na(b);u.resize(I)}b.oneTime(100,function(){d(window).bind("resize.terminal",function(){if(b.is(":visible")){var h=b.width(),j=b.height();if(Y!==j||W!==h)b.resize()}})});d.type(d.fn.init.prototype.mousewheel)==="function"&&b.mousewheel(function(h,j){j>0?b.scroll(-40):b.scroll(40);return false},true)})}b.data("terminal",b);return b}}})(jQuery);
