var shell=new Object();shell.module=function(d){var b=d.split(".");var c=window;for(var a=0;a<b.length;a++){if(typeof c[b[a]]=="undefined")c[b[a]]=new Object();c=c[b[a]]}};
jQuery.isValueIncludedInArray=function(a,b){return jQuery.inArray(a,b)>-1};jQuery.isEmpty=function(a){return a.length==0};jQuery.ArrayCompact=function(a){return jQuery.ArrayRemoveElement(a,"")};jQuery.ArrayRemoveElement=function(b,d){b=jQuery.grep(b,function(a){return a!=d});return b};jQuery.ArrayCopyAssociative=function(a,b){for(attr in b){a[attr]=b[attr]}};jQuery.ArrayHasKey=function(a,b){return(a[b]!=undefined)};jQuery.makeStruct=function(b){var b=b.split(' ');var d=b.length;function c(){for(var a=0;a<d;a++){this[b[a]]=arguments[a]}}return c};jQuery.ify=function(){var g={'"':'&quot;','&':'&amp;','<':'&lt;','>':'&gt;'};return{"link":function(b){return b.replace(/[a-z]+:\/\/[a-z0-9-_]+\.[a-z0-9-_:~%&\?\/.=]+[^:\.,\)\s*$]/ig,function(a){return'<a href="'+a+'">'+((a.length>25)?a.substr(0,24)+'...':a)+'</a>'})},"at":function(c){return c.replace(/(^|[^\w]+)\@([a-zA-Z0-9_]{1,15})/g,function(a,b,d){return b+'@<a href="http://twitter.com/'+d+'">'+d+'</a>'})},"hash":function(c){return c.replace(/(^|[^\w'"]+)\#([a-zA-Z0-9_]+)/g,function(a,b,d){return b+'#<a href="http://search.twitter.com/search?q=%23'+d+'">'+d+'</a>'})},"clean":function(a){return this.hash(this.at(this.link(a)))}}}();jQuery.hrefNewWindow=function(a){return a.replace(/<a href/gi,'<a target="_blank" href')};jQuery.relative_time=function(o){var h=o.split(" "),k=Date.parse(h[1]+" "+h[2]+", "+h[5]+" "+h[3]),j=new Date(k),l=(arguments.length>1)?arguments[1]:new Date(),e=parseInt((l.getTime()-k)/1000),f='';var p=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];function m(a){var b=a.getHours(),d=a.getMinutes()+"",c='AM';if(b==0){b=12}else if(b==12){c='PM'}else if(b>12){b-=12;c='PM'}if(d.length==1){d='0'+d}return b+':'+d+' '+c}function q(a){var b=a.toDateString().split(/ /),d=p[a.getMonth()],c=a.getDate()+'',g=parseInt(c),n=a.getFullYear(),r=(new Date()).getFullYear(),i='th';if((g%10)==1&&c.substr(0,1)!='1'){i='st'}else if((g%10)==2&&c.substr(0,1)!='1'){i='nd'}else if((g%10)==3&&c.substr(0,1)!='1'){i='rd'}if(c.substr(0,1)=='0'){c=c.substr(1)}return d+' '+c+i+(r!=n?', '+n:'')}e=e+(l.getTimezoneOffset()*60);if(e<5){f='less than 5 seconds ago'}else if(e<30){f='half a minute ago'}else if(e<60){f='less than a minute ago'}else if(e<120){f='1 minute ago'}else if(e<(45*60)){f=(parseInt(e/60)).toString()+' minutes ago'}else if(e<(2*90*60)){f='about 1 hour ago'}else if(e<(24*60*60)){f='about '+(parseInt(e/3600)).toString()+' hours ago'}else{if(e<(48*60*60)){f=m(j)+' yesterday'}else{f=m(j)+' '+q(j)}}return f};function ltrim(a){return a.replace(/^\s+/g,"")};function rtrim(a){return a.replace(/\s+$/g,"")};jQuery.unescapeHTML=function(a){return $("<div>"+a+"</div>").text()};String.prototype.reverse=function(){return this.split("").reverse().join("")}
shell.module("shell.keyboard");shell.keyboard.autocompletes=new Array();shell.keyboard.autocompletePosition=1;shell.keyboard.autocompleteWord="";shell.keyboard.history=new Array();shell.keyboard.historyPos=0;shell.keyboard.historyTemp=0;shell.keyboard.saveCurrentInput=function(){if(shell.keyboard.history[shell.keyboard.historyPos]){shell.keyboard.history[shell.keyboard.historyPos]=shell.UI.inputField.val()}else{shell.keyboard.historyTemp=shell.UI.inputField.val()}};shell.keyboard.upDownHistoryNav=function(a){if(a==38||a==40){shell.keyboard.saveCurrentInput()}if(a==38){shell.keyboard.historyPos--;if(shell.keyboard.historyPos<0)shell.keyboard.historyPos=0}else if(a==40){shell.keyboard.historyPos++;if(shell.keyboard.historyPos>shell.keyboard.history.length)shell.keyboard.historyPos=shell.keyboard.history.length}if(a==38||a==40){if(shell.keyboard.history[shell.keyboard.historyPos])shell.UI.inputField.val(shell.keyboard.history[shell.keyboard.historyPos]);else shell.UI.inputField.val(shell.keyboard.historyTemp)}};shell.keyboard.tabNav=function(){var b=shell.UI.inputField.val();var f=b.split(" ");last=f.pop();var e=new RegExp(last,"i");var c=jQuery.grep(shell.commands.listWithAlias(),function(a){return e.exec(a)});if(c.length>0){str=c.join(" ");if(c.length==1){var d=f.join(" ");if(d.length==0){d=c[0]+' '}else{d=d+' '+c[0]+' '}shell.UI.inputField.val(d)}else{var g="<div class='input'><span class='less'>";g+=shell.UI.getPrompt()+"</span>";g+=str+"</div>"}}};shell.keyboard.mcursor=function(a){var b=a.keyCode;if(!jQuery.isEmpty(shell.keyboard.history)){shell.keyboard.upDownHistoryNav(b)}if(b==13){shell.processInput()}};shell.keyboard.addNewCommandToHistory=function(a){if(a!=""){shell.keyboard.history[shell.keyboard.history.length]=a;shell.keyboard.historyPos=shell.keyboard.history.length}};shell.keyboard.getLatestCommandFromInput=function(){var a=shell.UI.inputField.val();var b=a.split("|").pop();return ltrim(b)};shell.keyboard.keyDownHandler=function(a){if(!a&&window.event){a=window.event}if(a){_lastKeyCode=a.keyCode}if(a&&a.keyCode==9){a.cancelBubble=true;a.returnValue=false;var b=shell.UI.inputField.val();var f=shell.UI.inputField[0].selectionStart;var e=b.lastIndexOf("|")+1;var c=b.substring(e,f);if(shell.keyboard.isDisplayCommands(c)){shell.keyboard.autoCompletePath(c,f,e)}return false}};shell.keyboard.isDisplayCommands=function(a){return(a.split(" ").length>1)};shell.keyboard.autoCompletePath=function(a,b,f){var e=a.split(" ");var c=e.pop();var d=c;if(shell.twitter_FS.isRelative(c)){d=shell.twitter_FS.expandPath(c)}var g=shell.twitter_FS.dirname(d);var j=shell.twitter_FS.basename(d);var i=shell.syscalls.path2Inode(g,"shell.callbacks.getUserTabCompletion");if(!(i==shell.macros.FAIL||i==shell.macros.PENDING)){var h=shell.twitter_FS.filterChildren(i.children,j);if(h.length==0){return false}else if(h.length==1){shell.keyboard.updateCurrentInput(c,h[0].name,e,a,true)}else{var k=shell.keyboard.shortestName(h);shell.keyboard.updateCurrentInput(c,k,e,a,false);shell.std.coutWithQueueByPass(h,shell.parsers.inodeArray);shell.std.print("<br/>")}}};shell.keyboard.shortestName=function(a){var b=shell.twitter_FS.getNamesFromInodes(a);var f=b[0].length;var e=true;var c=0;while((c<b.length)&&e){var d=0;while(d<f){if(b[c].charAt(d)==b[0].charAt(d)){d+=1}else{if(d==0)e=false;f=d;break}}c+=1}if(e){return b[0].substr(0,f)}else{return null}};shell.keyboard.updateCurrentInput=function(a,b,f,e,c){var d=shell.twitter_FS.dirname(a,b);var g=null;if(b!=null){if(d!=a){g=shell.twitter_FS.join(d,b)}else{g=b}g=(c==true)?(g+"/"):g;f.push(g);shell.UI.RegReplaceInInput(e,f.join(" "))}};
shell.initialize=function(a){shell.twitter_FS.initialize(a);shell.UI.initialize()};shell.module("shell.config");shell.config.user="nobody";shell.config.host="twitter.com";shell.config.mode="help";shell.config.visitedProfiles=new Array();shell.module("shell.UI");shell.UI.initialize=function(){shell.UI.bodyElement=$('#body');shell.UI.inputElement=$('#input');shell.UI.promptElement=$('#prompt');shell.UI.inputField=$('#inputfield');shell.UI.outputElement=$('#output');shell.UI.hookEvents();shell.UI.setPrompt();shell.UI.unlockInput();shell.UI.focusCursor();jQuery.ajaxSetup({'beforeSend':shell.UI.lockInput})};shell.UI.hookEvents=function(){shell.UI.inputField.keyup(function(a){return shell.keyboard.mcursor(a)});shell.UI.bodyElement.focus(function(a){return shell.UI.focusCursor(a)});shell.UI.bodyElement.click(function(a){return shell.UI.focusCursor(a)});shell.UI.inputField.keydown(function(a){return shell.keyboard.keyDownHandler(a)})};shell.UI.focusCursor=function(){var a="";if(document.selection)a=document.selection.createRange().text;else if(window.getSelection)a=window.getSelection().toString();if(a.length==0){document.f.q.value=document.f.q.value;if(shell.UI.inputElement.css("display")!="none")document.f.q.focus()}};shell.UI.scrollToCursor=function(){var a=shell.UI.inputField.position();window.scrollBy(a.left,a.top-10)};shell.UI.scroll=function(){window.scrollBy(0,122500)};shell.UI.getPrompt=function(){return shell.UI.promptElement.html()};shell.UI.setPrompt=function(){var a=shell.config.user+'@twitter.com:'+shell.syscalls.getPWD()+'>';shell.UI.promptElement.html(a)};shell.UI.lockInput=function(){shell.UI.inputElement.css('display','none')};shell.UI.unlockInput=function(){shell.UI.inputElement.css('display','block')};shell.UI.RegReplaceInInput=function(a,b){var c=new RegExp(a,'i');var d=shell.UI.inputField.val();shell.UI.inputField.val(d.replace(c,b))};shell.UI.prepareForNextCommand=function(){shell.UI.inputField.val('');shell.UI.focusCursor();shell.UI.scrollToCursor();shell.UI.unlockInput()};shell.processInput=function(){var a=shell.UI.inputField.val();var b=a.split(" | ");for(i=0;i<b.length;i++){if(b[i]!="")shell.pipe.callQueue.push(b[i])}window.location.hash="#"+encodeURIComponent(a);shell.std.echoInput();shell.keyboard.addNewCommandToHistory(a);shell.exec()};shell.exec=function(){var a=shell.pipe.callQueueNext();var b=a.split(" ");b=jQuery.ArrayCompact(b);if(shell.pipe.dataOnPipe){b.push(shell.pipe.dataOnPipe)}var c=shell.commands.findCommand(b[0]);if(c==null){c=shell.commands.list[shell.config.mode]}else{shell.execStack=b.slice();b.shift()}c.call(b);return false};shell.execFromCallStack=function(a){if(a==undefined)a=false;var b=shell.execStack.slice();var c=shell.commands.findCommand(b[0]);if(c==null){c=shell.commands.list[shell.config.mode]}else{b.shift()}(a?c.fail(b):c.call(b))};shell.execCallBack=function(a){var b=shell.execStack.slice();var c=shell.commands.findCommand(b[0]);c.callback(a)};shell.prepareForNextCommand=function(){shell.UI.prepareForNextCommand();shell.pipe.resetCallQueueEmpty()};shell.module("shell.errors");shell.errors.errindex=null;shell.errors.errors=new Array();shell.errors.errors['GENERAL']='error:';shell.module("shell.macros");shell.macros.FAIL=-1;shell.macros.PASS=1;shell.macros.PENDING=0;shell.execStack=null;
shell.module("shell.commands");shell.module("shell.command");shell.module("shell.commandObj");shell.commands.list=new Array();shell.command.base=function(){this.mode=false;this.parameters="";this.help="no helptext yet.";this.helpText="";this.hasMore=false;this.results=new Array();this.errors=new Array()};shell.commands.require=function(a,b){if(!b)b="base";eval('shell.command.'+a+'.prototype = new shell.command.'+b+';shell.commandObj.'+a+' = new shell.command.'+a+';shell.commands.list["'+a+'"] = shell.commandObj.'+a+";");jQuery.ArrayCopyAssociative(shell.errors.errors,shell.commands.findCommand(a).errors())};shell.commands.listWithAlias=function(){var a=[];for(key in shell.commands.list){a=a.concat(shell.commands.list[key].aliases)}return a};shell.commands.findCommand=function(a){var b=null;for(key in shell.commands.list){if(jQuery.isValueIncludedInArray(a,shell.commands.list[key].aliases)){b=shell.commands.list[key];break}}return b};
shell.module("shell.pipe");shell.pipe.callQueue=new Array();shell.pipe.dataOnPipe=null;var dataOnPipe_struct=jQuery.makeStruct("data parser");shell.pipe.callQueueEmpty=function(){return shell.pipe.callQueue.length==0};shell.pipe.resetCallQueueEmpty=function(){shell.pipe.callQueue.length=0;shell.pipe.dataOnPipe=null};shell.pipe.callQueueNext=function(){return shell.pipe.callQueue.shift()};
shell.module("shell.std");shell.std.cout=function(a,b){if(shell.pipe.callQueueEmpty()){var c=(b==null?a:b(a));shell.std.print(c);shell.prepareForNextCommand()}else{shell.pipe.dataOnPipe=new dataOnPipe_struct(a,b);shell.exec()}};shell.std.coutWithQueueByPass=function(a,b){var c=(b==null?a:b(a));shell.std.print(c)};shell.std.echoInput=function(){var a="<div class='input sexy'><span class=''>";a+=shell.UI.getPrompt()+"</span><span class='commands'>";a+=shell.UI.inputField.val()+"</span></div>";shell.std.print(a)};shell.std.cerr=function(a){output='<div class="error">'+shell.errors.errors[shell.errors.errindex]+a+"</div>";shell.std.print(output);shell.errors.errindex=null};shell.std.clog=function(a){if(console&&typeof console.log=="function"){console.log(a)}};shell.std.clear=function(a){shell.UI.outputElement.html('')};shell.std.print=function(a){shell.UI.outputElement.append(a)};
shell.command.clear=function(){this.name="clear";this.aliases=new Array("clear","c");this.help="clear the screen";this.parameters="N/A";this.errors=function(){return[]};this.call=function(a){shell.std.clear();shell.prepareForNextCommand()}};shell.commands.require("clear");
shell.module("shell.twitter_FS");shell.twitter_FS.MODE_FILE=0;shell.twitter_FS.MODE_DIR=1;shell.twitter_FS.MODE_MAGIC_DIR=2;shell.twitter_FS.ACL_PUBLIC=0;shell.twitter_FS.ACL_PRIVATE=1;shell.twitter_FS.File_SEPARATOR="/";var twitter_inode=jQuery.makeStruct("mode acl children parent name json_class mount_to mount_ptr link_to");var mount_struct=jQuery.makeStruct("mount_to mount_callback");twitter_inode.length=function(){return this.name};
shell.twitter_FS.root=null;shell.twitter_FS.cwd=null;shell.twitter_FS.cwdOld=null;shell.twitter_FS.initialize=function(a){if(a==undefined){shell.config.user="nobody"}else{shell.config.user=a}shell.syscalls.mkdir("/");shell.syscalls.mkdir("/home","twitter/users");shell.syscalls.mount("/home/","cd","twitter/users","shell.callbacks.getUser");shell.syscalls.mkdirAndMount("/public_timeline","ls","twitter/timelines/public_timeline","shell.callbacks.lsTweets");if(shell.twitter.loggedIn()){shell.syscalls.mkdirHome("/home/",shell.config.user);shell.syscalls.chdir(shell.twitter_FS.join("/home/",shell.config.user))}else{shell.syscalls.chdir('/')}};shell.twitter_FS.isRelative=function(a){return a[0]!='/'};shell.twitter_FS.basename=function(a){var b=a.replace(/^.*[\/\\]/g,'');if(typeof(suffix)=='string'&&b.substr(b.length-suffix.length)==suffix){b=b.substr(0,b.length-suffix.length)}return b};shell.twitter_FS.dirname=function(a){var b=a.replace(/\\/g,'/').replace(/\/[^\/]*$/,'');if(b==""){return"/"}return b};shell.twitter_FS.expandPath=function(a){return shell.twitter_FS.join(((shell.twitter_FS.cwd==null)?"/":shell.syscalls.getPWD()),a)};shell.twitter_FS.join=function(a,b){if(a.charAt(a.length-1)==shell.twitter_FS.File_SEPARATOR){a=a.slice(0,-1)}if(b.charAt(0)==shell.twitter_FS.File_SEPARATOR){b=b.substr(1)}return a+shell.twitter_FS.File_SEPARATOR+b};shell.twitter_FS.filterChildren=function(a,b){if(b==""){return a}var c=[];for(var d=0;d<a.length;d++){var e=new RegExp('\\b'+b,'gi');if(e.exec(a[d].name)){c.push(a[d])}}return c};shell.twitter_FS.getNamesFromInodes=function(a){var b=[];for(var c=0;c<a.length;c++){b.push(a[c].name)}return b};
shell.module("shell.syscalls");shell.syscalls.mkdir=function(b){var a=null;if(shell.twitter_FS.isRelative(b)){b=shell.twitter_FS.expandPath(b)}var c=null;if(b!="/"){c=shell.syscalls.path2Inode(shell.twitter_FS.dirname(b))}if(c==false){return false}var d=new twitter_inode(shell.twitter_FS.MODE_DIR,shell.twitter_FS.ACL_PUBLIC,[],c,shell.twitter_FS.basename(b),'Inode');var e=new twitter_inode(shell.twitter_FS.MODE_DIR,shell.twitter_FS.ACL_PUBLIC,[],d,"..",'Inode');var f=new twitter_inode(shell.twitter_FS.MODE_DIR,shell.twitter_FS.ACL_PUBLIC,[],d,".",'Inode');if(b=="/"){shell.twitter_FS.root=d;d.parent=shell.twitter_FS.root;e.parent=shell.twitter_FS.root;d.node_self=shell.twitter_FS.root;shell.twitter_FS.root.children.push(e);shell.twitter_FS.root.children.push(f)}else{c.children.push(d);d.children.push(e);d.children.push(f)}};shell.syscalls.path2Inode=function(b,a){if(b=="/"){return shell.twitter_FS.root}if(shell.twitter_FS.isRelative(b)){b=shell.twitter_FS.expandPath(b)}var c=b.split("/");c=jQuery.ArrayCompact(c);var d=shell.twitter_FS.root;for(var e=0;e<c.length;e++){d=shell.syscalls.DIRGlob(c[e],d,a);if(d==shell.macros.FAIL||d==shell.macros.PENDING){return d}}return d};shell.syscalls.inode2Path=function(b){var a=b;var c=[];while(a.parent!=a){c.push(a.name);a=a.parent}c=c.reverse();return"/"+c.join("/")};shell.syscalls.DIRGlob=function(b,a,c){if(b==".."){return a.parent}if(b=="."){return a}for(var d=0;d<a.children.length;d++){if(a.children[d].name.toLowerCase()==b.toLowerCase()){return a.children[d]}}if(a.mount_ptr!=null&&jQuery.ArrayHasKey(a.mount_ptr,'cd')){var e=a.mount_ptr['cd'];var f=shell.syscalls.inode2Path(a);if(c==undefined)c=e.mount_callback;$.ajax({type:"POST",url:'/'+e.mount_to,dataType:"json",data:{user:b,path:f},success:eval(c),beforeSend:function(){}});return shell.macros.PENDING}shell.errors.errindex="ENOTDIR";return shell.macros.FAIL};shell.syscalls.getPWD=function(){return shell.syscalls.inode2Path(shell.twitter_FS.cwd)};shell.syscalls.chdir=function(b){var a=null;if(b=="-"){a=shell.twitter_FS.cwdOld}else{a=shell.syscalls.path2Inode(b)}if(a==shell.macros.FAIL||a==shell.macros.PENDING){return a}else{if(a.mode==shell.twitter_FS.MODE_DIR){shell.twitter_FS.cwdOld=shell.twitter_FS.cwd;shell.twitter_FS.cwd=a;return 1}else{shell.errors.errindex="ENOTDIR";return shell.macros.FAIL}}return shell.macros.FAIL};shell.syscalls.mount=function(b,a,c,d){var e=shell.syscalls.path2Inode(b);if(e==shell.macros.FAIL){return e}var f=new mount_struct(c,d);if(e.mount_ptr==null){e.mount_ptr=new Array()}e.mount_ptr[a]=f;return shell.macros.PASS};shell.syscalls.mkdirHome=function(b,a){var c=shell.twitter_FS.join(b,a);shell.syscalls.mkdir(c);var d=shell.twitter_FS.join(c,'timelines');shell.syscalls.mkdir(d);shell.syscalls.mkdirAndMount(shell.twitter_FS.join(d,'timeline'),"ls","twitter/timelines/user_timeline","shell.callbacks.lsTweets");if(shell.twitter.loggedIn()&&shell.config.user==a){shell.syscalls.mkdirAndMount(shell.twitter_FS.join(d,'personal'),"ls","twitter/timelines/home_timeline","shell.callbacks.lsTweets");shell.syscalls.mkdirAndMount(shell.twitter_FS.join(c,'mentions'),"ls","twitter/mentions","shell.callbacks.lsTweets");var e=shell.twitter_FS.join(c,'retweets');shell.syscalls.mkdir(e);shell.syscalls.mkdirAndMount(shell.twitter_FS.join(e,'by_me'),"ls","twitter/retweets/by_me","shell.callbacks.lsTweets");shell.syscalls.mkdirAndMount(shell.twitter_FS.join(e,'to_me'),"ls","twitter/retweets/to_me","shell.callbacks.lsTweets");shell.syscalls.mkdirAndMount(shell.twitter_FS.join(e,'of_me'),"ls","twitter/retweets/of_me","shell.callbacks.lsTweets");shell.syscalls.mkdirAndMount(shell.twitter_FS.join(c,'favorites'),"ls","twitter/favorites/private","shell.callbacks.lsTweets")}else{shell.syscalls.mkdirAndMount(shell.twitter_FS.join(c,'mentions'),"ls","twitter/public_mentions","shell.callbacks.lsTweets");shell.syscalls.mkdirAndMount(shell.twitter_FS.join(c,'favorites'),"ls","twitter/favorites/public","shell.callbacks.lsTweets")}var f=shell.twitter_FS.join(c,'friends');var g=shell.twitter_FS.join(c,'followers');shell.syscalls.mkdir(f);shell.syscalls.mkdir(g);shell.syscalls.mount(f,"ls","twitter/users/friends","shell.callbacks.lsUsers");shell.syscalls.mount(g,"ls","twitter/users/followers","shell.callbacks.lsUsers")};shell.syscalls.mkdirAndMount=function(b,a,c,d){shell.syscalls.mkdir(b);shell.syscalls.mount(b,a,c,d)};shell.syscalls.ln=function(b,a){b.link_to=a}
shell.command.pwd=function(){this.name="pwd";this.aliases=new Array("pwd");this.help="return working directory name";this.parameters="N/A";this.errors=function(){return[]};this.call=function(b){var a='<div>'+shell.syscalls.getPWD()+'</div>';shell.std.cout(a);shell.prepareForNextCommand()}};shell.commands.require("pwd");
shell.command.cd=function(){this.name="cd";this.aliases=new Array("cd");this.help="Change the working directory to the specified user";this.helptext="";this.parameters="new path";this.errors=function(){var a=new Array();a["ENOTDIR"]="No such file or directory";a["EBADF"]="No such file or directory";return a};this.call=function(a){var b=shell.syscalls.chdir(a[0]);if(b==shell.macros.PASS){this.pass()}else if(b==shell.macros.FAIL){this.fail()}else{shell.UI.lockInput();return false}};this.fail=function(){shell.std.cerr("");shell.prepareForNextCommand()};this.pass=function(){shell.UI.setPrompt();shell.prepareForNextCommand()}};shell.commands.require("cd");
shell.module("shell.callbacks");shell.callbacks.getUser=function(a){if(shell.twitter.errored(a)){shell.errors.errindex="ENOTDIR";shell.execFromCallStack(true)}else{var b=a['data'];shell.syscalls.mkdirHome(b['path'],b['screen_name']);shell.execFromCallStack(false)}};shell.callbacks.lsTweets=function(a){shell.execCallBack(a)};shell.callbacks.lsUsers=function(a){shell.execCallBack(a)};shell.callbacks.getUserTabCompletion=function(a){if(shell.twitter.errored(a)){}else{var b=a['data'];shell.syscalls.mkdirHome(b['path'],b['screen_name']);e=jQuery.Event("keydown");e.keyCode=9;shell.UI.inputField.trigger(e)}};shell.callbacks.tweet=function(a){if(shell.twitter.errored(a)){shell.errors.errindex="GENERAL";shell.std.cerr(" "+a['data'].error);shell.prepareForNextCommand()}else{shell.std.cout(a['data'],eval("shell.parsers."+a['json_class']));shell.prepareForNextCommand()}};
shell.module("shell.twitter");shell.twitter.errored=function(a){return(a['data'].error?true:false)};shell.twitter.loggedIn=function(){return(shell.config.user!='nobody')};
shell.command.ls=function(){this.name="ls";this.aliases=new Array("ls");this.help="list directory contents";this.helptext="";this.parameters="path";this.errors=function(){var a=new Array();a["ENOTDIR"]="No such file or directory";a["EBADF"]="No such file or directory";return a};this.call=function(a){var b=a[0];if(b==null)b=".";var c=shell.syscalls.path2Inode(b);if(c==shell.macros.FAIL){this.fail()}else if(c==shell.macros.PENDING){return false}else{this.porcess(c)}};this.fail=function(a){if(a==undefined)a="";shell.std.cerr(a);shell.prepareForNextCommand()};this.pass=function(){shell.prepareForNextCommand()};this.porcess=function(a){if(a.mount_ptr!=null&&jQuery.ArrayHasKey(a.mount_ptr,'ls')){var b=a.mount_ptr['ls'];var c=shell.syscalls.inode2Path(a);$.post('/'+b.mount_to,{path:c},eval(b.mount_callback),"json")}else{shell.std.cout(a.children,shell.parsers.inodeArray);this.pass()}};this.callback=function(a){if(shell.twitter.errored(a)){shell.errors.errindex="GENERAL";this.fail(" "+a['data'].error)}else{shell.std.cout(a['data'],eval("shell.parsers."+a['json_class']));this.pass()}}};shell.commands.require("ls");
shell.module("shell.parsers");shell.parsers.inodeArray=function(b){var a='';for(var c=0;c<b.length;c++){if(b[c].name!='.'&&b[c].name!='..'){a+='<span class="dir">'+b[c].name+"</span>"}}return a};shell.parsers.Tweets=function(b){var a='<ol class="statuses" id="timeline">';for(var c=0;c<b.length;c++){var d=b[c];var e=eval("shell.parsers."+d['json_class']);a+=e(d['data'])}a+='</ol>';return a};shell.parsers.Tweet=function(b){var a='<li id="status_'+b['id']+'" class="hentry u-toot status">';a+='<span class="thumb vcard author"><a class="tweet-url profile-pic url" href="http://twitter.com/'+b['user']['screen_name']+'">';a+='<img width="48" height="48" src="'+b['user']['profile_image_url']+'" class="photo fn" alt="'+b['user']['name']+'"></a></span>';a+='<span class="status-body"><strong><a title="'+b['user']['name']+'" class="tweet-url screen-name" href="http://twitter.com/'+b['user']['screen_name']+'">';a+=b['user']['screen_name']+"</a></strong>";a+=' <span class="entry-content">'+jQuery.ify.clean(b['text'])+'</span>';a+=' <span class="meta entry-meta">';a+='<a href="http://twitter.com/'+b['user']['screen_name']+'/status/'+b['id']+'" rel="bookmark" class="entry-date">';a+='<span data="{time:\''+b['created_at']+'\'" class="published timestamp">'+jQuery.relative_time(b['created_at'])+'</span>';a+='</a>';a+='<span> from '+jQuery.unescapeHTML(b['source'])+' </span>';a+='</span>';a+='</span>';a+='</li>';a=jQuery.hrefNewWindow(a);return a};shell.parsers.Users=function(b){var a='<ul class="friends_dir">';for(var c=0;c<b['users'].length;c++){if(b['users'][c]['data']['screen_name']!='.'&&b['users'][c]['data']['screen_name']!='..'){a+='<li class="friend_dir">';a+='<a class="tweet-url profile-pic url" href="http://twitter.com/'+b['users'][c]['data']['screen_name']+'">';a+='<img width="48" height="48" src="'+b['users'][c]['data']['profile_image_url']+'" class="photo fn" alt="'+b['users'][c]['data']['name']+'">';a+="<br/>"+b['users'][c]['data']['screen_name'];a+='</a>';a+='</li>'}}a+='</ul>';return a};
shell.command.ssh=function(){this.name="ssh";this.aliases=new Array("ssh","login");this.help="Login to your twitter account --> (Oauth)";this.parameters="N/A";this.errors=function(){return[]};this.call=function(a){shell.UI.lockInput();window.location.replace("/oauth/connect")}};shell.commands.require("ssh");
shell.command.exit=function(){this.name="exit";this.aliases=new Array("exit");this.help="Termimate your current session with twitter.com ";this.parameters="N/A";this.errors=function(){return[]};this.call=function(a){shell.UI.lockInput();window.location="/oauth/disconnect"}};shell.commands.require("exit");
shell.command.head=function(){this.name="head";this.aliases=new Array("head");this.help="display first lines of a file/tweet. ls /home/moski_doski/timelines/timeline | head -n 1";this.errors=function(){var a=new Array();a["HEAD_NOINPUT"]="requires an input";a["HEAD_NOPTION"]="option require an argument";return a};this.call=function(a){if(!a||a.length==0){shell.errors.errindex="HEAD_NOINPUT";return this.fail(" -> example: ls /public_timeline | head ")}var c=5;var b=null;var d=null;for(i=0;i<a.length;i++){if(a[i]=='-n'){if(!a[i+1]){shell.errors.errindex='HEAD_NOPTION';return this.fail("")}c=a[i+1]}else{b=a[i]}}if(typeof(b['data'])!=undefined){d=b['parser'];b=b['data']}b=b.slice(0,c);shell.std.cout(b,d)};this.fail=function(a){shell.std.cerr(a)}};shell.commands.require("head");
shell.command.tail=function(){this.name="tail";this.aliases=new Array("tail");this.help="display the last part of a list of tweets. ls /home/moski_doski/timelines/timeline | tail ";this.errors=function(){var a=new Array();a["HEAD_NOINPUT"]="requires an input";a["HEAD_NOPTION"]="option require an argument";return a};this.call=function(a){if(!a||a.length==0){shell.errors.errindex="HEAD_NOINPUT";return this.fail(" -> example: ls /public_timeline | tail ")}var c=1;var b=null;var d=null;for(i=0;i<a.length;i++){if(a[i]=='-n'){if(!a[i+1]){shell.errors.errindex='HEAD_NOPTION';return this.fail("")}c=a[i+1]}else{b=a[i]}}if(typeof(b['data'])!=undefined){d=b['parser'];b=b['data']}b=b.slice(b.length-c,b.length);shell.std.cout(b,d)};this.fail=function(a){shell.std.cerr(a)}};shell.commands.require("tail");
shell.command.wc=function(){this.name="wc";this.aliases=new Array("wc");this.help="word and character count. ls /home/moski_doski/timelines/timeline | tail -n 1 | wc";this.errors=function(){var a=new Array();a["HEAD_NOINPUT"]="requires an input";a["HEAD_NOPTION"]="option require an argument";return a};this.call=function(a){if(!a||a.length==0){shell.errors.errindex="HEAD_NOINPUT";return this.fail(" -> example: ls /public_timeline | tail | wc -m ")}var b=1;var c=null;var e=null;var d=0;for(i=0;i<a.length;i++){if(a[i]=='-m'){d=0}else if(a[i]=='-w'){d=1}else{c=a[i]}}if(typeof(c['data'])!=undefined){e=c['parser'];c=c['data']}(d==0)?this.charCount(c):this.wordCount(c);return true};this.fail=function(a){shell.std.cerr(a)};this.charCount=function(a){var b=0;if(jQuery.isArray(a)){for(var c=0;c<a.length;c++){b+=this.charCountHelper(a[c])}}else{b+=this.charCountHelper(a)}shell.std.cout(b);return true};this.charCountHelper=function(a){var b=0;if(a['json_class']=='Tweet'){b+=a['data']['text'].length}else if(a['json_class']=='Inode'){b+=a.name.length}return b};this.wordCount=function(a){var b=0;if(jQuery.isArray(a)){for(var c=0;c<a.length;c++){b+=this.wordCountHelper(a[c])}}else{b+=this.wordCountHelper(a)}shell.std.cout(b);return true};this.wordCountHelper=function(a){var b=0;if(a['json_class']=='Tweet'){b+=a['data']['text'].split(" ").length}else if(a['json_class']=='Inode'){b+=a.name.split(" ").length}return b}};shell.commands.require("wc");
shell.command.wall=function(){this.name="wall";this.aliases=new Array("wall");this.help="Write a message to all followers.(tweeting); wall 'So say we all, tweetsh is awesome'";this.errors=function(){var a=new Array();a["HEAD_NOINPUT"]="requires an input";a["WALL_LOGGED_IN"]="Must be logged in to use the wall command";return a};this.call=function(a){var b="";var c=a[0];if(!shell.twitter.loggedIn()){shell.errors.errindex="WALL_LOGGED_IN";return this.fail("")}if(!a||a.length==0){shell.errors.errindex="HEAD_NOINPUT";return this.fail("")}if(a.length>=1&&typeof(c['data'])=="undefined"){for(var d=0;d<a.length;d++){b+=a[d]+' '}}else{parser=c['parser'];c=c['data'];b=this.parseInput(c)}$.post('/twitter/update',{update:b},shell.callbacks.tweet,"json");shell.UI.lockInput();return false};this.fail=function(a){shell.std.cerr(a)};this.parseInput=function(a){var b='';if(jQuery.isArray(a)){b=this.parseInputHelper(a[0])}else{b=this.parseInputHelper(a)}return b};this.parseInputHelper=function(a){var b='';if(a['json_class']=='Tweet'){b=a['data']['text']}else if(a['json_class']=='Inode'){b=a.name}return b}};shell.commands.require("wall");
shell.command.man=function(){this.name="man";this.aliases=new Array("help","man","h","?");this.help="displays help text";this.parameters="[command]";this.errors=function(){var c=new Array();c["MAN_NOCOMMAND"]="command not found";return c};this.call=function(c){this.help="displays help text";this.helptext="";this.parameters="[command]";var b="<span class='info'>help";if(c[0])b+=": "+c[0];b+="</span><br/><br/>";if(c[0]&&!shell.commands.list[c[0]]){shell.errors.errindex="MAN_NOCOMMAND";return this.fail("")}var b=this.drawHelp(c);shell.std.cout(b)};this.fail=function(c){shell.std.cerr(c)};this.drawHelp=function(c){var b;var a="<table border='0' class='help'>";a+="<tr class='help_header'><td class='less'>command</td><td class='less'>aliases</td><td class='less'>parameters</td><td class='less'>function</td></tr>";for(key in shell.commands.list){if(!c[0]||key==c[0]){b=shell.commands.list[key];a+="<tr><td";if(b.mode)a+=" class='info'";a+=">";a+=""+b.name+"</td><td>";if(b.aliases.length>1){a+="(";for(i=0;i<b.aliases.length;i++){if(b.aliases[i]!=b.name){a+=b.aliases[i];a+=","}}a=a.substr(0,a.length-1);a+=")"}a+="</td><td>";if(b.parameters)a+=b.parameters;a+="</td><td>";a+=""+b.help+"\n";a+="</td></tr>"}}a+="</table>";if(c[0]){a+=" <br/>";a+=b.helptext;a+=" <br/>"}else{a+=" <br/>";a+="- Aliases will expand to commands. <br/>";a+="- Use cursor up and down for command history.<br/>";a+="<br/>"}return a}};shell.commands.require("man");
shell.command.reverse=function(){this.name="reverse";this.aliases=new Array("reverse");this.help="reverse the incoming dirs/tweets. ls /home/moski_doski/timelines/timeline | reverse ";this.parameters="input(list of tweets or list of dirs)";this.errors=function(){var a=new Array();a["HEAD_NOINPUT"]="requires an input";return a};this.call=function(a){if(!a||a.length==0){shell.errors.errindex="HEAD_NOINPUT";return this.fail(" -> example: ls /public_timeline | reverse | head ")}var d=1;var b=a[0];var c=null;if(typeof(b['data'])!=undefined){c=b['parser'];b=b['data']}b.reverse();shell.std.cout(b,c)};this.fail=function(a){shell.std.cerr(a)}};shell.commands.require("reverse");
