Full version: jsB@nk » Status » Status » Text Writer in status bar
URL: https://www.javascriptbank.com/text-writer-in-status-bar.html
This JavaScript types your messages in status bar.
Full version: jsB@nk » Status » Status » Text Writer in status bar
URL: https://www.javascriptbank.com/text-writer-in-status-bar.html
<script>function initSequence(){// parametres par defaut : modifiablessequence = new Array();// tableau contenant les chaines a afficherwaitMsg = 1000;// delai par defaut avant d afficher le message suivant (millisecondes)waitLetter = 80;// delai par defaut avant d afficher la lettre suivante (millisecondes)// compteurs : ne pas changer les valeurs initiales !nMsg = 0;nextMsg = 0;nextLetter = 0;// parametres ponctuelswaitNextMsg = 0;// nombre de millisecondes a attendre avant d afficher le prochain messagewaitNextLetter = 0;// nombre de millisecondes a attendre avant d afficher la prochaine lettretimer = '';// pour faire un clearTimeout() (+ propre ?)}//// constructeur de l'objet "sequence"//function sequenceMaker( xtext, xwaitMsg, xwaitLetter, xconcat ){// rem : with(this) ne fonctionne pas icithis.text = xtext;this.waitMsg = xwaitMsg;this.waitLetter = xwaitLetter;this.concat = xconcat;// rem : return(this) n'est pas necessaire}//// ajoute un message a la liste//function displayText( text ){var xwaitMsg;var xwaitLetter;if( waitNextMsg > 0 ){ xwaitMsg = waitNextMsg; waitNextMsg = 0; }else{ xwaitMsg = waitMsg; }if( waitNextLetter > 0 ){ xwaitLetter = waitNextLetter; waitNextLetter = 0; }else{ xwaitLetter = waitLetter; }sequence[nMsg] = new sequenceMaker(text,xwaitMsg,xwaitLetter,false);nMsg++;}//// <=> displayText, mais complete le contenu actuel de la barre de status au lieu de l'effacer//function concatText( text ){var xwaitMsg;var xwaitLetter;if( waitNextMsg > 0 ){ xwaitMsg = waitNextMsg; waitNextMsg = 0; }else{ xwaitMsg = waitMsg; }if( waitNextLetter > 0 ){ xwaitLetter = waitNextLetter; waitNextLetter = 0; }else{ xwaitLetter = waitLetter; }sequence[nMsg] = new sequenceMaker(text,xwaitMsg,xwaitLetter,true);nMsg++;}//// joue un par un les messages, en affichant lettre par lettre//function playSequence(){///////////////////////////////////// conditions de sortie prematuree///////////////////////////////////// fin du texte -> message suivantif( nextLetter >= sequence[nextMsg].text.length ){nextLetter = 0;window.status = window.status + ' ';// l'espace final pour delimiter le message suivant s'il est concatenenextMsg++;}// termine si tous les messages ont ete lusif( nextMsg >= nMsg ){clearTimeout(timer);return(false);}//////////////////////////// traitement du message//////////////////////////// si c'est le debut d'un messageif( nextLetter == 0 ){var waitin = sequence[nextMsg].waitMsg;// avant toute chose on observe un delai si demandeif( waitin > 0 ){sequence[nextMsg].waitMsg = 0;timer = setTimeout("playSequence();" , waitin);return(true);}// ensuite on efface le contenu de la barre de status si demandeif( sequence[nextMsg].concat == false ){ window.status = ''; }}//////////////////////////// traitement des lettres//////////////////////////// affiche la lettre a la suite des autreswindow.status = window.status + sequence[nextMsg].text.charAt(nextLetter);// lettre suivantenextLetter++;timer = setTimeout("playSequence();" , sequence[nextMsg].waitLetter);return(true);}</script><script>function duneMarquee(){// initializes the global variants ; i'm working on the next version so it will not be needed anymoreinitSequence();// makes the sequence of sentencesdisplayText('The beginning is a very delicate time.');// replaces the content of the window's status bar with this textdisplayText('Know then that it is the year 10,191.');displayText('The known universe is ruled by the Paddishah Emperor Shaddam IV,');waitNextMsg = 1000;// the next sentence will show up in 1000 milliseconds (1 second)concatText('my father.');// adds this text to the end of the content of the status bardisplayText('In this time the most precious substance in the universe is the spice Melange.');displayText('The spice extends life.');displayText('The spice expands conciousness.');displayText('The spice is vital to space travel.');displayText('The Spacing Guild and its navigators whom the spice has mutated over 4,000 years');waitNextMsg = 500;displayText('use the orange spice gas,');waitNextMsg = 500;concatText('which gives them the ability to fold space.');displayText('That is,');waitNextMsg = 1000;concatText('travel to any part of the universe without actually moving.');displayText('Oh yes.');concatText('I forgot to tell you.');displayText('The spice exists on only one planet in the entire universe...');displayText('A desolate, dry planet with vast deserts.');displayText('Hidden away within the rocks of these deserts are a people known as the Fremen,');waitNextMsg = 500;displayText('who have long held a prophecy,');waitNextMsg = 1000;concatText('that the man would come,');concatText('the Messiah,');waitNextMsg = 1000;displayText('who would lead them to true freedom.');displayText('The planet is Arrakis,');waitNextMsg = 1000;concatText('also known as');waitNextMsg = 500;waitNextLetter = 500;// one letter of the next sentence will be displayed every 500 millisecondconcatText('DUNE');waitNextMsg = 100;concatText('!');// starts the sequenceplaySequence();}</script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<body onLoad="duneMarquee();"><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->