misc_pterodactyl-panel/public/js/jquery.terminal-0.11.6.min.js

37 lines
63 KiB
JavaScript
Raw Normal View History

2016-09-16 19:48:17 +00:00
/**@license
* __ _____ ________ __
* / // _ /__ __ _____ ___ __ _/__ ___/__ ___ ______ __ __ __ ___ / /
* __ / // // // // // _ // _// // / / // _ // _// // // \/ // _ \/ /
* / / // // // // // ___// / / // / / // ___// / / / / // // /\ // // / /__
* \___//____ \\___//____//_/ _\_ / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/
* \/ /____/ version 0.11.6
*
* This file is part of jQuery Terminal. http://terminal.jcubic.pl
*
* Copyright (c) 2010-2016 Jakub Jankiewicz <http://jcubic.pl>
* Released under the MIT license
*
* Contains:
*
* Storage plugin Distributed under the MIT License
* Copyright (c) 2010 Dave Schindler
*
* jQuery Timers licenced with the WTFPL
* <http://jquery.offput.ca/timers/>
*
* Cross-Browser Split 1.1.1
* Copyright 2007-2012 Steven Levithan <stevenlevithan.com>
* Available under the MIT License
*
* jQuery Caret
* Copyright (c) 2009, Gideon Sireling
* 3 clause BSD License
*
* sprintf.js
* Copyright (c) 2007-2013 Alexandru Marasteanu <hello at alexei dot ro>
* licensed under 3 clause BSD license
*
* Date: Thu, 15 Sep 2016 20:19:15 +0000
*/
(function(e){var n=function(){if(!n.cache.hasOwnProperty(arguments[0])){n.cache[arguments[0]]=n.parse(arguments[0])}return n.format.call(null,n.cache[arguments[0]],arguments)};n.format=function(e,r){var o=1,a=e.length,s="",l,f=[],c,u,h,p,m,g;for(c=0;c<a;c++){s=t(e[c]);if(s==="string"){f.push(e[c])}else if(s==="array"){h=e[c];if(h[2]){l=r[o];for(u=0;u<h[2].length;u++){if(!l.hasOwnProperty(h[2][u])){throw n('[sprintf] property "%s" does not exist',h[2][u])}l=l[h[2][u]]}}else if(h[1]){l=r[h[1]]}else{l=r[o++]}if(/[^s]/.test(h[8])&&t(l)!="number"){throw n("[sprintf] expecting number but found %s",t(l))}switch(h[8]){case"b":l=l.toString(2);break;case"c":l=String.fromCharCode(l);break;case"d":l=parseInt(l,10);break;case"e":l=h[7]?l.toExponential(h[7]):l.toExponential();break;case"f":l=h[7]?parseFloat(l).toFixed(h[7]):parseFloat(l);break;case"o":l=l.toString(8);break;case"s":l=(l=String(l))&&h[7]?l.substring(0,h[7]):l;break;case"u":l=l>>>0;break;case"x":l=l.toString(16);break;case"X":l=l.toString(16).toUpperCase();break}l=/[def]/.test(h[8])&&h[3]&&l>=0?"+"+l:l;m=h[4]?h[4]=="0"?"0":h[4].charAt(1):" ";g=h[6]-String(l).length;p=h[6]?i(m,g):"";f.push(h[5]?l+p:p+l)}}return f.join("")};n.cache={};n.parse=function(e){var n=e,r=[],t=[],i=0;while(n){if((r=/^[^\x25]+/.exec(n))!==null){t.push(r[0])}else if((r=/^\x25{2}/.exec(n))!==null){t.push("%")}else if((r=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(n))!==null){if(r[2]){i|=1;var o=[],a=r[2],s=[];if((s=/^([a-z_][a-z_\d]*)/i.exec(a))!==null){o.push(s[1]);while((a=a.substring(s[0].length))!==""){if((s=/^\.([a-z_][a-z_\d]*)/i.exec(a))!==null){o.push(s[1])}else if((s=/^\[(\d+)\]/.exec(a))!==null){o.push(s[1])}else{throw"[sprintf] huh?"}}}else{throw"[sprintf] huh?"}r[2]=o}else{i|=2}if(i===3){throw"[sprintf] mixing positional and named placeholders is not (yet) supported"}t.push(r)}else{throw"[sprintf] huh?"}n=n.substring(r[0].length)}return t};var r=function(e,r,t){t=r.slice(0);t.splice(0,0,e);return n.apply(null,t)};function t(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function i(e,n){for(var r=[];n>0;r[--n]=e){}return r.join("")}e.sprintf=n;e.vsprintf=r})(typeof global!="undefined"?global:window);(function(e,n){"use strict";e.omap=function(n,r){var t={};e.each(n,function(e,i){t[e]=r.call(n,e,i)});return t};var r={clone_object:function(n){var r={};if(typeof n=="object"){if(e.isArray(n)){return this.clone_array(n)}else if(n===null){return n}else{for(var t in n){if(e.isArray(n[t])){r[t]=this.clone_array(n[t])}else if(typeof n[t]=="object"){r[t]=this.clone_object(n[t])}else{r[t]=n[t]}}}}return r},clone_array:function(n){if(!e.isFunction(Array.prototype.map)){throw new Error("You'r browser don't support ES5 array map "+"use es5-shim")}return n.slice(0).map(function(e){if(typeof e=="object"){return this.clone_object(e)}else{return e}}.bind(this))}};var t=function(e){return r.clone_object(e)};var i=function(){var e="test",n=window.localStorage;try{n.setItem(e,"1");n.removeItem(e);return true}catch(r){return false}};var o=i();function a(e,n){var r;if(typeof e==="string"&&typeof n==="string"){localStorage[e]=n;return true}else if(typeof e==="object"&&typeof n==="undefined"){for(r in e){if(e.hasOwnProperty(r)){localStorage[r]=e[r]}}return true}return false}function s(e,n){var r,t,i;r=new Date;r.setTime(r.getTime()+31536e6);t="; expires="+r.toGMTString();if(typeof e==="string"&&typeof n==="string"){document.cookie=e+"="+n+t+"; path=/";return true}else if(typeof e==="object"&&typeof n==="undefined"){for(i in e){if(e.hasOwnProperty(i)){document.cookie=i+"="+e[i]+t+"; path=/"}}return true}return false}function l(e){return localStorage[e]}function f(e){var n,r,t,i;n=e+"=";r=document.cookie.split(";");for(t=0;t<r.length;t++){i=r[t];while(i.charAt(0)===" "){i=i.substring(1,i.length)}if(i.indexOf(n)===0){return i.substring(n.length,i.length)}}return null}function c(e){return delete localStorage[e]}function u(e){return s(e,"",-1)}e.extend({Storage:{set:o?a:s,get:o?l:f,remove:o?c:u}});var h=e;h.fn.extend({everyTime:function(e,n,r,t,i){
e.terminal.defaults={prompt:"> ",history:true,exit:true,clear:true,enabled:true,historySize:60,maskChar:"*",checkArity:true,raw:false,exceptionHandler:null,cancelableAjax:true,processArguments:true,linksNoReferrer:false,processRPCResponse:null,Token:true,convertLinks:true,historyState:false,echoCommand:true,login:null,outputLimit:-1,formatters:[],onAjaxError:null,onRPCError:null,completion:false,historyFilter:null,onInit:e.noop,onClear:e.noop,onBlur:e.noop,onFocus:e.noop,onTerminalChange:e.noop,onExit:e.noop,keypress:e.noop,keydown:e.noop,strings:{wrongPasswordTryAgain:"Wrong password try again!",wrongPassword:"Wrong password!",ajaxAbortError:"Error while aborting ajax call!",wrongArity:"Wrong number of arguments. Function '%s' expects %s got"+" %s!",commandNotFound:"Command '%s' Not Found!",oneRPCWithIgnore:"You can use only one rpc with ignoreSystemDescr"+"ibe",oneInterpreterFunction:"You can't use more than one function (rpc"+"with ignoreSystemDescribe counts as one)",loginFunctionMissing:"You didn't specify a login function",noTokenError:"Access denied (no token)",serverResponse:"Server responded",wrongGreetings:"Wrong value of greetings parameter",notWhileLogin:"You can't call `%s' function while in login",loginIsNotAFunction:"Authenticate must be a function",canExitError:"You can't exit from main interpreter",invalidCompletion:"Invalid completion",invalidSelector:'Sorry, but terminal said that "%s" is not valid '+"selector!",invalidTerminalId:"Invalid Terminal ID",login:"login",password:"password",recursiveCall:"Recursive call detected, skip"}};var X=[];var Z=new m;var V=[];var en;var nn=false;var rn=true;var tn=true;var on;e.fn.terminal=function(r,i){function o(n){if(e.isFunction(Fn.processArguments)){return C(n,Fn.processArguments)}else if(Fn.processArguments){return e.terminal.parse_command(n)}else{return e.terminal.split_command(n)}}function a(n){if(typeof n==="string"){ln.echo(n)}else if(n instanceof Array){ln.echo(e.map(n,function(n){return e.json_stringify(n)}).join(" "))}else if(typeof n==="object"){ln.echo(e.json_stringify(n))}else{ln.echo(n)}}function s(n){var r=/(.*):([0-9]+):([0-9]+)$/;var t=n.match(r);if(t){ln.pause();e.get(t[1],function(n){var r=location.href.replace(/[^\/]+$/,"");var i=t[1].replace(r,"");ln.echo("[[b;white;]"+i+"]");var o=n.split("\n");var a=+t[2]-1;ln.echo(o.slice(a-2,a+3).map(function(n,r){if(r==2){n="[[;#f00;]"+e.terminal.escape_brackets(n)+"]"}return"["+(a+r)+"]: "+n}).join("\n")).resume()},"text")}}function l(n){if(e.isFunction(Fn.onRPCError)){Fn.onRPCError.call(ln,n)}else{ln.error("&#91;RPC&#93; "+n.message);if(n.error&&n.error.message){n=n.error;var r=" "+n.message;if(n.file){r+=' in file "'+n.file.replace(/.*\//,"")+'"'}if(n.at){r+=" at line "+n.at}ln.error(r)}}}function f(n,r){var t=function(r,t){ln.pause();e.jrpc(n,r,t,function(n){if(n.error){l(n.error)}else{if(e.isFunction(Fn.processRPCResponse)){Fn.processRPCResponse.call(ln,n.result,ln)}else{a(n.result)}}ln.resume()},u)};return function(e,n){if(e===""){return}try{e=o(e)}catch(i){n.error(i.toString());return}if(!r||e.name==="help"){t(e.name,e.args)}else{var a=n.token();if(a){t(e.name,[a].concat(e.args))}else{n.error("&#91;AUTH&#93; "+An.noTokenError)}}}}function c(r,t,i,a){return function(s,l){if(s===""){return}var f;try{f=o(s)}catch(u){ln.error(u.toString());return}var h=r[f.name];var p=e.type(h);if(p==="function"){if(t&&h.length!==f.args.length){ln.error("&#91;Arity&#93; "+sprintf(An.wrongArity,f.name,h.length,f.args.length))}else{return h.apply(ln,f.args)}}else if(p==="object"||p==="string"){var m=[];if(p==="object"){m=Object.keys(h);h=c(h,t,i)}l.push(h,{prompt:f.name+"> ",name:f.name,completion:p==="object"?m:n})}else{if(e.isFunction(a)){a(s,ln)}else if(e.isFunction(Fn.onCommandNotFound)){Fn.onCommandNotFound(s,ln)}else{l.error(sprintf(An.commandNotFound,f.name))}}}}function u(n,r,t){ln.resume();if(e.isFunction(Fn.onAjaxError)){Fn.onAjaxError.call(ln,n,r,t)}else if(r!=="abort"){ln.error("&#91;AJAX&#93; "+r+" - "+An.serverResponse+": \n"+e.terminal.escape_brackets(n.responseText))}}function h(n,r,t){e.jrpc(n,"system.d