Welcome Guest [Log In] [Register]
This board has been archived and is no longer accepting new questions. If you have a support question for your ZetaBoard, please visit us at the new support board. Registration is free and easy.


Visit the NEW ZetaBoards Support forum!

Username:   Password:
Add Reply
Ad System v1
Topic Started: Jan 27 2008, 10:54 PM (6,009 Views)
Spark
Member Avatar
Nukem Corporation
[ *  * ]
Ad System v1

Authors: Spark. Thanks to GenerationStudio for the add row to board stats code.
Preview: http://nukem.sytes.net (look in Board Statistics)
Code:
Javascript box:
Quote:
 
<script type="text/javascript"><!--// Ad System v1
window.onload = initBannerLink;

var adImages = new Array("http://linkurl.com","http://linkurl.com","http://linkurl.com","http://linkurl.com"); var adURL = new Array("support.zetaboards.com","support.zetaboards.com","support.zetaboards.com","support.zetaboards.com");

var Ad = 0; function rotate() { Ad++; if (Ad == adImages.length) { Ad = 0;}
document.getElementById("adBanner").src = adImages[Ad]; setTimeout("rotate()", 3 * 1000);}
function newLocation() { document.location.href = "http://" + adURL[Ad]; return false;}
function initBannerLink() { if (document.getElementById("adBanner").parentNode.tagName == "A") { document.getElementById("adBanner").parentNode.onclick = newLocation;}
rotate();}
// Spark --></script>

Below the board:
Quote:
 
<script src='http://209.85.62.24/30/132/0/f23676/addrow.js'>// Add more boxes to Board Statistics</script>
<script type="text/javascript">
// Add more boxes to Board Statistics
$(function(){
$().newZBBS({
isOn: true,
Title: "Advertisements",
Info: "<a href='http://support.zetaboards.com'><img src='http://linkurl.com' id='adBanner' border='0' alt='Advertisement' /></a>",
Image: "http://209.85.62.24/30/132/0/f19188/users.png"
});
});
</script>

Installation: This code may seem complicated but in fact it's very easy to edit. Place the above codes in the boxes I have specified. For the first part, edit all the links in red. Do NOT add http:// in front of the image links, that has been done for you in the code.

For the second part you will need to edit the parts in red as you wish. Now, for the parts in blue. The link in blue is the link you have added first in the first part. In my code, support.zetaboards.com would be my first link. This time you have to add http:// in front of the link. Now, the image link is blue is the the image you have added first in the first part. In this case, http://linkurl.com is my first image link, so I add that. You must get that part right or the ads won't rotate.

Any questions, please ask.
Edited by Spark, Jan 28 2008, 09:38 PM.
Offline Profile Quote Post Goto Top
 
Dennis
Member Avatar
Member Extraordinaire

Why on earth aren't you using a nested array? Matching entries in two arrays is a horrible way to go about this.

array(
[0] = array (
link => 'http://support.zetaboards.com'
image => 'http://image.com/image.jpg'
)
[1] = array (
link => 'http://support.invisionfree.com'
image => 'http://image.com/image1.jpg'
)
)
Offline Profile Quote Post Goto Top
 
Victrixs
Member Avatar
Website Developer
[ *  *  * ]
sweet code I'm currently using this.
Offline Profile Quote Post Goto Top
 
Spark
Member Avatar
Nukem Corporation
[ *  * ]
Dennis, it will be improved in v2. For now it works, loads fine and won't cause the support team any trouble with members asking them to fix their board. ;)
Offline Profile Quote Post Goto Top
 
Dennis
Member Avatar
Member Extraordinaire

http://support.zetaboards.com/topic/1237/1/
Offline Profile Quote Post Goto Top
 
Spark
Member Avatar
Nukem Corporation
[ *  * ]
Dennis, I did some research into that type of array and found out that it is for PHP, not Javascript. ;)
Edited by Spark, Jan 28 2008, 01:32 AM.
Offline Profile Quote Post Goto Top
 
Dennis
Member Avatar
Member Extraordinaire

No, they certainly are for javascript as well.

http://en.wikibooks.org/wiki/JavaScript/Arrays#Nested_arrays
Offline Profile Quote Post Goto Top
 
Viral
Member Avatar
i'm stanley nao
[ *  *  *  *  * ]
That type of nesting is PHP. It's the only coding language I have ever seen it in. Also, that wikibook has a different type of nesting for JS.
Offline Profile Quote Post Goto Top
 
Dennis
Member Avatar
Member Extraordinaire

I realize that. The example I posted earlier isn't the code, it's the output. I should have been a bit clearer. When you build a nested array, what I posted is the logical output. While it may not be the exact output of printing an array, it's pretty close. Spark was confused, so I posted a link to how javascript works. I'm a php guy first, so I think and code in a method that's influenced by php, but the logic behind it is sound.
Edited by Dennis, Jan 28 2008, 02:41 PM.
Offline Profile Quote Post Goto Top
 
Eureka
Member
[ *  *  * ]
Heya Nuke,
For the arrays, you can do something like this:
Code:
 

<script>
var eArray=[];
eArray[eArray.length] = ["LINK_URL_1", "IMG_URL_1"];
eArray[eArray.length] = ["LINK_URL_2", "IMG_URL_2"];
// so on and so forth.
// here's the loop that go through them. The string will be stored in var ads;
var ads="";
for (e=0; e<eArray.length; e++) ads+="<a href='"+eArray[e][0]+"'><img src='"+eArray[e][1]+"' /></a>";
// optional
document.write(ads);
</script>


What do you think? Yes?

Eureka
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · User Created Codes · Next Topic »
Add Reply