»
EnglishFrenchVietnamese

Print - Scrollers in Status Bar I - JavaScriptBank.com

Full version: jsB@nk » Status » Status » Scrollers in Status Bar I
URL: https://www.javascriptbank.com/scrollers-in-status-bar-i.html

Scrollers in Status Bar I © JavaScriptBank.comThe script will display the messages which have characters are reduced the distance with every word.

Full version: jsB@nk » Status » Status » Scrollers in Status Bar I
URL: https://www.javascriptbank.com/scrollers-in-status-bar-i.html



JavaScript
<SCRIPT LANGUAGE="JavaScript"><!--// Copyright 1996 - Tomer and Yehuda Shiran// For more information contact Tomer or Yehuda Shiran <[email protected]>// set speed of banner (pause in milliseconds between addition of new character)var speed = 10 // decrease value to increase speed (must be positive)// set pause between completion of message and beginning of following messagevar pause = 1500 // increase value to increase pause// set initial valuesvar timerID = nullvar bannerRunning = false// create arrayvar ar = new Array()// assign the strings to the array's elementsar[0] = "Welcome to JavaScriptBank.com"ar[1] = "I hope you enjoy the free javascripts"ar[2] = "It is designed to be more stable than regular banners"ar[3] = "Don't forget to check out the other scripts!"// assign index of current messagevar message = 0// empty string initializationvar state = ""// no value is currently being displayedclearState()// stop the banner if it is currently runningfunction stopBanner() {// if banner is currently runningif (bannerRunning)// stop the bannerclearTimeout(timerID)// timer is now stoppedtimerRunning = false}// start the bannerfunction startBanner() {// make sure the banner is stoppedstopBanner()// start the banner from the current positionshowBanner()}// assign state a string of "0" characters of the length of the current messagefunction clearState() {// initialize to empty stringstate = ""// create string of same length containing 0 digitsfor (var i = 0; i < ar[message].length; ++i) {state += "0"}}// display the current messagefunction showBanner() {// if the current message is doneif (getString()) {// increment messagemessage++// if new message is out of range wrap around to first messageif (ar.length <= message)message = 0// new message is first displayed as empty stringclearState()// display next character after pause millisecondstimerID = setTimeout("showBanner()", pause)} else {// initialize to empty stringvar str = ""// built string to be displayed (only character selected thus far are displayed)for (var j = 0; j < state.length; ++j) {str += (state.charAt(j) == "1") ? ar[message].charAt(j) : "     "}// partial string is placed in status barwindow.status = str// add another character after speed millisecondstimerID = setTimeout("showBanner()", speed)}}function getString() {// set variable to true (it will stay true unless proven otherwise)var full = true// set variable to false if a free space is found in string (a not-displayed char)for (var j = 0; j < state.length; ++j) {// if character at index j of current message has not been placed in displayed stringif (state.charAt(j) == 0)full = false}// return true immediately if no space found (avoid infinitive loop later)if (full) return true// search for random until free space found (braoken up via break statement)while (1) {// a random number (between 0 and state.length - 1 == message.length - 1)var num = getRandom(ar[message].length)// if free space found break infinitive loopif (state.charAt(num) == "0")break}// replace the 0 character with 1 character at place foundstate = state.substring(0, num) + "1" + state.substring(num + 1, state.length)// return false because the string was not full (free space was found)return false}function getRandom(max) {// create instance of current datevar now = new Date()// create a random number (good generator)var num = now.getTime() * now.getSeconds() * Math.random()// cut random number to value between 0 and max - 1, inclusivereturn num % max}startBanner()// --></SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->