Post by ⓦ৹₪deⓡ on Oct 10, 2005 18:09:54 GMT -8
This code will add this button or the image of your choosing to the standard ProBoards UBBC buttons. What this new button does is add an expiration date to whatever text you have selected. You choose the date and after that date, the text within the expiration tags will no longer be displayed and will be replaced with whatever text you specify in the code. Edit where indicated in the Global Footer. Do NOT PM me for support or requests. Thats what the coding boards are for. Enjoy.
~Wonder
Top of Global Header
~Wonder
Top of Global Header
<script>
//Expiration Date UBBC Tag v1.0 [CB]
//Copyright 10-10-2005 by ~Wonder
//May be reposted anywhere as long as this header remains in tact
//Put at Top of Global Header
function getDate(d)
{
ty="";
if(ty=d.match(/(To|Yester)day/i)){d=document.getElementsByTagName("table")[0].innerHTML.match(/\.<br>.+ \d{1,2}\:/i)[0].replace(/\d{1,2}:/,"")+d.match(/( \d{1,2}\:\d{2}(a|pm)?)/);}
months=new Array("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");te=0;
curDate=d.match(/.+ (\d{1,2}\:\d{2}(a|pm)?)/i)[0];
time=RegExp.$1;dm=0;
curDate=curDate.toLowerCase().replace(/\.<br>/i,"").replace(time,"").replace(/ at /i,"").replace(/,/g,"").replace(/\.|\-|\//g," ").split(" ");
time=time.split(":");
if(time[1].match(/am/) && time[0].match(/12/)){time[0]=parseInt(time[0],10)-12;}
if(time[1].match(/pm/) && !time[0].match(/12/)){time[0]=parseInt(time[0],10)+12;}time[1]=time[1].replace(/[^\d]/g,"");
for(k=0;k<12;k++){if(curDate[0].match(months[k]) || curDate[1].match(months[k])){break;}}
if((t=curDate[0].match(months[k]))!=null && t!=""){curDate[0]=(k+1)+"";te=1;}else if((t=curDate[1].match(months[k]))!=null && t!=""){curDate[1]=(k+1)+"";temp2=curDate[1];curDate[1]=curDate[0];curDate[0]=temp2;te=1;}
curDate[0]=curDate[0].replace(/[^\d]/g,"");curDate[1]=curDate[1].replace(/[^\d]/g,"");
if(parseInt(curDate[0],10)>12){temp2=curDate[1];curDate[1]=curDate[0];curDate[0]=temp2;}
if(parseInt(curDate[1],10)<13 && te==0){now = new Date();if(parseInt(curDate[1],10)==(now.getMonth()+1)){temp2=curDate[1];curDate[1]=curDate[0];curDate[0]=temp2;}}
if(curDate[2].length<=2){curDate[2]=parseInt(curDate[2],10)+2000;}if(ty!=null && ty[0].match(/yesterday/i)){dm=1;}
return new Date(parseInt(curDate[2],10),parseInt(curDate[0],10)-1,parseInt(curDate[1],10)-dm,parseInt(time[0],10),parseInt(time[1],10));
}
mainDate=getDate(document.getElementsByTagName("table")[0].innerHTML.match(/\.<br>.+ (\d{1,2}\:\d{2}(a|pm)?)/i)[0]);
</script>
Top of Global Footer<script>
//Expiration Date UBBC Tag v1.0 [CB]
//Copyright 10-10-2005 by ~Wonder
//May be reposted anywhere as long as this header remains in tact
//Put at Top of Global Footer
//Enter expiration message. You can use HTML just \ special characters. Leave blank if you don't want a message.
expirationMessage="";
//Enter URL of the image you want to appear as the expiration date ubbc button
UBBCexpirationImage="http://img449.imageshack.us/img449/8573/pbclockicon7uh.gif";
if(document.postForm)
{
document.postForm.color.parentNode.innerHTML+="<a href=javascript:addExpiration()><img src=\""+UBBCexpirationImage+"\" alt=\"Insert Expiration Date\" border=\"0\"></a>";
}
function addExpiration()
{
nd=new Date((mainDate-0)+(86400000*7));
h=nd.getHours();
ap=h>12 ? "pm" : "am";
h=h>12 ? h-12 : h;
ed=(nd.getMonth()+1)+"/"+nd.getDate()+"/"+nd.getFullYear()+" at "+h+":"+nd.getMinutes()+ap;
add("[expires="+ed+"]","[/expires]");
}
font=document.getElementsByTagName("font");
for(i=0;i<font.length;i++)
{
if(font[i].getElementsByTagName("textarea").length==0 && font[i].innerHTML.match(/(\[expires\=(.+)\](.*?)\[\/expires\])/))
{
b=font[i].innerHTML.split("[/expires]");
for(j=0;j<b.length-1;j++)
{
b[j].match(/(\[expires\=(.+)\]([\s\S]*))/);
a=(RegExp.$1+"#"+RegExp.$2+"#"+RegExp.$3).split("#");
if(getDate(a[1],10)>=mainDate)
{
b[j]=b[j].replace(a[0],a[2]);
}
else
{
b[j]=b[j].replace(a[0],expirationMessage);
}
}
font[i].innerHTML=b.join("");
}
}
</script>