assets.terminal.jquery.terminal-0.8.8.min.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sirius-web Show documentation
Show all versions of sirius-web Show documentation
Provides a modern and scalable web server as SIRIUS module
(function(ctx){var sprintf=function(){if(!sprintf.cache.hasOwnProperty(arguments[0])){sprintf.cache[arguments[0]]=sprintf.parse(arguments[0])}return sprintf.format.call(null,sprintf.cache[arguments[0]],arguments)};sprintf.format=function(parse_tree,argv){var cursor=1,tree_length=parse_tree.length,node_type="",arg,output=[],i,k,match,pad,pad_character,pad_length;for(i=0;i>>0;break;case"x":arg=arg.toString(16);break;case"X":arg=arg.toString(16).toUpperCase();break}arg=/[def]/.test(match[8])&&match[3]&&arg>=0?"+"+arg:arg;pad_character=match[4]?match[4]=="0"?"0":match[4].charAt(1):" ";pad_length=match[6]-String(arg).length;pad=match[6]?str_repeat(pad_character,pad_length):"";output.push(match[5]?arg+pad:pad+arg)}}return output.join("")};sprintf.cache={};sprintf.parse=function(fmt){var _fmt=fmt,match=[],parse_tree=[],arg_names=0;while(_fmt){if((match=/^[^\x25]+/.exec(_fmt))!==null){parse_tree.push(match[0])}else if((match=/^\x25{2}/.exec(_fmt))!==null){parse_tree.push("%")}else if((match=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt))!==null){if(match[2]){arg_names|=1;var field_list=[],replacement_field=match[2],field_match=[];if((field_match=/^([a-z_][a-z_\d]*)/i.exec(replacement_field))!==null){field_list.push(field_match[1]);while((replacement_field=replacement_field.substring(field_match[0].length))!==""){if((field_match=/^\.([a-z_][a-z_\d]*)/i.exec(replacement_field))!==null){field_list.push(field_match[1])}else if((field_match=/^\[(\d+)\]/.exec(replacement_field))!==null){field_list.push(field_match[1])}else{throw"[sprintf] huh?"}}}else{throw"[sprintf] huh?"}match[2]=field_list}else{arg_names|=2}if(arg_names===3){throw"[sprintf] mixing positional and named placeholders is not (yet) supported"}parse_tree.push(match)}else{throw"[sprintf] huh?"}_fmt=_fmt.substring(match[0].length)}return parse_tree};var vsprintf=function(fmt,argv,_argv){_argv=argv.slice(0);_argv.splice(0,0,fmt);return sprintf.apply(null,_argv)};function get_type(variable){return Object.prototype.toString.call(variable).slice(8,-1).toLowerCase()}function str_repeat(input,multiplier){for(var output=[];multiplier>0;output[--multiplier]=input){}return output.join("")}ctx.sprintf=sprintf;ctx.vsprintf=vsprintf})(typeof exports!="undefined"?exports:window);(function($,undefined){"use strict";$.omap=function(o,fn){var result={};$.each(o,function(k,v){result[k]=fn.call(o,k,v)});return result};var isLS=typeof window.localStorage!=="undefined";function wls(n,v){var c;if(typeof n==="string"&&typeof v==="string"){localStorage[n]=v;return true}else if(typeof n==="object"&&typeof v==="undefined"){for(c in n){if(n.hasOwnProperty(c)){localStorage[c]=n[c]}}return true}return false}function wc(n,v){var dt,e,c;dt=new Date;dt.setTime(dt.getTime()+31536e6);e="; expires="+dt.toGMTString();if(typeof n==="string"&&typeof v==="string"){document.cookie=n+"="+v+e+"; path=/";return true}else if(typeof n==="object"&&typeof v==="undefined"){for(c in n){if(n.hasOwnProperty(c)){document.cookie=c+"="+n[c]+e+"; path=/"}}return true}return false}function rls(n){return localStorage[n]}function rc(n){var nn,ca,i,c;nn=n+"=";ca=document.cookie.split(";");for(i=0;itimes&×!==0||fn.call(element,counter)===false){jQuery.timer.remove(element,label,fn)}handler.inProgress=false};handler.$timerID=fn.$timerID;if(!element.$timers[label][fn.$timerID]){element.$timers[label][fn.$timerID]=window.setInterval(handler,interval)}if(!this.global[label]){this.global[label]=[]}this.global[label].push(element)},remove:function(element,label,fn){var timers=element.$timers,ret;if(timers){if(!label){for(var lab in timers){if(timers.hasOwnProperty(lab)){this.remove(element,lab,fn)}}}else if(timers[label]){if(fn){if(fn.$timerID){window.clearInterval(timers[label][fn.$timerID]);delete timers[label][fn.$timerID]}}else{for(var _fn in timers[label]){if(timers[label].hasOwnProperty(_fn)){window.clearInterval(timers[label][_fn]);delete timers[label][_fn]}}}for(ret in timers[label]){if(timers[label].hasOwnProperty(ret)){break}}if(!ret){ret=null;delete timers[label]}}for(ret in timers){if(timers.hasOwnProperty(ret)){break}}if(!ret){element.$timers=null}}}}});if(/(msie) ([\w.]+)/.exec(navigator.userAgent.toLowerCase())){jQuery(window).one("unload",function(){var global=jQuery.timer.global;for(var label in global){if(global.hasOwnProperty(label)){var els=global[label],i=els.length;while(--i){jQuery.timer.remove(els[i],label)}}}})}(function(undef){if(!String.prototype.split.toString().match(/\[native/)){return}var nativeSplit=String.prototype.split,compliantExecNpcg=/()??/.exec("")[1]===undef,self;self=function(str,separator,limit){if(Object.prototype.toString.call(separator)!=="[object RegExp]"){return nativeSplit.call(str,separator,limit)}var output=[],flags=(separator.ignoreCase?"i":"")+(separator.multiline?"m":"")+(separator.extended?"x":"")+(separator.sticky?"y":""),lastLastIndex=0,separator2,match,lastIndex,lastLength;separator=new RegExp(separator.source,flags+"g");str+="";if(!compliantExecNpcg){separator2=new RegExp("^"+separator.source+"$(?!\\s)",flags)}limit=limit===undef?-1>>>0:limit>>>0;while(match=separator.exec(str)){lastIndex=match.index+match[0].length;if(lastIndex>lastLastIndex){output.push(str.slice(lastLastIndex,match.index));if(!compliantExecNpcg&&match.length>1){match[0].replace(separator2,function(){for(var i=1;i1&&match.index=limit){break}}if(separator.lastIndex===match.index){separator.lastIndex++}}if(lastLastIndex===str.length){if(lastLength||!separator.test("")){output.push("")}}else{output.push(str.slice(lastLastIndex))}return output.length>limit?output.slice(0,limit):output};String.prototype.split=function(separator,limit){return self(this,separator,limit)};return self})();function str_parts(str,length){var result=[];var len=str.length;if(len0?data[data.length-1]:null}})}$.json_stringify=function(object,level){var result="",i;level=level===undefined?1:level;var type=typeof object;switch(type){case"function":result+=object;break;case"boolean":result+=object?"true":"false";break;case"object":if(object===null){result+="null"}else if(object instanceof Array){result+="[";var len=object.length;for(i=0;i1?",":"";if(level===1){result=result.replace(/,([\]}])/g,"$1")}return result.replace(/([\[{]),/g,"$1")};function History(name,size){var enabled=true;var storage_key="";if(typeof name==="string"&&name!==""){storage_key=name+"_"}storage_key+="commands";var data=$.Storage.get(storage_key);data=data?$.parseJSON(data):[];var pos=data.length-1;$.extend(this,{append:function(item){if(enabled){if(data[data.length-1]!==item){data.push(item);if(size&&data.length>size){data=data.slice(-size)}pos=data.length-1;$.Storage.set(storage_key,$.json_stringify(data))}}},data:function(){return data},reset:function(){pos=data.length-1},last:function(){return data[length-1]},end:function(){return pos===data.length-1},position:function(){return pos},current:function(){return data[pos]},next:function(){if(pos0){--pos}if(old!==-1){return data[pos]}},clear:function(){data=[];this.purge()},enabled:function(){return enabled},enable:function(){enabled=true},purge:function(){$.Storage.remove(storage_key)},disable:function(){enabled=false}})}$.fn.cmd=function(options){var self=this;var maybe_data=self.data("cmd");if(maybe_data){return maybe_data}self.addClass("cmd");self.append(''+' ');var clip=$("").addClass("clipboard").appendTo(self);if(options.width){self.width(options.width)}var num_chars;var prompt_len;var reverse_search=false;var reverse_search_string="";var reverse_search_position=null;var backup_prompt;var mask=options.mask||false;var command="";var selected_text="";var kill_text="";var position=0;var prompt;var enabled=options.enabled;var historySize=options.historySize||60;var name,history;var cursor=self.find(".cursor");var animation;if(supportAnimations()){animation=function(toggle){if(toggle){cursor.addClass("blink")}else{cursor.removeClass("blink")}}}else{animation=function(toggle){if(toggle&&!enabled){cursor.addClass("inverted");self.everyTime(500,"blink",blink)}else if(enabled){self.stopTime("blink",blink);cursor.removeClass("inverted")}}}function blink(i){cursor.toggleClass("inverted")}function draw_reverse_prompt(){prompt="(reverse-i-search)`"+reverse_search_string+"': ";draw_prompt()}function clear_reverse_state(){prompt=backup_prompt;reverse_search=false;reverse_search_position=null;reverse_search_string=""}function reverse_history_search(next){var history_data=history.data();var regex,save_string;var len=history_data.length;if(next&&reverse_search_position>0){len-=reverse_search_position}if(reverse_search_string.length>0){for(var j=reverse_search_string.length;j>0;j--){save_string=reverse_search_string.substring(0,j).replace(/([.*+{}\[\]?])/g,"\\$1");regex=new RegExp(save_string);for(var i=len;i--;){if(regex.test(history_data[i])){reverse_search_position=history_data.length-i;position=0;self.set(history_data[i],true);redraw();if(reverse_search_string.length!==j){reverse_search_string=reverse_search_string.substring(0,j);draw_reverse_prompt()}return}}}}reverse_search_string=""}function change_num_chars(){var W=self.width();var w=cursor.innerWidth();num_chars=Math.floor(W/w)}function str_repeat(str,n){var result="";for(var i=n;i--;){result+=str}return result}function get_splited_command_line(string){var first=string.substring(0,num_chars-prompt_len);var rest=string.substring(num_chars-prompt_len);return[first].concat(str_parts(rest,num_chars))}var redraw=function(self){var before=cursor.prev();var after=cursor.next();function draw_cursor_line(string,position){var len=string.length;if(position===len){before.html($.terminal.encode(string,true));cursor.html(" ");after.html("")}else if(position===0){before.html("");cursor.html($.terminal.encode(string.slice(0,1),true));after.html($.terminal.encode(string.slice(1),true))}else{var before_str=$.terminal.encode(string.slice(0,position),true);before.html(before_str);var c=string.slice(position,position+1);cursor.html(c===" "?" ":$.terminal.encode(c,true));if(position===string.length-1){after.html("")}else{after.html($.terminal.encode(string.slice(position+1),true))}}}function div(string){return""+$.terminal.encode(string,true)+""}function lines_after(lines){var last_ins=after;$.each(lines,function(i,line){last_ins=$(div(line)).insertAfter(last_ins).addClass("clear")})}function lines_before(lines){$.each(lines,function(i,line){before.before(div(line))})}var count=0;return function(){var string=mask?command.replace(/./g,"*"):command;var i,first_len;self.find("div").remove();before.html("");if(string.length>num_chars-prompt_len-1||string.match(/\n/)){var array;var tabs=string.match(/\t/g);var tabs_rm=tabs?tabs.length*3:0;if(tabs){string=string.replace(/\t/g,"\x00\x00\x00\x00")}if(string.match(/\n/)){var tmp=string.split("\n");first_len=num_chars-prompt_len-1;for(i=0;ifirst_len){array=[tmp[0].substring(0,first_len)];array=array.concat(str_parts(tmp[0].substring(first_len),num_chars))}else{array=[tmp[0]]}for(i=1;inum_chars){array=array.concat(str_parts(tmp[i],num_chars))}else{array.push(tmp[i])}}}else{array=get_splited_command_line(string)}if(tabs){array=$.map(array,function(line){return line.replace(/\x00\x00\x00\x00/g," ")})}first_len=array[0].length;if(first_len===0&&array.length===1){}else if(position"+$.terminal.encode(array[0],true)+"