Guest User

Untitled

a guest
Oct 18th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. var timerName = 'Timer';
  2. var timerSeconds = 15;
  3. var username = 'ChrisMissal';
  4.  
  5. var callback = function (response) { // if used for JSON-P
  6. var meta = response.meta;
  7. var data = response.data;
  8. console.log(meta);
  9. console.log(data);
  10. };
  11.  
  12. var getNotifications = function () {
  13. device.ajax(
  14. {
  15. url: '',
  16. type: 'GET',
  17. headers: {
  18. 'Content-Type': 'application/json'
  19. }
  20. },
  21. function onSuccess(body, textStatus, response) {
  22. var data;
  23. if(!(body && (data = JSON.parse(body)))) {
  24. console.error('error: ', body || '(null)');
  25. }
  26.  
  27. console.info(JSON.stringify(data));
  28. },
  29. function onError(textStatus, response){
  30. console.error('error code: ', response.status);
  31. });
  32. };
  33.  
  34. device.scheduler.setTimer({
  35. name: timerName,
  36. time: 0,
  37. interval: timerSeconds*1000,
  38. exact: false },
  39. getNotifications);
  40.  
  41. device.screen.on('off', function () {
  42. device.scheduler.removeTimer(timerName);
  43. });
Add Comment
Please, Sign In to add comment