I don't think so, once done for one time period should at least make it a little easier to do it for another. Javascript time is finicky and applying logic to it can get messy if you want reliable results in every circumstance that could apply during the achievement of the objective. That said, (every) next Thursday at 7pm is now a reality (I think), let me know if there are any problems:
Code:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="ddcubeclass.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="ddcubeclass.js"></script>
<script src="ddcubecountdown.js">
/***********************************************
* 3D Cube Countdown script- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Please keep this notice intact
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/
</script>
<script>
jQuery(function($){ // on DOM load
function nextthursdayat7pm(){
var now = new Date(), thur = 4, _7pm = 19, curday = now.getDay(), curhour = now.getHours();
if(curday === thur && curhour >= _7pm){now.setDate(now.getDate() + 1);}
while (curday !== thur){
now.setDate(now.getDate() + 1);
curday = now.getDay();
}
return new Date(now.getFullYear(), now.getMonth(), now.getDate(), _7pm);
}
var mycountdown;
function setcountdown(){
var theDate = nextthursdayat7pm();
mycountdown = new cubecountdown({
containerid: 'futuredate',
targetdate: theDate,
size: ['10em', '6em'], // specify cube dimensions in "em" only
unit: ['days']
});
$('#nextthursday').html((theDate.getMonth() + 1) + '/' + theDate.getDate() + '/' + theDate.getFullYear());
mycountdown.onEnd = function(){setcountdown();};
}
setcountdown();
});
</script>
</head>
<body>
<div id="futuredate"></div>
<div style="width:25em;text-align:center;font-weight:bold">until Next Thursday <span id="nextthursday"></span> at 7pm!</div>
</body>
</html>
Bookmarks