|
javascript countdownHow to make a Countdown Counter in QC using JavascriptHi everyone, I am trying to make a countdown counter in order to show when a specific video will finish. The input values usually enter manually. For example for a specific QC file I enter two inputs for minutes and seconds and then I want to show the countdown counter animation. I put together a Jsscript but for some reason it doesn't work at all. This is first time I am using JS in QC. Any help or tips would be really appreciated. Thank you, Here is the code: var mins; var secs; var result = new Object(); function cd() { mins = 1 * m("10"); // change minutes here secs = 0 + s(":01"); // change seconds here (always add an additional second to your total) redo(); } function m(obj) { for(var i = 0; i < obj.length; i++) { if(obj.substring(i, i + 1) == ":") break; } return(obj.substring(0, i)); } function s(obj) { for(var i = 0; i < obj.length; i++) { if(obj.substring(i, i + 1) == ":") break; } return(obj.substring(i + 1, obj.length)); } function dis(mins,secs) { var disp; if(mins <= 9) { disp = " 0"; } else { disp = " "; } disp += mins + ":"; if(secs <= 9) { disp += "0" + secs; } else { disp += secs; } return(disp); } function redo() { secs--; if(secs == -1) { secs = 59; mins--; } result.timeLeft = dis(mins,secs); // setup additional displays here. return result; if((mins == 0) && (secs == 0)) { // Show is finished } else { cd = setTimeout("redo()",1000); } } function init() { cd(); } function (__number timeLeft) main(){ init(); } [javascript]
|