slideshow and variable name for images (global?)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • drillbit_99@yahoo.com

    slideshow and variable name for images (global?)

    I have an HTML page of thumbnail images. Each image can begin a
    slideshow of the images on the page by clicking on the image. This
    opens another HTML page that begins the slideshow using large images of
    the thumbnails. When the slideshow begins it always starts with the
    first image. I would like to pass the name of the thumbnail to the
    slideshow HTML page and begin the slideshow with the same image the
    user clicks on. Is this asking too much? Does anyone have a solution?


    -----------------------------------------------------------------
    ---------thumbnail page
    -----------------------------------------------------------------
    -----------------------------------------------------------------
    -----------------------------------------------------------------


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    <html>
    <head>
    <title>DHS Homecoming 2005</title>
    <meta http-equiv="content-type" content="text/html;
    charset=iso-8859-1">
    <link rel=stylesheet type="text/css" href="styles.cs s">
    </head>

    <body>
    <h1 class=title>Hom ecoming 2005</h1>

    <p class=desc>Muns on Stadium, Forest Park - September 23,
    2005<br><br>Cli ck on any photo to see an enlarged version.
    </p>

    <br>

    <center>
    <table cellspacing="12 ">
    <tr>
    <td class=thumbnail width="192" height="192">
    <a href="pictures/slides.html" name="dsc_0021" ><img
    src="thumbs/DSC00067.jpg" width="192" height="131" border="0"
    alt="DSC00067.j pg"></a>
    </td>
    <td class=thumbnail width="192" height="192">
    <a href="pictures/slides.html" name="dsc_0018" ><img
    src="thumbs/DSC00068.jpg" width="192" height="131" border="0"
    alt="DSC00068.j pg"></a>
    </td>
    <td class=thumbnail width="192" height="192">
    <a href="pictures/slides.html" name="dsc_0020" ><img
    src="thumbs/DSC00069.jpg" width="192" height="131" border="0"
    alt="DSC00069.j pg"></a>
    </td>
    </tr>
    <tr>
    <td class=thumbnail width="192" height="192">
    <a href="pictures/slides.html" name="dsc_0022" ><img
    src="thumbs/DSC00070.jpg" width="192" height="131" border="0"
    alt="DSC00070.j pg"></a>
    </td>
    <td class=thumbnail width="192" height="192">
    <a href="pictures/slides.html" name="dsc_0029" ><img
    src="thumbs/DSC00071.jpg" width="192" height="131" border="0"
    alt="DSC00071.j pg"></a>
    </td>
    <td class=thumbnail width="192" height="192">
    <a href="pictures/slides.html" name="dsc_0030" ><img
    src="thumbs/DSC00072.jpg" width="192" height="131" border="0"
    alt="DSC00072.j pg"></a>
    </td>
    </tr>
    <tr>
    <td class=thumbnail width="192" height="192">
    <a href="pictures/slides.html" name="dsc_0031" ><img
    src="thumbs/DSC00073.jpg" width="192" height="131" border="0"
    alt="DSC00073.j pg"></a>
    </td>
    <td class=thumbnail width="192" height="192">
    <a href="pictures/slides.html" name="dsc_0033" ><img
    src="thumbs/DSC00074.jpg" width="192" height="131" border="0"
    alt="DSC00074.j pg"></a>
    </td>
    <td class=thumbnail width="192" height="192">
    <a href="pictures/slides.html" name="dsc_0035" ><img
    src="thumbs/DSC00075.jpg" width="192" height="131" border="0"
    alt="DSC00075.j pg"></a>
    </td>
    </tr>
    <tr>
    <td class=thumbnail width="192" height="192">
    <a href="pictures/slides.html" name="dsc_0038" ><img
    src="thumbs/DSC00076.jpg" width="192" height="131" border="0"
    alt="DSC00076.j pg"></a>
    </td>
    <td class=thumbnail width="192" height="192">
    <a href="pictures/slides.html" name="dsc_0039" ><img
    src="thumbs/DSC00077.jpg" width="192" height="131" border="0"
    alt="DSC00077.j pg"></a>
    </td>
    <td class=thumbnail width="192" height="192">
    <a href="pictures/slides.html" name="dsc_0040" ><img
    src="thumbs/DSC00078.jpg" width="192" height="131" border="0"
    alt="DSC00078.j pg"></a>
    </td>
    </tr>
    <tr>
    <td class=thumbnail width="192" height="192">
    <a href="pictures/slides.html" name="dsc_0041" ><img
    src="thumbs/DSC00079.jpg" width="192" height="131" border="0"
    alt="DSC00079.j pg"></a>
    </td>
    <td class=thumbnail width="192" height="192">
    <a href="pictures/slides.html" name="dsc_0046" ><img
    src="thumbs/DSC00080.jpg" width="192" height="131" border="0"
    alt="DSC00080.j pg"></a>
    </td>

    </tr>
    </table>
    </center>



    <br>
    <br>
    <table cellspacing="8" >
    <tr>
    <td width="20" height="20"> </td>
    </tr>
    </table>


    <p class=desc>Last updated: 6/10/2005
    </p>

    </body>
    </html>


    -----------------------------------------------------------------
    ----------slideshow page
    -----------------------------------------------------------------
    -----------------------------------------------------------------
    -----------------------------------------------------------------



    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    <html>
    <head>
    <title>SOSU Marching Contest</title> <script language="JavaS cript">

    <!-- Begin
    NewImg = new Array (
    "DSC00081.j pg",
    "DSC00082.j pg",
    "DSC00083.j pg",
    "DSC00084.j pg",
    "DSC00085.j pg",
    "DSC00086.j pg",
    "DSC00087.j pg",
    "DSC00088.j pg",
    "DSC00089.j pg",
    "DSC00090.j pg",
    "DSC00091.j pg",
    "DSC00092.j pg"
    );
    var ImgNum = 0;
    var ImgLength = NewImg.length - 1;


    var delay = 3000;

    var lock = false;
    var run;
    function chgImg(directio n) {
    if (document.image s) {
    ImgNum = ImgNum + direction;
    if (ImgNum > ImgLength) {
    ImgNum = 0;
    }
    if (ImgNum < 0) {
    ImgNum = ImgLength;
    }
    document.slides how.src = NewImg[ImgNum];
    }
    }
    function auto() {
    if (lock == true) {
    lock = false;
    window.clearInt erval(run);
    }
    else if (lock == false) {
    lock = true;
    run = setInterval("ch gImg(1)", delay);
    }
    }
    </script>
    <link rel="stylesheet " type="text/css" href="../styles.css">
    </head>
    <body>
    <img src="DSC00081.j pg" name="slideshow " width="850">
    <table border="10" frame="box" width="850" bgcolor="#FFCC3 3">
    <tr>
    <td align="center" width="100">
    <a href="javascrip t:chgImg(-1)">Previous</a>
    </td>
    <td align="center">
    <a href="javascrip t:auto()">Auto/Stop</a>
    </td>
    <td align="center" width="100">
    <a href="javascrip t:chgImg(1)">Ne xt</a>
    </td>
    </tr>
    </table>
    </body>
    </html>

  • ASM

    #2
    Re: slideshow and variable name for images (global?)

    drillbit_99@yah oo.com a écrit :[color=blue]
    > I have an HTML page of thumbnail images. Each image can begin a
    > slideshow of the images on the page by clicking on the image. This
    > opens another HTML page that begins the slideshow using large images of
    > the thumbnails. When the slideshow begins it always starts with the
    > first image. I would like to pass the name of the thumbnail to the
    > slideshow HTML page and begin the slideshow with the same image the
    > user clicks on. Is this asking too much? Does anyone have a solution?[/color]

    I'll expect functions of slideshow work

    ----slideshow page----

    [JS part]

    funcion getImg() {
    newImg = self.location.s earch.substring (1)
    auto(newImg);
    }

    function auto(nbrImg) {
    nbrImg = (nbrImg && nbrImg!='') nbrImg : 1;
    if (lock == true) {
    lock = false;
    window.clearInt erval(run);
    }
    else if (lock == false) {
    lock = true;
    run = setInterval("ch gImg("+nbrImg+" )", delay);
    }
    }

    [HTML part]

    <body onload="getImg( )">

    ----end complement slideshow----

    -----thumbnail page-----

    links this way :

    <a href="pictures/slides.html?67" name="dsc_0021" ><img
    src="thumbs/DSC00067.jpg" width="192" height="131" border="0"
    alt="thumbnail" title="click me to get me in a slideshow"></a>

    add number of image to load at end of href
    don't forget the '?'
    href="file.htm? number"



    --
    Stephane Moriaux et son [moins] vieux Mac

    Comment

    • drillbit_99@yahoo.com

      #3
      Re: slideshow and variable name for images (global?)

      I added the function "getImg" to the slideshow page and replaced the
      function "auto" with your script. I also replaced the "body" tag.

      I changed my link on the thumbnail page and made sure I kept the '?'.

      When I tried the code, a click on the second picture link (using '?68')
      it performed as if nothing had changed. The link still opens the first
      picture in the slideshow.

      Should the '?' variable be 'DSC00068.jpg'? I tried that also and
      nothing changed.

      Comment

      • ASM

        #4
        Re: slideshow and variable name for images (global?)

        drillbit_99@yah oo.com a écrit :[color=blue]
        > I added the function "getImg" to the slideshow page and replaced the
        > function "auto" with your script. I also replaced the "body" tag.
        >
        > I changed my link on the thumbnail page and made sure I kept the '?'.
        >
        > When I tried the code, a click on the second picture link (using '?68')
        > it performed as if nothing had changed. The link still opens the first
        > picture in the slideshow.
        >
        > Should the '?' variable be 'DSC00068.jpg'? I tried that also and
        > nothing changed.
        >[/color]
        an error in a function ?
        (a '?' forgoten)

        try this :

        function auto(nbrImg) {
        nbrImg = (nbrImg && nbrImg!='')? nbrImg : 1;
        if (lock == true) {
        lock = false;
        window.clearInt erval(run);
        }
        else if (lock == false) {
        lock = true;
        run = setInterval("ch gImg("+nbrImg+" )", delay);
        }
        }

        --
        Stephane Moriaux et son [moins] vieux Mac

        Comment

        • ASM

          #5
          Re: slideshow and variable name for images (global?)

          drillbit_99@yah oo.com a écrit :[color=blue]
          > I added the function "getImg" to the slideshow page and replaced the
          > function "auto" with your script. I also replaced the "body" tag.
          >
          > I changed my link on the thumbnail page and made sure I kept the '?'.
          >
          > When I tried the code, a click on the second picture link (using '?68')[/color]

          68 have to be the index of array corresponding
          to photo to start with

          that's to say i.e. "DSC00085.j pg" in your example :
          link -> href="pictures/slides.html?4"
          [color=blue]
          > it performed as if nothing had changed. The link still opens the first
          > picture in the slideshow.
          >
          > Should the '?' variable be 'DSC00068.jpg'? I tried that also and
          > nothing changed.[/color]

          sorry, some misunderstandin g with your original script
          hope this time it will be ok

          ----slideshow page----

          [JS part]

          // new function to start on correct image
          funcion getImg() {
          ImgNum = self.location.s earch.substring (1);
          // alert to verify if that's ok (to delete after tests)
          alert('image number : '+ImgNum);
          lock == false;
          chgImg(1);
          auto();
          }

          // re-insert old function auto()
          // and of course all complete old script you did have
          function auto() {
          nbrImg = (nbrImg && nbrImg!='') nbrImg : 1;
          if (lock == true) {
          lock = false;
          window.clearInt erval(run);
          }
          else if (lock == false) {
          lock = true;
          run = setInterval("ch gImg(1)", delay);
          }
          }

          <body onload="getImg( );">

          ----- end ----

          if that runs only after some delay
          you can try without the onload in body tag
          and puting in all end of page (before </body>)
          the following :

          <script type="text/javascript">
          getImg();
          </script>


          ====== variante ======

          if you prefer a link this way :
          (real photo number)

          <a href="pictures/slides.html?003 8" name="dsc_0038" ><img
          src="thumbs/DSC00076.jpg" width="192" height="131" border="0"
          alt="DSC00076.j pg">

          // new function to start on correct image
          funcion getImg() {
          var startImg = self.location.s earch.substring (1);
          // alert to verify if that's ok (to delete after tests)
          alert('image number : '+startImg);
          for var(i=0;i<ImgLe ngth;i++)
          if(NewImg[i].indexOf(startI mg)>0) ImgNum=i;
          // alert to verify if that's ok (to delete after tests)
          alert('image Array index = '+ImgNum);
          lock == false;
          chgImg(1);
          auto();
          }


          --
          Stephane Moriaux et son [moins] vieux Mac

          Comment

          • drillbit_99@yahoo.com

            #6
            Re: slideshow and variable name for images (global?)

            Well, I'm pretty stupid with Javascript. I placed the new code in the
            slideshow page, but I don't see where the function 'getImg' is called.
            Can you tell me how to make the call? Below is the revised code for
            the slideshow page. Thanks for the help.


            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
            "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
            <html>
            <head>
            <title>Homecomi ng</title> <script language="JavaS cript">
            <!-- Original: Mike Canonigo (mike@canonigo. com) -->
            <!-- Web Site: http://www.munkeehead.com -->

            <!-- This script and many more are available free online at -->
            <!-- The JavaScript Source!! http://javascript.internet.com -->

            <!-- Begin
            NewImg = new Array (
            "DSC00067.j pg",
            "DSC00068.j pg",
            "DSC00069.j pg",
            "DSC00070.j pg",
            "DSC00071.j pg",
            "DSC00072.j pg",
            "DSC00073.j pg",
            "DSC00074.j pg",
            "DSC00075.j pg",
            "DSC00076.j pg",
            "DSC00077.j pg",
            "DSC00078.j pg",
            "DSC00079.j pg",
            "DSC00080.j pg"
            );
            var ImgNum = 0;
            var ImgLength = NewImg.length - 1;

            //Time delay between Slides in milliseconds
            var delay = 3000;

            var lock = false;
            var run;
            function chgImg(directio n) {
            if (document.image s) {
            ImgNum = ImgNum + direction;
            if (ImgNum > ImgLength) {
            ImgNum = 0;
            }
            if (ImgNum < 0) {
            ImgNum = ImgLength;
            }
            document.slides how.src = NewImg[ImgNum];
            }
            }



            // new function to start on correct image
            function getImg() {
            ImgNum = self.location.s earch.substring (1);
            // alert to verify if that's ok (to delete after tests)
            alert('image number : '+ImgNum);
            lock == false;
            chgImg(1);
            auto();

            }

            // re-insert old function auto()
            // and of course all complete old script you did have
            function auto() {
            nbrImg = (nbrImg && nbrImg!='') nbrImg : 1;
            if (lock == true) {
            lock = false;
            window.clearInt erval(run);
            }

            else if (lock == false) {
            lock = true;
            run = setInterval("ch gImg(1)", delay);
            }

            }
            </script>
            <link rel="stylesheet " type="text/css" href="../styles.css">
            </head>
            <body onload="getImg( );">
            <img src="DSC00067.j pg" name="slideshow " width="850">
            <table border="10" frame="box" width="850" bgcolor="#FFCC3 3">
            <tr>
            <td align="center" width="100">
            <a href="javascrip t:chgImg(-1)">Previous</a>
            </td>
            <td align="center">
            <a href="javascrip t:auto()">Auto/Stop</a>
            </td>
            <td align="center" width="100">
            <a href="javascrip t:chgImg(1)">Ne xt</a>
            </td>
            </tr>
            </table>
            </body>
            </html>

            Comment

            • ASM

              #7
              Re: slideshow and variable name for images (global?)

              drillbit_99@yah oo.com a écrit :[color=blue]
              > Well, I'm pretty stupid with Javascript. I placed the new code in the
              > slideshow page, but I don't see where the function 'getImg' is called.
              > Can you tell me how to make the call? Below is the revised code for
              > the slideshow page. Thanks for the help.[/color]

              ok,
              with, in other page, links with real photo number
              (I don't know if photo number would be 0038 or 0076 ?)

              <a href="pictures/slides.html?003 8" name="dsc_0038" ><img
              src="thumbs/DSC00076.jpg" width="192" height="131" border="0"
              alt="DSC00076.j pg"></a>

              You can also do :
              href="pictures/slides.html?DSC 00070.jpg"
              if you prefer
              but take care : sensitive case (a 'D' is not a 'd')

              here is your page (tested)

              <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
              "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
              <html>
              <head>
              <title>Homecomi ng</title> <script language="JavaS cript">
              <!-- Original: Mike Canonigo (mike@canonigo. com) -->
              <!-- Web Site: http://www.munkeehead.com -->

              <!-- This script and many more are available free online at -->
              <!-- The JavaScript Source!! http://javascript.internet.com -->

              <!-- Begin
              NewImg = new Array (
              "DSC00067.j pg",
              "DSC00068.j pg",
              "DSC00069.j pg",
              "DSC00070.j pg",
              "DSC00071.j pg",
              "DSC00072.j pg",
              "DSC00073.j pg",
              "DSC00074.j pg",
              "DSC00075.j pg",
              "DSC00076.j pg",
              "DSC00077.j pg",
              "DSC00078.j pg",
              "DSC00079.j pg",
              "DSC00080.j pg"
              );
              var ImgNum = 0;
              var ImgLength = NewImg.length - 1;

              //Time delay between Slides in milliseconds
              var delay = 3000;

              var lock = false;
              var run;

              function chgImg(directio n) {
              if (document.image s) {
              ImgNum = ImgNum + direction;
              if (ImgNum > ImgLength) {
              ImgNum = 0;
              }
              if (ImgNum < 0) {
              ImgNum = ImgLength;
              }
              document.images['slideshow'].src = NewImg[ImgNum];
              }
              }

              function auto() {
              if (lock == true) {
              lock = false;
              window.clearInt erval(run);
              }
              else if (lock == false) {
              lock = true;
              run = setInterval("ch gImg(1)", delay);
              }
              }

              function getImg() {
              var startImg = self.location.s earch.substring (1);
              for (var i=0;i<ImgLength ;i++)
              if(NewImg[i].indexOf(startI mg)>0) ImgNum = +i-1;
              lock == false;
              chgImg(1);
              auto();
              }

              </script>
              <link rel="stylesheet " type="text/css" href="../styles.css">
              <style type="text/css">
              p, button { text-align: center; }
              img { margin: auto; margin-bottom: 10px; width: 850px; }
              p.buttons { background-color: #fc3; margin: 10px; border: 1px solid black; }
              button { border: outset goldenrod 3px; background: #ff9;
              color: maroon; margin: 4px 10px; width: 100px; }
              button:hover { border-style: inset; }
              button:active { background: orange; color: white; }
              </style>
              </head>
              <body>
              <p><img src="DSC00067.j pg" name="slideshow " width="850"></p>
              <p class="buttons" >
              <button onclick="delay= delay*1.2;auto( );auto();">Slow er</button>
              <button onclick="chgImg (-1)">Previous</button>
              <button onclick="auto() ">Auto/Stop</button>
              <button onclick="chgImg (1)">Next</button>
              <button onclick="delay= delay*.8;auto() ;auto();">Faste r</button>
              </p>
              <script type="text/javascript">
              getImg();
              </script>
              </body>
              </html>



              --
              Stephane Moriaux et son [moins] vieux Mac

              Comment

              • Richard Cornford

                #8
                Re: slideshow and variable name for images (global?)

                ASM wrote:
                <snip>[color=blue]
                > function auto(nbrImg) {
                > nbrImg = (nbrImg && nbrImg!='') nbrImg : 1;
                > if (lock == true) {
                > lock = false;
                > window.clearInt erval(run);
                > }
                > else if (lock == false) {
                > lock = true;
                > run = setInterval("ch gImg("+nbrImg+" )", delay);
                > }
                > }[/color]
                <snip>

                What a very bad example of programming. Beyond the omission of the
                question mark in the conditional expression, what values for - nbrImg -
                are expected to type convert to boolean true and then possibly equal the
                empty string? The possible value of - nbrImg - that will producde false
                in - nbrImg != '' - are boolean false, +/- zero and the empty string,
                all of which either are false or would type-convert to false in the
                right hand side of the logical expression.

                It is invariable unwise to perform type-converting comparison with a
                boolean value without a specific reason. The values that do equal true
                with type-converting comparison are: boolean true, the number 1 and the
                string "1". It is unusual to want to only allow this particular set of
                values to trigger the entry into a branch in an if/else statement. It is
                much more likely that the intention is that the - lock - value be
                exclusively boolean and so that requirement would be enforced with a
                strict comparison operation (===), or taken advantage of by allowing the
                internal ToBoolean call implicit in the - if - expression to react to
                the true-ness of the value, eliminating the then redundant comparison,
                and the - if - statement in the else branch. So either:-

                Only when boolean:-

                if(lock === true){ //only if boolean true
                ....
                }else if(lock === false){ //else if boolean false
                ...
                }

                -or, reacting to type-converted true-ness:-

                if(lock){ // any 'true' value including boolean true
                ...
                }else{ //else any 'false' value including boolean false
                ...
                }

                If the global - lock - variable is initialised (as it mist be for the
                original function to work at all) then it would be logical to initials
                it to boolean false, and then use the second if/else formulation where
                only boolean values are assigned to - lock -.

                Richard.


                Comment

                • ASM

                  #9
                  Re: slideshow and variable name for images (global?)

                  Richard Cornford a écrit :[color=blue]
                  > ASM wrote:
                  > <snip>
                  >[color=green]
                  >>function auto(nbrImg) {
                  >>nbrImg = (nbrImg && nbrImg!='') nbrImg : 1;
                  >>if (lock == true) {
                  >>lock = false;
                  >>window.clearI nterval(run);
                  >>}
                  >>else if (lock == false) {
                  >>lock = true;
                  >>run = setInterval("ch gImg("+nbrImg+" )", delay);
                  >> }
                  >>}[/color]
                  >
                  > <snip>
                  >
                  > What a very bad example of programming. Beyond the omission of the
                  > question mark in the conditional expression,[/color]

                  I've seen it too late
                  [color=blue]
                  > what values for - nbrImg -
                  > are expected to type convert to boolean true and then possibly equal the
                  > empty string? The possible value of - nbrImg - that will producde false
                  > in - nbrImg != '' - are boolean false, +/- zero and the empty string,
                  > all of which either are false or would type-convert to false in the
                  > right hand side of the logical expression.[/color]

                  I want only to know if nbrImg exists and if is not empty
                  -> answer waited : false or true
                  boolean or not is JS's problem.

                  histories about 'look' are not mine

                  you forgot to see in thread : <script language="JavaS cript">

                  tell all that to :
                  <!-- Original: Mike Canonigo (mike@canonigo. com) -->
                  <!-- Web Site: http://www.munkeehead.com -->
                  <!-- This script and many more are available free online at -->
                  <!-- The JavaScript Source!! http://javascript.internet.com -->

                  as I understood this script comes
                  Certainly a lot of job to correct all oldies and mal writed scripts
                  is waiting a good soul.

                  --
                  Stephane Moriaux et son [moins] vieux Mac

                  Comment

                  Working...