Post by Peter on Apr 29, 2006 13:20:30 GMT
What this script does is let's your members select a different banner to show in the welcome table. It is selectable from the profile, and it will remember the selection next time he/she visits.
Please read the instructions carefully.
<script type="text/javascript">
<!--
/*
Banner selection from profile - Created by Peter
This code cannot be reposted anywhere other than SSDesigns or ProBoards Support.
This header must stay intact.
*/
// URL to the blank image (added in skin area).
var theBlank = "http://www.4d5.net/v4images/blank.gif";
// List all the banners to show in drop down
var iBanners = [
["Select Banner", "DEFAULT BANNER URL"],
["Banner 1", "URL 1"],
["Banner 2", "URL 2"],
["Banner 3", "URL 3"],
["Banner 4", "URL 4"]
];
if(document.getElementsByTagName("img").item(0).src == theBlank){
document.getElementsByTagName("img").item(0).id = "banselect";
}
function getCook(){
if(document.cookie.match(/banid=(\d+)/)){
return RegExp.$1;
} else {
if(document.getElementById("banselect")){
document.getElementById("banselect").src = iBanners[0][1];
}
return null;
}
}
if(document.getElementById("banselect")){
if(getCook() != null){
document.getElementById("banselect").src = iBanners[getCook()][1];
}
}
//-->
</script>
Ok, first thing, and most important part of the code is the logo image. Enter a blank 1 x 1 pixel image as the logo. You can do this by going to admin > skins > modify skin, enter the blank image url into the logo field. Once you have done that, add that blank image url into the script. Change theBlank variable so it has your blank image url. Make sure you get the right, otherwise the script will not work.
Next part would be to add your default banner, this will be the one that will show up when the user hasn't selected one. Enter this into the first one of the array...
["Select Banner", "DEFAULT BANNER URL"],
Next add the other banners in, just replace URL X with the URL. If you wish to add more then what's there, add another ["Banner 4", "URL 4"]. So for example, if I wanted to add 2 more banners I would have this...
var iBanners = [
["Select Banner", "DEFAULT BANNER URL"],
["Banner 1", "URL 1"],
["Banner 2", "URL 2"],
["Banner 3", "URL 3"],
["Banner 4", "URL 4"],
["Banner 4", "URL 5"],
["Banner 4", "URL 6"]
];
Simple
All you need to do now is add that code into your Global headers.
Now, this code below is the one that allows the members to select the banner from their profile. You shouldn't need to touch this, so all you need to do is add it to your Main footer.
<script type="text/javascript">
<!--
/*
Banner selection from profile - Created by Peter
This code cannot be reposted anywhere other than SSDesigns or ProBoards Support.
This header must stay intact.
*/
var iBBDesTxt = "Select a banner you wish to have show in the welcome table instead of the default one.";
function setCookie(name,value,expires,domain){
document.cookie = name + "=" + encodeURI(value) + ((expires == null) ? "" : "; expires=" + expires.toGMTString()) + ((domain == null) ? "" : "; domain=" + domain);
}
function doBanSelect(){
var iTable = document.getElementsByTagName("table");
var bSel = document.createElement("select");
var iBFont = document.createElement("font");
var bDesc = document.createTextNode("Banner:");
iBFont.size = "-2";
var iBBDes = iBFont.cloneNode(true).appendChild(document.createTextNode(iBBDesTxt));
iBFont.size = "-1";
iBFont.appendChild(bDesc);
bSel.onchange = function(){
var iDomain = location.hostname;
var ExpDate = new Date ();
ExpDate.setTime(ExpDate.getTime() + (180 * 24 * 3600 * 1000));
setCookie("banid", this.selectedIndex, ExpDate, iDomain);
}
for(b = 0; b < iBanners.length; b ++){
bSel.options[bSel.options.length] = new Option(iBanners[0], b);
if(b == parseInt(getCook())){
bSel.options.selected = true;
}
}
for(t = 0; t < iTable.length; t ++){
if(iTable.item(t).width == "650" && iTable.item(t).innerHTML.match(/Show Age:/)){
var nRow = iTable.item(t).insertRow(iTable.item(t).rows.length);
var nCell = nRow.insertCell(0);
nCell.appendChild(iBFont);
nCell = nRow.insertCell(1);
nCell.appendChild(bSel);
nCell = nRow.insertCell(2).appendChild(iBBDes);
}
}
}
if(location.href.match(/=modifyprofile&user=/) && document.modifyForm){
doBanSelect();
}
//-->
</script>
There we go
Please read the instructions carefully.
<script type="text/javascript">
<!--
/*
Banner selection from profile - Created by Peter
This code cannot be reposted anywhere other than SSDesigns or ProBoards Support.
This header must stay intact.
*/
// URL to the blank image (added in skin area).
var theBlank = "http://www.4d5.net/v4images/blank.gif";
// List all the banners to show in drop down
var iBanners = [
["Select Banner", "DEFAULT BANNER URL"],
["Banner 1", "URL 1"],
["Banner 2", "URL 2"],
["Banner 3", "URL 3"],
["Banner 4", "URL 4"]
];
if(document.getElementsByTagName("img").item(0).src == theBlank){
document.getElementsByTagName("img").item(0).id = "banselect";
}
function getCook(){
if(document.cookie.match(/banid=(\d+)/)){
return RegExp.$1;
} else {
if(document.getElementById("banselect")){
document.getElementById("banselect").src = iBanners[0][1];
}
return null;
}
}
if(document.getElementById("banselect")){
if(getCook() != null){
document.getElementById("banselect").src = iBanners[getCook()][1];
}
}
//-->
</script>
Ok, first thing, and most important part of the code is the logo image. Enter a blank 1 x 1 pixel image as the logo. You can do this by going to admin > skins > modify skin, enter the blank image url into the logo field. Once you have done that, add that blank image url into the script. Change theBlank variable so it has your blank image url. Make sure you get the right, otherwise the script will not work.
Next part would be to add your default banner, this will be the one that will show up when the user hasn't selected one. Enter this into the first one of the array...
["Select Banner", "DEFAULT BANNER URL"],
Next add the other banners in, just replace URL X with the URL. If you wish to add more then what's there, add another ["Banner 4", "URL 4"]. So for example, if I wanted to add 2 more banners I would have this...
var iBanners = [
["Select Banner", "DEFAULT BANNER URL"],
["Banner 1", "URL 1"],
["Banner 2", "URL 2"],
["Banner 3", "URL 3"],
["Banner 4", "URL 4"],
["Banner 4", "URL 5"],
["Banner 4", "URL 6"]
];
Simple
All you need to do now is add that code into your Global headers.
Now, this code below is the one that allows the members to select the banner from their profile. You shouldn't need to touch this, so all you need to do is add it to your Main footer.
<script type="text/javascript">
<!--
/*
Banner selection from profile - Created by Peter
This code cannot be reposted anywhere other than SSDesigns or ProBoards Support.
This header must stay intact.
*/
var iBBDesTxt = "Select a banner you wish to have show in the welcome table instead of the default one.";
function setCookie(name,value,expires,domain){
document.cookie = name + "=" + encodeURI(value) + ((expires == null) ? "" : "; expires=" + expires.toGMTString()) + ((domain == null) ? "" : "; domain=" + domain);
}
function doBanSelect(){
var iTable = document.getElementsByTagName("table");
var bSel = document.createElement("select");
var iBFont = document.createElement("font");
var bDesc = document.createTextNode("Banner:");
iBFont.size = "-2";
var iBBDes = iBFont.cloneNode(true).appendChild(document.createTextNode(iBBDesTxt));
iBFont.size = "-1";
iBFont.appendChild(bDesc);
bSel.onchange = function(){
var iDomain = location.hostname;
var ExpDate = new Date ();
ExpDate.setTime(ExpDate.getTime() + (180 * 24 * 3600 * 1000));
setCookie("banid", this.selectedIndex, ExpDate, iDomain);
}
for(b = 0; b < iBanners.length; b ++){
bSel.options[bSel.options.length] = new Option(iBanners[0], b);
if(b == parseInt(getCook())){
bSel.options.selected = true;
}
}
for(t = 0; t < iTable.length; t ++){
if(iTable.item(t).width == "650" && iTable.item(t).innerHTML.match(/Show Age:/)){
var nRow = iTable.item(t).insertRow(iTable.item(t).rows.length);
var nCell = nRow.insertCell(0);
nCell.appendChild(iBFont);
nCell = nRow.insertCell(1);
nCell.appendChild(bSel);
nCell = nRow.insertCell(2).appendChild(iBBDes);
}
}
}
if(location.href.match(/=modifyprofile&user=/) && document.modifyForm){
doBanSelect();
}
//-->
</script>
There we go