Teletype in Form

[Total: 0    Average: 0/5]

Head Code:

<SCRIPT>

<!--  Activate Cloaking Device


// used to track position in message

   var i = 0; 

// used to cycle thru messages                                          

   var TextNumber = 0;

// array of messages                        

   var TextInput = new Object();

// used to load manipulate message          

   var HelpText="";                              

// used to load message

   var Text = "";  

// length of timeout (smaller is faster)                                  

   var Speed=50;

// added to end of each message to create a pause

   var WaitSpace="                "

// used to position text in ver 2.0

   var addPadding="rn";



// Each element of TextInput represents a single message.

TextInput[0] = "This is just another method of displaying information to your visitors.";  

TextInput[1] = "The routine is based on the T-Banner by Tomer and Yehuda Shiran.";

TextInput[2] = "I've selected the TextArea for display to utilize the wrap-around feature.";

TextInput[3] = "The messages can be made to cycle manually, check out Tele-Type 1 in Tim's Lab.";

TextInput[4] = "Though this scheme is not perfect, you have to admit it is different!";

TextInput[5] = "I've learned that you can reduce flicker by shortening the messages.";

TextInput[6] = "One may want to add speed adjustment to better match individual machines.";

TextInput[7] = "Whether practical or not, at least it was fun developing Timothy's Tele-Type Display!";

TotalTextInput = 7; // (0, 1, 2, 3, 4, 5, 6, 7)



// Positioning and speed vary between versions.

var Version =  navigator.appVersion;  

if (Version.substring(0, 1)==3)

   {

   Speed=200;

   addPadding="";

   }



for (var addPause = 0; addPause <= TotalTextInput; addPause++) 

   {TextInput[addPause]=addPadding+TextInput[addPause]+WaitSpace;}



var TimerId

var TimerSet=false;



// Called by the Start button.

function startMessage() 

   {

   if (!TimerSet)

      {

      TimerSet=true;

      teletype();

      }

   }



// Gets and displays character from rollMessage() . 

// Variable Speed controls length of timeout and thus the speed of typing.

function teletype() 

   {

   Text=rollMessage();

   TimerId = setTimeout("teletype()", Speed)

   document.forms[0].elements[0].value=Text;

   }



// Pulls one character at a time from string and returns (as Text) to function teletype() for displaying.

function rollMessage () 

   {

   Wait_yn=false;

   i++;

   var CheckSpace = HelpText.substring(i-1, i);

   CheckSpace = "" + CheckSpace;

   if (CheckSpace == " ") 

      {i++;}

   if (i >= HelpText.length+1) 

      {

      i=0; 

      if (TextNumber < TotalTextInput) 

         {TextNumber++;} 

      else {TextNumber = 0;} 

      initMessage();

      }

   Text = HelpText.substring(0, i);

   return (Text);

   }



// Called from onLoad in BODY tag & resetDisplay().

function titleDisplay()

   {

   document.forms[0].elements[0].value="rn         AutoCycle Tele-Type Display";

   initMessage();

   }



// Sets Text & HelpText equal to messages for use in rollMessage ().

function initMessage() 

   {

   Text = TextInput[TextNumber]

   HelpText = Text;

   }



// Called by Stop button.

function stopMessage() 

   {

   TimerSet=false; 

   clearTimeout (TimerId); 

   }



// Called by Reset button.

function resetDisplay()

   {

   TimerSet=false; 

   clearTimeout (TimerId);

   TextNumber=0;

   i=0;

   titleDisplay();   

   }





// Deactivate Cloaking -->

</SCRIPT>

Body Code:

<CENTER><STRONG>Automatic TeleType Display</STRONG></CENTER>

<BR><BR>



<FORM>

<TEXTAREA ROWS=2 COLS=55 wrap=yes></TEXTAREA>

<BR><BR>

<TABLE BORDER=0 WIDTH=300>

<TD align="center"><INPUT TYPE="button" VALUE="Start" onClick="startMessage()">

<TD align="center"><INPUT TYPE="button" VALUE="Reset" onClick="resetDisplay()">

<TD align="center"><INPUT TYPE="button" VALUE="Stop" onClick="stopMessage()">

</TABLE>
<script>
titleDisplay();
</script>

</FORM>

Times Viewed: 7

Leave a Reply

Your email address will not be published. Required fields are marked *