[pubcookie-dev] Time Remaining Javascript

Nathan Dors dors at cac.washington.edu
Wed Jun 21 09:29:17 PDT 2006


I'm going to defer looking at this one myself. I thought there was 
a countdown feature - or maybe that's something we have/had here.

It's a minor feature enhancement, but a medium-sized patch, so I'd 
rather put this off until current cvs is released.

-Nathan

On Tue, 20 Jun 2006, Bradley Schwoerer wrote:

> A change that needs some more testing, but I thought I would bring it up on
> this list.  It was suggested that using Javascript to actually do a count
> down timer would be nice.  This could easily be accomplished just by parsing
> the current print out, but then it would not be displayed if Javascript was
> turned off.  This change prints out the seconds remaining and the current
> time remaining to the HTML.  The seconds remaining is used by the
> Javascript, while the current remaining time is printed in noscript.
>
> Bradley Schwoerer
> University of Wisconsin-Madison
> DoIT Middleware
>
> ---[ ds/c/pubcookie/src ]---
>
> Index: ds/c/pubcookie/src/index.cgi.c
> diff -u ds/c/pubcookie/src/index.cgi.c:1.12
> ds/c/pubcookie/src/index.cgi.c:1.13
> --- ds/c/pubcookie/src/index.cgi.c:1.12 Tue Jun 13 15:11:25 2006
> +++ ds/c/pubcookie/src/index.cgi.c Tue Jun 20 13:37:30 2006
> @@ -18,7 +18,7 @@
> /** @file index.cgi.c
>  * Login server CGI
>  *
> - * $Id: index.cgi.c,v 1.12 2006/06/13 20:11:25 miner Exp $
> + * $Id: index.cgi.c,v 1.13 2006/06/20 18:37:30 schwoerb Exp $
>  */
>
> #ifdef WITH_FCGI
> @@ -1606,21 +1606,15 @@
>     return t;
> }
>
> -/**
> - * forms nice string with time remaining
> - * @param *c from login cookie
> - * @returns string
> - */
> -const char *time_remaining_text (pool * p, login_rec * c)
> +int seconds_remaining_int (pool * p, login_rec * c)
> {
> -    const char *remaining = NULL;
>     int secs_left = 0;
>
>     pbc_log_activity (p, PBC_LOG_DEBUG_VERBOSE,
> -                      "time_remaining_text: hello\n");
> +                      "seconds_remaining_int: hello\n");
>
>     if (c == NULL)
> -        return (NULL);
> +        return (0);
>
>     if (c->expire_ts == 0) {
>         secs_left = c->create_ts + DEFAULT_LOGIN_EXPIRE - pbc_time (NULL);
> @@ -1629,11 +1623,10 @@
>     }
>
>     if (secs_left <= 0)
> -        return (NULL);
> +        return (0);
>
> -    remaining = libpbc_time_text (p, secs_left, PBC_TRUE, PBC_FALSE);
> -    pbc_log_activity (p, PBC_LOG_DEBUG_LOW, "returning: %s\n", remaining);
> -    return (remaining);
> +    pbc_log_activity (p, PBC_LOG_DEBUG_LOW, "returning: %d\n", secs_left);
> +    return (secs_left);
>
> }
>
> @@ -1736,7 +1729,16 @@
>
> "logout_postscript_still_others"),
>                               NULL);
>         } else {
> -            const char *remaining = time_remaining_text (p, c);
> +            int secs_left = seconds_remaining_int(p, c);
> +            char secs_remaining[PBC_SHORT_STRING];
> +            const char *remaining;
> +
> +            if (secs_left > 0) {
> +                remaining = libpbc_time_text (p, secs_left, PBC_TRUE,
> PBC_FALSE);
> +                snprintf(secs_remaining, PBC_SHORT_STRING, "%i",
> secs_left);
> +            } else {
> +                remaining = NULL;
> +            }
>             ntmpl_print_html (p, TMPL_FNAME,
>                               libpbc_config_getstring (p,
>
> "tmpl_logout_still_weblogin",
> @@ -1750,7 +1752,8 @@
>
> "tmpl_logout_time_remaining",
>
> "logout_time_remaining"),
>                               "remaining",
> -                              (remaining == NULL ? "unknow" : remaining),
> +                              (remaining == NULL ? "unknown" : remaining),
> +                              "secs_remaining", (secs_left > 0 ?
> secs_remaining : "0"),
>                               NULL);
>             if (remaining != NULL)
>                 pbc_free (p, (char *) remaining);
> @@ -1928,11 +1931,19 @@
> void login_status_page (pool * p, login_rec * c)
> {
>     char *refresh_line = NULL;
> -    const char *remaining = time_remaining_text (p, c);
> +    int secs_left = seconds_remaining_int(p, c);
> +    char secs_remaining[PBC_SHORT_STRING];
> +    const char *remaining;
>     int refresh_needed_len = STATUS_INIT_SIZE;
>     int refresh_len = 0;
>     int delay = get_int_arg (p, "countdown", 0);
>     int min_delay = libpbc_config_getint (p, "min_countdown", 9999);
> +    if (secs_left > 0) {
> +        remaining = libpbc_time_text (p, secs_left, PBC_TRUE, PBC_FALSE);
> +        snprintf(secs_remaining, PBC_SHORT_STRING, "%i", secs_left);
> +    } else {
> +        remaining = NULL;
> +    }
>
>     while (delay != 0 && delay >= min_delay &&
>            refresh_needed_len > refresh_len) {
> @@ -1962,6 +1973,7 @@
>                                    NULL ? "unknown" : c->user),
>                       "remaining",
>                       (remaining == NULL ? "unknown" : remaining),
> +                      "secs_remaining", (secs_left > 0 ? secs_remaining :
> "0"),
>                       "version", PBC_VERSION_STRING, NULL);
>
>     if (remaining != NULL)
> @@ -2502,10 +2514,23 @@
> int pinit_response (pool * p, const security_context * context,
>                     login_rec * l)
> {
> -    const char *remaining = time_remaining_text (p, l);
> +    int secs_left = seconds_remaining_int(p, l);
> +    char secs_remaining[PBC_SHORT_STRING];
> +    const char *remaining;
>
>     pbc_log_activity (p, PBC_LOG_DEBUG_LOW, "pinit_response: hello");
>
> +    pbc_log_activity (p, PBC_LOG_DEBUG_LOW, "pinit_response:
> secs_remaining(%d)",secs_left);
> +
> +    if (secs_left > 0) {
> +        remaining = libpbc_time_text (p, secs_left, PBC_TRUE, PBC_FALSE);
> +        snprintf(secs_remaining, PBC_SHORT_STRING, "%i", secs_left);
> +    } else {
> +        remaining = NULL;
> +    }
> +
> +
> +
>     ntmpl_print_html (p, TMPL_FNAME,
>                       libpbc_config_getstring (p, "tmpl_pinit_response1",
>                                                "pinit_response1"), NULL);
> @@ -2519,8 +2544,9 @@
>                       libpbc_config_getstring (p,
>
> "tmpl_logout_time_remaining",
>                                                "logout_time_remaining"),
> -                      "remaining",
> -                      (remaining == NULL ? "unknown" : remaining), NULL);
> +                      "remaining", (remaining == NULL ? "unknown" :
> remaining),
> +                      "secs_remaining", (secs_left > 0 ? secs_remaining :
> "0"),
> +                      NULL);
>     ntmpl_print_html (p, TMPL_FNAME,
>                       libpbc_config_getstring (p, "tmpl_pinit_response2",
>                                                "pinit_response2"),
>
>
> ---
> You are currently subscribed to mst-cvs-ds-pubcookie as: bschwoerer at wisc.edu
> To unsubscribe send a blank email to leave-2878883-2267482D at lists.wisc.edu
>
> ------ End of Forwarded Message
>
>
> _______________________________________________
> pubcookie-dev mailing list
> pubcookie-dev at u.washington.edu
> http://mailman1.u.washington.edu/mailman/listinfo/pubcookie-dev
>


More information about the pubcookie-dev mailing list