Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Keep the originals in the iOS project because Xcode isn't able to dea…
…l with symlinks out of the box.
- Loading branch information
jtowle
committed
Mar 8, 2013
1 parent
008337c
commit c2a12a5
Showing
4 changed files
with
578 additions
and
578 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,314 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
<title>Phonegap Sample App</title> | ||
|
||
<link href="css/jquery.mobile-1.1.1.css" rel="stylesheet" type="text/css"/> | ||
|
||
<script type="text/javascript" src="lib/jquery.js"></script> | ||
<script type="text/javascript" src="js/jquery.mobile-1.1.1.js"></script> | ||
|
||
<script type="text/javascript" src="cordova-2.2.0.js"></script> | ||
<script type="text/javascript" src="lib/PushNotification.js"></script> | ||
<script type="text/javascript"> | ||
|
||
function onLoad() { | ||
document.addEventListener("deviceready", function() { | ||
|
||
push = window.pushNotification | ||
|
||
// Reset Badge on resume | ||
document.addEventListener("resume", function() { | ||
push.resetBadge() | ||
}) | ||
|
||
push.getIncoming(function (incoming) { | ||
if(incoming.message) { | ||
console.log("Incoming push: " + incoming.message) | ||
} else { | ||
console.log("No incoming message") | ||
} | ||
}) | ||
|
||
function on_push(data) { | ||
console.log("Received push: " + data.message) | ||
} | ||
|
||
function on_reg(error, pushID) { | ||
if (!error) { | ||
console.log("Reg Success: " + pushID) | ||
$('#id').text(pushID) | ||
} | ||
} | ||
|
||
push.registerEvent('registration', on_reg) | ||
|
||
push.registerEvent('push', on_push) | ||
|
||
function add_tag(tag) { | ||
$('#tags').prepend("<p>" + tag + "<input type='button' class='removeTagButton' value='Remove' /></p>") | ||
//This needs to be here because the element doesn't exist at load. | ||
$(".removeTagButton").on("click", function(ev) { | ||
p = $(ev.target).parent() | ||
tag = p.text() | ||
p.remove() | ||
push.getTags(function(obj) { | ||
console.log("Removing tag: " + tag) | ||
obj.tags.splice(obj.tags.indexOf(tag), 1) | ||
push.setTags(obj.tags) | ||
}) | ||
}) | ||
} | ||
|
||
function set_alias(alias) { | ||
$("#alias").text(alias) | ||
$("#setAliasField").val("") | ||
} | ||
|
||
push.isPushEnabled(function(has_push) { | ||
if (has_push) { | ||
$('#pushEnabled').val('on').change(); | ||
} else { | ||
$('#pushEnabled').val('off').change(); | ||
} | ||
}) | ||
|
||
push.isSoundEnabled(function(has_sound) { | ||
if (has_sound) { | ||
$('#soundEnabled').val('on').change(); | ||
} else { | ||
$('#soundEnabled').val('off').change(); | ||
} | ||
}) | ||
|
||
push.isVibrateEnabled(function(has_vibrate) { | ||
if (has_vibrate) { | ||
$('#vibrateEnabled').val('on').change(); | ||
} else { | ||
$('#vibrateEnabled').val('off').change(); | ||
} | ||
}) | ||
|
||
push.isQuietTimeEnabled(function(has_quiettime) { | ||
if (has_quiettime) { | ||
$('#quietTimeEnabled').val('on').change(); | ||
} else { | ||
$('#quietTimeEnabled').val('off').change(); | ||
} | ||
}) | ||
|
||
push.isLocationEnabled(function(enabled) { | ||
if (enabled) { | ||
$('#locationEnabled').val('on').change(); | ||
} else { | ||
$('#locationEnabled').val('off').change(); | ||
} | ||
}) | ||
|
||
$('#pushEnabled').change(function() { | ||
if ($('#pushEnabled').val() == "on") { | ||
// This means we want to turn it on | ||
push.enablePush() | ||
} else { | ||
push.disablePush() | ||
} | ||
}) | ||
|
||
$('#soundEnabled').change(function() { | ||
if ($('#soundEnabled').val() == "on") { | ||
//This means we want to turn it on | ||
push.setSoundEnabled(true) | ||
} else { | ||
push.setSoundEnabled(false) | ||
} | ||
}) | ||
|
||
$('#vibrateEnabled').change(function() { | ||
if ($('#vibrateEnabled').val() == "on") { | ||
//This means we want to turn it on | ||
push.setVibrateEnabled(true) | ||
} else { | ||
push.setVibrateEnabled(false) | ||
} | ||
}) | ||
|
||
$('#quietTimeEnabled').change(function() { | ||
if ($('#quietTimeEnabled').val() == "on") { | ||
//This means we want to turn it on | ||
push.setQuietTimeEnabled(true) | ||
} else { | ||
push.setQuietTimeEnabled(false) | ||
} | ||
}) | ||
|
||
$('#locationEnabled').change(function() { | ||
if ($('#locationEnabled').val() == "on") { | ||
//This means we want to turn it on | ||
push.enableLocation() | ||
} else { | ||
push.disableLocation() | ||
} | ||
}) | ||
|
||
$("#addTagButton").click(function(ev) { | ||
var new_tag = $("#addTagField").val() | ||
console.log("Adding new tag: " + new_tag) | ||
push.getTags(function(obj) { | ||
if (obj.tags.indexOf(new_tag) == -1) { | ||
console.log("Valid tag: " + new_tag) | ||
obj.tags = obj.tags.concat([new_tag]) | ||
push.setTags(obj.tags, function() { | ||
add_tag(new_tag) | ||
$("#addTagField").val('') | ||
}) | ||
} | ||
}) | ||
}) | ||
|
||
$("#setQuietTimeButton").click(function(ev) { | ||
var startHour = parseInt($("#startHour").val()) | ||
var startMinute = parseInt($("#startMinute").val()) | ||
var endHour = parseInt($("#endHour").val()) | ||
var endMinute = parseInt($("#endMinute").val()) | ||
|
||
push.setQuietTime(startHour, startMinute, endHour, endMinute, function() { | ||
console.log("Set quiet time from JS") | ||
}) | ||
}) | ||
|
||
$("#setAliasButton").click(function(ev) { | ||
var new_alias = $("#setAliasField").val() | ||
push.setAlias(new_alias, function() { | ||
set_alias(new_alias) | ||
}) | ||
}) | ||
|
||
push.getPushID(function (id) { | ||
if(id) { | ||
console.log("Got push ID: " + id) | ||
$('#id').text(id) | ||
} | ||
}) | ||
|
||
push.getAlias(function (alias) { | ||
if(alias) { | ||
console.log("Got alias: " + alias) | ||
set_alias(alias) | ||
} else { | ||
console.log("No alias"); | ||
} | ||
}) | ||
|
||
push.getTags(function(obj) { | ||
obj.tags.forEach(function(tag) { | ||
add_tag(tag) | ||
}) | ||
}) | ||
|
||
push.getQuietTime(function(obj) { | ||
$("#startHour").val(obj.startHour) | ||
$("#startMinute").val(obj.startMinute) | ||
$("#endHour").val(obj.endHour) | ||
$("#endMinute").val(obj.endMinute) | ||
}) | ||
|
||
push.registerForNotificationTypes(push.notificationType.badge | push.notificationType.sound | push.notificationType.alert) | ||
if (device.platform != "Android") { | ||
$("#soundEnabledSection").hide(); | ||
$("#vibrateEnabledSection").hide(); | ||
} | ||
}) | ||
} | ||
</script> | ||
</head> | ||
<body onload="onLoad()"> | ||
<div data-role="page" id="page"> | ||
|
||
<div data-role="header" class="ui-bar ui-bar-b"> | ||
<center> | ||
<img border="0" src="img/logo.png" alt="Urban Airship" align="center" /> | ||
</center> | ||
</div> | ||
|
||
<div data-role="content"> | ||
<form> | ||
<div class="ui-body ui-body-b"> | ||
|
||
<div data-role="fieldcontain"> | ||
<label for="id">Identifier:</label><br /> | ||
<span name="id" id="id" style="word-wrap: break-word;"></span> | ||
<center><h3>Push Settings</h3></center> | ||
<label>Alias: </label> | ||
<span name="alias" id="alias"></span><hr /> | ||
<input type="text" name="setAliasField" id="setAliasField" style="width:96.5%;" /> <input type="button" id="setAliasButton" value="Set alias" /> | ||
</div> | ||
|
||
<div data-role="controlgroup"> | ||
<label for="pushEnabled">Push Enabled</label> | ||
<select name="pushEnabled" id="pushEnabled" data-role="slider" data-theme="c" data-track-theme="c"> | ||
<option value="off">Off</option> | ||
<option value="on">On</option> | ||
</select> | ||
</div> | ||
|
||
<div data-role="controlgroup"> | ||
<span id="soundEnabledSection"> | ||
<label for="soundEnabled">Sound Enabled</label> | ||
<select name="soundEnabled" id="soundEnabled" data-role="slider" data-theme="c" data-track-theme="c"> | ||
<option value="off">Off</option> | ||
<option value="on">On</option> | ||
</select> | ||
</span> | ||
</div> | ||
|
||
<div data-role="controlgroup"> | ||
<span id="vibrateEnabledSection"> | ||
<label for="vibrateEnabled">Vibrate Enabled</label> | ||
<select name="vibrateEnabled" id="vibrateEnabled" data-role="slider" data-theme="c" data-track-theme="c"> | ||
<option value="off">Off</option> | ||
<option value="on">On</option> | ||
</select> | ||
</span> | ||
</div> | ||
|
||
<div data-role="controlgroup"> | ||
<label for="locationEnabled">Location Enabled</label> | ||
<select name="locationEnabled" id="locationEnabled" data-role="slider" data-theme="c" data-track-theme="c"> | ||
<option value="off">Off</option> | ||
<option value="on">On</option> | ||
</select> | ||
</div> | ||
|
||
<div data-role="controlgroup"> | ||
<label for="quietTimeEnabled">Quiet Time Enabled</label> | ||
<span id="quietTimeEnabledSection"> | ||
<select name="quietTimeEnabled" id="quietTimeEnabled" data-role="slider" data-theme="c" data-track-theme="c"> | ||
<option value="off">Off</option> | ||
<option value="on">On</option> | ||
</select> | ||
</span> | ||
</div> | ||
|
||
<div data-role="fieldcontain"> | ||
<label for="startHour">Start Time (24h)</label> | ||
<input name="startHour" style="width: 3em; margin-left: -5px;" id="startHour" />:<input name="startMinute" style="width: 3em;" id="startMinute" /><br /> | ||
<label for="startHour">End Time (24h)</label> | ||
<input name="endHour" style="width: 3em;" id="endHour" />:<input name="endMinute" style="width: 3em;" id="endMinute" /> | ||
<input type="button" id="setQuietTimeButton" value="Set Quiet Time" /> | ||
</div> | ||
|
||
<div data-role="fieldcontain"> | ||
<input name="addTagField" id="addTagField" /> | ||
<input type="button" id="addTagButton" value="Add tag" /> | ||
<div id="tags"></div> | ||
</div> | ||
|
||
</div> | ||
</form> | ||
</div> | ||
|
||
</div> | ||
</body> | ||
</html> |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.