Пример #1
0
function clearWakeup(elementName, element) {
  var wakeElement = '';
  switch(elementName) {
    case 'Pomodoro':
      pomodoroWakeup = 0;
      wakeElement = 'pomodoroWakeupId';
      break;
    case 'GetUp':
      getUpWakeup = 0;
      wakeElement = 'getUpWakeupId';
      break;
    case 'Small':
      smallBreakWakeup = 0;
      wakeElement = 'smallBreakWakeupId';
      break;
    case 'Long':
      longBreakWakeup = 0;
      wakeElement = 'longBreakWakeupId';
      break;
  }
  element.subtitle('Click the middle button to start');
  element.body('');
  Wakeup.cancel(localStorage.getItem(wakeElement));
  localStorage.removeItem(wakeElement);
}
Пример #2
0
function scheduleNextRealityCheck(freq) {   
    Wakeup.cancel('all');
    Wakeup.schedule({
        time: Date.now() / 1000 + freq * 60
    }, function(e) {
       if(e.failed) {
           // TODO: handle this
       } 
    });
}
Пример #3
0
	var setWakeUpSchedule = function (e) {
		Wakeup.cancel('all');
		var shouldAutoWakeUp = Settings.option('shouldAutoWakeUp');
		console.log("shouldAutoWakeUp="+shouldAutoWakeUp);
		if(shouldAutoWakeUp){
			var currentWeekday = (new Date()).getDay();
			for(var i=0; i<4; i++){
				var validWeekday = currentWeekday+i+1;
				if(validWeekday>5)
					validWeekday = validWeekday-5;
				var openTimeAM = Clock.weekday(validWeekday, 9, 30);
				var openTimePM = Clock.weekday(validWeekday, 13, 0);
				console.log(JSON.stringify({validWeekday:validWeekday, openTimeAM:openTimeAM, openTimePM:openTimePM}));
				Wakeup.schedule({time: openTimeAM},scheduleCallback);
				Wakeup.schedule({time: openTimePM},scheduleCallback);
			}
		}
	};
Пример #4
0
exports.scheduleWakeup = function() {
  Wakeup.cancel('all'); // Cancels all previous ones and sets a new one just in case
  // Adds one day and sets the time to 12:01 AM, then divides by 1000 because Wakeup requires seconds, not milliseconds
  var scheduleTime = moment().add(1, 'day').hours(0).minute(1).seconds(0) / 1000;
  Wakeup.schedule(
    {
      // Set the wakeup event for tomorrow at 12:01 AM
      time: scheduleTime,
    }, // Did it succeed?
    function(e) {
      if (e.failed) {
        // Log the error reason
        console.log('Wakeup set failed: ' + e.error);
      } else {
        console.log('Wakeup set! Event ID: ' + e.id);
        console.log('Wakeup set! At this time: ' + scheduleTime);
      }
    }
  );
  console.log('The scheduled time is ' + scheduleTime); // For debug purposes
};
Пример #5
0
        campuses.show();
        break;
    default:
        log('ERROR: could not resolve input');    
    }
});


Wakeup.on('wakeup', function(e) {
    if (settings.vibe()) {
        shortVibeNotification();
    }
});

// reset first
Wakeup.cancel('all');

// Set the wakeup events
Wakeup.schedule({time: Clock.weekday('monday', 10, 25)},
    function(e) {
        if (e.failed) {
            log('Wakeup set failed: ' + e.error);
        } else {
            log('Wakeup set! Event ID: ' + e.id);
        }
    }
);

Wakeup.schedule({time: Clock.weekday('tuesday', 10, 25)},
    function(e) {
        if (e.failed) {