var monthDate;
var cleanChime = 1;
var lastChime;
var timeStamp;
var clockScale = 1;
var theRate;
var secondCnt = 0;//seconds display
var tenSecCnt = 0;
var miniteCnt = 0;//minites display
var tenMinCnt = 0;
var startFlag = 0;
var hourResult = 0;
var minResult = 0;
//var secResult = 0;
var alarmFlag = 0;
//display the time
function updateTime()
{
theDate = new Date();
theHour = theDate.getHours();
theMinutes = theDate.getMinutes();
theSeconds = theDate.getSeconds();
if ( theHour > 12 )
{
theHour = String(theHour - 12);
}
if (theHour == 0)
{
theHour = "12";
}
if( (timeStamp - lastChime) > 60000 )
{
cleanChime = 1;
}
secondHand.rotation = (theSeconds*6);
minuteHand.rotation = ((theMinutes)*6)+(theSeconds*0.1);
hourHand.rotation = ((theHour)*30)+(theMinutes*0.5);
setChime();//set chime
setDate();//dispaly date
}
//set the size of clock
function sizeClock( )
{
clockScale = preferences.clockSize.value / 100;
//main_window.visible = false;
counters.width = 130 * clockScale;
counters.height = 50 * clockScale;
counters.size = 15 * clockScale;
counters.hOffset = 130 *clockScale;
counters.vOffset = 60 *clockScale;
background1.width = 250 * clockScale;
background1.height = 260 * clockScale;
background1.hOffset = 45 *clockScale;
background1.vOffset = 42 *clockScale;
background0.width = 268 * clockScale;
background0.height = 268 * clockScale;
background0.hOffset = 36 *clockScale;
background0.vOffset = 36 *clockScale;
background.width = 268 * clockScale;
background.height = 268 * clockScale;
background.hOffset = 36 *clockScale;
background.vOffset = 36 *clockScale;
dateWell.width = 268 * clockScale;
dateWell.height = 268 * clockScale;
dateWell.hOffset = 36 * clockScale;
dateWell.vOffset = 36 * clockScale;
tmerField.width = 55 * clockScale;
tmerField.height = 20 * clockScale;
tmerField.hOffset = 140 *clockScale;
tmerField.vOffset = 270 *clockScale;
leftImg.width = 20 * clockScale;
leftImg.height = 18 * clockScale;
leftImg.hOffset = 115 *clockScale;
leftImg.vOffset = 270 *clockScale;
rightImg.width = 20 * clockScale;
rightImg.height = 18 * clockScale;
rightImg.hOffset = 200 *clockScale;
rightImg.vOffset = 270 *clockScale;
alarmImg.width = 30 * clockScale;
alarmImg.height = 30 * clockScale;
alarmImg.hOffset = 155 *clockScale;
alarmImg.vOffset = 25 *clockScale;
seconds.width = 10* clockScale;
seconds.height = 20* clockScale;
seconds.hOffset = 183 *clockScale;
seconds.vOffset = 270 *clockScale;
tenSeconds.width = 10* clockScale;
tenSeconds.height = 20* clockScale;
tenSeconds.hOffset = 173 *clockScale;
tenSeconds.vOffset = 270 *clockScale;
pionts.width = 10* clockScale;
pionts.height = 20* clockScale;
pionts.hOffset = 163 *clockScale;
pionts.vOffset = 270 *clockScale;
minites.width = 10* clockScale;
minites.height = 20* clockScale;
minites.hOffset = 153 *clockScale;
minites.vOffset = 270 *clockScale;
tenMinites.width = 10* clockScale;
tenMinites.height = 20* clockScale;
tenMinites.hOffset = 143 *clockScale;
tenMinites.vOffset = 270 *clockScale;
dateText.size = 15 * clockScale;
dateText.hOffset = 203 * clockScale;
dateText.vOffset = 148 * clockScale;
minuteHand.width = 15 * clockScale;
minuteHand.height = 82 * clockScale;
minuteHand.hOffset = 170 * clockScale;
minuteHand.vOffset = 170 * clockScale;
minuteHand.hRegistrationPoint = 8 * clockScale;
minuteHand.vRegistrationPoint = 83 * clockScale;
hourHand.width = 29 * clockScale;
hourHand.height = 61 * clockScale;
hourHand.hOffset = 170 * clockScale;
hourHand.vOffset = 170 * clockScale;
hourHand.hRegistrationPoint = 15 * clockScale;
hourHand.vRegistrationPoint = 60 * clockScale;
secondHand.width = 5 * clockScale;
secondHand.height = 76 * clockScale;
secondHand.hOffset = 170 * clockScale;
secondHand.vOffset = 170 * clockScale;
secondHand.hRegistrationPoint = 3 * clockScale;
secondHand.vRegistrationPoint = 76 * clockScale;
main_window.visible = true;
}
function setChime()
{
switch(preferences.chimePref.value)
{
case "None":
theRate = 0;
break
case "One hour":
theRate = 60;
break
case "Half hour":
theRate = 30;
break
case "Ten minites":
theRate = 10;
break
default:
break;
}
if (theRate != 0)
{
if (!(theMinutes % theRate) && cleanChime && (theSeconds > 1))
{
var sndFile = preferences.customSound.value;
if (filesystem.itemExists(sndFile) == true ){
play(sndFile);
}
else
{
play("Resources/chime.wav");
cleanChime = 0;
lastChime = timeStamp;
}
}//end if
}//end switch
}
//display the date
function setDate()
{
if (preferences.dateDisplayPref.value == 1)
{
monthDate = String(theDate.getDate());
dateWell.opacity = 255;
dateText.opacity = 255;
dateText.data = String(monthDate);
}
else
{
dateWell.opacity = 0;
dateText.opacity = 0;
}
}
//set all colors include:frame,bg,text.
function setColors()
{
background1.colorize = preferences.frameColor.value;
background.colorize = preferences.bgcolors.value;
background0.colorize = preferences.textColors.value;
}
//display the timer
function getSecondClock()
{
if(startFlag == 1){
secondCnt++;
switch(secondCnt%10)
{
//display seconds
case 0:
seconds.src = "Resources/clock/main-0.png";
tenSecCnt++;
break;
case 1:
seconds.src = "Resources/clock/main-1.png";
break;
case 2:
seconds.src = "Resources/clock/main-2.png";
break;
case 3:
seconds.src = "Resources/clock/main-3.png";
break;
case 4:
seconds.src = "Resources/clock/main-4.png";
break;
case 5:
seconds.src = "Resources/clock/main-5.png";
break;
case 6:
seconds.src = "Resources/clock/main-6.png";
break;
case 7:
seconds.src = "Resources/clock/main-7.png";
break;
case 8:
seconds.src = "Resources/clock/main-8.png";
break;
case 9:
seconds.src = "Resources/clock/main-9.png";
break;
default:
break;
}
switch(tenSecCnt%10)
{
case 0:
tenSeconds.src = "Resources/clock/main-0.png";
break;
case 1:
tenSeconds.src = "Resources/clock/main-1.png";
break;
case 2:
tenSeconds.src = "Resources/clock/main-2.png";
break;
case 3:
tenSeconds.src = "Resources/clock/main-3.png";
break;
case 4:
tenSeconds.src = "Resources/clock/main-4.png";
break;
case 5:
tenSeconds.src = "Resources/clock/main-5.png";
break;
case 6:
tenSeconds.src = "Resources/clock/main-6.png";
break;
case 7:
tenSeconds.src = "Resources/clock/main-7.png";
break;
case 8:
tenSeconds.src = "Resources/clock/main-8.png";
break;
case 9:
tenSeconds.src = "Resources/clock/main-9.png";
break;
default:
break;
}
}
}
function getMiniteClock()
{
if(startFlag == 1){
miniteCnt++;
tenMinCnt++;
switch((miniteCnt/100)%10)
{
//display minites
case 0:
minites.src = "