js/notification.js
changeset 0 54063d8b0412
equal deleted inserted replaced
-1:000000000000 0:54063d8b0412
       
     1 
       
     2 /**
       
     3  * This class provides access to notifications on the device.
       
     4  */
       
     5 function Notification() {
       
     6 	
       
     7 }
       
     8 
       
     9 Notification.prototype.vibrate = function(mills)
       
    10 {
       
    11 	
       
    12 	if (!Notification.getSysinfoObject())
       
    13 		Notification.embedSysinfoObject();
       
    14 	
       
    15 	this.sysinfo = Notification.getSysinfoObject();
       
    16 	this.sysinfo.startvibra(mills, 100);
       
    17 };
       
    18 
       
    19 //TODO: this is not beeping
       
    20 Notification.prototype.beep = function(count, volume)
       
    21 {
       
    22 	if (!Notification.getSysinfoObject())
       
    23 		Notification.embedSysinfoObject();
       
    24 	
       
    25 	this.sysinfo = Notification.getSysinfoObject();	
       
    26 	this.sysinfo.beep(220,2000);
       
    27 };
       
    28 
       
    29 
       
    30 /**
       
    31  * Open a native alert dialog, with a customizable title and button text.
       
    32  * @param {String} message Message to print in the body of the alert
       
    33  * @param {String} [title="Alert"] Title of the alert dialog (default: Alert)
       
    34  * @param {String} [buttonLabel="OK"] Label of the close button (default: OK)
       
    35  */
       
    36 Notification.prototype.alert = function(message, title, buttonLabel) {
       
    37     // Default is to use a browser alert; this will use "index.html" as the title though
       
    38     alert(message);
       
    39 };
       
    40 
       
    41 /**
       
    42  * Start spinning the activity indicator on the statusbar
       
    43  */
       
    44 Notification.prototype.activityStart = function() {
       
    45 };
       
    46 
       
    47 /**
       
    48  * Stop spinning the activity indicator on the statusbar, if it's currently spinning
       
    49  */
       
    50 Notification.prototype.activityStop = function() {
       
    51 };
       
    52 
       
    53 /**
       
    54  * Causes the device to blink a status LED.
       
    55  * @param {Integer} count The number of blinks.
       
    56  * @param {String} colour The colour of the light.
       
    57  */
       
    58 Notification.prototype.blink = function(count, colour) {
       
    59 	
       
    60 };
       
    61 
       
    62 Notification.embedSysinfoObject = function() {
       
    63 	var el = document.createElement("embed");
       
    64 	el.setAttribute("type", "application/x-systeminfo-widget");
       
    65 	el.setAttribute("hidden", "yes");
       
    66 	document.getElementsByTagName("body")[0].appendChild(el);
       
    67 	return;
       
    68 };
       
    69 
       
    70 Notification.getSysinfoObject = function() {
       
    71 	return document.embeds[0];
       
    72 };
       
    73 
       
    74 if (typeof navigator.notification == "undefined") navigator.notification = new Notification();