2009-11-18 02:38:49 +08:00
|
|
|
/**
|
|
|
|
* This class provides access to notifications on the device.
|
|
|
|
*/
|
|
|
|
function Notification() {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Open a native alert dialog, with a customizable title and button text.
|
|
|
|
* @param {String} message Message to print in the body of the alert
|
|
|
|
* @param {String} [title="Alert"] Title of the alert dialog (default: Alert)
|
|
|
|
* @param {String} [buttonLabel="OK"] Label of the close button (default: OK)
|
|
|
|
*/
|
|
|
|
Notification.prototype.alert = function(message, title, buttonLabel) {
|
2010-10-07 02:31:30 +08:00
|
|
|
var _title = (title || "Alert");
|
|
|
|
var _buttonLabel = (buttonLabel || "OK");
|
|
|
|
PhoneGap.execAsync(null, null, "Notification", "alert", [message,_title,_buttonLabel]);
|
2009-11-18 02:38:49 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Start spinning the activity indicator on the statusbar
|
|
|
|
*/
|
|
|
|
Notification.prototype.activityStart = function() {
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stop spinning the activity indicator on the statusbar, if it's currently spinning
|
|
|
|
*/
|
|
|
|
Notification.prototype.activityStop = function() {
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Causes the device to blink a status LED.
|
|
|
|
* @param {Integer} count The number of blinks.
|
|
|
|
* @param {String} colour The colour of the light.
|
|
|
|
*/
|
|
|
|
Notification.prototype.blink = function(count, colour) {
|
2010-09-16 03:27:46 +08:00
|
|
|
|
2009-11-18 02:38:49 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Causes the device to vibrate.
|
|
|
|
* @param {Integer} mills The number of milliseconds to vibrate for.
|
|
|
|
*/
|
|
|
|
Notification.prototype.vibrate = function(mills) {
|
2010-09-30 00:10:08 +08:00
|
|
|
PhoneGap.execAsync(null, null, "Notification", "vibrate", [mills]);
|
2009-11-18 02:38:49 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Causes the device to beep.
|
2010-09-16 03:27:46 +08:00
|
|
|
* On Android, the default notification ringtone is played.
|
|
|
|
*
|
2009-11-18 02:38:49 +08:00
|
|
|
* @param {Integer} count The number of beeps.
|
|
|
|
*/
|
2010-09-16 03:27:46 +08:00
|
|
|
Notification.prototype.beep = function(count) {
|
2010-09-30 00:10:08 +08:00
|
|
|
PhoneGap.execAsync(null, null, "Notification", "beep", [count]);
|
2009-11-18 02:38:49 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// TODO: of course on Blackberry and Android there notifications in the UI as well
|
|
|
|
|
|
|
|
PhoneGap.addConstructor(function() {
|
|
|
|
if (typeof navigator.notification == "undefined") navigator.notification = new Notification();
|
|
|
|
});
|
|
|
|
|