var JsWordyClock=function(a,b){if(!a||typeof a!=="object"){throw new Error("You need to supply an HTML element for me to append the clock to");}this.element=a;this.fontsize=b;this.FACE_STYLE="#ddd";this.CLOCK_STYLE="#000";this.init();};JsWordyClock.prototype.init=function(){this.createElements();var a=this.getTime();this.hoursAndMinutes=this.roundToClosest5Minutes(a[0],a[1]);var c=this.convertToWords(this.hoursAndMinutes[0],this.hoursAndMinutes[1]);this.attachedFormattedText(this.clock,this.blankOutTargetFromBase(c.toUpperCase(),this.clockFace),this.CLOCK_STYLE);var b=this;setTimeout(function(){b.refresh();},60000);};JsWordyClock.prototype.getTime=function(){var c=new Date();var a=c.getHours();var b=c.getMinutes();return[a,b];};JsWordyClock.prototype.attachedFormattedText=function(b,c,a){if(b.tagName=="PRE"&&"outerHTML" in b){b.outerHTML='<PRE id="face" style="position:absolute;margin:0;">'+c+"</PRE>";var b=document.getElementById("face");b.id="";this.addStyle(b,a);}else{b.innerHTML=c;}if(!this.element.style.minHeight){this.element.style.minHeight=b.offsetHeight+"px";}};JsWordyClock.prototype.addStyle=function(b,a){b.style.position="absolute";b.style.margin=0;b.style.color=a;};JsWordyClock.prototype.createElements=function(){this.element.style.fontFamily="monospace";this.element.style.fontSize=this.fontsize||"1em";var a=document.createElement("pre");this.addStyle(a,this.FACE_STYLE);this.element.appendChild(a);this.attachedFormattedText(a,this.clockFace,this.FACE_STYLE);this.clock=document.createElement("pre");this.addStyle(this.clock,this.CLOCK_STYLE);this.element.appendChild(this.clock);};JsWordyClock.prototype.refresh=function(){var b=this.getTime();var a=this.roundToClosest5Minutes(b[0],b[1]);if(a!=this.hoursAndMinutes){this.clock.innerHTML="";var d=this.convertToWords(a[0],a[1]);this.attachedFormattedText(this.clock,this.blankOutTargetFromBase(d.toUpperCase(),this.clockFace));}var c=this;setTimeout(function(){c.refresh();},60000);};JsWordyClock.prototype.clockFace="ITLISXABOUT\nACQUARTERDC\nTWENTYRFIVE\nHALFBTENFTO\nPASTEXSNINE\nONESIXTHREE\nFOURFIVETWO\nEIGHTELEVEN\nTENMIDNIGHT\nSEVENTYNOON";JsWordyClock.prototype.minuteNameLookup={0:"",5:"five past ",10:"ten past ",15:"a quarter past ",20:"twenty past ",25:"twenty five past ",30:"half past ",35:"twenty five to ",40:"twenty to ",45:"a quarter to ",50:"ten to ",55:"five to "};JsWordyClock.prototype.hourNameLookup={0:"midnight",1:"one",2:"two",3:"three",4:"four",5:"five",6:"six",7:"seven",8:"eight",9:"nine",10:"ten",11:"eleven",12:"noon",13:"one",14:"two",15:"three",16:"four",17:"five",18:"six",19:"seven",20:"eight",21:"nine",22:"ten",23:"eleven",24:"midnight"};JsWordyClock.prototype.roundToClosest5Minutes=function(a,b){var c=Math.round(b/5)*5;if(c===60){return[(a+1),0];}else{return[a,c];}};JsWordyClock.prototype.convertToWords=function(b,c){if(c>30){b=b+1;}var a="it is about "+(c?this.minuteNameLookup[c]:"")+this.hourNameLookup[b];return a;};JsWordyClock.prototype.convertToRegex=function(d){var c=d.split(" ");for(var b=0,a=c.length;b<a;b++){c[b]="("+c[b]+")";}return new RegExp("[\\s\\S]*"+c.join("[\\s\\S]*")+"[\\s\\S]*");};JsWordyClock.prototype.blankOutTargetFromBase=function(h,l){var c=this.convertToRegex(h);var m=l.replace(/./g," ");var e=l.match(c);var f=m.split("");var k="";var a=0;for(var d=1,b=e.length-1;d<=b;d++){var g=l.indexOf(e[d],a);k+=f.slice(a,g).join("");k+=e[d];a=g+e[d].length;}k+=f.slice(a,f.length).join("");return k;};
