Ad rotator with with OPENX array

Discussion in 'Javascript' started by SunBum, Jul 31, 2011.

  1. SunBum

    SunBum Guest

    Hey all,

    I need a one page html file that displays banner ads.

    I use OpenX to return an array of 10 banner ads.

    I need to do a couple of things with this array.

    1) Make the initial "call" to OpenX that returns an array of ads.
    check returned array for length and if less than 10 items are
    contained, fill out the array with static ads from a local directory,
    say ".\HouseAds into the array.

    2) loop for 1 to 10 and display the ad in index number of loop

    3) delay some time, say 30 seconds

    4) next loop

    5) when end of array reached, call #1 above and repeat.

    I need to do this without a page refresh.

    Here is sample code I have thus far:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <title>Example usage of Single Page Call tags </title>

    *****-(The following is the Array structure)-****

    <script type='text/javascript'><!--// <![CDATA[
    var OA_zones = {
    'zone_one_1' : 1,
    'zone_one_2' : 1,
    'zone_one_3' : 1,
    'zone_one_4' : 1,
    'zone_one_5' : 1,
    'zone_one_6' : 1,
    'zone_one_7' : 1,
    'zone_one_8' : 1,
    'zone_one_9' : 1,
    'zone_one_10' : 1
    }
    // ]]> --></script>

    *****-(The following is the call to OpenX that returns Array of Ads)-
    ****

    <script type='text/javascript' src='http://www.mydomain.com/openx/www/
    delivery/spcjs.php?id=1&amp;block=1&amp;withtext=1'></script>


    *****-(check len of array returned and if less than 10,
    load as many as needed to fill out array from
    local dir ".\houseAds))-****

    </head>

    <body>

    *****-(The following is an example of how each ad is called. There
    will be just one
    QA call with "OA_show('zone_one_#')" where # is the number
    from loop)-****

    *****-(Begin Loop through Array Here)-****

    <script type='text/javascript'><!--// <![CDATA[
    OA_show('zone_one_#');
    // ]]> --></script>

    *****-(delay here say 30 seconds)-****
    *****-(Next)-****
    *****-(End loop Here)-****

    *****-(Go back to start with fetch call to OpenX)-****

    </body>
    </html>

    I hope this makes sense ...

    Thanks for any help!

    Mike
     
    SunBum, Jul 31, 2011
    #1
    1. Advertisements

  2. SunBum

    SAM Guest

    Le 31/07/11 22:48, SunBum a écrit :
    it is not an array but an object .... !
    var count = 0;
    var myLoop = setInterval( function() {
    count++;
    if(count>10) { count=0; clearInterval(myLoop); }
    else OA_show(OA_zones['zone_one_'+count]);
    }, 30000);

    That was done just above

     
    SAM, Aug 2, 2011
    #2
    1. Advertisements

  3. SunBum

    Evertjan. Guest

    SAM wrote on 02 aug 2011 in comp.lang.javascript:
    So it is HTML

    NO! It is XHTML.

    No. HTML.
    Quite so, Stéphane.
    So why the [CDATA-stuff? It is "just" HTML.

    Why so rigid?

    =====================
    var OA_zones = {};
    fillOA('zone_one_', 1, 10, 1);

    function fillOA(group, min, max, val) {
    for (var i=min;i<=max;i++)
    OA_zones[group+i] = val;
    };
    =====================
     
    Evertjan., Aug 2, 2011
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.