-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathterminalize.min.js
executable file
·1 lines (1 loc) · 1.67 KB
/
terminalize.min.js
1
(function(a){a.fn.xterm_effect=function(c,b){this.each(function(){var f=a(this),e=f.text(),d=0;e=(e.length%2==0)?e=e+" ":e;f.text("");var g=setInterval(function(){f.text(e.substring(0,d++)+(d&1?"_":""));if(d>e.length){clearInterval(g);if(b!=undefined){b.call(this)}}},c)});return this};a.fn.terminalize_init=function(c){var d={prompt:"terminal>",};c=a.extend({},d,c);var b=a(this).selector;var e=a(b);allCommands=a(b+" .cmd");allResponses=a(b+" .cmd-response");allCommands.css("visibility","hidden");allResponses.css({visibility:"hidden",display:"block"});a(b).children(".prompt").remove();a(b).prepend('<a class="prompt">'+c.prompt+"</a>")};a.fn.terminalize=function(e){var g={velocity:120,mode:"single",prompt:"terminal>",};e=a.extend({},g,e);e.prompt+=" ";var c=a(this).selector;var h=a(c);allCommands=a(c+" .cmd");allResponses=a(c+" .cmd-response");allCommands.css("visibility","hidden");allResponses.css({visibility:"hidden",display:"block"});a(c).children(".prompt").remove();a(c).prepend('<a class="prompt">'+e.prompt+"</a>");if(h.length>1){if(e.mode==="single"){f(0,a(h))}else{if(e.mode==="all"){var d=Array();h.each(function(i){d[i]=new b(0,a(h[i])),0})}}}function f(j,i){len=i.length;if(j<len){terminal=i[j];b(0,a(terminal),function(){f(j+1,i)})}}function b(j,k,i){commands=k.children(".cmd");responses=k.children(".cmd-response");len=commands.length;if(j<len){if(j===0){commandtmp=k.children(".prompt");cmdprmpt=a(commandtmp[0]);cmdprmpt.remove()}cmdAct=a(commands[j]);cmdAct.before('<a class="prompt">'+e.prompt+"</a>");cmdAct.css("visibility","visible");cmdAct.xterm_effect(e.velocity,function(){a(responses[j]).css("visibility","visible");b(j+1,k,i)})}else{if(i!=undefined){i.call(this)}}}}})(jQuery);