Skip to content

Commit

Permalink
MDL-57772 chat: BEEP is back baby!
Browse files Browse the repository at this point in the history
  • Loading branch information
Damyon Wiese committed Nov 7, 2017
1 parent 159b4e5 commit efe2681
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
Binary file added mod/chat/beep.mp3
Binary file not shown.
Binary file removed mod/chat/beep.wav
Binary file not shown.
7 changes: 5 additions & 2 deletions mod/chat/chatd.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function __construct() {
$this->_trace_level = E_ALL ^ E_USER_NOTICE;
$this->_pcntl_exists = function_exists('pcntl_fork');
$this->_time_rest_socket = 20;
$this->_beepsoundsrc = $GLOBALS['CFG']->wwwroot.'/mod/chat/beep.wav';
$this->_beepsoundsrc = $GLOBALS['CFG']->wwwroot.'/mod/chat/beep.mp3';
$this->_freq_update_records = 20;
$this->_freq_poll_idle_chat = $GLOBALS['CFG']->chat_old_ping;
$this->_stdout = fopen('php://stdout', 'w');
Expand Down Expand Up @@ -754,8 +754,11 @@ public function message_broadcast($message, $sender) {
$this->conn_sets[$sessionid][CHAT_CONNECTION_CHANNEL]);

if ($output->beep) {
$playscript = '(function() { var audioElement = document.createElement("audio");' . "\n";
$playscript .= 'audioElement.setAttribute("src", "'.$this->_beepsoundsrc.'");' . "\n";
$playscript .= 'audioElement.play(); })();' . "\n";
$this->write_data($this->conn_sets[$sessionid][CHAT_CONNECTION_CHANNEL],
'<embed src="'.$this->_beepsoundsrc.'" autostart="true" hidden="true" />');
'<script>' . $playscript . '</script>');
}

if ($info['quirks'] & QUIRK_CHUNK_UPDATE) {
Expand Down
4 changes: 3 additions & 1 deletion mod/chat/gui_ajax/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ M.mod_chat_ajax.init = function(Y, cfg) {
item.addClass((message.mymessage) ? 'mdl-chat-my-entry' : 'mdl-chat-entry');
Y.one('#messages-list').append(item);
if (message.type && message.type == 'beep') {
Y.one('#chat-notify').setContent('<embed src="../beep.wav" autostart="true" hidden="true" name="beep" />');
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', '../beep.mp3');
audioElement.play();
}
},

Expand Down
6 changes: 5 additions & 1 deletion mod/chat/gui_header_js/jsupdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@
<body>
<?php
if ($beep) {
echo '<embed src="../beep.wav" autostart="true" hidden="true" name="beep" />';
echo '<script> (function() {';
echo 'var audioElement = document.createElement("audio");';
echo 'audioElement.setAttribute("src", "../beep.mp3");';
echo 'audioElement.play(); })();';
echo '</script>';
}
?>
<a href="<?php echo $refreshurlamp ?>" name="refreshLink">Refresh link</a>
Expand Down
6 changes: 5 additions & 1 deletion mod/chat/gui_header_js/jsupdated.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@
print "//]]>\n";
print '</script>' . "\n\n";
if ($beep) {
print '<embed src="../beep.wav" autostart="true" hidden="true" name="beep" />';
print '<script> (function() {';
print 'var audioElement = document.createElement("audio");';
print 'audioElement.setAttribute("src", "../beep.mp3");';
print 'audioElement.play(); })();';
print '</script>';
}
print $CHAT_DUMMY_DATA;
sleep($CFG->chat_refresh_room);
Expand Down

0 comments on commit efe2681

Please sign in to comment.