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

Automatically change to hour format display via callback #75

Closed
arvi opened this issue Oct 12, 2016 · 3 comments
Closed

Automatically change to hour format display via callback #75

arvi opened this issue Oct 12, 2016 · 3 comments

Comments

@arvi
Copy link

arvi commented Oct 12, 2016

Hello! 😄

Thanks for your great work. I need to change the timer to "%H:%M:%S" format when it reached 59:59. So far I was able to do it but not sure if this is how you'd prefer to be doing it... if yes, then it would be helpful to others if something like this is also added in the documentation examples. If no 😄 I'd be cool if you share your way of doing it. 😄

var callDuration = $('#call-duration');

callDuration.timer({
    duration: '61s', //since 3599 is divisible by 59 or 61
    seconds: 3590, //simulation purposes
    format: '%M:%S',
    callback: function() {

        var total = callDuration.data('seconds');

        if(total === 3599) { //change to hour format (3600 - 1 to prevent display bug)
            this.format = '%H:%M:%S';
        }
    },
    repeat: true //repeatedly call the callback
});
@walmik
Copy link
Owner

walmik commented Oct 13, 2016

Hi @arvi

This looks great, Once I get some time, I m planning to add some recipes for a bunch of things. I ll add this once I get to it.

@arvi
Copy link
Author

arvi commented Oct 13, 2016

Noted. I've updated the sample above (duration and total) upon encountering a bug in the display.

@walmik
Copy link
Owner

walmik commented Apr 12, 2017

Added this to http://jquerytimer.com/

@walmik walmik closed this as completed Apr 12, 2017
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