CSCI 4230
Internet Applicaiton Development
Spring 2001
Suggested Solution to Homework #6

(1)    For example:

<html>
<head>
<title>Homework #6, CSCI 4230, Spring 2001</title>
<link rel="stylesheet" type="text/css" href="styles/DynamicLink.css">
</head>
<body onload="showTicker();">
Recommended Tickers:
<p>
<div style="position:absolute" id="ticker"></div>
<script>

//Change the parameters below.
var fontsize=16;
var refreshInterval=4000;

function nextTicker()
{   nextTicker.count++;
    if (nextTicker.count >= nextTicker.Tickers.length)
    {   nextTicker.count = 0;
    }
    return nextTicker.Tickers[nextTicker.count];
}

nextTicker.Tickers = new Array(

<%  '    number of links in the ticker.
    numLinks=0

    ' Use Request parameter to get file.
    filename = Request.QueryString("filename")
    localFilename = ""
    if (filename <> "") Then
        localFilename = server.mappath(filename)
    End if
    Set fs = CreateObject("Scripting.FileSystemObject")

    If fs.FileExists(localFilename) Then
        Set thisfile = fs.OpenTextFile(localFilename, 1, False)
        do while not thisfile.AtEndOfStream
            description=thisfile.readline
            description=Replace(description,"\","\\")
            description=Replace(description,"""","\""")
            url =thisfile.readline
            if (numLinks > 0) then
                response.write ","
                response.write vBCrLf
            end if

            response.write """" & description & ": <a href='" & url & "'>" & url & "</a>"""
            numLinks=numLinks+1
        loop

        thisfile.Close
        set thisfile=nothing
        set fs=nothing
    End If

    if (numLinks = 0) then
    '    Default link values
%>
    "Bun Yue's page at nasmain: <a href='http://sce.uhcl.edu/yue'>http://sce.uhcl.edu/yue</a>",
    "Bun Yue's page at turquoise: <a href='http://turquoise.rocks.uhcl.edu/yue'>http://turquoise.rocks.uhcl.edu/yue</a>"
<%
    end if
%>
          );
<!--  End array nextTicker  -->
nextTicker.count = nextTicker.Tickers.length-1;

'    showing the next ticker value.
function showTicker(){
    var tickerHtmlCode = '<div class="ticker">'+nextTicker()+'</div>';
    if (document.layers){
        document.ticker.document.write(tickerHtmlCode);
        document.ticker.document.close();
    }
    else if (document.all)
       ticker.innerHTML=tickerHtmlCode;
    setTimeout("showTicker()",refreshInterval);
}
</script>
</body>
</html>