I think having a separate sound when a private message (whisper) is received would be a great idea to improve AJAX Chat. Maybe the chat becomes busy, or your attention is on another matter so you've turned off the sound for standard messages. By having a different sound it is more difficult to miss a private chat message in these scenarios.
I have implemented this in one instance of AJAX Chat successfully, and I've included the code changes below, however there might be a better way to do it, or it might not work at all with your instance of AJAX Chat. This worked for me but I suggest testing this privately and I won't accept responsibility if it breaks your chat (take a backup of all modified files as a fail-safe!).
- Find in chat/js/config.js:
// Defines the sound that is played on error messages:
soundError: 'sound_6',
Add Below:
// Defines the sound that is played when private messages are received:
soundPrivate: 'sound_7',
- Find in chat/js/config.js:
Replace with:
sound_6: 'sound_6.mp3',
sound_7: 'sound_7.mp3'
- Find in chat/js/chat.js:
default:
this.playSound(this.settings['soundReceive']);
break;
Replace with:
default:
var messageParts = messageText.split(' ', 1);
switch(messageParts[0]) {
case '/privmsg':
this.playSound(this.settings['soundPrivate']);
break;
default:
this.playSound(this.settings['soundReceive'])
}
break;
- Find in chat/lib/lang/en.php: (and any other languages you may have - you'll need to translate this yourself)
$lang['settingsSoundError'] = 'Sound for error messages:';
Add Below:
$lang['settingsSoundPrivate'] = 'Sound for private messages:';
- Find in chat/lib/template/loggedIn.html:
ajaxChat.fillSoundSelection('soundErrorSetting', ajaxChat.getSetting('soundError'));
Add Below:
ajaxChat.fillSoundSelection('soundPrivateSetting', ajaxChat.getSetting('soundPrivate'));
- Find in chat/lib/template/loggedIn.html:
<tr class="rowOdd">
<td><label for="soundErrorSetting">[LANG]settingsSoundError[/LANG]</label></td>
<td class="setting">
<select id="soundErrorSetting" onchange="ajaxChat.setSetting('soundError', this.options[this.selectedIndex].value);"><option value="">-</option></select><input type="image" src="img/pixel.gif" class="button playback" alt="[LANG]playSelectedSound[/LANG]" title="[LANG]playSelectedSound[/LANG]" onclick="ajaxChat.playSound(this.previousSibling.options[this.previousSibling.selectedIndex].value);"/>
</td>
</tr>
Add Below:
<tr class="rowEven">
<td><label for="soundPrivateSetting">[LANG]settingsSoundPrivate[/LANG]</label></td>
<td class="setting">
<select id="soundPrivateSetting" onchange="ajaxChat.setSetting('soundPrivate', this.options[this.selectedIndex].value);"><option value="">-</option></select><input type="image" src="img/pixel.gif" class="button playback" alt="[LANG]playSelectedSound[/LANG]" title="[LANG]playSelectedSound[/LANG]" onclick="ajaxChat.playSound(this.previousSibling.options[this.previousSibling.selectedIndex].value);"/>
</td>
</tr>
For cosmetic purposes you may want to alternate the "rowEven" and "rowOdd" classes on the remaining table rows that follow from the settings menu.
- Upload an MP3 sound file (that you'll supply yourself from somewhere) to chat/sounds/sound_7.mp3
Is this idea worthy of merging with the AJAX Chat release? It is serving a purpose in the instance I've added it to but I can see that it may be a benefit to others too.
PS: I hope this is the correct place to post this, as I'm not asking for help, but providing code samples for this idea.