[TriLUG] javascript samples

Jeffery Painter painter at kiasoft.com
Sun Jan 30 19:04:34 EST 2005


Took me about 10 minutes. I wrote up a quick php script... if you are 
interested.

  http://kiasoft.com/~painter/random.php

Basically, you just create .txt files in a ./testimonial/ subdirectory, 
and it will randomly pull one... you can even include <html> code in your 
.txt files!

Enjoy


On Sun, 30 Jan 2005, Jim Ray wrote:

> Here are the best samples of javascript I've found on this lovely Sunday
> with 2 kids plus Bob the Builder:
> 
> http://www.neuse.net/javascript.htm
> 
> If I had the refresh functionality of # 2 with the ability to place the
> script output inside a specific table cell, I'd be happy.
> 
> If I could place the multi line capability of # 4 (and ditto for # 8) inside
> a table cell, I'd also be happy.
> 
> # 5 will work yet has only one line and scrolls right to left instead of
> multiline with bottom to top.
> 
> # 9 looks like it *is* in a table cell and would be way cool to implement if
> I could control the table cell.
> 
> If anyone knows of some others that work good and support multiple browsers,
> I am all ears.
> 
> Sincerely,
> 
> Jim
> 
> Jim Ray, MCSE
> President
> 

-- 
Jeffery Painter
    2431 Reunion Meadows Lane
    Apex, NC 27539
    voice: 919.321.0378

- --
painter at kiasoft.com                http://jeff.kiasoft.com
PGP FP: 9CE8 83A2 33FA 32B1 0AB1  4E62 E4CB E4DA 5913 EFBC

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE/qEQE5Mvk2lkT77wRAnMJAJ9vJ6qOkg/mvqqIpz7troCEQJ8bFACglu/U
YNXabx7DZOV2Hd9LwSTmGpY=
=dWiu
-----END PGP SIGNATURE-----
-------------- next part --------------
<html>
    <head>
        <title> Random Text reader </title>
    </head>

    <body bgcolor="#ffffff">

        <div align="center">
                                <?php
                                    //read folder
                                    $folder=opendir("./testimonial/");
                                    $maxImage = 0;
                                    while ($file = readdir($folder)) {
                                     $names[count($names)] = $file;
                                    }
                                    closedir($folder);

                                    //sort file names in array
                                    sort($names);

                                    //remove any non-text files from array
                                    $tempvar=0;
                                    for ($i=0;$names[$i];$i++)
                                    {
                                     $ext = strtolower(substr($names[$i],-4));
                                     if ($ext==".txt")
                                     {
                                            $names1[$tempvar]=$names[$i];$tempvar++;
                                     }
                                    }

                                    //random
                                    srand ((double) microtime() * 10000);
                                    $rand_keys = array_rand ($names1, 2);

                                    //assign random text file from array
                                    $slika=$names1[$rand_keys[0]];

                                    //debug statement
                                    echo "Filename: $slika <br/>";

                                    chdir( "./testimonial/" );
                                    $fp = fopen( $slika, "r" );
                                    if(!$fp)
                                    {
                                        echo "Couldn't open the data file. Try again later.";
                                        exit;
                                    } else {
                                        $content = fread( $fp, filesize( $slika ) );
                                        echo "$content";
                                    }
                                ?>

        </div>

    </body>
</html>


More information about the TriLUG mailing list