Array.prototype.swap=function(a,b){var x=this[a];this[a]=this[b];this[b]=x;return this;} Array.prototype.inArray=function(a){for(var x=0;x1?r:r[0] } function addEvent(obj,att,set){ var atts=att+'s' if(!obj[atts]) { obj[atts]=Array(); if(obj[att])obj[atts].push(obj[att]); obj[att]=function(e){for(var x=0;x12?"pm":"am" dstr=old.getDate()+' '+old.getMonth()+' '+old.getFullYear() hours%=12 hours=hours||12 delta=(now-old)/1000 if (delta<90) fmt="a minute ago"; else if (delta<3600) fmt=Math.round(delta/60)+" minutes ago"; else if (now.getDate()+' '+now.getMonth()+' '+now.getFullYear()==dstr) fmt="Today @ "+hours+':'+JAX.prepad(mins,2)+' '+ampm; else if (yday.getDate()+' '+yday.getMonth()+' '+yday.getFullYear()==dstr) fmt="Yesterday @ "+hours+':'+JAX.prepad(mins,2)+' '+ampm; else fmt=months[old.getMonth()]+" "+old.getDate()+", "+old.getFullYear()+" @ "+hours+':'+JAX.prepad(mins,2)+' '+ampm; return fmt; } this.prepad=function(st,len,chr){ st=st.toString() if(!chr) chr='0' var l=st.length for(var x=0;x=1&&typeof sindex!='undefined'){ JAX.el.removeClass(els[sindex],'selected') JAX.el.addClass(els[sindex-1],'selected') } else if (e.DOWN&&l&&(sindexmax) max=Number(a[x].style.zIndex) return max+1 } } /********************************************************************/ this.SWF=function(url,name,settings){ url+='?'+(new Date).valueOf() var object,embed,x,s={width:'100%',height:'100%',quality:'high'} for(x in settings) s[x]=settings[x]; object=''; embed=''; embed+=' '+x+'="'+s[x]+'"' } embed+='>'; object+='' var tmp=document.createElement('span');tmp.innerHTML=JAX.browser.ie?object:embed; return tmp.getElementsByTagName("*")[0] } /********************************************************************/ this.color=function(a){ if(this==JAX) return new JAX.color(a) var tmp,x if(a.charAt&&a.charAt(0)=="#") a=a.substr(1) //RGB if (typeof a=="object") this.rgb=a else if (a.match&&(tmp=a.match(/^rgb\((\d+),\s?(\d+),\s?(\d+)\)/i))) { tmp[1]=parseFloat(tmp[1]);tmp[2]=parseFloat(tmp[2]);tmp[3]=parseFloat(tmp[3]); tmp.shift();this.rgb=tmp; //HEX } else if(a.match&&!a.match(/[^\da-fA-F]/)){ if (a.length==3) a=a.charAt(0)+a.charAt(0)+a.charAt(1)+a.charAt(1)+a.charAt(2)+a.charAt(2) if (a.length!=6) this.rgb=[0,0,0] else {this.rgb=[];for(x=0;x<3;x++) this.rgb[x]=parseInt(a.substr(x*2,2),16);} } else this.rgb=[0,0,0] this.toRGB=function(){return this.rgb;} this.toHex=function(){ if (!this.rgb) return false var tmp2,tmp="",x,hex="0123456789ABCDEF" for(x=0;x<3;x++) { tmp2=this.rgb[x] tmp+=hex.charAt(Math.floor(tmp2/16))+hex.charAt(Math.floor(tmp2%16)) } return tmp } return this }, /********************************************************************/ this.sfx=function(el,steps,delay,loop){ var tmp,x,y,me=this if(JAX==me) me={} me.el=el;me.steps=steps||30;me.delay=delay||20;me.stepCount=me.curLineup=0;me.loop=loop||0; me.lineup=[[]] me.play=function(){ me.interval=setInterval(function(){me.step();},me.delay) return this } me.morph=function(from,percent,to){ var x,r if (JAX.isArray(from)&&from.length==to.length) {r=[];for(x=0;xme.curLineup) { me.stepCount=0 me.curLineup++ } else if (me.loop==1) { me.stepCount=me.curLineup=0 } else clearInterval(me.interval); } } me.add=function(what,from,to){ var t=['','',''] if(what.match(/color/i)) {from=JAX.color(from).toRGB();t[1]=JAX.color(to).toRGB();} else {(t=to.match(/(\D*)(\-?\d+)(\D*)/)).shift();from=parseFloat(from.match(/\-?\d+/));} me.lineup[me.lineup.length-1].push([what,from,t[1],t[0],t[2]]); return this } me.dehighlight=function(){ me.el.style.backgroundColor='' var bg=JAX.el.getComputedStyle(me.el).backgroundColor.toString(),bg2 JAX.el.addClass(me.el,"highlight"); bg2=JAX.el.getComputedStyle(me.el).backgroundColor.toString() if(bg2==bg) bg2='FF0' JAX.el.removeClass(me.el,"highlight"); return me.add('backgroundColor',bg2,bg).then(function(){me.el.style.backgroundColor=bg;}) } me.then=function(what,from,to,steps){ this.lineup.push([]) if (steps) this.steps=steps if(typeof what=="function") { this.lineup[me.lineup.length-1].push(what) } else { this.add(what,from,to) } return this } return me } /********************************************************************/ this.editor=function(textarea,iframe){ if(iframe.editor) return; var me={} me.iframe=iframe iframe.editor=me iframe.className="editorframe" me.mode=1 //1 for html editing mode, 0 for textarea mode me.textarea=textarea me.window=iframe.contentWindow me.doc=iframe.contentWindow.document me.doc.designMode='on' me.buildEditBar=function(){ me.editbar.className="editbar" var cmds=['bold','italic','underline','forecolor','backcolor','insertimage','createlink', 'c_email','justifyleft','justifycenter','justifyright','c_youtube', 'c_code','c_quote','c_spoiler','insertorderedlist','insertunorderedlist', 'c_smileys','c_switcheditmode'], cmddesc=['Bold','Italic','Underline','Foreground Color','Background Color','Insert Image','Insert Link', 'Insert email','Align left','Center','Align right','Insert video from youtube', 'Insert code','Insert Quote','Insert Spoiler','Create Ordered List','Create Unordered List', 'Insert Emoticon','Switch editor mode'], l=cmds.length,a,x for(x=0;x'+selection+'' bbcode="[bgcolor="+b+"]"+selection+"[/bgcolor]" break; case "c_code": a="inserthtml";bbcode=b='[code]'+selection+'[/code]' break; case "c_quote": a="inserthtml"; b=prompt("Who said this?"); b=bbcode='[quote'+(b?'='+b:'')+']'+selection+'[/quote]' break; case "c_spoiler": a="inserthtml"; b=bbcode='[spoiler]'+selection+'[/spoiler]' break; case "c_youtube": a="inserthtml"; b=prompt("Youtube URL?"); if(!b) return; b=bbcode="[youtube]"+b+"[/youtube]"; break; case "inserthtml": bbcode=b break; } if(me.mode) { if(a=="inserthtml"&&JAX.browser.ie) { rng=me.doc.selection.createRange() if(!rng.text.length) me.doc.body.innerHTML+=b else { rng.pasteHTML(b) rng.collapse(false) rng.select() } } else me.doc.execCommand(a,false,b||false) } else me.setSelection(bbcode) } me.getSelection=function(){ if(me.mode) return JAX.browser.ie?me.doc.selection.createRange().text:me.window.getSelection(); else { if(JAX.browser.ie) { me.textarea.focus() return document.selection.createRange().text } else { return me.textarea.value.substring(me.textarea.selectionStart,me.textarea.selectionEnd) } } } me.setSelection=function(stuff){ if(me.mode) return; if(JAX.browser.ie) { me.textarea.focus() document.selection.createRange().text=stuff } else { var s=me.textarea.selectionStart,e=me.textarea.selectionEnd,t=me.textarea t.value=t.value.substring(0,s)+stuff+t.value.substr(e) } } me.getSource=function(){ return me.doc.body.innerHTML; } me.setSource=function(a){ if(me.doc&&me.doc.body) me.doc.body.innerHTML=a } me.setSource("
") me.BBtoHTML=function(a){ a=a.replace(//g,">") a=me.replaceAll(a,/\n/g,"
"); a=me.replaceAll(a,/\[(b|i|u)\]([\w\W]*?)\[\/\1\]/ig,"<$1>$2") a=me.replaceAll(a,/\[img\]([^'"]+)\[\/img\]/ig,'') a=me.replaceAll(a,/\[color=([^\]]+)\](.*?)\[\/color\]/ig,'$2') a=me.replaceAll(a,/\[size=([^\]]+)\](.*?)\[\/size\]/ig,'$2') a=me.replaceAll(a,/\[url=([^\]]+)\](.*?)\[\/url\]/ig,'$2') a=me.replaceAll(a,/\[(ul|ol)\]([\w\W]*?)\[\/\1\]/ig,function(s){ var tag=RegExp.$1,lis="",list=RegExp.$2.split(/([\r\n]|^)\*/),x; for(x=0;x' return '<'+tag+'>'+lis+''; }) return a } me.replaceAll=function(a,b,c){ var tmp=a do{ a=tmp tmp=a.replace(b,c) } while(a!=tmp) return tmp } me.HTMLtoBB=function(a){ a=a.replace(/]*>/ig,"\n") a=a.replace(//g,"[img]$1[/img]"); a=me.replaceAll(a,/<(span|b|strong|p|i|em|u|font|a|ol|ul|li|br|div|img)([^>]*)>([\w\W]*?)<\/\1>/ig,function(whole,tag,attributes,innerhtml){ var att={},style='' attributes.replace(/(color|size|style|href|src)=(['"]?)(.*?)\2/gi,function(whole,attr,q,value){att[attr]=value}); if(att.style) style=att.style tag=tag.toLowerCase() if(style.match(/background(\-color)?:[^;]+(rgb\([^\)]+\)|#\s+)/i)) innerhtml="[bgcolor=#"+(new JAX.color(RegExp.$2)).toHex()+"]"+innerhtml+"[/bgcolor]" if(style.match(/text\-align: ?(right|center|left);/i)) innerhtml="[align="+RegExp.$1+"]"+innerhtml+"[/align]" if(style.match(/font\-style: ?italic;/i)||tag=="i" ||tag=="em") innerhtml="[I]"+innerhtml+"[/I]" if(style.match(/text\-decoration: ?underline;/i) ||tag=="u") innerhtml="[U]"+innerhtml+"[/U]" if(style.match(/font\-weight: ?bold;/i)||tag=="strong"||tag=="b") innerhtml="[B]"+innerhtml+"[/B]" if(att.size||style.match(/font\-size: ?([^;]+)/i)) innerhtml='[size='+(att.size||RegExp.$1)+']'+innerhtml+'[/size]' if(att.color||style.match(/color: ?([^;]+)/i)) innerhtml="[color=#"+(new JAX.color(att.color||RegExp.$1).toHex())+']'+innerhtml+'[/color]' if(tag=="a"&&att.href) innerhtml='[url='+att.href+']'+innerhtml+'[/url]' if(tag=="ol") innerhtml="[ol]"+innerhtml+"[/ol]" if(tag=="ul") innerhtml="[ul]"+innerhtml+"[/ul]" if(tag=="li") innerhtml='*'+innerhtml.replace(/[\n\r]+/,'')+"\n" if(tag=="p") innerhtml=(innerhtml==" "?"":innerhtml)+"\n" return innerhtml }) return a.replace(/>/g,">").replace(/&/g,"&").replace(/</g,"<").replace(/ /g," ") } me.switchMode=function(toggle){ var t=me.textarea,f=me.iframe if(!toggle){ t.value=me.HTMLtoBB(me.getSource()) t.style.display='' f.style.display='none' } else { me.setSource(me.BBtoHTML(t.value)) t.style.display='none' f.style.display='' } me.mode=toggle } me.submit=function(){ if(me.mode) {me.switchMode(0);me.switchMode(1);} } me.switchMode(me.mode) return me } /********************************************************************/ this.scrollTo=function(pos,el){ //make this animate/not animate later based on preferences var dB=document.body, el=el||(JAX.browser.chrome?dB:dE), screenrel=parseFloat(dB.clientHeight)-parseFloat(dE.clientHeight), top=parseFloat(el.scrollTop), pos=screenrel=me.steps) {clearInterval(me.interval);me.onend();} },30) me.then=function(a){ me.onend=a } return me } /********************************************************************/ this.drag=function(){ var me=this; me.priv={ start:function(e,t,handle){ e=(new JAX.event(e)).cancel().stopBubbling();var el=t||this,s=JAX.el.getComputedStyle(el),highz=JAX.el.getHighestZIndex() if(me._nochild&&(e.srcElement||e.target)!=(handle||el)) return; if(el.getAttribute('draggable')=="false") return me.sess={el:el,mx:parseInt(e.pageX),my:parseInt(e.pageY),ex:parseInt(s.left)||0,ey:parseInt(s.top)||0,info:{},bc:JAX.el.getCoordinates(el)} me.sess.zIndex=el.style.zIndex; if(!me.sess.zIndex||Number(me.sess.zIndex)<(highz-1)) el.style.zIndex=highz if(typeof me.onstart=='function'){ var sess=me.sess sess.droptarget=me.priv.testdrops(sess.mx,sess.my); me.onstart(sess) } document.onmousemove=me.priv.drag;me.priv.drag(e); document.onmouseup=me.priv.drop; }, drag:function(e){ e=(new JAX.event(e)).cancel(); var s=me.sess.el.style,sess,tmp=false,tx,ty,tmp2 var tx,ty,mx=tx=parseInt(e.pageX),my=ty=parseInt(e.pageY),left=me.sess.ex+mx-me.sess.mx,top=me.sess.ey+my-me.sess.my,b=me.bounds if(b){if(leftb[0]+b[2])left=b[0]+b[2]; if(topb[1]+b[3])top=b[1]+b[3];} s.left=left+"px";s.top=top+"px"; tmp=JAX.el.getCoordinates(me.sess.el) if(me.useElCoord){tx=tmp.x;ty=tmp.y;} tmp=(sess=me.sess.info).droptarget; me.sess.info=sess={left:left,top:top,e:e,el:me.sess.el,mx:mx,my:my,droptarget:me.priv.testdrops(tx,ty),dx:mx-(sess.mx||mx),dy:my-(sess.my||my),self:me,sx:me.sess.ex,sy:me.sess.ey}; if(typeof me.ondrag=='function')me.ondrag(sess) if(typeof me.ondragover=='function'&&sess['droptarget']&&tmp!=sess['droptarget'])me.ondragover(sess) if(typeof me.ondragout=='function'&&tmp&&sess['droptarget']!=tmp){tmp2=sess['droptarget'];sess['droptarget']=tmp;me.ondragout(sess);sess['droptarget']=tmp2;} }, drop:function(){ document.onmousemove=document.onmouseup=function(){} if(typeof me.ondrop=='function')me.ondrop(me.sess.info) if(!me._autoz) me.sess.el.style.zIndex=me.sess.zIndex; return true }, testdrops:function(a,b){ var x,d=me.droppables,z,r=false,max=[9999,9999] if (!d) return r for(x=0;xz.w&&max[1]>z.h&&a>=z.x&&b>=z.y&&a<=z.xw&&b<=z.yh){max=[z.w,z.h];r=d[x];} } return r } } me.drops=function(a){this.droppables=a;return this;} me.addDrops=function(a){if(!this.droppables) {return this.drops(a);} this.droppables=this.droppables.concat(a);return this;} me.addListener=function(a){extend(this,a);return this;} me.apply=function(el,t){var x;if(el[0]){for(x=0;x=index;x--) { if(a.el==d[x])continue; c=me.coords[x] if((ov?a.my>c.y&&a.dy>0:a.mx>c.x&&a.my>c.y)) {JAX.el.insertAfter(a.el,d[x]);if(d.swap)me.elems=d.swap(index,x);ch=1;break;} }} else if (d.swap)me.elems=d.swap(index,ch); if(ch!==false){me.coords=[];me.change=1;c2=JAX.el.getCoordinates(a.el);me.sess.ex-=(c2.x-cel.x);me.sess.ey-=(c2.y-cel.y);me.priv.drag(a.e);} return false } for(var x=0;x0&&(s+b)2)) for(x=0;x