var EricWillis={};EricWillis.Page=function(){function rot13(text){return text.replace(/[a-zA-Z]/g,function(c){return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26)})}return{freshen:function(){$(".rotten").each(function(rottenLink){var link=$(this);link.attr("href",rot13(link.attr("href")))})},init:function(){EricWillis.Page.freshen()}}}();
EricWillis.Magnets=function(){var MAGNET_CONTAINER="magnets";var MAGNET_CLASS="magnet";var BASE_WORDS="the,of,and,a,to,in,is,you,that,it,he,for,was,on,are,as,with,his,they,at,be,this,from,I,have,or,by,one,had,not,but,what,all,were,when,we,there,can,an,your,which,their,said,if,do,will,each,about,how,up,out,them,then,she,many,some,so,these,would,other,into,has,more,her,two,like,him,see,time,could,no,make,than,first,been,its,who,now,people,my,made,over,did,down,only,way,find,use,may,water,long,little,very,after,words,called,just,where,most,know,get,through,back,much,go,before,good,new,write,our,used,me,man,too,any,day,same,right,look,think,also,around,another,came,come,work,three,word,must,because,does,part,even,plance,well,such,here,take,why,things,help,put,years,different,away,again,off,went,old,number,great,tell,men,say,small,every,found,still,between,name,should,Mr.,home,big,give,air,line,set,own,under,us,end,read,last,never,left,along,while,might,next,sound,below,saw,both,something,thought,few,those,always,looked,show,large,often,together,asked,house,don't,world,going,want,school,important,until,form,food,keep,children,feet,land,side,without,boy,once,animals,life,enough,took,Earth,sometimes,four,head,above,kind,began,almost,live,page,got,need,far,let,hand,high,year,monther,light,parts,country,father,night,following,picture,being,study,second,eyes,soon,times,story,boys,since,white,days,ever,sure,paper,hard,near,sentence,better,best,across,during,today,others,sure,however,means,knew,it's,try,told,young,miles,sun,ways,thing,whole,hear,example,heard,several,change,answer,room,sea,against,top,turned,learn,point,city,play,toward,five,using,himself,usually";var FUNZIES=
"Large Hadron Collider,txt,msg,Mac,dingo,awkward,undies,sex,poop,ninja,pirate,lol,wtf,stfu,brb,:),:(,;),:|,:D,1.21 jigawatts,lolcat,masticate,poppycock,scrumptious,delicious,pants,discombobulate,floozy,smorgasbord,floccinaucinihilipilification,caddywampus,tomfoolery,kumquat";var DUPLICATE_THESE="s,es,ing,ly,d,ed,the,and,a,to,in,is,you,that,it,he,was,for,on,are,as,with,his,they,I,at,be,this,have,or,by,but,we,your,an,she,do,if,so,her,like,make,him,go,no,yes,my,who,its";var _originalLayout=null;var _edited=
false;function _setupMagnets(alreadyLoaded){if(!alreadyLoaded){var baseWords=BASE_WORDS.split(",");var funzies=FUNZIES.split(",");var duplicateThese=(new String(DUPLICATE_THESE+","+DUPLICATE_THESE)).split(",");$.each(baseWords,function(){_stickMagnetToPage(this.toString(),false)});$.each(funzies,function(){_stickMagnetToPage(this.toString(),true)});$.each(duplicateThese,function(){_stickMagnetToPage(this.toString(),false)})}$("."+MAGNET_CLASS).each(function(){$(this).draggable({stack:"."+MAGNET_CLASS,
drag:function(e,ui){if(!_edited)$("#toolbar").animate({backgroundColor:"#fe0"},500,function(){$("#toolbar").animate({backgroundColor:"#eee"},500);_edited=true})}});$(this).css("position","absolute")});_originalLayout=$("#"+MAGNET_CONTAINER).html()}function _stickMagnetToPage(word,highlight){var width=$(document).width();var height=$(document).height();var offsetLeft=50;var offsetRight=100;var offsetTop=height/2>230?height/2:230;var offsetBottom=50;var magnet=$(document.createElement("div"));var randX=
parseInt(Math.random((new Date).getTime())*(width-offsetLeft-offsetRight))+offsetLeft;var randY=parseInt(Math.random((new Date).getMilliseconds())*(height-offsetTop-offsetBottom))+offsetTop;var randFg=Math.floor(Math.random((new Date).getSeconds())*(51-5)+16).toString(16);var randColorFg="#"+randFg+randFg+randFg;var randBg,randColorBg,randBgR,randBgG,randBgB;if(!highlight){randBg=Math.floor(Math.random((new Date).getMilliseconds())*(255-222)+222).toString(16);randColorBg="#"+randBg+randBg+randBg}else{randBgR=
Math.floor(Math.random((new Date).getTime())*(255-204)+204).toString(16);randBgG=Math.floor(Math.random((new Date).getMilliseconds())*(255-204)+204).toString(16);randBgB=Math.floor(Math.random((new Date).getSeconds())*(255-204)+204).toString(16);randColorBg="#"+randBgR+randBgG+randBgB}magnet.text(word).addClass(MAGNET_CLASS);magnet.css("left",randX+"px");magnet.css("top",randY+"px");magnet.css("background-color",randColorBg);magnet.css("color",randColorFg);magnet.css("position","absolute");$("#"+
MAGNET_CONTAINER).append(magnet)}function _reset(){$("#"+MAGNET_CONTAINER).html(_originalLayout);$("."+MAGNET_CLASS).draggable({stack:"."+MAGNET_CLASS})}function _toolbar(){$("#toolbar-save").button({icons:{primary:"ui-icon-disk"}}).click(function(){_save()});$("#toolbar-reset").button({icons:{primary:"ui-icon-arrowrefresh-1-w"}}).click(function(){if(confirm("Seriously?"))_reset()});$("#toolbar-latest").button({icons:{primary:"ui-icon-arrowstop-1-e"}}).click(function(){$.post("/api/latest",function(data){window.location=
"/"+data})});$("#toolbar-home").button({icons:{primary:"ui-icon-home"}}).click(function(){window.location="/-"});$("#toolbar-random").button({icons:{primary:"ui-icon-lightbulb"}}).click(function(){$.post("/api/random",function(data){window.location="/"+data})});$("#toolbar-filter").button({icons:{primary:"ui-icon-search"},text:false});$("#toolbar-clear").button({icons:{primary:"ui-icon-close"},text:false}).click(function(){$("#toolbar-filter-text").val("");$(".magnet").each(function(){$(this).fadeTo(0,
1)})});$("#toolbar-filter-text").keyup(function(e){var filter=$(this).val();if(e.keyCode==27){filter="";$(this).val("")}if(e.keyCode==8)$(".magnet").each(function(){$(this).fadeTo(0,1)});if(filter.length>0)$(".magnet").each(function(){var magnet=$(this);if(magnet.html().indexOf(filter)!=0){magnet.fadeTo(0,0.25);magnet.css("z-index","-1")}else magnet.css("z-index","1")});else $(".magnet").each(function(){$(this).fadeTo(0,1)})});$("#toolbar-open").button({icons:{primary:"ui-icon-triangle-1-e"},text:false}).click(function(){$("#toolbar button, #toolbar input").css("display",
"inline");$("#toolbar-open").css("display","none")});$("#toolbar-close").button({icons:{primary:"ui-icon-triangle-1-w"},text:false}).click(function(){$("#toolbar button, #toolbar input").css("display","none");$("#toolbar-open").css("display","inline")});$("#toolbar button, #toolbar input").css("display","none");$("#toolbar-open").css("display","inline")}function _save(){var previousId=window.location.pathname.replace(/\//gi,"");var message=$("#"+MAGNET_CONTAINER).html();$("#toolbar-save").button("option",
"label","Saving...");$.post("/api/save",{previousId:previousId,message:message},function(data){window.location="/"+data})}return{reset:_reset,save:_save,init:function(alreadyLoaded){_toolbar();_setupMagnets(alreadyLoaded)}}}();
