jchavannes / jquery-timer Goto Github PK
View Code? Open in Web Editor NEWBasically setTimeout with more options.
License: MIT License
Basically setTimeout with more options.
License: MIT License
To me looks crucial that the funcions pad() and formatTime() should be in the main timer js since it is very useful and 'humanly' necessary
ERROR in /Users/zhangyu27/Documents/git.oschina.net/DuoBaoWeb/src/app/app.component.ts (19,24): Property 'timer' does not exist on type 'JQueryStatic'.
ERROR in /Users/zhangyu27/Documents/git.oschina.net/DuoBaoWeb/src/app/app.component.ts (21,11): Cannot find name 'JQueryTimer'.
Why?
for example:
I want to break out from timer loop when the result is success from an Ajax call, see below code:
<div id="tip_text">请等待。。。。</div>
<script type=text/javascript>
alert('<%=@comp_job_id%>');
var complete_done = "";
var timer = $.timer(function() {
$.ajax({
url: "/reports/check_report_status",
data: { comp_job_id: '<%=@comp_job_id%>' }
})
.done(function( ret_json ) {
ret_json_struct = $.parseJSON(ret_json);
alert(ret_json_struct.msg);
complete_done = ret_json_struct.status;
$("#tip_text").html(ret_json_struct.msg+"<a href=\"/reports/download_report?rep_name="+ret_json_struct.file_name+"\">download file here</a>");
alert(complete_done);
$(this).stop();
alert(complete_done);
});
//$.ajax({
//url: "reports/check_report_status",
// data: {}
//});
});
timer.set({ time : 5000, autostart : true });
</script>
Can you please provide/include the license under which this software can be used? Is it under MIT license? If so can you please explicitly state that and include the license in the zip file?
Thank you,
AJ
Hello, thanks for the great plugin. I'm using it on my online exam project.
The countdown pauses when user activated a different tab of browser, how can I keep time running anytime:?
Thanks
The code available here: http://jchavannes.com/include/scripts/3p/jquery.timer.js
Is different than the code available here: http://jchavannes.com/download/jquery-timer-demo.zip
I had been using them interchangeably until I found a bug that only showed up when I used the hosted version of the code. The bug doesn't show up on the downloaded version.
In brief, the bug was that I couldn't get a timer to restart itself by calling .play()
after calling .stop()
- in a very convoluted scenario. Using the downloaded version solved the problem.
I used timer but there is one major issue, the timer control shows time lag when compared to the actual clock. The timer ticks are slow as compared to actual clock ticks which results in time lag and that can be in minutes.
Is there any way to fix this.
timer started with once don't seem to be cancelled when invoking stop() method...
m_timer = $.timer( function (){
// do something here
}).once(k_someDelay);
// and later on
m_timer.stop();
When you call $.timer()
, this
is $
, therefore you're attaching functions to $
directly when you do this.toggle = function () {...}
. Here's a fiddle demonstrating the issue: http://jsfiddle.net/shnom7c9/
All of the functions you define on this
are being set on $
.
I 'm using your jQuery Timer .
When open another tag in my browser, the jQuery Timer turn to pause.
Return to the tag which jQuery Timer was running ,the jQuery Timer turn to resume.
How can the jQuery Timer run in background, when i work in other tag.
If my action throw an exception, the $.timer object does not set the next execution and has timer.isActive=true
.
This is pretty obvious on your code here:
Line 99 in b43a3ce
If this.action()
fails for some reason, you don't set the timer again.
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.