javascript - How to add different days on one of the following countdown time function? -
the following javascript code contains 3 functions 2 of counts times daily , csw timer
occurs once every 7 days (sunday), however, want make bdwtimer()
not everyday wednesday (3) , friday(5). struggling how since @ moment it's everyday specific hours? how can appreciated ... time!
for example: if monday -- bdw timer should display 2(days until wednesday):x hours:x minutes:x seconds .. if wednesday should display 0 days , rest , if done day (total of 4 events) move on next friday, again: 2(days until wednesday):x hours:x minutes:x seconds ..
<script> var currdate = new date(); var currdate = new date(); var day = currdate.getday(); var hrs = currdate.gethours(); var hrs0 = currdate.gethours(); var hrs00 = currdate.gethours(); var mins = currdate.getminutes(); var secs = currdate.getseconds(); var cswday = 7; var cswhrs = 19; var fthrs1 = 6; var fthrs2 = 14; var fthrs3 = 22; var bdwhrs1 = 5; var bdwhrs2 = 11; var bdwhrs3 = 17; var bdwhrs4 = 23; var ftmins1 = 59; var ftsecs1 = 60; var hrsout = 0; var hrsout2 = 0; var hrs1 = fthrs1 - hrs; var hrs2 = fthrs2 - hrs; var hrs3 = fthrs3 - hrs; var hrs01 = bdwhrs1 - hrs0; var hrs02 = bdwhrs2 - hrs0; var hrs03 = bdwhrs3 - hrs0; var hrs04 = bdwhrs4 - hrs0; var day = cswday - day; var hrs001 = cswhrs - hrs00; if (day == 7) day = 0; if ((hrs > 22) || ((hrs >= 0) && (hrs < 7))) { if (hrs > 22) hrsout = 7; else hrsout = hrs1; } if ((hrs > 6) && (hrs < 15)) hrsout = hrs2; if ((hrs > 14) && (hrs < 23)) hrsout = hrs3; if ((hrs0 > 23) || ((hrs0 >= 0) && (hrs0 < 6))) { if (hrs0 > 23) hrsout2 = 6; else hrsout2 = hrs01; } if ((hrs0 > 5) && (hrs0 < 12)) hrsout2 = hrs02; if ((hrs0 > 11) && (hrs0 < 18)) hrsout2 = hrs03; if ((hrs0 > 17) && (hrs0 <= 23)) hrsout2 = hrs04; mins = ftmins1 - mins; secs = ftsecs1 - secs; var counter=setinterval(fttimer, 1000); var counter=setinterval(bdwtimer, 1000); var counter=setinterval(cswtimer, 1000); function fttimer() { secs=secs-1; if (hrsout < 0) { clearinterval(counter); } else if (mins < 0) { secs = 59; mins = 59; hrsout = hrsout - 1; return; } else if (secs < 0) { secs = 59; mins = mins - 1; return; } if (secs < 10 && mins < 10 && hrsout < 10) document.getelementbyid("fttimer").innerhtml="0"+hrsout+":0"+mins+":0"+secs; else if (mins < 10 && hrsout < 10) document.getelementbyid("fttimer").innerhtml="0"+hrsout+":0"+mins+":"+secs; else if (secs < 10 && hrsout < 10) document.getelementbyid("fttimer").innerhtml="0"+hrsout+":"+mins+":0"+secs; else if (secs < 10 && mins < 10) document.getelementbyid("fttimer").innerhtml=hrsout+":0"+mins+":0"+secs; else if (hrsout < 10) document.getelementbyid("fttimer").innerhtml="0"+hrsout+":"+mins+":"+secs; else if (mins < 10) document.getelementbyid("fttimer").innerhtml=hrsout+":0"+mins+":"+secs; else if (secs < 10) document.getelementbyid("fttimer").innerhtml=hrsout+":"+mins+":0"+secs; else document.getelementbyid("fttimer").innerhtml=hrsout+":"+mins+":"+secs; } function bdwtimer() { if (hrsout2 < 0) { clearinterval(counter); } else if (mins < 0) { secs = 59; mins = 59; hrsout2 = hrsout2 - 1; return; } else if (secs < 0) { secs = 59; mins = mins - 1; return; } if (secs < 10 && mins < 10 && hrsout2 < 10) document.getelementbyid("bdwtimer").innerhtml="0"+hrsout2+":0"+mins+":0"+secs; else if (mins < 10 && hrsout2 < 10) document.getelementbyid("bdwtimer").innerhtml="0"+hrsout2+":0"+mins+":"+secs; else if (secs < 10 && hrsout2 < 10) document.getelementbyid("bdwtimer").innerhtml="0"+hrsout2+":"+mins+":0"+secs; else if (secs < 10 && mins < 10) document.getelementbyid("bdwtimer").innerhtml=hrsout2+":0"+mins+":0"+secs; else if (hrsout2 < 10) document.getelementbyid("bdwtimer").innerhtml="0"+hrsout2+":"+mins+":"+secs; else if (mins < 10) document.getelementbyid("bdwtimer").innerhtml=hrsout2+":0"+mins+":"+secs; else if (secs < 10) document.getelementbyid("bdwtimer").innerhtml=hrsout2+":"+mins+":0"+secs; else document.getelementbyid("bdwtimer").innerhtml=hrsout2+":"+mins+":"+secs; } function cswtimer() { if (day < 0) { day = 6; return; } else if (hrs001 < 0) { if (hrs001 == -1) hrs001 = 23; else if (hrs001 == -2) hrs001 = 22; else if (hrs001 == -3) hrs001 = 21; else if (hrs001 == -4) hrs001 = 20; day = day - 1; return; } else if (mins < 0) { secs = 59; mins = 59; hrs001 = hrs001 - 1; return; } else if (secs < 0) { secs = 59; mins = mins - 1; return; } if (secs < 10 && mins < 10 && hrs001 < 10) document.getelementbyid("cswtimer").innerhtml=day+":0"+hrs001+":0"+mins+":0"+secs; else if (mins < 10 && hrs001 < 10) document.getelementbyid("cswtimer").innerhtml=day+":0"+hrs001+":0"+mins+":"+secs; else if (secs < 10 && hrs001 < 10) document.getelementbyid("cswtimer").innerhtml=day+":0"+hrs001+":"+mins+":0"+secs; else if (secs < 10 && mins < 10) document.getelementbyid("cswtimer").innerhtml=day+":"+hrs001+":0"+mins+":0"+secs; else if (hrs001 < 10) document.getelementbyid("cswtimer").innerhtml=day+":0"+hrs001+":"+mins+":"+secs; else if (mins < 10) document.getelementbyid("cswtimer").innerhtml=day+":"+hrs001+":0"+mins+":"+secs; else if (secs < 10) document.getelementbyid("cswtimer").innerhtml=day+":"+hrs001+":"+mins+":0"+secs; else document.getelementbyid("cswtimer").innerhtml=day+":"+hrs001+":"+mins+":"+secs; } </script>
Comments
Post a Comment