Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset timestamp #12

Closed
chaospixel opened this issue Jun 3, 2010 · 2 comments
Closed

Reset timestamp #12

chaospixel opened this issue Jun 3, 2010 · 2 comments

Comments

@chaospixel
Copy link

This is more of a suggested enhancement than a bug really. I would like to be able to reset the timestamp. I'm using timeago to display the length of time until the user's session times out - when the user acts to extend the session I would like to extend the timestamp.

Here is my implementation:

    $.fn.timeago = function(timestamp, text) {
        var self = this;

        if (timestamp) {    // Reset the timestamp.
            self.removeData("timeago")
                .html(text && text.length > 0 ? text : "")
                .attr("title", timestamp);
        }

        self.each(refresh);

        var $s = $t.settings;
        if ($s.refreshMillis > 0) {
            setInterval(function() { self.each(refresh); }, $s.refreshMillis);
        }   // For now just keep spawning extra timers...

        return self;
    };

astute observers may notice that every time this method is used it spawns an extra timer. I couldn't think of a quick way to fix that issue and it's unlikely to cause problems in my particular situation.

Besides... Calling timeago multiple times on the same element has the same effect (I think).

@rmm5t
Copy link
Owner

rmm5t commented Jun 3, 2010

Hi. Take a look at my first comment to Issue #9 (specifically Option 2). Does that solve your problem?

http://github.com/rmm5t/jquery-timeago/issues/issue/9#issue/9/comment/215351

@chaospixel
Copy link
Author

Yes, thanks - that's much better than my solution! My apologies for not noticing it myself.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants