/** * Notification JS * Shims up the Notification API * * @author Andrew Dodson * @website http://adodson.com/notification.js/ */ // // Does the browser support the the Notification API? // .. and does it have a permission property? // (function(window, document){ var PERMISSION_GRANTED = 'granted', PERMISSION_DENIED = 'denied', PERMISSION_UNKNOWN = 'unknown'; var a = [], iv, i=0; // // Swap the document.title with the notification // function swaptitle(title){ if(a.length===0){ a = [document.title]; } a.push(title); if(!iv){ iv = setInterval(function(){ // has document.title changed externally? if(a.indexOf(document.title) === -1 ){ // update the default title a[0] = document.title; } document.title = a[++i%a.length]; }, 1000); } } function swapTitleCancel(){ // dont do any more if we haven't got anything open if(a.length===0){ return; } // if an IE overlay is present, kill it if("external" in window && "msSiteModeClearIconOverlay" in window.external ){ window.external.msSiteModeClearIconOverlay(); } clearInterval(iv); iv = false; document.title = a[0]; a = []; } // // Add aevent handlers function addEvent(el,name,func){ if(name.match(" ")){ var a = name.split(' '); for(var i=0;i