Skip to content

Instantly share code, notes, and snippets.

@mcav
Created April 24, 2014 21:21
Show Gist options
  • Save mcav/11269934 to your computer and use it in GitHub Desktop.
Save mcav/11269934 to your computer and use it in GitHub Desktop.
addAlert: function(alert) {
var testOpts = alert.testOpts || {};
if (this.alerts.length) {
this.removeCurrentAlert();
}
this.alerts.unshift(alert);
this.grabScreenLock();
this.grabCPULock();
this.silence();
this.ringLabel.textContent = this.alert.label ||
mozL10n.get(this.alert.type === 'alarm' ? 'alarm' : 'timer');
this.ringDisplay.dataset.ringType = this.alert.type;
this.time.innerHTML = Utils.getLocalizedTimeHtml(alert.time);
if (this.alert.sound) {
this.ringtonePlayer.playRingtone(this.alert.sound);
}
if (this.alert.vibrate && ('vibrate' in navigator)) {
clearInterval(this.vibrateInterval);
var vibrateOnce = function() {
navigator.vibrate([1000]);
};
this.vibrateInterval = setInterval(vibrateOnce, 2000);
vibrateOnce();
}
document.documentElement.classList.add('ready');
window.focus();
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment