caike / jquery-simple-timer Goto Github PK
View Code? Open in Web Editor NEWA countdown timer plugin for jQuery
Home Page: https://csouza.me/jQuery-Simple-Timer
License: MIT License
A countdown timer plugin for jQuery
Home Page: https://csouza.me/jQuery-Simple-Timer
License: MIT License
Add support for data-minutes-left
Fix this https://github.com/caike/jQuery-Simple-Timer/blob/master/dojo.js#L5
Pass intervalId
as the argument to the onComplete
function.
if I set timer for 30 minutes and I change system clock to 5 minutes earlier, timer would increase by 5 minutes
Thanks for this plugin its really helpful. Can you please tell me how can I set the value using jquery of this below tag. I cannot give time to data-seconds-left with my h4 tag. Its remaining time is coming from the server-side. So, I need to assign it on page load.
It would be interesting to have the possibility to configure the element type created for hour, minutes and second. Currently it is only possible to create a div, but I had the need to use span.
https://github.com/caike/jQuery-Simple-Timer/blob/master/jquery.simple.timer.js#L69
not working in ie 11. im getting this error
Object doesn't support property or method 'isInteger'
Add option to repeat forever.
$('timer').startTimer({
loop: true, // restarts timer after each time out
loopInterval: 5, // waits 5 seconds before starting timer again
})
When I use the function :
$(function(){
$('.timer').startTimer({
onComplete: function(){
console.log('Complete');
},
allowPause: true
});
If you do nothing, the console show 'Complete', but if you pause it (by clicking on timer), at the end time, there is nothing on the console to try :
https://rawgit.com/caike/jQuery-Simple-Timer/master/examples/index.html
Hi, thanks for your script - it is easy and working as expected. Only one thing I miss is posibble to show days left. I've tried to extend plugin but it is broken :) Would be fine to have this option.
Hi, i tried using the timer with data-seconds-left =2 , after the 2 seconds run out, i run some ajax, after ajax returns, i want to run the timer with a 10 seconds duration.
Any idea on how to make this possible?
The timer seems to run back the 2 seconds timer even after i change the data-seconds-left to 10 seconds via $('#timer').attr('data-seconds-left',10);
Thanks.
This happens when using multiple timers on the page with different class names on each.
how to pause the timer by clicking on some button without clicking on the timer ? I've tried all the suggestion you gave and from the previous issues solved. But it didn't help me out. Please response ASAP.
Hi!!
I have a timer and i want a function to stop timer.
var inter = $(`#my-record-${id} .timer`).startTimer();
But the library don't have any function to stop.
Thanks
i can't do pause and resume functionality in this timer library
Hi,
I want to specify the number of the timer loop! I can set the loop interval but I don't know how to limit the loop number?!
any idea?
thanks
Mansour
I use your Time as a Sun clock which counts down the seconds to sunset.
If the data-minutes-left="0"
is set to 0 (which happens after sunset) there is nothing displayed anymore. Is it somehow possible to keep it in the 00:00:00
format?
From this
$('.timer').startTimer({
onComplete: function(element){
clearInterval(element.intervalId);
element.addClass('timeout');
}
});
to this
$('.timer').startTimer({
onComplete: function(element){
element.clearInterval();
element.addClass('timeout');
}
});
Todo:
allowPause
examples (gh-pages branch)According to the official plugin website, these should be published to npm.
http://plugins.jquery.com/
http://blog.npmjs.org/post/111475741445/publishing-your-jquery-plugin-to-npm-the-quick
http://blog.npmjs.org/post/112064849860/using-jquery-plugins-with-npm
I followed the NPM installation method:
"use strict";
let $ = require("jquery");
require("jquery-simple-timer")($);
$(() => {
$('.timer').startTimer();
});
and it says jQuery is not defined.
Not sure if this has something to do with the fact that Im transpiling ES6 code using babelify and browserify.
Note: The jQuery is not defined comes from the plugin file itself "jquery.simple.timer.js:189"
Thanks in advance!
Requiring the lib automatically detects elements with class='simple-timer'
, like so:
<span class='simple-timer' data-minutes-left=30></span>
Raise error if time is greater than 99:99:99
Bump version so that bower sees new features.
Hi Carlos,
I am using this code . It is not working in any version of IE. Although it works fine in all other browsers like Mozilla,Chrome and Safari. Could you provide any solution.
Thanks,
Deepak
When using multiple tabs in Safari or Chrome, the onComplete
event is not properly fired if a different tab is active when the timer finishes.
I used your plugin severyl times but no it's not working anymore.
I load it like this:
<div class="sunLocDuration timer itIsDay" data-seconds-left="19999"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/caike/jQuery-Simple-Timer/1bc86823/jquery.simple.timer.js"></script>
<script>
$( document ).ready(function() {
$('.timer').startTimer();
});
</script>
This does nothing. It doesnt even throw an error. It simply doesn't work. What's the catch here?
A data-timeout="HH:ii" of the finish time would be appreciated.
We'll stick with npm only.
When either seconds and minutes left are greater than 24 hours, the timer resolves wrong initial time.
Reported in #22
Add example showing how to restart the timer from the onComplete
function and with a new value for timeout. Mention the .attr()
method will not work and we must use the .data()
method instead. See #20
Using Simple-Timer as an auto-logout for a private database I encountered an issue: e.g. the timer is set to 30', the computer goes to standby at 28' and is re-activated 4 minutes later, the timer is at 23h 58', having missed the onComplete event at 0'00''.
Inserting a new line 125
if (timeLeft < 0) timeLeft = 0;
did solve this for me.
Accept custom classes for span elements (hours, minutes, seconds and clearDiv) and for timeout via a classNames
option. Like this:
$('#timer').startTimer({
classNames: {
hours: 'banana-hours',
minutes: 'banana-minutes',
seconds: 'banana-seconds',
clearDiv: 'banana-clearDiv',
timeout: 'banana-timeout'
}
});
Is it possible to add an "on almost complete" to the mix so the counter gets other styles when the time is almost up?
hi,excuse me , im working with your timer but i dont know how can i stop the timer ? please
thanks
sincerely
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.