-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ryan Willoughby
committed
Dec 4, 2009
0 parents
commit b0e1963
Showing
7 changed files
with
336 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
body { | ||
width: 360px; | ||
height: 620px; | ||
font-family: Helvetica; | ||
margin: 0px; | ||
font-size: 16pt; | ||
} | ||
|
||
.header { | ||
width: 100%; | ||
text-align: center; | ||
font-size: 27pt; | ||
padding: 20px 0px; | ||
} | ||
|
||
.menu { | ||
width: 100%; | ||
height: 120px; | ||
font-size: 18pt; | ||
} | ||
.menu-item { | ||
width: 118px; | ||
height: 25px; | ||
text-align: center; | ||
float: left; | ||
padding: 5px 0px; | ||
background-color: #0F659C; | ||
border: 1px solid white; | ||
} | ||
.selected { | ||
background-color: #78B2D1; | ||
} | ||
|
||
.view { | ||
padding-top: 20px; | ||
} | ||
|
||
.list { | ||
width: 100%; | ||
} | ||
|
||
.list-item { | ||
padding: 8px 2px; | ||
} | ||
|
||
.list-item-small { | ||
font-size: 13pt; | ||
padding-top: 3px; | ||
float: right; | ||
} | ||
|
||
.contacts { | ||
width: 100%; | ||
} | ||
|
||
.nitobi-logo { | ||
position: absolute; | ||
bottom: 10px; | ||
right: 10px; | ||
height: 35px; | ||
width: 35px; | ||
} | ||
|
||
.img_preview { | ||
width: 340px; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
var timeout = null; | ||
var displayState = 0; | ||
var accel_watch_id; | ||
var CURRENT_VIEW = "CONTACTS"; | ||
var current_menu = null; | ||
|
||
function init() { | ||
current_menu = document.getElementById("mnu-cont"); | ||
} | ||
|
||
var changeView = function (e) { | ||
if (current_menu) | ||
current_menu.className = "menu-item"; | ||
current_menu = e.target; | ||
e.target.className = "menu-item selected"; | ||
var id = e.target.innerHTML; | ||
document.getElementById(CURRENT_VIEW).style.display = "none"; | ||
document.getElementById(id).style.display = "block"; | ||
CURRENT_VIEW = id; | ||
} | ||
|
||
function getLocation() { | ||
var options = new Object(); | ||
options.frequency = 5000; | ||
timeout = setInterval("animate()", 500); | ||
navigator.geolocation.watchPosition(updateLocation, function(){ | ||
}, options); | ||
} | ||
|
||
function updateLocation(position) { | ||
clearTimeout(timeout); | ||
//pt.latitude, pt.longitude, pt.altitude, pt.accuracy, pt.heading, pt.speed | ||
var pt = position.coords; | ||
document.getElementById('latitude').innerHTML = pt.latitude; | ||
document.getElementById('longitude').innerHTML = pt.longitude; | ||
document.getElementById('altitude').innerHTML = pt.altitude; | ||
document.getElementById('heading').innerHTML = pt.heading; | ||
document.getElementById('speed').innerHTML = pt.speed; | ||
var dt = new Date(); | ||
dt.setTime(position.timestamp); | ||
document.getElementById('timestamp').innerHTML = dt.getHours() + ":" + | ||
dt.getMinutes() + ":" + dt.getSeconds(); | ||
} | ||
|
||
function watchAccel() { | ||
var options = new Object(); | ||
options.frequency = 1000; | ||
accel_watch_id = navigator.accelerometer.watchAcceleration(updateAcceleration, function(ex){ | ||
navigator.accelerometer.clearWatch(accel_watch_id); | ||
alert("accel fail (" + ex.name + ": " + ex.message + ")"); | ||
}, options); | ||
} | ||
|
||
function updateAcceleration(accel) { | ||
document.getElementById('accel_x').innerHTML = accel.x; | ||
document.getElementById('accel_y').innerHTML = accel.y; | ||
document.getElementById('accel_z').innerHTML = accel.z; | ||
} | ||
|
||
function watchOrientation() { | ||
var options = new Object(); | ||
options.frequency = 1000; | ||
navigator.orientation.watchOrientation(updateOrientation, null, options); | ||
} | ||
|
||
function getContacts() { | ||
var filter = document.getElementById("contact-filter").value; | ||
navigator.contacts.find({ name: filter }, displayContacts, function(){ | ||
alert('getallcontacts fail'); | ||
}, { limit:200, page:1 }); | ||
} | ||
|
||
function displayContacts(contacts) { | ||
var output = ""; | ||
for (var i=0; i<contacts.length; i++) { | ||
var phone = getNonEmptyNumber(contacts[i]); | ||
output += "<div class='list-item'>" + contacts[i].givenName + " " + contacts[i].familyName + | ||
"<span class='list-item-small'> Phone(" + phone.type + "): " + phone.number + | ||
"</div>"; | ||
} | ||
document.getElementById('contacts').innerHTML = output; | ||
} | ||
|
||
function getNonEmptyNumber(contact) { | ||
for (var i=0; i<contact.phones.length; i++) { | ||
if (contact.phones[i].number != undefined && contact.phones[i].number != "") | ||
return contact.phones[i]; | ||
} | ||
return contact.phones[0]; | ||
} | ||
|
||
function vibrate() { | ||
try { | ||
navigator.notification.vibrate(2000); | ||
} catch (ex) { | ||
alert(ex.name + ": " + ex.message); | ||
} | ||
} | ||
|
||
function animate() { | ||
switch (displayState) { | ||
case 0: | ||
displayStatus('finding satellites.'); | ||
displayState = 1; | ||
break; | ||
case 1: | ||
displayStatus('finding satellites..'); | ||
displayState = 2; | ||
break; | ||
case 2: | ||
displayStatus('finding satellites...'); | ||
displayState = 3; | ||
break; | ||
case 3: | ||
displayStatus('finding satellites'); | ||
displayState = 0; | ||
break; | ||
|
||
} | ||
} | ||
|
||
function displayStatus(status) { | ||
document.getElementById('latitude').innerHTML = status; | ||
document.getElementById('longitude').innerHTML = status; | ||
document.getElementById('altitude').innerHTML = status; | ||
document.getElementById('heading').innerHTML = status; | ||
document.getElementById('speed').innerHTML = status; | ||
} | ||
|
||
function sendSMS() { | ||
var number = document.getElementById('sms_number').value; | ||
navigator.sms.send(number, "I love scotch. scotch scotch scotch", smsSuccess, smsFailure); | ||
} | ||
|
||
function smsSuccess() { | ||
document.getElementById("sms_status").innerHTML = "success"; | ||
} | ||
|
||
function smsFailure() { | ||
document.getElementById("sms_status").innerHTML = "failed"; | ||
} | ||
|
||
function takePicture() { | ||
navigator.camera.getPicture(cameraSuccess, cameraFailure, null); | ||
} | ||
|
||
function cameraSuccess(imageUrls) { | ||
//this is an array of all the photos taken while the camera app was open | ||
document.getElementById('preview').innerHTML = "<img class=\"img_preview\" src=\"" + imageUrls[0] + "\" alt=\"\" />"; | ||
} | ||
|
||
function cameraFailure(error) { | ||
alert("camera fail: " + error.name + " - " + error.message); | ||
} | ||
|
||
function updateOrientation(orientation) { | ||
document.getElementById("orientation").innerHTML = orientation; | ||
} | ||
|
||
function checkStorage() { | ||
var store = navigator.storage.getItem("store_test"); | ||
if (store) { | ||
document.getElementById("storage_output").innerHTML = "You stored this: " + store; | ||
} | ||
} | ||
|
||
function testStorage(mode) { | ||
try { | ||
if (mode == 'store') { | ||
|
||
navigator.storage.setItem("store_test", document.getElementById("storage_string").value); | ||
} | ||
else { | ||
navigator.storage.removeItem("store_test"); | ||
} | ||
} catch (ex) { | ||
alert(ex.name + ": " + ex.message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<title>PhoneGap Symbian.WRT</title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | ||
<script language="javascript" type="text/javascript" src="phonegap.js"></script> | ||
<script language="javascript" type="text/javascript" src="controller.js"></script> | ||
<link rel="stylesheet" href="assets/master.css" type="text/css" media="screen" title="no title" charset="utf-8"> | ||
<META NAME="Generator" CONTENT="Nokia WRT plug-in for Aptana Studio 2.0.0" /> | ||
</head> | ||
<body onload="javascript:init();"> | ||
<div class="header">phonegap symbian.wrt</div> | ||
<div class="menu"> | ||
<div class="menu-item" onclick="changeView(event);">LOCATION</div> | ||
<div class="menu-item" onclick="changeView(event);">ACCEL</div> | ||
<div id="mnu-cont" class="menu-item selected" onclick="changeView(event);">CONTACTS</div> | ||
<div class="menu-item" onclick="changeView(event);">ORIENT</div> | ||
<div class="menu-item" onclick="changeView(event);">SOUND</div> | ||
<div class="menu-item" onclick="changeView(event);">SMS</div> | ||
<div class="menu-item" onclick="changeView(event);">CAMERA</div> | ||
<div class="menu-item" onclick="changeView(event);">STORAGE</div> | ||
<div class="menu-item" onclick="changeView(event);">NOTIFY</div> | ||
</div> | ||
<div id="LOCATION" class="view" style="display:none;"> | ||
<a href="javascript:getLocation();">get location</a> | ||
<div class="list"> | ||
<div class="list-item">latitude: <span id="latitude">-</span></div> | ||
<div class="list-item">longitude: <span id="longitude">-</span></div> | ||
<div class="list-item">altitude: <span id="altitude">-</span></div> | ||
<div class="list-item">heading: <span id="heading">-</span></div> | ||
<div class="list-item">speed: <span id="speed">-</span></div> | ||
<div class="list-item">timestamp: <span id="timestamp">-</span></div> | ||
</div> | ||
</div> | ||
<div id="ACCEL" class="view" style="display:none;"> | ||
<a href="javascript:watchAccel()">watch acceleration</a> | ||
<div class="list"> | ||
<div class="list-item">X-Accel: <span id="accel_x"></span></div> | ||
<div class="list-item">Y-Accel: <span id="accel_y"></span></div> | ||
<div class="list-item">Z-Accel: <span id="accel_z"></span></div> | ||
</div> | ||
</div> | ||
<div id="ORIENT" class="view" style="display:none;"> | ||
<a href="javascript:watchOrientation();">watch orientation</a> | ||
<div class="list-item"><label>Current orientation: </label><label id="orientation"> - </label></div> | ||
</div> | ||
<div id="CONTACTS" class="view" style="display:block;"> | ||
filter:<input id="contact-filter" name="contact-filter"/> | ||
<a href="javascript:getContacts();">get contacts</a><br/> | ||
<div id="contacts" class="contacts"></div> | ||
</div> | ||
<div id="NOTIFY" class="view" style="display:none;"> | ||
Notification | ||
<div class="list-item"><a href="javascript:vibrate();">vibrate</a></div> | ||
</div> | ||
<div id="SOUND" class="view" style="display:none;"> | ||
Sound | ||
<div class="list-item"> | ||
<a href="javascript:navigator.media.play('beep.mp3');">Play Sound 1</a><br/> | ||
<a href="javascript:navigator.media.play('beep2.mp3');">Play Sound 2</a> | ||
</div> | ||
</div> | ||
<div id="SMS" class="view" style="display:none;"> | ||
<div class="list-item"> | ||
number: <input id="sms_number" type="text" /><br/> | ||
message:<br/> | ||
<textarea rows=3 /> | ||
<a href="javascript:sendSMS()">Send SMS</a><br/> | ||
<span id="sms_status"></span> | ||
</div> | ||
</div> | ||
<div id="CAMERA" class="view" style="display:none;"> | ||
Camera | ||
<div class="list-item"> | ||
<a href="javascript:takePicture();">Take picture</a> | ||
<div id="preview"></div> | ||
</div> | ||
</div> | ||
<div id="STORAGE" class="view" style="display:none;"> | ||
<a href="javascript:checkStorage()">check storage</a><br/> | ||
<div class="list-item"><input id="storage_string" type="text" /><br/> | ||
<a href="javascript:testStorage('store');">Store this</a><br/> | ||
<a href="javascript:testStorage('clear');">Clear this</a> | ||
</div> | ||
<div class="list-item"><label id="storage_output"></label></div> | ||
</div> | ||
<a href="javascript:widget.openURL('http://www.nitobi.com');"><img src="assets/nitobi-avatar.png" class="nitobi-logo" /></a> | ||
</body> | ||
</html> | ||
|