var fun=null;var bg =null;var h1 =null;var h2 =null;var ul =null;var bdy =null;var ulnav =null;var input =null;var header =null;var console =null;var quakea =null;var quakeb =null;var container=null;var mtop =100;var mleft=300; $(document).ready(function(){ bg =$('#bg'); h1 =$('h1'); h2 =$('h2'); ul =$('ul'); bdy =$('body'); ulnav =$('ul.nav'); input =$('#input'); header =$('#header'); console =$('#console'); quakea =$('#top'); quakeb =$('#bottom'); container=$('#container'); $('li a').each(function (i) { $(this).attr("href", "javascript:void(0)"); }); input.keypress(function(event) { if ( event.which == 13 ) { event.preventDefault(); cmd(input.val()); } }); $(window).resize(function() { fix_fullscreen_dimension(); }); console.click(function() { input.focus(); input.select(); }); }); function toggle_animate_bg() { if (fun!=null) { clearTimeout(fun); bg.stop(); bg.animate({ top: "-50%",left: "0"},1000); console.append("  No more fun!
$ "); fun=null; } else { go_home(); animate_bg(); } } function animate_bg() {var top=-mtop+Math.floor(Math.random()*mtop*2);var left=-mleft+Math.floor(Math.random()*mleft*2);var otop=parseInt(bg.css('top'));var oleft=parseInt(bg.css('left'));var diff=Math.max( Math.max(Math.abs(top),Math.abs(otop)) , Math.max(Math.abs(left),Math.abs(oleft))); bg.animate({ top: top+"px",left: left+"px"},2000+Math.floor(Math.random()*2*diff), function(){ fun=setTimeout('animate_bg();', Math.floor(Math.random()*2000)); }); } function cmd(c) { if (!input.hasClass('loading')) { loading();var p=""; if (c.indexOf(" ")!=-1) { p=base64_encode(c.substr(c.indexOf(" ")+1)); c=c.substr(0,c.indexOf(" ")); } _gaq.push(['_trackEvent', 'Shell Command', c]); if (c!="asl" && !(c=="login"&&p!="")) console.append(c+"
"); $.post('ajax/command.php',{ cmd: c,param: p }, function (data) { loading_done();var action=data.substring(0,3);var data =data.substring(3); if (action=='src') { eval(data); } else if (action=='msg' || action=='asl') {var pre="  "; if (action=="asl") pre=""; console.append(pre+data+"
$ "); console.animate({ scrollTop: console.prop("scrollHeight") }, 300); } else if (action=='url') { window.location=data.replace(/^\s+|\s+$/g, ''); } if (action!='asl') { input.focus(); input.select(); } }); } } function loading() { input.addClass('loading'); input.attr("disabled",true); } function loading_done() { input.removeClass('loading'); input.removeAttr("disabled"); input.focus(); input.select(); } function close_overlay() { $('#overlay').hide(); $('#content').html(""); } function login() { cmd("login "+$('#username').val()+" "+$('#password').val()); close_overlay(); } function login_form() { $.get('ajax/login.php', function (data) { $('#content').html(data); $('#overlay').show(); $('#username').focus(); $('#content .text').keypress(function(event) { if ( event.which == 13 ) { event.preventDefault(); login(); } else if ( event.which == 27 ) { event.preventDefault(); close_overlay(); } }); }); } function uh_oh() { _gaq.push(['_trackEvent', 'Don\'t Click This', "Uh Oh..."]); h2.html("...."); ul.hide(); h2.hide(); bg.hide(); spin(); quake(); } function spin() { bdy.css('background-color',"#"+random_color()); h1.css('color',"#"+random_color()); setTimeout('spin()',10); } function quake() {var per=Math.floor(Math.random()*30)+5; quakea.animate({ top: "-"+per+"%"},100); quakeb.animate({ bottom: "-"+per+"%"},100); h1.animate({fontSize: Math.floor(Math.random()*50)+35+"px"},100); setTimeout('quake()',100); } function explore() { _gaq.push(['_trackEvent', 'Terminal', "Explore..."]); console.html(""); h2.html("exploring..."); ulnav.hide(); input.val(""); header.animate({ marginTop: "-300px" }, 1500, function() { h2.animate({marginTop: "-75px"}, 500); container.show(500); input.focus(); cmd('asl'); }); } function instaExplore() { console.html(""); h2.html("exploring..."); ulnav.hide(); input.val(""); header.animate({ marginTop: "-300px" }, 0, function() { h2.animate({marginTop: "-75px"}, 0); container.show(0); input.focus(); cmd('asl'); }); } function go_home() { bdy.removeClass('fullscreen'); fix_fullscreen_dimension(); h2.html("a place for things."); h2.animate({marginTop: "5px"}, 500); container.hide(500,function() { header.animate({ marginTop: "-75px" },function() { ulnav.show(); }); }); } function random_color() { return Math.round(0xffffff * Math.random()); } function toggle_fullscreen() { bdy.toggleClass('fullscreen'); fix_fullscreen_dimension(); } function fix_fullscreen_dimension() { if (bdy.hasClass('fullscreen')) { console.css("height",($(window).height()-80)+"px"); input.css("width",($(window).width()-68)+"px"); } else { console.css("height","300px"); input.css("width","760px"); } console.animate({ scrollTop: console.prop("scrollHeight") }, 300); }