Eggtimer/basic.js
author Eugene Ostroukhov <eugeneo@symbian.org>
Mon, 01 Nov 2010 14:47:36 -0700
changeset 1 8452783e7980
parent 0 0b6daedcf7e1
child 2 2da62bb63910
permissions -rw-r--r--
Updated eggtimer application
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     1
/*
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     2
 * JavaScript file
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     3
 */
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     4
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     5
var SETUP_ID = 1;
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     6
1
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
     7
var timervalue = 60;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
     8
var initialTimer = 60;
0
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     9
var timeoutId = null;
1
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    10
var paused = true;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    11
var displayUp = true;
0
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    12
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    13
function init()
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    14
{
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    15
	showMainWindow();
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    16
	widget.setDisplayPortrait();
1
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    17
	watchSensorNotifications();
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    18
}
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    19
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    20
// Call this function to add a callback that will be notified of orientation
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    21
// changes
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    22
function watchSensorNotifications() {
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    23
	var sensors = device.getServiceObject("Service.Sensor", "ISensor");
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    24
	var SensorParams = {
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    25
		SearchCriterion : "Orientation"
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    26
	};
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    27
	var result = sensors.ISensor.FindSensorChannel(SensorParams);
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    28
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    29
	if (result.ErrorCode != 0) {
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    30
		var errorCode = result.ErrorCode;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    31
		var errorMessage = result.ErrorMessage;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    32
		return null;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    33
	}
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    34
	var result2 = sensors.ISensor.RegisterForNotification(
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    35
			{ ChannelInfoMap : result.ReturnValue[0], 
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    36
				ListeningType : "ChannelData" }, sensorCallback);
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    37
	if (result.ErrorCode == 0) {
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    38
		var transactionId = result.TransactionID;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    39
		return transactionId;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    40
	} else {
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    41
		var errorCode = result.ErrorCode;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    42
		var errorMessage = result.ErrorMessage;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    43
		return null;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    44
	}
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    45
}
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    46
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    47
function turn(up) {
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    48
	if (up != displayUp) {
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    49
		displayUp = up;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    50
		timervalue = initialTimer - timervalue;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    51
		showValues();
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    52
	}
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    53
}
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    54
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    55
// This function can be passed as callback to
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    56
// sensors.ISensor.RegisterForNotification method
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    57
function sensorCallback(transactionId, code, result) {
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    58
	if (result.ErrorCode == 0) {
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    59
		var dataType = result.ReturnValue.DataType;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    60
		var orientation = result.ReturnValue.DeviceOrientation;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    61
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    62
		if (orientation == "DisplayUp") {
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    63
			turn(true);
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    64
		} else if (orientation == "DisplayDown") {
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    65
			turn(false);
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    66
		}
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    67
	} else {
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    68
		var errorCode = result.ErrorCode;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    69
		var errorMessage = result.ErrorMessage;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    70
	}
0
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    71
}
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    72
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    73
function startTimer() {
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    74
	var hr = parseInt(document.getElementById("hrs").value);
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    75
	var min = parseInt(document.getElementById("min").value);
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    76
	var sec = parseInt(document.getElementById("sec").value);
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    77
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    78
	timervalue = hr * 3600 + min * 60 + sec;
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    79
	initialTimer = timervalue;
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    80
	showMainWindow();
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    81
	startCountdown();
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    82
}
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    83
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    84
function startCountdown() {
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    85
	if (timeoutId) {
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    86
		clearInterval(timeoutId);
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    87
	}
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    88
	timeoutId = window.setInterval(tick, 1000);
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    89
	tick();
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    90
}
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    91
1
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    92
function showValues() {
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    93
	var hrs = Math.floor(timervalue / 3600);
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    94
	var mins = Math.floor((timervalue % 3600) / 60);
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    95
	var sec = timervalue % 60;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    96
	
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    97
	var sz = pad(hrs) + ":" + pad(mins) + ":" + pad(sec);
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    98
	document.getElementById("timervalue").innerHTML = sz;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
    99
	var sand=document.getElementById("sand");
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
   100
	var sandBottom = document.getElementById("sand-bottom");
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
   101
	var top, bottom;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
   102
	top = (50 * (initialTimer-timervalue)/initialTimer).toFixed(0) + "%";
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
   103
	bottom = "50%";
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
   104
	if (displayUp) {
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
   105
		sand.style.top = top;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
   106
		sand.style.bottom = bottom;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
   107
	} else {
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
   108
		sandBottom.style.bottom = top;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
   109
		sandBottom.style.top = bottom;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
   110
	}
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
   111
	bottom = "0%";
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
   112
	top = (50 + (50 * timervalue/initialTimer)).toFixed(0) + "%";
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
   113
	if (displayUp) {
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
   114
		sandBottom.style.top = top;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
   115
		sandBottom.style.bottom = bottom;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
   116
	} else {
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
   117
		sand.style.top = bottom;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
   118
		sand.style.bottom = top;
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
   119
	}
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
   120
}
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
   121
0
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   122
function tick() {
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   123
	if (timervalue > 0) {
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   124
		timervalue = timervalue - 1;
1
8452783e7980 Updated eggtimer application
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 0
diff changeset
   125
		showValues();
0
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   126
		if (timervalue == 0) {
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   127
			cancelTimer();
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   128
		}
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   129
	}
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   130
}
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   131
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   132
function pad(num) {
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   133
	if (num < 10) {
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   134
		return '0' + num;
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   135
	} else {
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   136
		return num;
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   137
	}
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   138
}
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   139
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   140
function cancelTimer() {
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   141
	clearInterval(timeoutId);
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   142
	timeoutId = 0;
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   143
	timervalue = 0;
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   144
	document.getElementById("timervalue").innerHTML = "00:00:00";
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   145
	document.getElementById("sand").style.top="50%";
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   146
	document.getElementById("sand-bottom").style.top="50%";
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   147
}
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   148
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   149
function showMainWindow() {
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   150
	document.getElementById("main-window").style.display = "inherit";
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   151
	document.getElementById("time-setup").style.display = "none";
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   152
	var item = new MenuItem("Setup timer", SETUP_ID);
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   153
	item.onSelect = showTimerSetup;
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   154
	menu.append(item);
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   155
	menu.setRightSoftkeyLabel("Exit", null);
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   156
}
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   157
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   158
function showTimerSetup() {
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   159
	document.getElementById("main-window").style.display = "none";
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   160
	document.getElementById("time-setup").style.display = "inherit";
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   161
	var item = menu.getMenuItemById(SETUP_ID);
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   162
	menu.remove(item);
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   163
	menu.setRightSoftkeyLabel("Cancel", showMainWindow);
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   164
}
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   165
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   166
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   167
function pauseStart() {
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   168
	if (paused) {
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   169
		startCountdown();
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   170
		document.getElementById("pausestart").style.backgroundPosition = "0px 0px";
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   171
		paused = false;
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   172
	} else {
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   173
		if (timeoutId) {
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   174
			window.clearInterval(timeoutId);
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   175
			timeoutId = null;
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   176
		}
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   177
		document.getElementById("pausestart").style.backgroundPosition = "0px 32px";
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   178
		paused = true;
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   179
	}
0b6daedcf7e1 Initial commit of two sample projects
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   180
}