Scripted Updated Indicator

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • xxnonexnonexx@tampascanner.info

    Scripted Updated Indicator

    I use the following piece of code to show when the page thats being accessed was
    last updated:

    <!--
    var modified = new Date(document.l astModified);
    document.write( "<b>Last Updated:<i> "+modified+ "</I></B>");
    // -->

    This works great, but it only does it for the page thats currently displayed.

    Is there some way to possibly get my main page to show an updated indicator
    likie:


    some page link <UPDATED> then date/time

    Where <updated> is an animated gif I use that flashes updated.

    I've been doing this by hand for my main page, but would like to automate it so
    that if the page has been updated within say the last 5 days it would
    automatically add this flashing graphic and the date/time next to the link for
    the page.

    Thanks for any pointers.



    ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
  • FredOz

    #2
    Re: Scripted Updated Indicator

    xxnonexnonexx@t ampascanner.inf o wrote:[color=blue]
    > I use the following piece of code to show when the page thats being accessed was
    > last updated:
    >
    > <!--
    > var modified = new Date(document.l astModified);
    > document.write( "<b>Last Updated:<i> "+modified+ "</I></B>");
    > // -->[/color]

    Hiding scripts is unnecessary and potentially harmful, don't do it.
    [color=blue]
    >
    > This works great, but it only does it for the page thats currently displayed.[/color]

    It will also only work if the user has JavaScript enabled. Not to be
    picky, but why does it need to work on pages that aren't currently
    displayed? :-)

    Oh, I get it (I'm a bit slow this morning), you mean it doesn't work
    for resources indicated by URI's.

    So your dilema is that you want to determine the last modified date of
    the resource at the end of the link, not the current document. And to
    do that reliably is probably beyond the capability of any browser (note
    that the content may have changed even if the actual HTML file that
    hosts the content has not - e.g. modified images or dynamic content).

    For more (general) information on lastModified, read the group FAQ:

    <URL:http://www.jibbering.c om/faq/#FAQ4_30>
    [color=blue]
    >
    > Is there some way to possibly get my main page to show an updated indicator
    > likie:
    >
    >
    > some page link <UPDATED> then date/time
    >
    > Where <updated> is an animated gif I use that flashes updated.[/color]

    Flashing gifs ...ugghhh! They are truely despised, please reconsider.
    Also, if the user has images turned off, they won't see the gif.

    Anyway, let's proceed on the assumption that you will just place an
    attractive 'New' gif (or just coloured text) next to links that point
    to content less than 5 days old.

    How you determine the period depends on how accurately you want to
    measure your 5 days. By far the simplest method is to work it out at
    your server and just add the appropriate highlight before sending the
    page. You are then insulated from the vaguaries of client systems and
    the accuracy of their internal clock.

    If you're going to trust the client system's clock, you can send a date
    object in your file, create a 'now' date object at the client, convert
    them both to the same reference system (say UTC), find the difference
    and if it's greater than 4.32e8 (the number milliseconds in 5 days)
    show the highlight. That is likely not exact, but near enough for
    now.

    You could include a string in the value of some attribute of each link
    (say in the class) that represents the date last modified of the linked
    resource and can be converted into a date object. A script could
    extract the value, convert it, compare it to 'now' and conditionally
    add the highlight.

    But for all that effort you may as well just add the highlight at the
    server instead of the embedded date string, avoiding client-side
    issues. Your server can get the last modified timestamp for linked
    resources without your intervention, so that part is catered for too
    (but the issue of updated content in the linked resource is not).

    The server script would likely be no more complex than a client
    script of similar functionality.
    [color=blue]
    >
    > I've been doing this by hand for my main page, but would like to automate it so
    > that if the page has been updated within say the last 5 days it would
    > automatically add this flashing graphic and the date/time next to the link for
    > the page.[/color]

    A client-side, script-dependant, unreliable solution is likely not
    suitable when a better server side solution is availabe.


    --
    Fred

    Comment

    Working...