Click here to Skip to main content
15,907,497 members
Articles / Web Development / HTML
Article

Telemetered Secure Data Effect

Rate me:
Please Sign up or sign in to vote.
4.11/5 (5 votes)
25 Dec 2008BSD 16.6K   65   4  
JavaScript based effect that simulates the transmission of secure data to a terminal.

TelemeteredDataEffect

Introduction

This JavaScript based effect simulates the character-by-character transmission of secure data to a terminal.

Background

The code has been designed to move through a set of text on a character-by-character basis with a telemetry data received audio “blip”. This happens by making a copy of the text in a hidden DIV tag, and clearing the tag text then showing the DIV. Next, each character is reintroduced into the DIV tag one at a time while playing a “blip” sound.

The script also supports changing the audio “blip” style through an embedded tag: <!--SWAPSOUND-->. Here is the function that displays the next character:

Disclaimer: I have only tested the code on Internet Explorer so far.

JavaScript
function DisplayNextChar()
{
    var nextChar = text.charAt(index);

    if (nextChar == "<")
    {
        var endOfTag = text.indexOf(">", index) + 1;
        var tag = text.substring(index, endOfTag).toUpperCase();

        if (tag == "<!--SWAPSOUND-->")
        {
            Pause();
            tickSound = !tickSound;
            Resume();
        }
        else if (tag == "<BR>")
            document.all.message.innerHTML += "<BR><BR>";
        else
            document.all.message.innerHTML += tag;

        index = endOfTag;
    }
    else if (nextChar == "&")
    {
        var endOfElem = text.indexOf(";", index) + 1;

        document.all.message.innerHTML += text.substring(index, endOfElem);
        index = endOfElem;
    }
    else
    {
        document.all.message.innerHTML += nextChar;
        index++;
    }

    document.all.ScrollMarker.scrollIntoView();

    if (index >= text.length - 1)
    {
        Pause();
        document.all.EndTransmissionSound.src = "BlipEnd.wma";
    }
    else if (nextChar == ".")
    {
        Pause();
        setTimeout(Resume, 100);
    }
}

To add to the effect, the sound balance is rotated from one speaker to the other, adding to the allusion that the data is moving. This is accomplished by adjusting the sound’s balance property on a timer:

JavaScript
function RotateBalance()
{
    var balance = document.all.TelemetrySound.balance;

    balance += 50;
    if (balance > 5000) balance = -5000;

    document.all.TelemetrySound.balance = balance;
}

Using the code

The following code shows some example text and the script code in ONLOAD that starts the effect (make sure and download the entire set of script for proper operation - only excerpts of the code have been provided):

HTML
<BODY BGCOLOR="black" ONLOAD="InitTextEffect()" STYLE="MARGIN: 0px">
    <DIV ID="message" CLASS="message" STYLE="DISPLAY:none; PADDING-LEFT: 10px; ">
      Transmission one.<BR>
      <!--SWAPSOUND--><BR>
      Transmission two.<BR>
    </DIV>
    <A HREF="#" ID="ScrollMarker"></A>
</BODY>

License

This article, along with any associated source code and files, is licensed under The BSD License


Written By
Architect
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --