--- a/Eggtimer/.settings/org.symbian.tools.tmw.previewer.xml Thu Oct 28 11:00:31 2010 -0700
+++ b/Eggtimer/.settings/org.symbian.tools.tmw.previewer.xml Mon Nov 01 14:47:36 2010 -0700
@@ -2,8 +2,9 @@
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="__SYM_NOKIA_EMULATOR_DEVICE_MODE">portrait</entry>
-<entry key="__SYM_NOKIA_CONSOLE_OPEN">false</entry>
-<entry key="__SYM_SELECTED_CONTROLS_TAB">1</entry>
+<entry key="__SYM_NOKIA_CONSOLE_OPEN">true</entry>
<entry key="__SYM_WRT_VERSION">WRT 1.1</entry>
+<entry key="__SYM_SELECTED_CONTROLS_TAB">1</entry>
<entry key="__SYM_NOKIA_EMULATOR_DEVICE">360x640</entry>
+<entry key="__SYM_DEVICE_ORIENTATION">DisplayUp</entry>
</properties>
--- a/Eggtimer/.settings/org.symbian.tools.tmw.ui.xml Thu Oct 28 11:00:31 2010 -0700
+++ b/Eggtimer/.settings/org.symbian.tools.tmw.ui.xml Mon Nov 01 14:47:36 2010 -0700
@@ -1,3 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
-<deployment targetId="mtw.filesystem" typeId="org.symbian.tools.tmw.fileSystem">
<target targetId="Testing5800" typeId="org.symbian.tools.tmw.bluetooth"/>
<target path="/Users/eugeneo/Desktop/Eggtimer.wgz" targetId="mtw.filesystem" typeId="org.symbian.tools.tmw.fileSystem"/>
-</deployment>
\ No newline at end of file
+<deployment targetId="mtw.filesystem" typeId="org.symbian.tools.tmw.fileSystem">
<target targetId="Testing5800" typeId="org.symbian.tools.tmw.bluetooth"/>
<target path="/Users/eugeneo/Desktop/Eggtimer.wgz" targetId="mtw.filesystem" typeId="org.symbian.tools.tmw.fileSystem"/>
</deployment>
\ No newline at end of file
--- a/Eggtimer/basic.css Thu Oct 28 11:00:31 2010 -0700
+++ b/Eggtimer/basic.css Mon Nov 01 14:47:36 2010 -0700
@@ -2,7 +2,6 @@
* Add your Stylesheet contents here
*/
#remaining-time {
- background-color: olive;
width: 170px;
height: 40px;
position: absolute;
@@ -17,6 +16,7 @@
right: -138px;
top: -32px;
background-image: url('images/button.png');
+ background-position: 0px 32px
}
.digits {
@@ -31,7 +31,7 @@
}
#sand {
- background-color: yellow;
+ background-color: rgb(255, 208, 52);
position: absolute;
top: 0;
bottom: 50%;
@@ -40,7 +40,7 @@
}
#sand-bottom {
- background-color: yellow;
+ background-color: rgb(255, 208, 52);
position: absolute;
top: 100%;
bottom: 0;
--- a/Eggtimer/basic.js Thu Oct 28 11:00:31 2010 -0700
+++ b/Eggtimer/basic.js Mon Nov 01 14:47:36 2010 -0700
@@ -4,14 +4,70 @@
var SETUP_ID = 1;
-var timervalue = 0;
-var initialTimer = 0;
+var timervalue = 60;
+var initialTimer = 60;
var timeoutId = null;
+var paused = true;
+var displayUp = true;
function init()
{
showMainWindow();
widget.setDisplayPortrait();
+ watchSensorNotifications();
+}
+
+// Call this function to add a callback that will be notified of orientation
+// changes
+function watchSensorNotifications() {
+ var sensors = device.getServiceObject("Service.Sensor", "ISensor");
+ var SensorParams = {
+ SearchCriterion : "Orientation"
+ };
+ var result = sensors.ISensor.FindSensorChannel(SensorParams);
+
+ if (result.ErrorCode != 0) {
+ var errorCode = result.ErrorCode;
+ var errorMessage = result.ErrorMessage;
+ return null;
+ }
+ var result2 = sensors.ISensor.RegisterForNotification(
+ { ChannelInfoMap : result.ReturnValue[0],
+ ListeningType : "ChannelData" }, sensorCallback);
+ if (result.ErrorCode == 0) {
+ var transactionId = result.TransactionID;
+ return transactionId;
+ } else {
+ var errorCode = result.ErrorCode;
+ var errorMessage = result.ErrorMessage;
+ return null;
+ }
+}
+
+function turn(up) {
+ if (up != displayUp) {
+ displayUp = up;
+ timervalue = initialTimer - timervalue;
+ showValues();
+ }
+}
+
+// This function can be passed as callback to
+// sensors.ISensor.RegisterForNotification method
+function sensorCallback(transactionId, code, result) {
+ if (result.ErrorCode == 0) {
+ var dataType = result.ReturnValue.DataType;
+ var orientation = result.ReturnValue.DeviceOrientation;
+
+ if (orientation == "DisplayUp") {
+ turn(true);
+ } else if (orientation == "DisplayDown") {
+ turn(false);
+ }
+ } else {
+ var errorCode = result.ErrorCode;
+ var errorMessage = result.ErrorMessage;
+ }
}
function startTimer() {
@@ -33,17 +89,40 @@
tick();
}
+function showValues() {
+ var hrs = Math.floor(timervalue / 3600);
+ var mins = Math.floor((timervalue % 3600) / 60);
+ var sec = timervalue % 60;
+
+ var sz = pad(hrs) + ":" + pad(mins) + ":" + pad(sec);
+ document.getElementById("timervalue").innerHTML = sz;
+ var sand=document.getElementById("sand");
+ var sandBottom = document.getElementById("sand-bottom");
+ var top, bottom;
+ top = (50 * (initialTimer-timervalue)/initialTimer).toFixed(0) + "%";
+ bottom = "50%";
+ if (displayUp) {
+ sand.style.top = top;
+ sand.style.bottom = bottom;
+ } else {
+ sandBottom.style.bottom = top;
+ sandBottom.style.top = bottom;
+ }
+ bottom = "0%";
+ top = (50 + (50 * timervalue/initialTimer)).toFixed(0) + "%";
+ if (displayUp) {
+ sandBottom.style.top = top;
+ sandBottom.style.bottom = bottom;
+ } else {
+ sand.style.top = bottom;
+ sand.style.bottom = top;
+ }
+}
+
function tick() {
if (timervalue > 0) {
timervalue = timervalue - 1;
- var hrs = Math.floor(timervalue / 3600);
- var mins = Math.floor((timervalue % 3600) / 60);
- var sec = timervalue % 60;
-
- var sz = pad(hrs) + ":" + pad(mins) + ":" + pad(sec);
- document.getElementById("timervalue").innerHTML = sz;
- document.getElementById("sand").style.top=(50 * (initialTimer-timervalue)/initialTimer).toFixed(0) + "%";
- document.getElementById("sand-bottom").style.top=(50+(50 * timervalue/initialTimer)).toFixed(0) + "%";
+ showValues();
if (timervalue == 0) {
cancelTimer();
}
@@ -84,7 +163,6 @@
menu.setRightSoftkeyLabel("Cancel", showMainWindow);
}
-var paused = false;
function pauseStart() {
if (paused) {
--- a/Eggtimer/index.html Thu Oct 28 11:00:31 2010 -0700
+++ b/Eggtimer/index.html Mon Nov 01 14:47:36 2010 -0700
@@ -11,7 +11,7 @@
<body onload="javascript:init();">
<div id="main-window">
<div id="remaining-time">
- <div id="time" ><a href="javascript:showTimerSetup()" id="timervalue">00:00:00</a></div>
+ <div id="time" ><a href="javascript:showTimerSetup()" id="timervalue">00:01:00</a></div>
<div id="pausestart" onclick="pauseStart()"> </div>
</div>
<div id="hourglass">
@@ -22,7 +22,7 @@
</div>
<div id="time-setup">
Specify time:
- <input id="hrs" class="digits" value="00"/>:<input id="min" class="digits" value="00"/>:<input id="sec" class="digits" value="00"/>
+ <input id="hrs" class="digits" value="00"/>:<input id="min" class="digits" value="01"/>:<input id="sec" class="digits" value="00"/>
<input type="button" value="Start" onclick="startTimer()"/><input type="button" value="Cancel" onclick="showMainWindow()"/>
</div>
</body>