www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 08-28-2006, 11:40 AM
    ozeire ozeire is offline
    Registered User
     
    Join Date: Jul 2005
    Posts: 13
    resolved [RESOLVED] Help add in another Banner size

    Hi Guys

    I hope one of you might be able to help me . I have very very little knowledge of java script . Have one running on my site that rotates banners .

    I wonder if one of you could tell me how i add in another few banner size into it .

    At the moment it has three .

    Quote:
    BannerMgr.BAN = 0;
    BannerMgr.BTN = 1;
    BannerMgr.BTN2X = 2;

    This is the java script i have already below


    Thank you all in advance for any help at all you can give

    Regards

    Alan


    Quote:
    function FlashInstalled()
    {
    result = false;
    if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"])
    {
    result = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
    }
    else if (document.all && (navigator.appVersion.indexOf("Mac")==-1))
    {
    // IE Windows only -- check for ActiveX control, have to hide code in eval from Netscape (doesn't like try)
    eval ('try {var xObj = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");if (xObj) result = true; xObj = null; } catch (e) {}');
    }
    return result;
    }

    function GetFlashHTML(url,width,height)
    {
    var htm = '<OBJECT classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000"';
    htm += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" ';
    htm += ' WIDTH=' + width + ' HEIGHT=' + height + '>';
    htm += ' <PARAM NAME=movie VALUE="' + url + '"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> ';
    htm += ' <EMBED src="' + url + '" quality=high bgcolor=#FFFFFF ';
    htm += ' swLiveConnect=FALSE WIDTH=' + width + ' HEIGHT=' + height;
    htm += ' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">';
    htm += ' </EMBED></OBJECT>';
    return htm;
    }

    function BannerMgr_Switch(imageObj,kind,criteria)
    {
    var banObj = this.GetBanner(kind,criteria);
    if (banObj != null)
    {
    imageObj.src = banObj.imgSrc;
    this.SetAnchorRef(imageObj.name+"Ref",banObj.ref);
    }
    }

    function BannerMgr_SetAnchorRef(name,ref)
    {
    for (var i=0;i<document.anchors.length;i++)
    {
    if (document.anchors[i].name == name)
    {
    document.anchors[i].href = ref;
    break;
    }
    }
    }

    function BannerMgr_GetBanner(kind, criteriaStr)
    {
    var banArray = this.banners[kind];
    var possibles = new Array();
    var result = null;

    for (var i=0;i<banArray.length;i++)
    {
    var criteria = criteriaStr.split(",");

    var matches = false;
    for (var j=0;j<criteria.length;j++)
    {
    if ((criteria[j]=="all") || (banArray[i].keywords.indexOf(criteria[j]) >= 0))
    {
    matches = true;
    }
    else
    matches = false;
    }
    if (matches)
    possibles[possibles.length] = banArray[i];
    }


    if (possibles.length > 0)
    {
    var choice = Math.floor(Math.random()*possibles.length);
    result = possibles[choice];
    }

    return result;
    }

    function BannerMgr_Add(kind, keywords, imgSrc, altText, ref, flashSrc)
    {
    var banArray = this.banners[kind];
    var banObj = new Object();
    banObj.name = "ban" + banArray.length;
    banObj.keywords = keywords;
    banObj.imgSrc = imgSrc;
    banObj.altText = altText;
    banObj.ref = ref;

    if (arguments.length > 5)
    banObj.flashSrc = flashSrc;
    else
    banObj.flashSrc = null;

    banArray[banArray.length] = banObj;
    }

    function BannerMgr_WriteBanner(kind,criteria)
    {
    var htm = this.GetBannerHTML(kind,criteria);
    document.write(htm);

    }

    function BannerMgr_GetBannerHTML(kind,criteria)
    {
    var banObj = this.GetBanner(kind,criteria);
    var wh = this.GetWidthHeight(kind);

    var htm = '';
    if (banObj.flashSrc && FlashInstalled())
    {
    htm = GetFlashHTML(banObj.flashSrc+"?link="+banObj.ref,wh.width,wh.height);
    }
    else
    {
    htm += '<a name="' + banObj.name + 'Ref" href="' + banObj.ref + '" target="_blank">';
    htm += '<img name="' + banObj.name + '" src="' + banObj.imgSrc + '" width=';
    htm += wh.width + ' height=' + wh.height + ' onerror="gBannerMgr.Switch(this,' + kind + ',\'local,' + criteria + '\')" ';
    htm += 'alt="' + banObj.altText + '" border=0></a>';

    // support for airplane banner
    if (kind==BannerMgr.BAN)
    {
    gBannerName = banObj.name;
    gBannerLinkName = banObj.name;
    gBannerLinkURL = banObj.ref;
    }
    }

    return htm;
    }

    function BannerMgr_GetWidthHeight(kind)
    {
    var returnObj = new Object();
    switch(kind)
    {
    case 0:
    returnObj.width = 498;
    returnObj.height = 100;
    break;
    case 1:
    returnObj.width = 345;
    returnObj.height = 255;
    break;
    case 2:
    returnObj.width = 96;
    returnObj.height = 72;
    break;

    }
    return returnObj;
    }



    function BannerMgr()
    {
    this.banners = new Array( new Array(), new Array(),new Array() );
    // Methods
    this.GetWidthHeight = BannerMgr_GetWidthHeight;
    this.WriteBanner = BannerMgr_WriteBanner;
    this.Add = BannerMgr_Add;
    this.GetBanner = BannerMgr_GetBanner;
    this.SetAnchorRef = BannerMgr_SetAnchorRef;
    this.Switch = BannerMgr_Switch;
    this.GetBannerHTML = BannerMgr_GetBannerHTML;
    }
    BannerMgr.BAN = 0;
    BannerMgr.BTN = 1;
    BannerMgr.BTN2X = 2;



    var gBannerMgr = new BannerMgr();




    // Regular Size Banner Examples
    //gBannerMgr.Add(BannerMgr.BAN, "index,linkx","banner/scbanner.gif", "http://www.stonedcrow.com/default.htm","http://www.stonedcrow.com/default.htm");

    //gBannerMgr.Add(BannerMgr.BAN, "index,linkx","banner/iwantyou.jpg", "http://www.ozeire.com/Forum/weblog.php?w=1","http://www.ozeire.com/Forum/weblog.php?w=1");

    //gBannerMgr.Add(BannerMgr.BAN, "index,links","banner/downunder.gif", "http://comedyfestival.com.au/season/2006/index.php","http://comedyfestival.com.au/season/2006/index.php");

    //gBannerMgr.Add(BannerMgr.BAN, "index,links","banner/MelbCFes.JPG", "http://www.comedyfestival.com.au/season/2006/index.php","http://www.comedyfestival.com.au/season/2006/index.php");
    //gBannerMgr.Add(BannerMgr.BAN, "index,links","banner/SydneyEaster1.jpg", "http://www.eastershow.com.au/","http://www.eastershow.com.au/");

    //gBannerMgr.Add(BannerMgr.BAN, "index,links","banner/circus1.JPG", "http://www.circusoz.com","http://www.circusoz.com");

    gBannerMgr.Add(BannerMgr.BAN, "index,links","banner/travel.gif", "http://www.ozeire.com/ccount/click.php?id=68","http://www.ozeire.com/ccount/click.php?id=68");

    gBannerMgr.Add(BannerMgr.BAN, "indextop","banner/travel10.jpg", "http://www.sydneyontheweb.com/essential_info/ticket_options.shtml","http://www.sydneyontheweb.com/essential_info/ticket_options.shtml");

    //gBannerMgr.Add

    //(BannerMgr.BAN, "index,linkx","banner/bannertest5.jpg", "http://www.ozeire.com/ccount/click.php?

    //id=61","http://www.ozeire.com/ccount/click.php?id=61");




    // Button Size Banner Examples

    //gBannerMgr.Add(BannerMgr.BTN, "index", "http://au.i1.yimg.com/au.yimg.com/i/ch/chma_1.gif", "Ancestry.com", "http://au.chat.yahoo.com/");
    gBannerMgr.Add(BannerMgr.BTN, "index", "Home_/pics/sun.jpg", "travellerspoint.com/photography.cfm", "http://www.ozeire.com/ccount/click.php?id=71");
    gBannerMgr.Add(BannerMgr.BTN, "index", "Home_/pics/The Olgas.jpg", "travellerspoint.com/photography.cfm", "http://www.ozeire.com/ccount/click.php?id=71");
    gBannerMgr.Add(BannerMgr.BTN, "index", "Home_/pics/kellygang.gif", "travellerspoint.com/photography.cfm", "http://www.ozeire.com/ccount/click.php?id=71");





    // mid Button Size Banner (Picture right Side)

    gBannerMgr.Add(BannerMgr.BTN2X, "index,gethere", "banner/shop/bag.php.jpg", "Online Store", "home/shop.html");
    Reply With Quote
      #2  
    Old 08-28-2006, 12:25 PM
    mopenstein mopenstein is offline
    Registered User
     
    Join Date: Aug 2006
    Posts: 5
    Quote:
    Originally Posted by ozeire
    function BannerMgr_GetWidthHeight(kind)
    {
    var returnObj = new Object();
    switch(kind)
    {
    case 0:
    returnObj.width = 498;
    returnObj.height = 100;
    break;
    case 1:
    returnObj.width = 345;
    returnObj.height = 255;
    break;
    case 2:
    returnObj.width = 96;
    returnObj.height = 72;
    break;
    //look here >>>>>>>>>>>>>>>
    case 3:
    returnObj.width = 4000;
    returnObj.height = 4000;
    break;

    }
    return returnObj;
    }

    ...................................

    BannerMgr.BAN = 0;
    BannerMgr.BTN = 1;
    BannerMgr.BTN2X = 2;
    BannerMgr.BTN4000 = 3;
    Reply With Quote
      #3  
    Old 08-29-2006, 07:35 AM
    ozeire ozeire is offline
    Registered User
     
    Join Date: Jul 2005
    Posts: 13
    Thank for the help mopenstein

    Done what you said but the banner doesn't seem to show up

    Quote:
    function BannerMgr_GetWidthHeight(kind)
    {
    var returnObj = new Object();
    switch(kind)
    {
    case 0:
    returnObj.width = 498;
    returnObj.height = 100;
    break;
    case 1:
    returnObj.width = 345;
    returnObj.height = 255;
    break;
    case 2:
    returnObj.width = 96;
    returnObj.height = 72;
    break;
    case 3:
    returnObj.width = 498;
    returnObj.height = 100;
    break;

    }
    return returnObj;
    }



    function BannerMgr()
    {
    this.banners = new Array( new Array(), new Array(),new Array() );
    // Methods
    this.GetWidthHeight = BannerMgr_GetWidthHeight;
    this.WriteBanner = BannerMgr_WriteBanner;
    this.Add = BannerMgr_Add;
    this.GetBanner = BannerMgr_GetBanner;
    this.SetAnchorRef = BannerMgr_SetAnchorRef;
    this.Switch = BannerMgr_Switch;
    this.GetBannerHTML = BannerMgr_GetBannerHTML;
    }
    BannerMgr.BAN = 0;
    BannerMgr.BTN = 1;
    BannerMgr.BTN2X = 2;
    BannerMgr.BTN4000 = 3;



    var gBannerMgr = new BannerMgr();


    gBannerMgr.Add(BannerMgr.BAN, "index,links","banner/travel.gif", "http://www.ozeire.com/ccount/click.php?id=68","http://www.ozeire.com/ccount/click.php?id=68");

    gBannerMgr.Add(BannerMgr.BTN4000, "index","banner/travel10.jpg", "http://www.sydneyontheweb.com/essential_info/ticket_options.shtml","http://www.sydneyontheweb.com/essential_info/ticket_options.shtml");
    Reply With Quote
      #4  
    Old 09-12-2006, 11:06 AM
    ozeire ozeire is offline
    Registered User
     
    Join Date: Jul 2005
    Posts: 13
    Thanks mopenstein for all your help . Got this working a different way

    Regards

    Alan
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 04:35 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.