1/* 2Author: Robert Hashemian 3http://www.hashemian.com/ 4 5You can use this code in any manner so long as the author's 6name, Web address and this disclaimer is kept intact. 7******************************************************** 8Usage Sample: 9 10<script language="JavaScript"> 11TargetDate = "12/31/2020 5:00 AM"; 12BackColor = "palegreen"; 13ForeColor = "navy"; 14CountActive = true; 15CountStepper = -1; 16LeadingZero = true; 17DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds."; 18FinishMessage = "It is finally here!"; 19</script> 20<script language="JavaScript" src="https://scripts.hashemian.com/js/countdown.js"></script> 21*/ 22 23function calcage(secs, num1, num2) { 24 s = ((Math.floor(secs/num1))%num2).toString(); 25 if (LeadingZero && s.length < 2) 26 s = "0" + s; 27 return s; 28} 29 30function CountBack(secs) { 31 if (secs < 0) { 32 document.getElementById("cntdwn").innerHTML = FinishMessage; 33 return; 34 } 35 DisplayStr = DisplayFormat.replace(/%%D%%/g, calcage(secs,86400,100000)); 36 DisplayStr = DisplayStr.replace(/%%H%%/g, calcage(secs,3600,24)); 37 DisplayStr = DisplayStr.replace(/%%M%%/g, calcage(secs,60,60)); 38 DisplayStr = DisplayStr.replace(/%%S%%/g, calcage(secs,1,60)); 39 40 document.getElementById("cntdwn").innerHTML = DisplayStr; 41 if (CountActive) 42 setTimeout("CountBack(" + (secs+CountStepper) + ")", SetTimeOutPeriod); 43} 44 45function putspan(backcolor, forecolor) { 46 document.write("<span id='cntdwn' style='background-color:" + backcolor + 47 "; color:" + forecolor + "'></span>"); 48} 49 50if (typeof(BackColor)=="undefined") 51 BackColor = "white"; 52if (typeof(ForeColor)=="undefined") 53 ForeColor= "black"; 54if (typeof(TargetDate)=="undefined") 55 TargetDate = "12/31/2020 5:00 AM"; 56if (typeof(DisplayFormat)=="undefined") 57 DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds."; 58if (typeof(CountActive)=="undefined") 59 CountActive = true; 60if (typeof(FinishMessage)=="undefined") 61 FinishMessage = ""; 62if (typeof(CountStepper)!="number") 63 CountStepper = -1; 64if (typeof(LeadingZero)=="undefined") 65 LeadingZero = true; 66 67 68CountStepper = Math.ceil(CountStepper); 69if (CountStepper == 0) 70 CountActive = false; 71var SetTimeOutPeriod = (Math.abs(CountStepper)-1)*1000 + 990; 72putspan(BackColor, ForeColor); 73var dthen = new Date(TargetDate); 74var dnow = new Date(); 75if(CountStepper>0) 76 ddiff = new Date(dnow-dthen); 77else 78 ddiff = new Date(dthen-dnow); 79gsecs = Math.floor(ddiff.valueOf()/1000); 80CountBack(gsecs);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.