View Full Version: A couple of scripts for this site

RPGXP Unlimited > Feedback and suggestions > A couple of scripts for this site


Title: A couple of scripts for this site


SCMike - August 25, 2006 05:19 PM (GMT)
Hey, I figured I'd share these with you, Marked. It's an award system and a "today, yesterday" post script as well as a hide posts by certain group system. Place them in the footer if you use them...

Award:
CODE
<script language="javascript">
// Advanced Awards System
// created by Ryan Fan/Nitrogenix
// http://www.ifsz.com , 2005
var x = document.getElementsByTagName('TABLE')
for(y=0;y<x.length;y++){
if(x[y].cellPadding == "6" && x[y].cellSpacing == "1" && x[y].width == "100%" && x[y].rows[0].cells[0].innerHTML == "Information" && x[y].rows[0].cells[0].className == "maintitle"){
iRowx = x[y].insertRow(5)
rowt = iRowx.insertCell(0)
rowt.innerHTML = "<b>Awards</b>"
rowt.className = "row3"
rowt.width = "30%"
rowt.vAlign = "top"
rowf = iRowx.insertCell(1)
rowf.innerHTML = "<i>No Information</i>"
}}
function awarduser(iD, Img, Iname){
if(location.href.match('showuser=' + iD + '$')){
rowf.innerHTML = rowf.innerHTML.replace(/No Information/i, "")
rowf.innerHTML += Iname + " - " + "<img src='" + Img + "'><br>"
rowf.className = "row1"
rowf.align = "left"
}}
awarduser("1", "http://img.photobucket.com/albums/v59/tamo_konichi/Fire.png", "Test Award")
</script>
Just take where it says awarduser at the bottom. It will give people awards. You just have to know user number, then a picture for the award, then a name for the award.

Yesterday, Today posting
CODE
<script language="JavaScript">
/*
Show "Today" or "Yesterday" in Last Post Info - v2.0
by Verminox
http://forum.ifcode.com
*/

function write_date(theday)
{
var thetime=new Date();

var nmonth=thetime.getMonth();
if(theday=='t'){
var ntoday=(thetime.getDate());
}
else if(theday=='y'){
var ntoday=(thetime.getDate()-1);
}
var nyear=thetime.getYear();

nmonth+=1;

var xmonth = new Array()
xmonth[1] = "Jan"
xmonth[2] = "Feb"
xmonth[3] = "Mar"
xmonth[4] = "Apr"
xmonth[5] = "May"
xmonth[6] = "Jun"
xmonth[7] = "Jul"
xmonth[8] = "Aug"
xmonth[9] = "Sept"
xmonth[10] = "Oct"
xmonth[11] = "Nov"
xmonth[12] = "Dec"

for(n=1;n<13;n++){
if (nmonth==n){
nmonth=xmonth[n];
}}


if (nyear<=99)
nyear= "19"+nyear;

if ((nyear>99) && (nyear<2000))
nyear+=1900;


return nmonth + " " + ntoday + " " + nyear;


}

var today = write_date('t')

var yesterday = write_date('y')

var datecell = document.getElementsByTagName('TD')

for(x=0;x<datecell.length;x++){
if(datecell[x].innerHTML.match(today) && datecell[x].innerHTML.match(/By:/i)){
datecell[x].innerHTML = datecell[x].innerHTML.replace(today, "Today")
}}

for(y=0;y<datecell.length;y++){
if(datecell[y].innerHTML.match(yesterday) && datecell[y].innerHTML.match(/By:/i)){
datecell[y].innerHTML = datecell[y].innerHTML.replace(yesterday, "Yesterday")
}}

</script><script language='javascript' type='text/javascript'>
<!--
itm = null;
itm = document.getElementById('qr_open');
if (itm) itm.style.display = '';
//-->
</script>
This code changes it so that the posts say "Today" if it was posted today or "yesterday" if it was posted yesterday...otherwise, it goes back to normal.

Hide Posts of Banned Group:
CODE
<script type="text/javascript">
/*
Hide Posts of Banned Group
by Verminox
http://forum.ifcode.com
*/


var group = "Permanently Banned"


var spn = document.getElementsByTagName('SPAN')
for(x=0;x<spn.length;x++){
if(spn[x].className=="postdetails" && spn[x].innerHTML.match("Group: " + group)){
spn[x].parentNode.parentNode.parentNode.parentNode.style.display = "none"
}}
</script>
I use this to hide the posts of banned people...

EDIT: Added an offline/online legend. Just put it in the Header & Body underneath everything else...

CODE
<script>//Online/Offline Legend v2 - By Markup
dir="http://img.photobucket.com/albums/v59/tamo_konichi/Forum/"
home=location.href.lastIndexOf("/")>26?location.href.substr(0,location.href.lastIndexOf("/")):location.href
names=[]
if(top.location==location)
document.write("<IFRAME id=index name=index src="+home+" width=0 height=0 border=0 frameBorder=0></IFRAME>")
else
{
div=document.body.getElementsByTagName("DIV")
for(i=0;i<div.length;i++)
if(div[i].className=="thin")
 break
a=div[i].getElementsByTagName("A")
for(i=0;i<a.length;i++)
names[i]=a[i].innerHTML.replace(/<[^>]+>/g,"")
parent.updateStatus()
}
function updateStatus()
{
td=document.body.getElementsByTagName("TD")
for(i=0;i<td.length;i++)
if((td[i].className=="post1"||td[i].className=="post2")&&td[i].innerHTML.match("Posts: ")&&td[i].width!="100%")
{
 found=false
 sPost=td[i].getElementsByTagName("SPAN")[0]
 names=parent.frames['index'].names
 for(a=0;a<names.length;a++)
  if(td[i-2].innerHTML.replace(/<[^>]+>/g,"")==names[a])
  {
   sPost.innerHTML+="<P align=left><IMG SRC="+dir+"Online.png"+"></P>"
   found=true
  }
 if(!found)
  sPost.innerHTML+="<P align=left><IMG SRC="+dir+"Offline.png"+"></P>"
}
}
</script>

At the top you will see "dir="http://img.photobucket.com/albums/v59/tamo_konichi/Forum/"" Edit that to wherever your online and offline images are. Then just find where it says "Online.png" and "Offline.png" and change them to whatever the image is that you have.

Marked - August 26, 2006 04:20 AM (GMT)
Thanks SCMike, I'll move this into the correct section.
I had many script added before, but they one was making the forum topics not viewable by some members. So I have to be careful. I dont think we need an awards system yet, but if other members want one, I will add it in.




* Hosted for free by InvisionFree