Hey I did some programming for fun...
Copy and Paste thie following code to notepad and save it as HTML code. For instance save it as quit.html to your desktop then open it with your browser. Don't forget to change your inputs listed on the top...
Oh yea and ignore the PHP code header... It should really say JavaScript but was unavailable.
If you guys have idea to write a program that will help us quitters please let me know your ideas and we can try to paint it to reality...
[PHP]
<script language="JavaScript">
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
//*** Put your input here *****\\
//-----------------------------------------------------------------------//
PricePerPack = 4.25;
//-----------------------------------------------------------------------//
TargetDate = "Thursday, November 22, 2007 12:00 AM";
//-----------------------------------------------------------------------//
SmokedFor = "20 Cigarettes per day for approx. 22 years";
//-----------------------------------------------------------------------//
BackColor = "yellow";
//-----------------------------------------------------------------------//
ForeColor = "navy";
//-----------------------------------------------------------------------//
CountActive = true;
//-----------------------------------------------------------------------//
CountStepper = 1;
//-----------------------------------------------------------------------//
LeadingZero = true;
//-----------------------------------------------------------------------//
DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds";
//-----------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
function calcage(secs, num1, num2) {
s = ((Math.floor(secs/num1))%num2).toString();
if (LeadingZero && s.length < 2)
s = "0" + s;
return "<b>" + s + "</b>";
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
function CountBack(secs) {
if (secs < 0) {
document.getElementById("cntdwn").innerHTML = FinishMessage;
return;
}
DisplayStr = DisplayFormat.replace(/%%D%%/g, calcage(secs,86400,100000));
DisplayStr = DisplayStr.replace(/%%H%%/g, calcage(secs,3600,24));
DisplayStr = DisplayStr.replace(/%%M%%/g, calcage(secs,60,60));
DisplayStr = DisplayStr.replace(/%%S%%/g, calcage(secs,1,60));
document.getElementById("cntdwn").innerHTML = DisplayStr;
if (CountActive)
setTimeout("CountBack(" + (secs+CountStepper) + ")", SetTimeOutPeriod);
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
function putspan(backcolor, forecolor) {
var dquit = new Date(TargetDate);
var dtoday = new Date();
var diff = new Date(dtoday-dquit);
var s = Math.floor(diff.valueOf()/1000);
var money = Math.floor( (s/86400)%100000 );
var saved = PricePerPack * money;
document.write("<br />" + "Quit: " + TargetDate);
document.write("<br />" + "Smoked: " + SmokedFor);
document.write("<br />" + "Price per pack: " + formatCurrency(PricePerPack));
document.write("<br />" + "Method: Cold Turkey");
document.write("<br />" + "<br />" + "Quit: ");
document.write("<span id='cntdwn' style='background-color:" + backcolor +
"; color:" + forecolor + "'></span> days ago...");
document.write("<br />Saved: ");
document.write("<strong><span id='saved' style='background-color:" + BackColor +
"; color:" + ForeColor + "'>" + formatCurrency(saved) + "</span></strong>");
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
function formatCurrency(num)
{
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + '$' + num + '.' + cents);
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
if (typeof(BackColor)=="undefined")
BackColor = "white";
if (typeof(ForeColor)=="undefined")
ForeColor= "black";
if (typeof(TargetDate)=="undefined")
TargetDate = "12/31/2020 5:00 AM";
if (typeof(DisplayFormat)=="undefined")
DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
if (typeof(CountActive)=="undefined")
CountActive = true;
if (typeof(FinishMessage)=="undefined")
FinishMessage = "";
if (typeof(CountStepper)!="number")
CountStepper = -1;
if (typeof(LeadingZero)=="undefined")
LeadingZero = true;
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
CountStepper = Math.ceil(CountStepper);
if (CountStepper == 0)
CountActive = false;
var SetTimeOutPeriod = (Math.abs(CountStepper)-1)*1000 + 990;
putspan(BackColor, ForeColor);
var dthen = new Date(TargetDate);
var dnow = new Date();
if(CountStepper>0)
ddiff = new Date(dnow-dthen);
else
ddiff = new Date(dthen-dnow);
gsecs = Math.floor(ddiff.valueOf()/1000);
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
CountBack(gsecs);
////////////////////////////////////////////////////////////////////////
</script>
[/PHP]
Happy programming!