Author Topic: adding a javascript Notification()  (Read 9446 times)

0 Members and 1 Guest are viewing this topic.

garethGZA

  • Jr. Member
  • **
  • Posts: 3
adding a javascript Notification()
« on: April 08, 2015, 01:01:14 PM »
Hi All,

I have a client that is using Mibew, and none of the staff have speakers on their terminals. The staff dont know when a user is waiting to chat with them, I have turned on the popup in operator/settings/features but it doesnt do anything. I have looked and found some javascript for Notification() and tested it and it works, but where in the code can I add this? I have written it as a function NotifyMe() and it works, but i need to find where in the code to place it, I was thinking of adding it where the code to play the sound it, but I cant find that, what would I be looking for in the code?

Here is the Stack article on how it works, http://stackoverflow.com/questions/2271156/chrome-desktop-notification-example

Regards
Gareth

Dmitriy Simushev

  • Moderator
  • Native
  • *****
  • Posts: 345
Re: adding a javascript Notification()
« Reply #1 on: April 08, 2015, 01:10:19 PM »
Hi,

First of all you don't specify the exact version of Mibew you use, so I cannot really say where you should place the code.

The second. There is a title notification plugin for Mibew 2.0. It can be downloaded here: https://mibew.org/plugins#mibew-title-notification

garethGZA

  • Jr. Member
  • **
  • Posts: 3
Re: adding a javascript Notification()
« Reply #2 on: April 16, 2015, 10:00:25 AM »
I am using 2.0.0-beta.3. I have tried the title plugin, but have not managed to get it working. Does the title notification thing make a popup/notification on the screen or does it just do something on the title? I have tried to read about it, but couldn't find the answer to it. I was looking to find where in the code it makes the sound play, because from there I think i can add code to make the notification() work.

Is there a site/demo with the title notification thing installed that I can check how it looks?

Thank you very much.
 

Dmitriy Simushev

  • Moderator
  • Native
  • *****
  • Posts: 345
Re: adding a javascript Notification()
« Reply #3 on: April 16, 2015, 10:34:55 AM »
We release stable 2.0.0 version some time ago. It includes several bug fixes and improvements, so I recommend you to update your installation.

Title notification plugin, as its name says, affects only browser title. This plugin is installed in the official demo (https://demo2.mibew.org).

If you want to add custom notification I recommend you to create a plugin, like Mibew:TitleNotification one. You can get its sources here: https://github.com/Mibew/title-notification-plugin . The sources are well documented thus I don't think it's too hard to make a similar plugin with different notification logic.

Nevertheless, if you really want to patch Mibew Core, the function that plays sound is located here: https://github.com/Mibew/mibew/blob/master/src/mibew/js/source/default/utils.js#L108 . After you change it, you have to rebuild the application. Read https://github.com/Mibew/mibew#build-from-sources to get how it could be done.

garethGZA

  • Jr. Member
  • **
  • Posts: 3
Re: adding a javascript Notification()
« Reply #4 on: April 16, 2015, 08:09:35 PM »
Thank you, I'll upgrade and then have a look.

You should build something like that notification into the one you release, I think a lot of people would want it as I have seen other questions on the forum where people have asked the same thing

Thank you :D

Dmitriy Simushev

  • Moderator
  • Native
  • *****
  • Posts: 345
Re: adding a javascript Notification()
« Reply #5 on: April 16, 2015, 08:15:40 PM »
Quote
You should build something like that notification into the one you release

You're wrong. This feature is not critical thus it will never be built into the core. As I've told you before one can create a plugin with such feature.