Results 1 to 4 of 4

Thread: Snow

  1. #1
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    227
    Thanks
    82
    Thanked 3 Times in 3 Posts

    Default Snow

    1) Script Title: Snow

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex3/snow.htm

    3) Describe problem: I've adapted the script to http://www.marainlaw.com/page.php?here=quotations. It works fine. However, I am trying to understand it. It contains the following line: [ICODE]snowsrc=(snowsrc.indexOf("dynamicdrive.com")!=-1)? "snow.gif" : snowsrc
    [ICODE] Might someone have the time to explain what this line does? And how it does it?

    A.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    It (if it's not efited or removed) prevents hotlinking to Dynamic Drive's snow.gif or other images.

    It does this by checking to see if "dynamicdrive" is in the snowsrc variable as configured earlier in the script. If so, it changes the snowsrc variable to 'snow.gif', which would then look for that image in the same folder as the page. If "dynamicdrive" is not in the snowsrc variable, then it leaves it alone and looks for the snowsrc image as the designer has configured it earlier in the script.

    It's really not needed any longer because since this script was written, Dynamic Drive has configured its servers to not allow hot linking of images. But, as long as you're not hotlinking to Dynamic Drive, it doesn't do anything anyway, so there's no need for it to be removed.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    227
    Thanks
    82
    Thanked 3 Times in 3 Posts

    Default

    Thank you.

    My reason for asking was this: Now on my to-do list is to modify snow to present a distinct image, depending on month of the year. The line in question referenced the image that came with the original script. Thus I needed to understand it in order to determine whether I needed to make changes to it when implementing my contemplated modifications.

    ("to-do" list means God knows when I'll get to it.)

    Best,

    A.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Well, put another way, it's just a shorthand way of doing:

    Code:
    if (snowsrc.indexOf("dynamicdrive.com") != -1){
    	snowsrc = "snow.gif";
    } else {
    	snowsrc = snowsrc;
    }
    And if done that way, in this case the highlighted and red else part can be skipped.

    As I said, you don't need to worry about it. If you want date dependent images you can do that up front where the snowsrc is first defined.

    Like if you wanted a different image for each month (near the top where it first defines snowsrc, you could replace that with):

    Code:
    snowsrc = new Date().getMonth() + '.gif';
    That way it would look for 0.gif in Jan, 1.gif in Feb, and so on.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. The Following User Says Thank You to jscheuer1 For This Useful Post:

    marain (08-01-2012)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •