").addClass("terminal-output").appendTo(ha),ha.addClass("terminal"),xa.login&&a.isFunction(xa.onBeforeLogin))try{xa.onBeforeLogin(ha)===!1&&(Ca=!1)}catch(Fa){throw w(Fa,"onBeforeLogin"),Fa}var Ga;xa.login;if("string"==typeof c)Ga=c;else if(c instanceof Array)for(var Ha=0,Ia=c.length;Ia>Ha;++Ha)if("string"==typeof c[Ha]){Ga=c[Ha];break}!Ga||"string"!=typeof xa.login&&xa.login!==!0||(xa.login=t(Ga,xa.login)),Z.append(ha);var Ja,Ka,La;return o(c,!!xa.login,function(c){function d(b){var c=Z.get()[b[0]];if(c&&ra==c.id()&&b[2])try{if(Ba){var d=a.Deferred();return ga.push(function(){return c.exec(b[2]).then(function(a,e){c.save_state(b[2],!0,b[1]),d.resolve()})}),d.promise()}return c.exec(b[2]).then(function(a,d){c.save_state(b[2],!0,b[1])})}catch(e){var f=a.terminal.escape_brackets(command),g="Error while exec with command "+f;c.error(g).exception(e)}}(xa.completion&&"boolean"!=typeof xa.completion||!xa.completion)&&(c.completion="settings"),Ja=new k(a.extend({name:xa.name,prompt:xa.prompt,keypress:xa.keypress,keydown:xa.keydown,resize:xa.onResize,greetings:xa.greetings,mousewheel:xa.mousewheel},c)),Ka=a("
").appendTo(ha).cmd({prompt:xa.prompt,history:xa.history,historyFilter:xa.historyFilter,historySize:xa.historySize,width:"100%",enabled:za&&!B,keydown:T,keypress:function(b){var c=Ja.top();return a.isFunction(c.keypress)?c.keypress(b,ha):a.isFunction(xa.keypress)?xa.keypress(b,ha):void 0},onCommandChange:function(b){if(a.isFunction(xa.onCommandChange))try{xa.onCommandChange(b,ha)}catch(c){throw w(c,"onCommandChange"),c}x()},commands:H}),za&&ha.is(":visible")&&!B?ha.focus(b,!0):ha.disable(),ha.oneTime(100,function(){function b(b){var c=a(b.target);!c.closest(".terminal").length&&ha.enabled()&&xa.onBlur(ha)!==!1&&ha.disable()}a(document).bind("click.terminal",b).bind("contextmenu.terminal",b)});var e=a(window);if(B||e.on("focus",U).on("blur",V),B?ha.click(function(){ha.enabled()||Aa?ha.focus(!1):(ha.focus(),Ka.enable())}):!function(){var b=0,c=!1;ha.mousedown(function(){a(window).mousemove(function(){c=!0,b=0,a(window).unbind("mousemove")})}).mouseup(function(){var d=c;c=!1,a(window).unbind("mousemove"),d||1!=++b||(b=0,ha.enabled()||Aa||(ha.focus(),Ka.enable()))})}(),ha.delegate(".exception a","click",function(b){var c=a(this).attr("href");c.match(/:[0-9]+$/)&&(b.preventDefault(),g(c))}),navigator.platform.match(/linux/i)||ha.mousedown(function(a){if(2==a.which){var b=r();ha.insert(b)}}),ha.is(":visible")&&(la=ha.cols(),Ka.resize(la),ma=q(ha)),xa.login?ha.login(xa.login,!0,Q):Q(),ha.oneTime(100,function(){e.bind("resize.terminal",function(){if(ha.is(":visible")){var a=ha.width(),b=ha.height();(oa!==b||na!==a)&&ha.resize()}})}),xa.execHash&&location.hash?setTimeout(function(){try{var b=location.hash.replace(/^#/,"");X=a.parseJSON(decodeURIComponent(b));var c=0;!function f(){var a=X[c++];a?d(a).then(f):_=!0}()}catch(e){}}):_=!0,a.event.special.mousewheel){var f=!1;a(document).bind("keydown.terminal",function(a){a.shiftKey&&(f=!0)}).bind("keyup.terminal",function(a){(a.shiftKey||16==a.which)&&(f=!1)}),ha.mousewheel(function(b,c){if(!f){var d=Ja.top();if(a.isFunction(d.mousewheel)){var e=d.mousewheel(b,c,ha);if(e===!1)return}else a.isFunction(xa.mousewheel)&&xa.mousewheel(b,c,ha);c>0?ha.scroll(-40):ha.scroll(40)}})}ta.resolve()}),ha.data("terminal",ha),ha}}(jQuery),function(a){a(document).ready(function(){function b(b){b&&("string"==typeof b?s.echo(b):b instanceof Array?s.echo(a.map(b,function(b){return a.json_stringify(b)}).join(" ")):"object"==typeof b?s.echo(a.json_stringify(b)):s.echo(b))}function c(){var a=m.path;return a&&a.length>l.prompt_path_length&&(a="..."+a.slice(a.length-l.prompt_path_length+3)),"[[b;#d33682;]"+(m.user||"user")+"]@[[b;#6c71c4;]"+(m.hostname||l.domain||"web-console")+"] "+(a||"~")+"$ "}function d(a){a.set_prompt(c())}function e(b,c){c&&(a.extend(m,c),d(b))}function f(b,c,d,e,f,g){g=a.extend({pause:!0},g),g.pause&&b.pause(),a.jrpc(l.url,c,d,function(c){if(g.pause&&b.resume(),c.error)if(f)f();else{var d=a.trim(c.error.message||""),h=a.trim(c.error.data||"");!d&&h&&(d=h,h=""),b.error("[ERROR] RPC: "+(d||"Unknown error")+(h?" ("+h+")":""))}else e&&e(c.result)},function(c,d,e){if(g.pause&&b.resume(),f)f();else if("abort"!==d){var h=a.trim(c.responseText||"");b.error("[ERROR] AJAX: "+(d||"Unknown error")+(h?"\nServer reponse:\n"+h:""))}})}function g(a,b,c,d,e,g){var h=a.token();if(h){var i=[h,m];c&&c.length&&i.push.apply(i,c),f(a,b,i,d,e,g)}else a.error("[ERROR] Access denied (no authentication token found)")}function h(c,d){if(c=a.trim(c||"")){var f=a.terminal.splitCommand(c),h=null,i=[];"cd"===f.name.toLowerCase()?(h="cd",i=[f.args.length?f.args[0]:""]):(h="run",i=[c]),h&&g(d,h,i,function(a){e(d,a.environment),b(a.output)})}}function i(c,d,g){c=a.trim(c||""),d=a.trim(d||""),c&&d?f(s,"login",[c,d],function(a){a&&a.token?(m.user=c,e(s,a.environment),b(a.output),g(a.token)):g(null)},function(){g(null)}):g(null)}function j(a,c,d){var e=a.export_view(),f=e.command.substring(0,e.position);g(a,"completion",[c,f],function(a){b(a.output),a.completion&&a.completion.length&&(a.completion.reverse(),d(a.completion))},null,{pause:!1})}function k(){o=!0;try{s.clear(),s.logout()}catch(a){}o=!1}var l={url:"",prompt_path_length:32,domain:document.domain||window.location.host,is_small_window:a(document).width()<625?!0:!1},m={user:"",hostname:"",path:""},n="undefined"!=typeof ?:!1,o=!1,p="Web Console",q="http://web-console.org",r=q+"\n";l.is_small_window||(p=" _ _ _ _____ _ \n | | | | | | / __ \\ | | \n | | | | ___| |__ | / \\/ ___ _ __ ___ ___ | | ___ \n | |/\\| |/ _ \\ '_ \\| | / _ \\| '_ \\/ __|/ _ \\| |/ _ \\ \n \\ /\\ / __/ |_) | \\__/\\ (_) | | | \\__ \\ (_) | | __/ \n \\/ \\/ \\___|____/ \\____/\\___/|_| |_|___/\\___/|_|\\___| ",r="\n "+q+"\n");var s=a("body").terminal(h,{login:n?!1:i,prompt:c(),greetings:n?"":"You are authenticated",tabcompletion:!0,completion:j,onBlur:function(){return!1},exceptionHandler:function(a){o||s.exception(a)}});n?s.set_token("NO_LOGIN"):(k(),a(window).unload(function(){k()})),p&&s.echo(p),r&&s.echo(r)})}(jQuery);