-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added user type selection, and ParentHome panel
- Loading branch information
Showing
8 changed files
with
123 additions
and
431 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,19 @@ | ||
function UPSUser() | ||
{ | ||
this.storage = window.localStorage; | ||
} | ||
|
||
UPSUser.prototype.GetUserType = function() | ||
{ | ||
if(!this.storage.getItem("usertype")) | ||
{ | ||
this.storage.setItem("usertype","none"); | ||
} | ||
|
||
return this.storage.getItem("usertype"); | ||
} | ||
|
||
UPSUser.prototype.SetUserType = function(type) | ||
{ | ||
this.storage.setItem("usertype",type); | ||
} |
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,10 @@ | ||
|
||
Ext.regApplication('UPSApp', { | ||
defaultTarget:'viewport', | ||
name:'UPSApp', | ||
launch: function() { | ||
|
||
// The Ext.regApplication call automatically creates our 'views' namespace | ||
this.views.viewport = new this.views.Viewport(); | ||
} | ||
}); |
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,27 @@ | ||
UPSApp.views.SelectUserType = Ext.extend(Ext.Panel, { | ||
cardSwitchAnimation:'slide', | ||
dockedItems:[], | ||
items:[ | ||
{ | ||
xtype:'button', | ||
text:"I'm a Parent", | ||
handler:function() { | ||
User.SetUserType('parent'); | ||
UPSApp.views.viewport.setActiveItem('parenthome'); | ||
} | ||
}, | ||
{ | ||
xtype:'button', | ||
text:"I'm a Student" | ||
}, | ||
{ | ||
xtype:'button', | ||
text:"I'm an Alumnus" | ||
} | ||
], | ||
initComponent: function() { | ||
|
||
|
||
UPSApp.views.Viewport.superclass.initComponent.apply(this, arguments); | ||
} | ||
}); |
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,49 @@ | ||
var User; | ||
|
||
UPSApp.views.Viewport = Ext.extend(Ext.Panel, { | ||
fullscreen:true, | ||
layout: 'card', | ||
cardSwitchAnimation:'pop', | ||
dockedItems:[ | ||
new Ext.Toolbar({ | ||
dock:'bottom', | ||
title:"Debug", | ||
items:[ | ||
{ | ||
xtype:'button', | ||
text:'Reset Usertype', | ||
handler:function(){User.SetUserType("none");} | ||
} | ||
] | ||
}) | ||
], | ||
items:[], | ||
activeItem:0, | ||
initComponent: function() { | ||
|
||
User = new UPSUser(); | ||
|
||
UPSApp.views.toolbar = new Ext.Toolbar({ | ||
title:'University of Puget Sound' | ||
}); | ||
|
||
this.dockedItems[1] = UPSApp.views.toolbar; | ||
|
||
UPSApp.views.selectUserType = new UPSApp.views.SelectUserType(); | ||
UPSApp.views.parentHome = new UPSApp.views.ParentHome(); | ||
|
||
this.items[0] = UPSApp.views.selectUserType; | ||
this.items[1] = UPSApp.views.parentHome; | ||
|
||
if(User.GetUserType() == "none") | ||
Ext.apply(this, { | ||
activeItem:0 | ||
}) | ||
else if(User.GetUserType() == "parent") | ||
Ext.apply(this, { | ||
activeItem:1 | ||
}) | ||
|
||
UPSApp.views.Viewport.superclass.initComponent.apply(this, arguments); | ||
} | ||
}); |
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,10 @@ | ||
UPSApp.views.ParentHome = Ext.extend(Ext.Panel, { | ||
id:'parenthome', | ||
dockedItems:[], | ||
items:[], | ||
html:"<p>I'm a <b>Parent</b></p>", | ||
initComponent: function() { | ||
|
||
UPSApp.views.Viewport.superclass.initComponent.apply(this, arguments); | ||
} | ||
}); |
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
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 |
---|---|---|
@@ -1,184 +1,5 @@ | ||
var getLocation = function() { | ||
var suc = function(p) { | ||
|
||
document.getElementById("loclat").innerHTML = 'Latitude: ' | ||
+ p.coords.latitude; | ||
document.getElementById("loclong").innerHTML = 'Longitude: ' | ||
+ p.coords.longitude; | ||
document.getElementById("locaccur").innerHTML = 'Accuracy: ' | ||
+ p.coords.accuracy + 'm'; | ||
document.addEventListener("deviceready", onDeviceReady, false); | ||
|
||
var mapview = document.getElementById('mapview'); | ||
|
||
var image_url = "http://maps.google.com/maps/api/staticmap?sensor=false¢er=" | ||
+ p.coords.latitude | ||
+ "," | ||
+ p.coords.longitude | ||
+ "&zoom=13&size=220x180&markers=color:blue|" | ||
+ p.coords.latitude + ',' + p.coords.longitude; | ||
|
||
mapview.style.display = ""; | ||
mapview.style.position = "absolute"; | ||
mapview.style.bottom = "7px"; | ||
mapview.style.left = "14px"; | ||
document.getElementById("mapcanvas").src = image_url; | ||
}; | ||
var fail = function(error) { | ||
document.getElementById("loclong").innerHTML = '<span style="color:red;">Failed to get location</span>'; | ||
switch (error.code) { | ||
case error.PERMISSION_DENIED: | ||
alert("User did not share geolocation data."); | ||
break; | ||
|
||
case error.POSITION_UNAVAILABLE: | ||
alert("Could not detect current position."); | ||
break; | ||
|
||
case error.TIMEOUT: | ||
alert("Retrieving position timed out."); | ||
break; | ||
|
||
default: | ||
alert("Unknown error."); | ||
break; | ||
} | ||
}; | ||
|
||
if (navigator.geolocation) { | ||
document.getElementById("loclong").innerHTML = "Getting geolocation . . ."; | ||
navigator.geolocation.getCurrentPosition(suc, fail); | ||
} else { | ||
document.getElementById("loclong").innerHTML = '<span style="color:red;">Device or browser can not get location</span>'; | ||
} | ||
}; | ||
|
||
var closeLocation = function() { | ||
document.getElementById("loclat").innerHTML = ""; | ||
document.getElementById("loclong").innerHTML = ""; | ||
document.getElementById("locaccur").innerHTML = ""; | ||
document.getElementById("mapcanvas").src = ""; | ||
document.getElementById("mapview").style.display = "none"; | ||
}; | ||
|
||
var beep = function() { | ||
navigator.notification.beep(2); | ||
}; | ||
|
||
var vibrate = function() { | ||
navigator.notification.vibrate(0); | ||
}; | ||
|
||
function roundNumber(num) { | ||
var dec = 3; | ||
var result = Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec); | ||
return result; | ||
} | ||
|
||
var accelerationWatch = null; | ||
|
||
function updateAcceleration(a) { | ||
document.getElementById('x').innerHTML = roundNumber(a.x); | ||
document.getElementById('y').innerHTML = roundNumber(a.y); | ||
document.getElementById('z').innerHTML = roundNumber(a.z); | ||
} | ||
|
||
function toggleAccel() { | ||
if (accelerationWatch !== null) { | ||
navigator.accelerometer.clearWatch(accelerationWatch); | ||
updateAcceleration({ | ||
x : "", | ||
y : "", | ||
z : "" | ||
}); | ||
accelerationWatch = null; | ||
} else { | ||
var options = {}; | ||
options.frequency = 1000; | ||
accelerationWatch = navigator.accelerometer.watchAcceleration( | ||
updateAcceleration, function(ex) { | ||
alert("accel fail (" + ex.name + ": " + ex.message + ")"); | ||
}, options); | ||
} | ||
} | ||
|
||
var preventBehavior = function(e) { | ||
e.preventDefault(); | ||
}; | ||
|
||
function dump_pic(data) { | ||
var viewport = document.getElementById('viewport'); | ||
//console.log(data); | ||
viewport.style.display = ""; | ||
viewport.style.position = "relative"; | ||
viewport.style.top = "10px"; | ||
viewport.style.left = "20px"; | ||
document.getElementById("test_img").src = "data:image/jpeg;base64," + data; | ||
} | ||
|
||
function fail(msg) { | ||
alert(msg); | ||
} | ||
|
||
function show_pic() { | ||
navigator.camera.getPicture(dump_pic, fail, { | ||
quality : 30 | ||
}); | ||
} | ||
|
||
function closeviewport() { | ||
var viewport = document.getElementById('viewport'); | ||
viewport.style.display = "none"; | ||
document.getElementById("test_img").src = ""; | ||
} | ||
|
||
function contacts_success(contacts) { | ||
alert(contacts.length | ||
+ ' contacts returned.' | ||
+ (contacts[2] && contacts[2].name && | ||
contacts[2].name.formatted ? (' Third contact is ' + contacts[2].name.formatted) | ||
: '')); | ||
} | ||
|
||
function get_contacts() { | ||
var obj = new ContactFindOptions(); | ||
obj.filter = ""; | ||
obj.multiple = true; | ||
navigator.contacts.find( | ||
[ "displayName", "name" ], contacts_success, | ||
fail, obj); | ||
} | ||
|
||
var check_network = function() { | ||
var networkState = navigator.network.connection.type; | ||
|
||
var states = {}; | ||
states[Connection.UNKNOWN] = 'Unknown connection'; | ||
states[Connection.ETHERNET] = 'Ethernet connection'; | ||
states[Connection.WIFI] = 'WiFi connection'; | ||
states[Connection.CELL_2G] = 'Cell 2G connection'; | ||
states[Connection.CELL_3G] = 'Cell 3G connection'; | ||
states[Connection.CELL_4G] = 'Cell 4G connection'; | ||
states[Connection.NONE] = 'No network connection'; | ||
|
||
document.getElementById("networktext").innerHTML = "<span>Connection type:<br/>" | ||
+ states[networkState] + "</span>"; | ||
}; | ||
|
||
var compassWatch = null; | ||
|
||
function updateHeading(h) { | ||
document.getElementById('h').innerHTML = h.magneticHeading; | ||
} | ||
|
||
function toggleCompass() { | ||
if (compassWatch !== null) { | ||
navigator.compass.clearWatch(compassWatch); | ||
compassWatch = null; | ||
updateHeading({ magneticHeading : "Off"}); | ||
} else { | ||
var options = { frequency: 1000 }; | ||
compassWatch = navigator.compass.watchHeading(updateHeading, function(e) { | ||
alert('Compass Error: ' + e.code); | ||
}, options); | ||
} | ||
function onDeviceReady() { | ||
|
||
} |
Oops, something went wrong.