Sound for the notifications system. for Javascript experts...
5 posters
Page 1 of 1
Sound for the notifications system. for Javascript experts...
I thinking in adding a notify sound when the toolbar (the notifications system) receives a new notification, any ideas?
I did not find any correct answer for this feature so far.
I did not find any correct answer for this feature so far.
Ahmed.K- Forumember
- Posts : 349
Reputation : 4
Language : English
Re: Sound for the notifications system. for Javascript experts...
Hello Ahmed,
I have written up a draft code which you can test.
Administration panel > modules > javascript codes management > create a new script
Title : what you wish
Placement : in all the page
Paste the code below und save :
You can change the audio file by modifying the variable at the top of the script :
I have written up a draft code which you can test.
Administration panel > modules > javascript codes management > create a new script
Title : what you wish
Placement : in all the page
Paste the code below und save :
- Code:
var audioFile = 'http://www.freesfx.co.uk/rx2/mp3s/2/1305_1256857800.mp3';
notifChecker = setInterval('checkNotif()',500);
function checkNotif() {
if ($('.fa_notification').length > 0) {
window.clearInterval(notifChecker);
alertNotif();
}
};
dispCheck = setInterval('removeNotif()',500);
function removeNotif() {
if ($('.fa_notification').css('display') == 'none') {
$('.fa_notification').remove();
$('.audioElem').remove();
notifChecker = setInterval('checkNotif()',500);
}
};
function alertNotif() { $('body').append('<audio class="audioElem" style="display:none;" controls autoplay><source src="'+audioFile+'" type="audio/mpeg"></audio>'); };
You can change the audio file by modifying the variable at the top of the script :
- Code:
var audioFile = 'http://www.freesfx.co.uk/rx2/mp3s/2/1305_1256857800.mp3';
Re: Sound for the notifications system. for Javascript experts...
hi angeAnge Tuteur wrote:Hello Ahmed,
I have written up a draft code which you can test.
Administration panel > modules > javascript codes management > create a new script
Title : what you wish
Placement : in all the page
Paste the code below und save :
- Code:
var audioFile = 'http://www.freesfx.co.uk/rx2/mp3s/2/1305_1256857800.mp3';
notifChecker = setInterval('checkNotif()',500);
function checkNotif() {
if ($('.fa_notification').length > 0) {
window.clearInterval(notifChecker);
alertNotif();
}
};
dispCheck = setInterval('removeNotif()',500);
function removeNotif() {
if ($('.fa_notification').css('display') == 'none') {
$('.fa_notification').remove();
$('.audioElem').remove();
notifChecker = setInterval('checkNotif()',500);
}
};
function alertNotif() { $('body').append('<audio class="audioElem" style="display:none;" controls autoplay><source src="'+audioFile+'" type="audio/mpeg"></audio>'); };
You can change the audio file by modifying the variable at the top of the script :
- Code:
var audioFile = 'http://www.freesfx.co.uk/rx2/mp3s/2/1305_1256857800.mp3';
this code really nice i test it on my test forum
but i have one thing to ask
can this code work with out the forum toolbar
i use my own bar and i will make this bar in English and i will send it as tuto
Michael_vx- Forumember
- Posts : 664
Reputation : 29
Language : Arabic and some English
Location : Egypt
Re: Sound for the notifications system. for Javascript experts...
This checks for the fa_notification, if you have a dynamic element for notifications then you need only change fa_notification to your selector.
Re: Sound for the notifications system. for Javascript experts...
Ange Tuteur wrote:This checks for the fa_notification, if you have a dynamic element for notifications then you need only change fa_notification to your selector.
th toolbar i use dose not have any notification mode
its a HTML code im about to start to translate this toolbar
i will try make it fast
Edit
i have just done the toolbar and sent a PM i hope my tuto is to be good
Last edited by Michael_vx on May 5th 2014, 9:40 am; edited 1 time in total (Reason for editing : add new info)
Michael_vx- Forumember
- Posts : 664
Reputation : 29
Language : Arabic and some English
Location : Egypt
Re: Sound for the notifications system. for Javascript experts...
Hi Ange, It does not work. You have a PM.
Ahmed.K- Forumember
- Posts : 349
Reputation : 4
Language : English
Re: Sound for the notifications system. for Javascript experts...
works in all versions?
GyGu- New Member
- Posts : 13
Reputation : 1
Language : Portuguese
Re: Sound for the notifications system. for Javascript experts...
i make test on phpbb2 work fineGyGu wrote:works in all versions?
but i guess it should be fine with other versions like phpbb3 or punbb
Michael_vx- Forumember
- Posts : 664
Reputation : 29
Language : Arabic and some English
Location : Egypt
Re: Sound for the notifications system. for Javascript experts...
No, does not work here.
Ahmed.K- Forumember
- Posts : 349
Reputation : 4
Language : English
Re: Sound for the notifications system. for Javascript experts...
are you sure that the forum toolbar is active if not the code will not workAhmed.K wrote:No, does not work here.
also i make test on all versions works on phpbb2 and phpbb3 also the punbb and invision the most needed thing is tick all pages and the toolbar of forum is active
Michael_vx- Forumember
- Posts : 664
Reputation : 29
Language : Arabic and some English
Location : Egypt
Re: Sound for the notifications system. for Javascript experts...
Of course.Michael_vx wrote:are you sure that the forum toolbar is activeAhmed.K wrote:No, does not work here.
Ahmed.K- Forumember
- Posts : 349
Reputation : 4
Language : English
Re: Sound for the notifications system. for Javascript experts...
Ahmed.K they are not talking about your toolbar but the default Forumotion toolbar. I am just saying this so no mistakes are made!
Re: Sound for the notifications system. for Javascript experts...
Yes, I know. I am using the default Forumotion toolbar too.Marios94 wrote:Ahmed.K they are not talking about your toolbar but the default Forumotion toolbar. I am just saying this so no mistakes are made!
Anyway, waiting for an answer from Ange about that code.
Ahmed.K- Forumember
- Posts : 349
Reputation : 4
Language : English
Re: Sound for the notifications system. for Javascript experts...
I have checked your forum and could not seem to find the script installed on it, so I could look for any errors.
If you can, provide the following information please.
If you can, provide the following information please.
- The browser you're using + version of the browser
Re: Sound for the notifications system. for Javascript experts...
I installed it again. take a look on it. I get many errors.
Ahmed.K- Forumember
- Posts : 349
Reputation : 4
Language : English
Re: Sound for the notifications system. for Javascript experts...
You have wrapped the code I gave you with :
There is no need to launch the function with jQuery, as the check is set in half a second intervals to see if the notif exists and if its display state changes. Wrapping the code with jQuery is causing the errors you're seeing thrown in the console, so remove that and just add the code in as :
- Code:
$(document).ready(function () { });
There is no need to launch the function with jQuery, as the check is set in half a second intervals to see if the notif exists and if its display state changes. Wrapping the code with jQuery is causing the errors you're seeing thrown in the console, so remove that and just add the code in as :
- Code:
var audioFile = 'http://www.freesfx.co.uk/rx2/mp3s/2/1305_1256857800.mp3';
notifChecker = setInterval('checkNotif()',500);
function checkNotif() {
if ($('.fa_notification').length > 0) {
window.clearInterval(notifChecker);
alertNotif();
}
};
dispCheck = setInterval('removeNotif()',500);
function removeNotif() {
if ($('.fa_notification').css('display') == 'none') {
$('.fa_notification').remove();
$('.audioElem').remove();
notifChecker = setInterval('checkNotif()',500);
}
};
function alertNotif() { $('body').append('<audio class="audioElem" style="display:none;" controls autoplay><source src="'+audioFile+'" type="audio/mpeg"></audio>'); };
Re: Sound for the notifications system. for Javascript experts...
Done. and still does not work.
Ahmed.K- Forumember
- Posts : 349
Reputation : 4
Language : English
Re: Sound for the notifications system. for Javascript experts...
I cannot look into this closer as you've set a limit on the posts needed before sending private messages.
Re: Sound for the notifications system. for Javascript experts...
Ok, you can send private messages now.
Ahmed.K- Forumember
- Posts : 349
Reputation : 4
Language : English
Re: Sound for the notifications system. for Javascript experts...
I tested and the audio file appended and played :
Could you provide info on the browser you're using ?
Thank you.
Could you provide info on the browser you're using ?
Thank you.
Ahmed.K- Forumember
- Posts : 349
Reputation : 4
Language : English
Re: Sound for the notifications system. for Javascript experts...
That is your problem.
I will need to add another file which Opera supports. When it is done I'll let you know.
I will need to add another file which Opera supports. When it is done I'll let you know.
Re: Sound for the notifications system. for Javascript experts...
Hmmm...Which format i should add? Wav or what?
Ahmed.K- Forumember
- Posts : 349
Reputation : 4
Language : English
Re: Sound for the notifications system. for Javascript experts...
Yes, wav.
I have added another variable. One is for MP3s the other is for WAVs.
Just add the sound you want to play with a MP3 and WAV file.
I have added another variable. One is for MP3s the other is for WAVs.
- Code:
var audioFileMP3 = 'http://www.freesfx.co.uk/rx2/mp3s/2/1305_1256857800.mp3';
var audioFileWAV = '';
notifChecker = setInterval('checkNotif()',500);
function checkNotif() {
if ($('.fa_notification').length > 0) {
window.clearInterval(notifChecker);
alertNotif();
}
};
dispCheck = setInterval('removeNotif()',500);
function removeNotif() {
if ($('.fa_notification').css('display') == 'none') {
$('.fa_notification').remove();
$('.audioElem').remove();
notifChecker = setInterval('checkNotif()',500);
}
};
function alertNotif() { $('body').append('<audio class="audioElem" style="display:none;" controls autoplay><source src="'+audioFileMP3+'" type="audio/mpeg"><source src="'+audioFileWAV+'" type="audio/wav"></audio>'); };
Just add the sound you want to play with a MP3 and WAV file.
Re: Sound for the notifications system. for Javascript experts...
Yes, i found this, HTML <audio> Tag - Browser compatibility:
http://www.w3schools.com/tags/tag_audio.asp
https://developer.mozilla.org/en-US/docs/HTML/Supported_media_formats
It doesn't work when I login and i find new notifications.
But it works fine when i be online and i get a new notification.
any ideas?
http://www.w3schools.com/tags/tag_audio.asp
https://developer.mozilla.org/en-US/docs/HTML/Supported_media_formats
It doesn't work when I login and i find new notifications.
But it works fine when i be online and i get a new notification.
any ideas?
Ahmed.K- Forumember
- Posts : 349
Reputation : 4
Language : English
Re: Sound for the notifications system. for Javascript experts...
Unfortunately this will only work while you're logged in. The reason is because of the live notification which pops up while logged in, so if you're logged in and this live notification pops up a sound will play.
Now if I were to change this to play audio when there is a notification number(for new notifs) it will constantly play each time you change a page until it is read.
Now if I were to change this to play audio when there is a notification number(for new notifs) it will constantly play each time you change a page until it is read.
Re: Sound for the notifications system. for Javascript experts...
looks good idea to me can you make something like that to play audio also when there is notification already too and when live notification come wil play also sound this will be better to meAnge Tuteur wrote:Unfortunately this will only work while you're logged in. The reason is because of the live notification which pops up while logged in, so if you're logged in and this live notification pops up a sound will play.
Now if I were to change this to play audio when there is a notification number(for new notifs) it will constantly play each time you change a page until it is read.
Michael_vx- Forumember
- Posts : 664
Reputation : 29
Language : Arabic and some English
Location : Egypt
Similar topics
» Sound for the notifications system... for Javascript experts...
» New BBCodes...for Javascript experts...
» Calculating the ratio... (to Javascript experts)
» Calculating the ratio... (to Javascript experts)
» just use the notifications system from fa_toolbar
» New BBCodes...for Javascript experts...
» Calculating the ratio... (to Javascript experts)
» Calculating the ratio... (to Javascript experts)
» just use the notifications system from fa_toolbar
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum