You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2012/04/28 02:27:55 UTC

[14/17] bada-wac commit: adding beep vibrate and lighton

adding beep vibrate and lighton


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/commit/fa18c75f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/tree/fa18c75f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/diff/fa18c75f

Branch: refs/heads/master
Commit: fa18c75f5181b511b22acba73a679ce47602aad5
Parents: 07c467f
Author: Anis Kadri <an...@gmail.com>
Authored: Fri Apr 6 16:46:51 2012 -0700
Committer: Anis Kadri <an...@gmail.com>
Committed: Fri Apr 6 16:46:51 2012 -0700

----------------------------------------------------------------------
 Res/index.html         |   20 +++++++++++++++++
 Res/js/notification.js |   48 +++++++++++++++++++++++++++++++++++++++++++
 Res/js/sample.js       |   24 +++++++++++++++++++++
 3 files changed, 92 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/blob/fa18c75f/Res/index.html
----------------------------------------------------------------------
diff --git a/Res/index.html b/Res/index.html
index c8a8d19..86cbf94 100644
--- a/Res/index.html
+++ b/Res/index.html
@@ -18,6 +18,7 @@ button.btn {
 		  } 
 </style>
 <script type="text/javascript" src="osp://webapp/js/webapp_core.js"> </script>
+<script type="text/javascript" src="osp://webapp/js/webapp_ui.js"> </script>
 <script>
 /*
 	Osp.App.Application.addEventListener("initializing", function()
@@ -79,7 +80,26 @@ button.btn {
 				<span id="connection"></span>
 			</div>
 		</li>
+		<li>
+			<h3>Notifications</h3>
+			<div>
+				<button type="button" class="btn" onclick="notificationAlert();">Alert</button>
+			</div>
+			<div>
+				<button type="button" class="btn" onclick="notificationAlert();">Confirm</button>
+			</div>
+			<div>
+				<button type="button" class="btn" onclick="notificationVibrate();">Vibrate</button>
+			</div>
+			<div>
+				<button type="button" class="btn" onclick="notificationBeep();">Beep</button>
+			</div>
+			<div>
+				<button type="button" class="btn" onclick="notificationLightOn();">Light ON</button>
+			</div>
+		</li>
 	</ul>
+<script type="text/javascript" src="./js/notification.js"></script>
 <script type="text/javascript" src="./js/connection.js"></script>
 <script type="text/javascript" src="./js/accelerometer.js"></script>
 <script type="text/javascript" src="./js/compass.js"></script>

http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/blob/fa18c75f/Res/js/notification.js
----------------------------------------------------------------------
diff --git a/Res/js/notification.js b/Res/js/notification.js
new file mode 100644
index 0000000..11c8021
--- /dev/null
+++ b/Res/js/notification.js
@@ -0,0 +1,48 @@
+navigator.notification = {
+		alert: function(message, alertCallback, title, buttonName) {
+			alert(message);
+		},
+		confirm: function(message, confirmCallback, title, buttonLabels) {
+			alert(message);
+		},
+		beep: function(times, milliseconds) {
+			try {
+				deviceapis.deviceinteraction.stopNotify();
+				if(times == 0) {
+					return;
+				}
+			    deviceapis.deviceinteraction.startNotify(function() {
+					console.log("Notifying");
+			    },
+			    function(e) {
+			        console.log("Failed to notify: " + e);
+			    },
+			    milliseconds);
+			    Osp.Core.Function.delay(this.beep, 1000+milliseconds, this, times - 1, milliseconds);
+			} catch(e) {
+			    console.log("Exception thrown: " + e);
+			}
+		},
+		vibrate: function(milliseconds) {
+			try {
+			    deviceapis.deviceinteraction.startVibrate(function() {
+			        console.log("Vibrating...");
+			    },
+			    function(e) {
+			        console.log("Failed to vibrate: " + e);
+			    },
+			    milliseconds);
+			} catch(e) {
+			    console.log("Exception thrown: " + e);
+			}
+		},
+		lightOn: function(milliseconds) {
+			deviceapis.deviceinteraction.lightOn(function() {
+			    console.log("Lighting for "+milliseconds+" second");
+			},
+			function() {
+			    console.log("Failed to light");
+			},
+			milliseconds);
+		}
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/blob/fa18c75f/Res/js/sample.js
----------------------------------------------------------------------
diff --git a/Res/js/sample.js b/Res/js/sample.js
index 61b569f..1ffd6ab 100644
--- a/Res/js/sample.js
+++ b/Res/js/sample.js
@@ -174,4 +174,28 @@ function clearHeadingWatch() {
 function getConnection() {
 	var connectionEm = document.getElementById("connection");
 	connectionEm.innerHTML = "Connection type "+navigator.network.connection.type;
+}
+
+/*
+ * Notification
+ */
+
+function notificationAlert() {
+	var notifEm = document.getElementById('result');
+	var alertDismissed = function() {
+		console.log('alertDismissed');
+	};
+	navigator.notification.alert('You are the winner!', alertDismissed, 'Game Over', 'Done');
+}
+
+function notificationVibrate() {
+	navigator.notification.vibrate(2000);
+}
+
+function notificationBeep() {
+	navigator.notification.beep(4, 2000);
+}
+
+function notificationLightOn() {
+	navigator.notification.lightOn(2000);
 }
\ No newline at end of file