Implemented sound reminders (#T1310)
Summary: Fixes T1310 Reviewers: #roundcube_kolab_plugins_developers Maniphest Tasks: T1310 Differential Revision: https://git.kolab.org/D183
This commit is contained in:
parent
27df671c91
commit
6790ac80d3
4 changed files with 51 additions and 4 deletions
BIN
plugins/libcalendaring/alarm.mp3
Normal file
BIN
plugins/libcalendaring/alarm.mp3
Normal file
Binary file not shown.
BIN
plugins/libcalendaring/alarm.wav
Normal file
BIN
plugins/libcalendaring/alarm.wav
Normal file
Binary file not shown.
|
@ -570,13 +570,19 @@ function rcube_libcalendaring(settings)
|
|||
if (this.alarm_dialog)
|
||||
this.alarm_dialog.dialog('destroy').remove();
|
||||
|
||||
this.alarm_dialog = $('<div>').attr('id', 'alarm-display');
|
||||
var i, actions, adismiss, asnooze, alarm, html,
|
||||
audio_alarms = [], records = [], event_ids = [], buttons = {};
|
||||
|
||||
var i, actions, adismiss, asnooze, alarm, html, event_ids = [], buttons = {};
|
||||
for (i=0; i < alarms.length; i++) {
|
||||
alarm = alarms[i];
|
||||
alarm.start = this.parseISO8601(alarm.start);
|
||||
alarm.end = this.parseISO8601(alarm.end);
|
||||
|
||||
if (alarm.action == 'AUDIO') {
|
||||
audio_alarms.push(alarm);
|
||||
continue;
|
||||
}
|
||||
|
||||
event_ids.push(alarm.id);
|
||||
|
||||
html = '<h3 class="event-title">' + Q(alarm.title) + '</h3>';
|
||||
|
@ -594,9 +600,17 @@ function rcube_libcalendaring(settings)
|
|||
});
|
||||
actions = $('<div>').addClass('alarm-actions').append(adismiss.data('id', alarm.id)).append(asnooze.data('id', alarm.id));
|
||||
|
||||
$('<div>').addClass('alarm-item').html(html).append(actions).appendTo(this.alarm_dialog);
|
||||
records.push($('<div>').addClass('alarm-item').html(html).append(actions));
|
||||
}
|
||||
|
||||
if (audio_alarms.length)
|
||||
this.audio_alarms(audio_alarms);
|
||||
|
||||
if (!records.length)
|
||||
return;
|
||||
|
||||
this.alarm_dialog = $('<div>').attr('id', 'alarm-display').append(records);
|
||||
|
||||
buttons[rcmail.gettext('close')] = function() {
|
||||
$(this).dialog('close');
|
||||
};
|
||||
|
@ -635,6 +649,38 @@ function rcube_libcalendaring(settings)
|
|||
this.alarm_ids = event_ids;
|
||||
};
|
||||
|
||||
/**
|
||||
* Display a notification and play a sound for a set of alarms
|
||||
*/
|
||||
this.audio_alarms = function(alarms)
|
||||
{
|
||||
var elem, txt = [],
|
||||
src = rcmail.assets_path('plugins/libcalendaring/alarm'),
|
||||
plugin = navigator.mimeTypes ? navigator.mimeTypes['audio/mp3'] : {};
|
||||
|
||||
// first generate and display notification text
|
||||
$.each(alarms, function() { txt.push(this.title); });
|
||||
|
||||
rcmail.display_message(rcmail.gettext('alarmtitle','libcalendaring') + ': ' + Q(txt.join(', ')), 'notice', 10000);
|
||||
|
||||
// Internet Explorer does not support wav files,
|
||||
// support in other browsers depends on enabled plugins,
|
||||
// so we use wav as a fallback
|
||||
src += bw.ie || (plugin && plugin.enabledPlugin) ? '.mp3' : '.wav';
|
||||
|
||||
// HTML5
|
||||
try {
|
||||
elem = $('<audio>').attr('src', src);
|
||||
elem.get(0).play();
|
||||
}
|
||||
// old method
|
||||
catch (e) {
|
||||
elem = $('<embed id="libcalsound" src="' + src + '" hidden=true autostart=true loop=false />');
|
||||
elem.appendTo($('body'));
|
||||
window.setTimeout("$('#libcalsound').remove()", 10000);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Show a drop-down menu with a selection of snooze times
|
||||
*/
|
||||
|
|
|
@ -727,7 +727,8 @@ class libcalendaring extends rcube_plugin
|
|||
'id' => $alarm['id'],
|
||||
'start' => $alarm['start'] ? $this->adjust_timezone($alarm['start'])->format('c') : '',
|
||||
'end' => $alarm['end'] ? $this->adjust_timezone($alarm['end'])->format('c') : '',
|
||||
'allDay' => ($alarm['allday'] == 1)?true:false,
|
||||
'allDay' => $alarm['allday'] == 1,
|
||||
'action' => $alarm['action'],
|
||||
'title' => $alarm['title'],
|
||||
'location' => $alarm['location'],
|
||||
'calendar' => $alarm['calendar'],
|
||||
|
|
Loading…
Add table
Reference in a new issue