Online Documentation Server
 ПОИСК
ods.com.ua Web
 КАТЕГОРИИ
Home
Programming
Net technology
Unixes
Security
RFC, HOWTO
Web technology
Data bases
Other docs

 


 ПОДПИСКА

 О КОПИРАЙТАХ
Вся предоставленная на этом сервере информация собрана нами из разных источников. Если Вам кажется, что публикация каких-то документов нарушает чьи-либо авторские права, сообщите нам об этом.




Previous Table of Contents Next

At first, the speed of the banner is set to 100. This is equal to the pause between each character of a message in milliseconds. The pause (in milliseconds) between the completion of a message (string) and its deletion is assigned to the variable pause. The identifier for the current timeout is assigned null, because no timeout is set yet. The current state of the banner (false because it is not running yet) is assigned to the variable bannerRunning. An array is then created to hold the strings that are to be displayed as banner messages. The first string is assigned to the first element of the array, ar[0], and so on. The number 0 is assigned to currentMessage because the first message displayed is ar[0]. The index of the last character displayed at a given moment in the status bar is assigned to the global variable offset. It is set to zero because the first appearance of the banner consists of only one character—the first one—whose index is zero.

stopBanner()

// start the banner
function startBanner() {
  // make sure the banner is stopped
  stopBanner()

  // start the banner from the current position
  showBanner()
}

This function is called to stop the banner. If the banner is running, the current timeout is cleared. The variable bannerRunning is set to false because the banner is stopped.

startBanner()

// start the banner
function startBanner() {
  // make sure the banner is stopped
  stopBanner()

  // start the banner from the current position
  showBanner()
}

This function calls the stopBanner function to make sure the banner is stopped, and then calls the function showBanner to start running the T-banner.

showBanner()

// type in the current message
function showBanner() {
  // assign current message to variable
  var text = ar[currentMessage]

  // if current message has not finished being displayed
  if (offset < text.length) {
 // if last character of current message is a space
 if (text.charAt(offset) == " ")
// skip the current character
offset++

// assign the up-to-date to-be-displayed substring
// second argument of method accepts index of last char plus one
var partialMessage = text.substring(0, offset + 1)

// display partial message in status bar
window.status = partialMessage

// increment index of last character to be displayed
offset++ // IE sometimes has trouble with "++offset"

// recursive call after specified time
timerID = setTimeout("showBanner()", speed)

// banner is running
bannerRunning = true
   } else {
// reset offset
offset = 0

// increment subscript (index) of current message
currentMessage++

// if subscript of current message is out of range
if (currentMessage == ar.length)
   // wrap around (start from beginning)
   currentMessage = 0

// recursive call after specified time
timerID = setTimeout("showBanner()", pause)

// banner is running
bannerRunning = true
   }
}

The current message is assigned to the local variable text. The function then continues in one of two directions. The first is selected if the current message is still being displayed; that is, if the index of the last character that was displayed of the current message is the last character or less. In that case the expression offset < text.length evaluates to true. If the last character to be displayed during this pass through the function is a space, the value of offset is incremented, and no time is wasted on typing the space character. The substring that needs to be displayed during the current iteration is assigned to the local variable partialMessage. Since the second argument of the substring method is the index of the last character plus one, it is set to be offset + 1. The current substring is displayed in the status bar, and the value of offset is incremented. The function is called once more after speed milliseconds.

When the end of the current message has been reached, another execution path is taken. In this case the variable offset is assigned zero, the index of the first character of a string. To allow posting of the next message in the array, the index of the array element holding the current message is incremented. If the new value of currentMessage is out of range, it is set to zero, so the following message is the first one. The function is called recursively after pause milliseconds. This time the function should take the first route, because the message is only at its beginning.

Event Handlers

The startBanner function is called when the document has finished loading by the onLoad event handler.

R-banner

While T stands for type, typewriter, or Tomer, R probably stands for random, denoting the flavor of this special banner. The messages appear by popping up various characters of the message in a random order. Another special effect involved in this banner is the scrolling motion from right to left. This effect is being achieved by simply letting each character that pops up take a three-character space. Take a look at the script now:

Previous Table of Contents Next


With any suggestions or questions please feel free to contact us