spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / dhtml / column27
Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

Logo

Dynamic Headline Fader, Version 3.0
more on multiple headlines


The Display String

In FDRmakeStr(), we need to create a string that contains the number of headlines specified in FDRhdlineCount. For this, we use a simple for statement:

function FDRmakeStr(){
   tempStr = "";

   for (i=0;i<FDRhdlineCount;i++){
      if(newsCount >= arNews.length) break;

      dispStr = arNews[newsCount];
      linkStr = arNews[newsCount+1];
      isLink = linkStr.length;
      if (isLink) {
         tempStr += "<A CLASS=newslink "
                 + "HREF='" + prefix + linkStr + "'>"
                 + dispStr + "</A>"
      }
      else {
         tempStr +=
          (NS4) ? ("<P CLASS=nolink>"+dispStr+"</P>") : dispStr;
      }
      if(IE4mac) tempStr += "<BR>"

      newsCount += 2;
   }

   return tempStr;
}

Every time the for statement is invoked, it first compares the value of newsCount (our array pointer) to the length of the arNews array. If we have reached the end of the array (newsCount >= arNews.length), meaning that there are no more headlines, we break out of the loop. Otherwise we continue to build the string for the headline in question.

At the end of the for statement, we increment newsCount. Therefore, newsCount changes with every headline, not with every display, as it did in Version 2.01.

The Status Bar Display

With our old single-headline Fader, we tracked the user's mouse position. If it was over the Fader, we updated the browser status bar display if a transition occured. The relevant statement is in FDRfade():

window.status = (FDRisOver && isLink) ? (prefix + linkStr) : "";

Since there now may be more than one headline, of different lengths, this status bar update courtesy gesture should occur only when we are displaying single headlines. The statement is changed to:

if(FDRhdlineCount==1)
 window.status = (FDRisOver && isLink) ? (prefix + linkStr) : "";

Fader Restart Pointer

In FDRend(), we declared the startIndex variable. This stored a pointer to the array index from which to restart the Fader if the user double-clicked on it:

function FDRend(){
    .
    .
    .
    if (FDRreplayOnClick) {
        startIndex = FDRendWithFirst ? 2 : 0;
        .
        .
        .
    }
}

We should make it account for multiple headlines, so that when the user double-clicks the display will update with the next headlines in the array sequence:

function FDRend(){
    .
    .
    .
    if (FDRreplayOnClick) {
        startIndex = FDRendWithFirst ? (FDRhdlineCount * 2) : 0;
        .
        .
        .
    }
}

That's it for the two new features. Now back to browser-specific stuff.


Produced by Peter Belesis and

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

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

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business

All Rights Reserved. Legal Notices.
Created: Nov 30, 1999
Revised: Nov 30, 1999

URL: http://www.webreference.com/dhtml/column27/fade3hdline2.html