Post by Todge on Mar 19, 2010 10:10:34 GMT -8
This code allows you to give awards to members of your forum, the awards are viewable in the member's profile page and as a pop-up in their mini-profile.
Put it in your Global Footer...
You need to edit this part at the head of the code..
Red is the list of USERNAMES of the moderators you'd like to be able to give or take awards.. They must have the power to modify members' proflies..
Blue is the URL of your awards. All your award images must be hosted in the same place and numbered from 1 upwards. Then replace the award number with '##' when you place the URL in the code.. (See below)..
Green is the number of awards you have. You can have up to 255 awards, BUT any one member can only have a maximum of 148 awards at any given time..
Purple is the width of the awards as they appear in the profile page. Use 'px' for a set width, or '%' for a percentage of the containing cell.. Using % will obviously vary on varying resolutions, whereas px will be a fixed width.
Lime Green is the amount of awards you'd like in each row in the profile page. If set to '0' the awards will fill the space available.
Orange is a list of the titles and a short description of each award. Separate the title and description with the | character. This list is optional, but will obviously alter the look of the code if you leave it out.
The code 'should' now work with other codes that use the Custom Title area, you can now give members a custom title too, though, as the space of the custom title field is limited, any code or info you add will reduce the amount of awards that you can give to any one person.. Depending on where you have this code in your footer, will depend on whether you loose awards or other information if you run out of space.
Just put this code over the top of the previous one if you have it installed, and edit where indicated. Any awards you have already given should be retained.
Put it in your Global Footer...
<script type="text/javascript">
<!--
// Delete password field in Firefox
function ffPW()
{
document.modifyForm.password.value = '';
return;
}
if(document.modifyForm && document.modifyForm.password)
{
if(document.addEventListener){
window.addEventListener('load', ffPW, false);
}
else{
window.attachEvent('onload', ffPW);
}}
// -->
</script>
<!-- Awards System -->
<style type="text/css">
<!--
.nope { opacity: 0.5; filter:alpha(opacity=40); }
.yep { opacity: 1.0; filter:alpha(opacity=100); }
-->
</style>
<div id="peepAwards" class="windowbg" style="border: 1px solid black; width: 500px; height: 300px; position: fixed; padding: 5px; display: none;" align="center" onClick="this.style.display='none';">
<b id="peepName"></b>
<hr width="80%">
<div id="theAwards" style="width: 480px; height: 270px; overflow : auto;"></div>
</div>
<script type="text/javascript">
<!--
/*
Awards system
by Todge
Copyright © 2009
Please keep this header intact
*/
// Edit Below...
// List of mods you want to allow to give or take awards.
var mods = /^(admin|mod1|mod2)$/;
// URL of your award images. Replace the number with '##'.
var cardcode = 'http://myimages.com/awards/award##.png';
// How many awards do you have?
var awdInfo = new Array(3);var aLength = awdInfo.length;
// If you want the awards displayed at a set size, put the width here.
// use px for set size or % for a percentage of the CELL width
var awdWidth = '10%';
// If you'd like the awards displayed in set rows, how many in a row?
// Set to 0 if you want the awards to fill the available space.
var awdRow = 0;
awdInfo[1] = "TITLE|Award 1";
awdInfo[2] = "TITLE|Award 2";
awdInfo[3] = "TITLE|Award 3";
// Edit Above...
if(awdInfo[aLength] == undefined)
{
awdInfo.length++;
}
var awdimgs = new Array();
var awdsofar = '';
function popAwards(theAwards)
{
theAwards = theAwards.split('|');
document.getElementById('peepAwards').style.left = '200px';
document.getElementById('peepAwards').style.top = '100px';
document.getElementById('peepAwards').style.display = '';
if(document.all)
{
document.getElementById('peepAwards').style.position = 'absolute';
document.getElementById('peepAwards').style.top = document.body.scrollTop+100;
}
document.getElementById('peepName').innerHTML = theAwards[0].replace(/_/g,' ')+"'s Awards";
theAwards[0] = 0;
theAwards = theAwards.sort();
document.getElementById('theAwards').innerHTML = '<img src="'+cardcode.replace('##',parseInt('0x'+theAwards[1]))+'" width="50px" title="'+awdInfo[parseInt('0x'+theAwards[1])].split('|')[1]+'" alt="'+awdInfo[parseInt('0x'+theAwards[1])].split('|')[1]+'">';
for(t=2; t<theAwards.length; t++)
{
document.getElementById('theAwards').innerHTML += '<img src="'+cardcode.replace('##',parseInt('0x'+theAwards[t]))+'" width="50px" title="'+awdInfo[parseInt('0x'+theAwards[t])].split('|')[1]+'" alt="'+awdInfo[parseInt('0x'+theAwards[t])].split('|')[1]+'">';
}}
// Get received awards from the mini-profile...
if(location.href.match(/action=(viewprofile|(pm|calendar)view|display|recent|search2)/) || document.title.match(/- Preview( Personal)?( Message)?$/))
{
var miniPro = document.getElementsByTagName('td');
for(m=0; m<miniPro.length; m++)
{
if(miniPro[m].className.match(/windowbg/) && miniPro[m].width == '20%' && miniPro[m].innerHTML.match(/\[AWD/))
{
if(miniPro[m].getElementsByTagName('a')[0].href.match(/action=viewprofile/))
{
var ma = 0;
}
else
{
var ma = 2;
}
if(miniPro[m].innerHTML.match(/\[AWD\]/))
{
awdsofar = miniPro[m].innerHTML.split(/\[AWD\]/)[1].split(/<br/i)[0];
var tr = '[AWD]'+awdsofar;
}
else
{
awdsofar = miniPro[m].innerHTML.split(/\[AWD:/)[1].split(/\]/)[0];
var tr = '[AWD:'+awdsofar+']';
}
if(location.href.match(/action=viewprofile/))
{
miniPro[m].innerHTML = miniPro[m].innerHTML.replace(tr,'').replace(/br><br>member/i,'br>member');
break;
}
else
{
if(miniPro[m].getElementsByTagName('a')[ma].firstChild.nodeName != '#text')
{
var peep = miniPro[m].getElementsByTagName('a')[ma].firstChild.innerHTML;
}
else
{
var peep = miniPro[m].getElementsByTagName('a')[ma].innerHTML;
}
peep = peep.replace(/ /g,'_');
awdsofarlength = awdsofar.length-2;
for(w=awdsofarlength; w>0; w=w-2)
{
awdsofar = awdsofar.replace(awdsofar.substring(0,w),awdsofar.substring(0,w)+'|');
}
miniPro[m].innerHTML = miniPro[m].innerHTML.replace(tr,'<a href=javascript:popAwards("'+peep+'|'+awdsofar+'")>Awards</a><br>');
miniPro[m].innerHTML = miniPro[m].innerHTML.replace(tr,'').replace(/br><br>member/i,'br>member');
}}}
awdsofarlength = awdsofar.length-2;
for(w=awdsofarlength; w>0; w=w-2)
{
awdsofar = awdsofar.replace(awdsofar.substring(0,w),awdsofar.substring(0,w)+'|');
}}
// Add award images to profile page..
if(location.href.match(/action=viewprofile/))
{
var awardsCell = document.getElementsByTagName('td');
for(a=0; a<awardsCell.length; a++)
{
if(awardsCell[a].colSpan == '2' && awardsCell[a].innerHTML.match(/Recent Activity/))
{
awardsCell = awardsCell[a].parentNode;
break;
}}
var newTR = document.createElement('TR');
var newTD = document.createElement('TD');
newTD.id = 'awards';
newTD.colSpan = 2;
newTR.appendChild(newTD);
var awardContent = '<font size="2"><b>Awards Received</b><hr size="1"></font><table width="100%"><tbody><tr><td align="center" valign="top" width="66%" style="border-right: 1px solid black;">';
var acount = 0;
var icount = 1;
for(a=1; a<awdInfo.length; a++)
{
if(a<16){var awd = new RegExp('0'+a.toString(16));}
else {var awd = new RegExp(a.toString(16));}
var id = 'award'+awd;
id = id.replace(/\//g,'');
if(awdRow > 0 && acount/awdRow == icount)
{
awardContent += '<br>';
icount++;
}
awardContent += '<img ';
if(awdsofar.search(awd) == -1 && pb_username.match(mods)){awardContent += 'class="nope" '; acount++;}
else if(awdsofar.search(awd) == -1 && !pb_username.match(mods)){awardContent += ' style="display: none;" '; }
else if(awdsofar.search(awd) != -1){acount++;}
awardContent += 'src="'+cardcode.replace('##',a)+'" border="0" alt="'+awdInfo[a]+'" id="'+id+'" width="'+awdWidth+'">';
}
awardContent += '</td><td width="34%" valign="top" align="center"><br>';
awardContent += '<br><div id="awardInfo"></div></td></tr></tbody></table>';
newTD.innerHTML = awardContent;
awardsCell.parentNode.insertBefore(newTR,awardsCell);
// Add mouseover and onclick functions to the awards..
for(a=1; a<awdInfo.length; a++)
{
if(a<16){
var awd = 'award0'+a.toString(16);}
else{
var awd = 'award'+a.toString(16);}
document.getElementById(awd).onmouseover = function(){
document.getElementById('awardInfo').innerHTML = '<img src="'+this.src+'" width = "80%"><br><b>'+this.alt.replace('|','</b><br>');}
if(pb_username.match(mods)){
document.getElementById(awd).style.cursor = 'pointer';
var modLink = document.links;
for(m=0; m<modLink.length; m++)
{
if(modLink[m].href.match(/tion=modifyprofile/))
{
modLink = modLink[m].href;
break;
}}
document.getElementById(awd).onclick = function(){
location.href = modLink+'&award='+this.id.split('award')[1];
}}}}
// Add awards code to the Custom Title field and hide the awards from the custometitle field..
// Convert old system ([AWD]01) to new system ([AWD:01])..
if(document.modifyForm && document.modifyForm.customtitle && document.modifyForm.customtitle.value.match(/\[AWD/))
{
function updateCode()
{
document.modifyForm.customtitle.value = '[AWD:'+awdsofar+']'+document.modifyForm.customtitle.value;
return;
}
if(document.modifyForm.customtitle.value.match(/\[AWD\]/))
{
document.modifyForm.customtitle.value = document.modifyForm.customtitle.value.replace('AWD]','AWD:')+']';
}
if(document.modifyForm.customtitle.value.match(/\[AWD:/))
{
var awdsofar = document.modifyForm.customtitle.value;
awdsofar = awdsofar.split('AWD:')[1].split(/\]/)[0];
if(!location.href.match(/&award=/))
{
document.modifyForm.customtitle.value = document.modifyForm.customtitle.value.replace('[AWD:'+awdsofar+']','');
if(window.addEventListener)
{
document.modifyForm.addEventListener('submit', updateCode, false);
}
else{
document.modifyForm.attachEvent('onsubmit', updateCode);
}}}}
// Add/remove awards..
if(document.modifyForm && document.modifyForm.customtitle && location.href.match(/&award=/))
{
var td = document.getElementsByTagName('td');
for(t=0; t<td.length; t++)
{
if(td[t].className == 'titlebg' && td[t].width == '100%' && td[t].innerHTML.match(/Modify Profile<\/b>/i))
{
td[t].firstChild.innerHTML = 'Confirm Award';
var confTR = document.createElement('tr');
var confTD = document.createElement('td');
confTD.id = 'confirmation';
confTD.className = 'windowbg';
confTD.align = 'center';
confTR.appendChild(confTD);
td[t+1].parentNode.parentNode.insertBefore(confTR,td[t+1].parentNode);
}}
var mForm = document.modifyForm;
var inst = document.getElementsByTagName('font');
for(i=0; i<inst.length; i++)
{
if(inst[i].innerHTML.match(/The information you fill out on this page/) && inst[i].size == '2')
{
inst[i].parentNode.align = 'center';
inst[i].id = 'instructions';
}}
var mTot = mForm.children.length;
for(m=0; m<mTot-1; m++)
{
if(mForm.children[m].nodeName == 'INPUT' && mForm.children[m].value.match(/Modify Profile/))
{
break;
}
else
{
mForm.children[m].style.display = 'none';
}}
var modButton = document.getElementsByTagName('INPUT');
for(m=0; m<modButton.length; m++)
{
if(modButton[m].value.match(/Modify Profile/))
{
modButton[m].value = 'Confirm';
modButton[m+1].style.display = 'none';
function goBack()
{
document.location.href = document.referrer;
return;
}
var cancel = document.createElement('a');
cancel.href = document.location.href.replace('modify','view').split('&award')[0];
cancel.innerHTML = '<input type="button" value="Cancel">';
cancel.onclck = function(){document.location.href = document.referrer;}
modButton[m].parentNode.insertBefore(cancel,modButton[m+1]);
}}
var award = location.href.split('&award=')[1];
var awdsofar = document.modifyForm.customtitle.value;
if(awdsofar.match(/\[AWD:/))
{
awdsofar = awdsofar.split('[AWD:')[1].split(']')[0];
}
else
{
awdsofar = '';
}
var oldawds = '[AWD:'+awdsofar+']';
awdsofarlength = awdsofar.length-2;
for(w=awdsofarlength; w>0; w=w-2)
{
awdsofar = awdsofar.replace(awdsofar.substring(0,w),awdsofar.substring(0,w)+'|');
}
if(awdsofar.length>0 && awdsofar.match(award))
{
document.getElementById('instructions').innerHTML = document.getElementById('instructions').innerHTML.replace(/The information you fill out on this page will be used on various parts of this forum/,'You have chosen to remove this award from '+document.modifyForm.name.value)
document.getElementById('instructions').innerHTML = document.getElementById('instructions').innerHTML.replace(/All required fields are marked with an asterisk \*/,'Please confirm or <a href="'+cancel.href+'">cancel</a> to return to the profile page');
awdsofar = awdsofar.replace(award,'');
if(awdsofar.length>1)
{
awdsofar = '[AWD:'+awdsofar.replace(/\|/g,'')+']';
}
else
{
awdsofar = '';
}
document.modifyForm.customtitle.value = document.modifyForm.customtitle.value.replace(oldawds,awdsofar);
document.getElementById('confirmation').innerHTML = '<img src="'+cardcode.replace('##',parseInt('0x'+award))+'"><br><b>'+awdInfo[parseInt('0x'+award)].replace('|','<\/b><br>');
}
else if(awdsofar.length>0)
{
document.getElementById('instructions').innerHTML = document.getElementById('instructions').innerHTML.replace(/The information you fill out on this page will be used on various parts of this forum/,'You have chosen to give '+document.modifyForm.name.value+' this award.')
document.getElementById('instructions').innerHTML = document.getElementById('instructions').innerHTML.replace(/All required fields are marked with an asterisk \*/,'Please confirm or <a href="'+cancel.href+'">cancel</a> to return to the profile page');
awdsofar += award;
awdsofar = '[AWD:'+awdsofar.replace(/\|/g,'')+']';
document.modifyForm.customtitle.value = document.modifyForm.customtitle.value.replace(oldawds,awdsofar);
document.getElementById('confirmation').innerHTML = '<img src="'+cardcode.replace('##',parseInt('0x'+award))+'"><br><b>'+awdInfo[parseInt('0x'+award)].replace('|','<\/b><br>');
}
else
{
document.getElementById('instructions').innerHTML = document.getElementById('instructions').innerHTML.replace(/The information you fill out on this page will be used on various parts of this forum/,'You have chosen to give '+document.modifyForm.name.value+' this award.')
document.getElementById('instructions').innerHTML = document.getElementById('instructions').innerHTML.replace(/All required fields are marked with an asterisk \*/,'Please confirm or <a href="'+cancel.href+'">cancel</a> to return to the profile page');
document.modifyForm.customtitle.value = '[AWD:'+award+']'+document.modifyForm.customtitle.value;
document.getElementById('confirmation').innerHTML = '<img src="'+cardcode.replace('##',parseInt('0x'+award))+'"><br><b>'+awdInfo[parseInt('0x'+award)].replace('|','<\/b><br>');
}}
// -->
</script>
You need to edit this part at the head of the code..
// List of mods you want to allow to give or take awards.
var mods = /^(admin|mod1|mod2)$/;
// URL of your award images. Replace the number with '##'.
var cardcode = 'myimages.com/awards/award##.png';
// How many awards do you have?
var awdInfo = new Array(3);var aLength = awdInfo.length;
// If you want the awards displayed at a set size, put the width here.
// use px for set size or % for a percentage of the CELL width
var awdWidth = '10%';
// If you'd like the awards displayed in set rows, how many in a row?
// Set to 0 if you want the awards to fill the available space.
var awdRow = 0;
awdInfo[1] = "TITLE|Award 1";
awdInfo[2] = "TITLE|Award 2";
awdInfo[3] = "TITLE|Award 3";
Red is the list of USERNAMES of the moderators you'd like to be able to give or take awards.. They must have the power to modify members' proflies..
Blue is the URL of your awards. All your award images must be hosted in the same place and numbered from 1 upwards. Then replace the award number with '##' when you place the URL in the code.. (See below)..
Green is the number of awards you have. You can have up to 255 awards, BUT any one member can only have a maximum of 148 awards at any given time..
Purple is the width of the awards as they appear in the profile page. Use 'px' for a set width, or '%' for a percentage of the containing cell.. Using % will obviously vary on varying resolutions, whereas px will be a fixed width.
Lime Green is the amount of awards you'd like in each row in the profile page. If set to '0' the awards will fill the space available.
Orange is a list of the titles and a short description of each award. Separate the title and description with the | character. This list is optional, but will obviously alter the look of the code if you leave it out.
The code 'should' now work with other codes that use the Custom Title area, you can now give members a custom title too, though, as the space of the custom title field is limited, any code or info you add will reduce the amount of awards that you can give to any one person.. Depending on where you have this code in your footer, will depend on whether you loose awards or other information if you run out of space.
Just put this code over the top of the previous one if you have it installed, and edit where indicated. Any awards you have already given should be retained.
All your award images must be the same type and numbered sequentially starting from 1..
So, on your PC, rename all the images, with the same name but number them sequentially, like so:-award1.jpg
award2.jpg
award3.jpg
etc..
Then upload them to the same image host, so that the URLs of all your images are identical except for the number.. E.g.http://www.myimagehost/Awards/award1.jpg
http://www.myimagehost/Awards/award2.jpg
http://www.myimagehost/Awards/award3.jpg
etc..
Then put ONE URL in the awards code, but replace the number with ##, so with this example you'd edit the code like..var cardcode = 'http://www.myimagehost/Awards/award##.jpg';