javascript - Jquery countdown timer that doesn't reset on page refresh -
i need one. using vassilis dourdounis jquery plugin, , have created countdown timer hides link on complete. restarts whenever page refreshed, , shouldn't, should finish count , disappear. can anypne help, please?
this jquery:
/*! * jquery countdown plugin v1.0 * http://www.littlewebthings.com/projects/countdown/ * * copyright 2010, vassilis dourdounis * * permission hereby granted, free of charge, person obtaining copy * of software , associated documentation files (the "software"), deal * in software without restriction, including without limitation rights * use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of software, , permit persons whom software * furnished so, subject following conditions: * * above copyright notice , permission notice shall included in * copies or substantial portions of software. * * software provided "as is", without warranty of kind, express or * implied, including not limited warranties of merchantability, * fitness particular purpose , noninfringement. in no event shall * authors or copyright holders liable claim, damages or other * liability, whether in action of contract, tort or otherwise, arising from, * out of or in connection software or use or other dealings in * software. */ (function($){ $.fn.countdown = function (options) { config = {}; $.extend(config, options); diffsecs = this.setcountdown(config); if (config.oncomplete) { $.data($(this)[0], 'callback', config.oncomplete); } if (config.omitweeks) { $.data($(this)[0], 'omitweeks', config.omitweeks); } $('#' + $(this).attr('id') + ' .digit').html('<div class="top"></div><div class="bottom"></div>'); $(this).docountdown($(this).attr('id'), diffsecs, 500); return this; }; $.fn.stopcountdown = function () { cleartimeout($.data(this[0], 'timer')); }; $.fn.startcountdown = function () { this.docountdown($(this).attr('id'),$.data(this[0], 'diffsecs'), 500); }; $.fn.setcountdown = function (options) { var targettime = new date(); if (options.targetdate) { targettime = new date(options.targetdate.month + '/' + options.targetdate.day + '/' + options.targetdate.year + ' ' + options.targetdate.hour + ':' + options.targetdate.min + ':' + options.targetdate.sec + (options.targetdate.utc ? ' utc' : '')); } else if (options.targetoffset) { targettime.setfullyear(options.targetoffset.year + targettime.getfullyear()); targettime.setmonth(options.targetoffset.month + targettime.getmonth()); targettime.setdate(options.targetoffset.day + targettime.getdate()); targettime.sethours(options.targetoffset.hour + targettime.gethours()); targettime.setminutes(options.targetoffset.min + targettime.getminutes()); targettime.setseconds(options.targetoffset.sec + targettime.getseconds()); } var nowtime = new date(); diffsecs = math.floor((targettime.valueof()-nowtime.valueof())/1000); $.data(this[0], 'diffsecs', diffsecs); return diffsecs; }; $.fn.docountdown = function (id, diffsecs, duration) { $this = $('#' + id); if (diffsecs <= 0) { diffsecs = 0; if ($.data($this[0], 'timer')) { cleartimeout($.data($this[0], 'timer')); } } secs = diffsecs % 60; mins = math.floor(diffsecs/60)%60; hours = math.floor(diffsecs/60/60)%24; if ($.data($this[0], 'omitweeks') == true) { days = math.floor(diffsecs/60/60/24); weeks = math.floor(diffsecs/60/60/24/7); } else { days = math.floor(diffsecs/60/60/24)%7; weeks = math.floor(diffsecs/60/60/24/7); } $this.dashchangeto(id, 'seconds_dash', secs, duration ? duration : 800); $this.dashchangeto(id, 'minutes_dash', mins, duration ? duration : 1200); $this.dashchangeto(id, 'hours_dash', hours, duration ? duration : 1200); $this.dashchangeto(id, 'days_dash', days, duration ? duration : 1200); $this.dashchangeto(id, 'weeks_dash', weeks, duration ? duration : 1200); $.data($this[0], 'diffsecs', diffsecs); if (diffsecs > 0) { e = $this; t = settimeout(function() { e.docountdown(id, diffsecs-1) } , 1000); $.data(e[0], 'timer', t); } else if (cb = $.data($this[0], 'callback')) { $.data($this[0], 'callback')(); } }; $.fn.dashchangeto = function(id, dash, n, duration) { $this = $('#' + id); (var i=($this.find('.' + dash + ' .digit').length-1); i>=0; i--) { var d = n%10; n = (n - d) / 10; $this.digitchangeto('#' + $this.attr('id') + ' .' + dash + ' .digit:eq('+i+')', d, duration); } }; $.fn.digitchangeto = function (digit, n, duration) { if (!duration) { duration = 800; } if ($(digit + ' div.top').html() != n + '') { $(digit + ' div.top').css({'display': 'none'}); $(digit + ' div.top').html((n ? n : '0')).slidedown(duration); $(digit + ' div.bottom').animate({'height': ''}, duration, function() { $(digit + ' div.bottom').html($(digit + ' div.top').html()); $(digit + ' div.bottom').css({'display': 'block', 'height': ''}); $(digit + ' div.top').hide().slideup(10); }); } }; })(jquery);
this html code:
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <script language="javascript" type="text/javascript" src="js/jquery-1.4.1.js"></script> <script language="javascript" type="text/javascript" src="js/jquery.lwtcountdown-1.0.js"></script> <script language="javascript" type="text/javascript" src="js/jquery.cookie.js"></script> <script language="javascript" type="text/javascript" src="js/misc.js"></script> <link rel="stylesheet" type="text/css" href="style/main.css"></link> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>test</title> </head> <body> <div id="container"> <h2>offer</h2> <img src="images/top.png" style="float:left;padding-left:15px;"> <div id="top_offer"> <p>register , special bonuses!</p> </div> <!-- countdown dashboard start --> <div id="countdown_dashboard"> <div class="dash minutes_dash"> <span class="dash_title"></span> <div class="digit">0</div> <div class="digit">0</div> </div> <div class="dash seconds_dash"> <span class="dash_title"></span> <div class="digit">0</div> <div class="digit">0</div> </div> </div> <!-- countdown dashboard end --> <div class="info_message" id="complete_info_message"> <a href="http://www.fxlider.com/lp4/education-kit" target="_blank"> <img src="images/offer.png" /> <p>klikni ovde ► </p></a> </div> <script language="javascript" type="text/javascript"> // set countdown jquery(document).ready(function() { $('#countdown_dashboard').countdown({ targetoffset: { 'day': 0, 'month': 0, 'year': 0, 'hour': 0, 'min': 0, 'sec': 60 }, // oncomplete function oncomplete: function() { $('#container').slideup() } }); }); </script> </div> </body> </html>
thank you!
are sure called
$.cookie('mytimeout', count, { expires: 7, path: '/' }
try putting in oncomplete function
Comments
Post a Comment