Advertisement
callmeyesh

notification.js

Aug 18th, 2011
473
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // The Plugin used for Notifications is
  2. // https://github.com/saileshmittal/phonegap-system-notification-plugin
  3.  
  4. document.addEventListener("deviceready", onDeviceReady, false);
  5. // PhoneGap is ready
  6. //
  7. function onDeviceReady() {
  8. // Empty
  9. }
  10.  
  11. google.load("feeds", "1");
  12. google.setOnLoadCallback(function () {
  13. var rss1old = '',
  14.     rss1new = '',
  15.     rss2old ='',
  16.     rss2new ='',
  17.    
  18.     getRss = function (url, callback) {
  19.         (url) && (function (url) {
  20.             var feed = new google.feeds.Feed(url);
  21.  
  22.             feed.load(function (result) {
  23.                 (!result.error && callback) && (callback(result.feed.entries[0].title));
  24.             });
  25.         }(url));
  26.     };
  27.  
  28. setInterval(function () {
  29.     getRss(
  30.         'http://yofreesamples.com/category/free-coupons/feed/?type=rss',
  31.         function (title) {
  32.             rss1new = title;
  33.             if(rss1old !== rss1new) {
  34.                 rss1old = rss1new;
  35.                 navigator.systemNotification.onBackground();
  36.                 navigator.systemNotification.updateNotification(rss1new,rss1new);
  37.                 navigator.notification.beep(1);
  38.                 navigator.notification.vibrate(2000);
  39.                
  40.             }
  41.            
  42.         }
  43.     );
  44. },60000);
  45.  
  46. setInterval(function () {
  47.     getRss(
  48.         'http://yofreesamples.com/category/real-freebies/feed/?type=rss',
  49.         function (title) {
  50.             rss2new = title;
  51.             if(rss2old !== rss2new) {
  52.                 rss2old = rss2new;
  53.                 navigator.systemNotification.onBackground();
  54.                 navigator.systemNotification.updateNotification(rss2new,rss2new);
  55.                 navigator.notification.beep(1);
  56.                 navigator.notification.vibrate(1000);
  57.                
  58.             }
  59.            
  60.         }
  61.     );
  62. },60000);
  63. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement