var clip=new ZeroClipboard.Client(),filler=[""],titles={"Edgar Rice Burroughs":["A Princess of Mars","At the Earth's Core"],"Herman Melville":["Moby-Dick"],"L. Frank Baum":["The Wizard of Oz"],"H. G. Wells":["The War of the Worlds Bk 1"],"Jules Verne":["Around the World in 80 Days"],"Lewis Carroll":["Alice in Wonderland"],"Jack London":["The Scarlet Plague"]},authors=["L. Frank Baum","Edgar Rice Burroughs","Lewis Carroll","Jack London","Herman Melville","Jules Verne","H. G. Wells"],paras={"prncssfmrs":933,"mbydck":2301,"tthrthscr":664,"thwzrdfz":1003,"thwrfthwrldsbk1":584,"rndthwrldn80dys":1504,"thcllfthwld":231,"lcnwndrlnd":658,"thscrltplg":165},paranum,onbar=false,refreshing=false,scale={"p":{"n":76,"u":"paragraph","mx":10,"d":1},"h":{"n":7.53,"u":"word","mx":100,"d":15},"li":{"n":15.3,"u":"sentence","mx":50,"d":5},"t":{"n":1,"u":"word","mx":750,"d":100}},t="p",cscale=76,mx=10,newtxt,txtfiller,headsize=1,copymessage=false,langok=false,$GDL={'en':'English','ar':'\u202B\u0627\u0644\u0639\u0631\u0628\u064A\u0629\u202C','bg':'\u202A\u0431\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438\u202C','ca':'\u202ACatal\u00E0\u202C','hr':'\u202AHrvatski\u202C','cs':'\u202A\u010De\u0161tina\u202C','da':'\u202ADansk\u202C','nl':'\u202ANederlands\u202C','fi':'\u202ASuomi\u202C','fr':'\u202AFran\u00E7ais\u202C','de':'\u202ADeutsch\u202C','el':'\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC','iw':'\u202B\u05E2\u05D1\u05E8\u05D9\u05EA\u202C','hi':'\u202A\u0939\u093F\u0902\u0926\u0940\u202C','it':'Italiano','ko':'\u202A\uD55C\uAD6D\uC5B4\u202C','lv':'\u202ALatvie\u0161u\u202C','lt':'\u202ALietuvi\u0173\u202C','no':'\u202ANorsk bokm\u00E5l\u202C','pl':'Polski','pt':'\u202APortugu\u00EAs\u202C','ro':'\u202ARom\u00E2n\u0103\u202C','ru':'\u202A\u0420\u0443\u0441\u0441\u043A\u0438\u0439\u202C','sr':'\u202A\u0421\u0440\u043F\u0441\u043A\u0438\u202C','sk':'\u202ASlovensk\u00FD\u202C','sl':'\u202ASloven\u0161\u010Dina\u202C','es':'\u202AEspa\u00F1ol\u202C','sv':'Svenska','uk':'\u202A\u0443\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430\u202C','vi':'\u202ATi\u1EBFng Vi\u1EC7t\u202C'},lang="en",enfiller,$s=$.shortcut({"dbarf":"#dbarf","ta":"textarea","qty":"#dbar>p","units":"#units","max":"#max","pview":"#preview","random":"#random","refresh":"#refresh","lih":"li.h","c2c":"#c2c","c2cp":"_c2c_ p","c2cm":"_c2c_ em","authtitle":"#auth_title","alist":"#alist","tlist":"#tlist","tlistul":"_tlist_ ul","author":"_authtitle_ .auth>a","title":"_authtitle_ .title>a","chptrs":"#chptrs","langlnk":"#chptrwrap>span","langs":"#langs","gbrand":"#gBrandingText"},"$",this);function getFiller(A,B){var A=A||$s.title.text().replace(/[aeiou\W]/gi,"").toLowerCase(),B=B||Math.floor(Math.random()*paras[A]);$s.pview.empty().addClass("loading");$.ajax({type:"GET",url:"/json/getpara",data:{"b":A,"c":B},dataType:"json",success:function(C){if(C==null||(C&&C.status&&C.status=="error")){return false}else{filler=C.p;enfiller=filler;if($("#tags li.on").text()!=="p"){txtfiller=filler.join(" ").split($("#tags li.on").text()==="li"?".":" ")}if(lang!=="en"){translate(lang)}else{setPview(scale[t].d)}$s.chptrs.text(C.ch[0]+(C.ch.length>1?(" - "+C.ch[1]):""));paranum=B;refreshing=false}}})}if(localStorage&&localStorage.fillerati){try{var locdata=localStorage.fillerati,tmphtml="";locdata=JSON.parse(locdata);filler=locdata.filler;$s.author.text(locdata.author);$s.title.text(locdata.title);paranum=locdata.paranum;getFiller(locdata.title.toLowerCase().replace(/[aeiou\W]/gi,""),paranum);$s.random.add($s.refresh).removeClass("on");$.each(titles[locdata.author],function(B,A){tmphtml+="<li><a>"+A+"</a></li>"});$s.tlistul.html(tmphtml)}catch(e){delete localStorage["fillerati"];getFiller()}}else{getFiller()}$("#tags li").click(function(){t=$(this).addClass("on").siblings().removeClass("on").end().text();cscale=scale[t].n;mx=scale[t].mx;$s.units.text(scale[t].u);$s.max.text(mx);$s.qty.text(scale[t].d);if(t!=="p"){txtfiller=filler.join(" ").split(t==="li"?".":" ")}setPview(scale[t].d)});$("body").bind("mousemove",function(C){if(onbar){var B=C.pageX-$s.dbarf.parent()[0].offsetLeft,A=Math.ceil((B)/cscale);if(B<10){$s.c2cm.css("left",(15+(10-B))+"px")}A=A<1?1:A>mx?mx:A;setPview(A);$s.c2c.css({"left":(C.pageX-30)+"px"}).show();if(!copymessage){$s.c2cp.text("Click to Copy")}}else{$s.c2c.hide()}});function setPview(B){$s.units.text(B===1?scale[t].u:scale[t].u+"s");var A=t,A=t==="h"?A+"1":A;iotag=otag=t==="t"?"":"<"+A+">",ictag=ctag=t==="t"?"":"</"+A+">",spacer=t==="t"?" ":"\n\n";if(t==="h"){spacer=" ";iotag=ictag="";otag="<h"+headsize+">";ctag="</h"+headsize+">"}newtxt=(t==="p"?filler:txtfiller).slice(0,B).join(ictag+spacer+iotag);newtxt=otag+newtxt+ctag;clip.setText(newtxt);$s.qty.text(B);$s.pview.html(newtxt).removeClass("loading")}clip.setHandCursor(true);clip.addEventListener("mouseOver",function(A){onbar=true;$s.c2cm.css("left","15px")});clip.addEventListener("mouseOut",function(A){onbar=false});clip.addEventListener("mouseUp",function(A){copymessage=true;$s.c2cp.text("Copied!");setTimeout(function(){copymessage=false},1000)});clip.glue("dbarf","dbar");$s.random.click(function(){$s.random.add($s.refresh).toggleClass("on");if(!$s.random.is(".on")){localStorage.fillerati=JSON.stringify({"author":$s.author.text(),"title":$s.title.text(),"paranum":paranum,"filler":filler})}else{delete localStorage["fillerati"]}});$s.refresh.click(function(){if($s.refresh.is(".on")&&!refreshing){var B=authors[Math.floor(Math.random()*(authors.length))],A="";$s.author.text(B);$s.title.text(titles[B][Math.floor(Math.random()*(titles[B].length))]);refreshing=true;getFiller();$.each(titles[B],function(D,C){A+="<li><a>"+C+"</a></li>"});$s.tlistul.html(A)}});$s.lih.mousewheel(function(A,B){changeHeadSize(B);return false});$("#up,#down").click(function(A){changeHeadSize(({"up":1,"down":0})[A.target.id])});function changeHeadSize(A){if(A>0){headsize+=headsize<6?1:0}else{headsize-=headsize<2?0:1}$s.lih[0].className="h h"+headsize}$s.authtitle.click(function(A){A=$(A.target);A=A.is("div,a")?A.parents("dd:first"):A;if(A.is(".auth")){$s.tlist.hide();if($s.alist.is(":hidden")){$s.alist.find("a:contains("+$s.author.text()+")").parent().addClass("current").siblings().removeClass("current");$s.alist.css({"left":((A.position().left+A[0].offsetWidth)-$s.alist.width())+"px","top":(A.position().top+A.height())+"px"}).hide().fadeIn()}else{$s.alist.fadeOut("fast")}}else{if(A.is(".title")){$s.alist.hide();if($s.tlist.is(":hidden")){$s.tlist.find("a:contains("+$s.title.text()+")").parent().addClass("current").siblings().removeClass("current");$s.tlist.css({"left":((A.position().left+A[0].offsetWidth)-$s.tlist.width())+"px","top":(A.position().top+A.height())+"px"}).hide().fadeIn()}else{$s.tlist.fadeOut("fast")}}else{$s.alist.hide();$s.tlist.hide()}}});$s.alist.click(function(B){B=$(B.target);B=B.is("a")?B:B.find("a");if(B.length>0){var A="";$s.author.text(B.text());$s.title.text(titles[B.text()][0]);$s.alist.fadeOut("fast");$.each(titles[B.text()],function(D,C){A+="<li><a>"+C+"</a></li>"});$s.tlistul.html(A);$s.tlist.fadeOut("fast");getFiller(titles[B.text()][0].toLowerCase().replace(/[aeiou\W]/gi,""))}}).mouseleave(function(){$s.alist.fadeOut("fast")});$s.tlist.click(function(A){A=$(A.target);A=A.is("a")?A:A.find("a");if(A.length>0){if(!A.parent().hasClass("current")){$s.title.text(A.text());$s.tlist.find("a:contains("+$s.title.text()+")").parent().addClass("current").siblings().removeClass("current");$s.tlist.fadeOut("fast");getFiller(A.text().toLowerCase().replace(/[aeiou\W]/gi,""))}}}).mouseleave(function(){$s.tlist.fadeOut("fast")});for(var i=2;i<7;i++){var img=new Image();img.src="/images/h"+i+".png"}$s.langlnk.click(function(){window.alert('Sorry, no translations until I update to the new Google Translate API!');return false;$s.langs[$s.langs.is(":visible")?"fadeOut":"fadeIn"]("fast")});$s.langs.click(function(B){var A=$(B.target).closest("li")[0];$s.langlnk.text($GDL[A.id]).addClass("lngload");translate(A.id);$s.langs.fadeOut("fast");if(A.id!=="en"){$.getScript("/lang/"+A.id)}});function langinit(){for(l in google.language.Languages){var A=(l.length>0)?l.substring(0,1)+l.substring(1).toLowerCase():"",B=google.language.Languages[l];if(google.language.isTranslatable(B)&&B!=""&&A.indexOf("_")==-1&&$GDL[B]){$("#langs>ul").append("<li id=\""+B+"\"><a>"+($GDL[B]||A)+"</a></li>")}}}var transobj={},count=0,transfiller=[];function preflight(){transobj={};$.each(enfiller||filler,function(B,C){count+=1;if(C.length>15){C=C.split(". ");var A=C.slice(0,Math.floor(C.length/2)),D=C.slice(Math.floor(C.length/2));transobj[count+""]={"t":A.join(". ")};count+=1;transobj[count+""]={"t":D.join(". "),"p":true}}else{transobj[count+""]={"t":C}}});return transobj}function translate(B){lang=B;if(B==="en"){filler=enfiller;txtfiller=filler.join(" ").split(t==="li"?".":" ");setPview(scale[t].d);$s.langlnk.removeClass("lngload");$s.gbrand.fadeOut()}else{transfiller=[];enfiller=enfiller||filler;var A=0;preflight();$.each(transobj,function(C,D){D.o=parseInt(C);google.language.translate(D.t,"en",B,function(E){A+=1;if(!E.error){D.ot=D.t;D.t=E.translation;transfiller.push(D);if(transfiller.length==count){count=0;setFiller()}}else{transfiller.push(D);if(transfiller.length==count){count=0;setFiller()}}})})}}function setFiller(){var A=transfiller.sort(function(D,C){var B=D.o,E=C.o;return((B<E)?-1:((B>E)?1:0))});filler=[];$.each(A,function(B,C){if($.trim(C.t)!=""){if(C.p){filler[filler.length-1]+=". "+C.t}else{filler.push(C.t)}}});txtfiller=filler.join(" ").split(t==="li"?".":" ");$s.langlnk.removeClass("lngload");setPview(scale[t].d);$s.gbrand.fadeIn()}
