The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Chatbox: Sound Notification Issue

5 posters

Go down

Solved Chatbox: Sound Notification Issue

Post by Nayashima Tokóro July 14th 2015, 7:05 pm

Well, I tried some codes for my chatbox but neither worked...

1. I tried to add the Sound Notification but it didn't work. The code was correct but nothing happened..

2. When the Sound didn't work, I tried the other Notification. Correct code, but nothing happened..

What may cause this? I'm using phpBB2, this is the link to my forum: http://sscp.forumotion.com/
(Don't judge the design, it's temproarily. I'm working on my own design).


Last edited by Nayashima on July 16th 2015, 7:39 pm; edited 1 time in total
Nayashima Tokóro
Nayashima Tokóro
New Member

Male Posts : 20
Reputation : 1
Language : English, Swedish, Danish,
Location : Sweden

http://sscp.forumotion.com/

Back to top Go down

Solved Re: Chatbox: Sound Notification Issue

Post by SLGray July 14th 2015, 7:43 pm

Where did you get the codes for the chatbox?


Chatbox:  Sound Notification Issue Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51554
Reputation : 3524
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Solved Re: Chatbox: Sound Notification Issue

Post by Nayashima Tokóro July 14th 2015, 10:04 pm

Nayashima Tokóro
Nayashima Tokóro
New Member

Male Posts : 20
Reputation : 1
Language : English, Swedish, Danish,
Location : Sweden

http://sscp.forumotion.com/

Back to top Go down

Solved Re: Chatbox: Sound Notification Issue

Post by JScript July 15th 2015, 12:10 am

@Nayashima
You could leave the code active so we can check his behavior?

Thanks,

JS
JScript
JScript
Forumember

Male Posts : 741
Reputation : 175
Language : PT-BR, EN
Location : Brazil

http://jscript.forumeiros.com/

Back to top Go down

Solved Re: Chatbox: Sound Notification Issue

Post by Nayashima Tokóro July 15th 2015, 9:20 am

JScript wrote:@Nayashima
You could leave the code active so we can check his behavior?

Thanks,

JS

Exactly what do you mean?
Nayashima Tokóro
Nayashima Tokóro
New Member

Male Posts : 20
Reputation : 1
Language : English, Swedish, Danish,
Location : Sweden

http://sscp.forumotion.com/

Back to top Go down

Solved Re: Chatbox: Sound Notification Issue

Post by Ange Tuteur July 15th 2015, 12:11 pm

Hi @Nayashima,

Just to make sure :

1. Have you enabled JS codes management ? The option above your scripts should be set to yes.
Chatbox:  Sound Notification Issue Captur58

2. You're using the default chatbox on the homepage, correct ?
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Chatbox: Sound Notification Issue

Post by Nayashima Tokóro July 15th 2015, 6:08 pm

Ange Tuteur wrote:Hi @Nayashima,

Just to make sure :

1. Have you enabled JS codes management ? The option above your scripts should be set to yes.
Chatbox:  Sound Notification Issue Captur58

2. You're using the default chatbox on the homepage, correct ?

Yes and Yes.
Nayashima Tokóro
Nayashima Tokóro
New Member

Male Posts : 20
Reputation : 1
Language : English, Swedish, Danish,
Location : Sweden

http://sscp.forumotion.com/

Back to top Go down

Solved Re: Chatbox: Sound Notification Issue

Post by Ange Tuteur July 16th 2015, 10:28 am

@Nayashima thanks Smile

After looking over the code it appears there was a problem with it on Firefox. Luckily the code was updated on the French side, so you can find it below as well as in the chatbox topic.
Code:
window.localStorage && $(window).load(function() {
  var chatbox_script = function() {
    var sounds = {
      'future': 'http://illiweb.com/fa/fdf/future.mp3',
      'hal': 'http://illiweb.com/fa/fdf/hal.mp3',
      'secret': 'http://illiweb.com/fa/fdf/secret.mp3',
      'zelda': 'http://illiweb.com/fa/fdf/zelda.mono.mp3'
    };
    var default_sound = sounds['zelda'];
    var default_freq = 'new';
    var default_when = 'once';
    var default_volume = 100;
 
 
    if(localStorage.cb_sound && !localStorage.cb_sound.indexOf('https://dl.dropboxusercontent.com/u/181621985/')) localStorage.removeItem('cb_sound');
    var a = document.createElement('audio');
    if(!a.canPlayType) return;
    a.volume = Math.min(1, Math.max(0, localStorage.cb_volume||(default_volume/100)));
 
    var origin_send = Chatbox.prototype.send;
    Chatbox.prototype.send = function(params) {
      var m = $.trim($("#message").val());
      if(m.indexOf('/sound')&&m.indexOf('/soudn'))
        return origin_send.call(this, params);
      m = $.trim(m.substr(6)).split(/\s+/,3);
      var bad_apple = false;
      switch(m[0].toLowerCase()) {
        case "":
          if(!a.src) {
            a.src = localStorage.cb_sound||default_sound;
            a.load();
        }
          a.play();
          break;
        case "all":
        case "new":
          localStorage.cb_freq = m[0]; break;
        case "always":
        case "off":
        case "on":
        case "once":
        case "never":
          localStorage.cb_when = m[0]; break;
        case "stop":
          if(!a.paused) a.pause();
          if(!a.ended && a.readyState > 0) a.currentTime = 0;
          break;
        case "pause":
          if(!a.paused) a.pause();
          break;
        case "volume":
          if(m.length>1) {
            localStorage.cb_volume = Math.min(1, Math.max(0, parseFloat(m[1].replace(',','.'))/100));
            a.volume = localStorage.cb_volume;
            break
          }
        default:
          bad_apple = true;
      };
      if(bad_apple) {
        if(m[0] in sounds) {
          m[0]= sounds[m[0]];
        }
        if(m[0]=="default") {
          m[0]=default_sound;
          localStorage.removeItem('cb_sound');
          localStorage.removeItem('cb_freq');
          localStorage.removeItem('cb_volume');
          localStorage.removeItem('cb_when');
          a.volume = Math.min(1, Math.max(0, default_volume/100));
        }
        if(/^https?:\/\/.+/.test(m[0])) {
          localStorage.cb_sound = m[0];
          a.pause();
          a.src = m[0];
          a.load();
          a.play();
        } else {
          var message = $('#message').val();
          alert('/sound [all | new]\n/sound [always | off | on | once | never]\n/sound [stop | pause]\n/sound default\n/sound volume 0-100\n/sound ['+$.map(sounds,function(_,k){return k}).join(' | ')+']\n/sound [http://* | https://*]');
          setTimeout(function(){ $("#message").val(message).select().focus(); }, 100);
          return;
        }
      }
      return $("#message").val('').focus();
    };
 
    $(window).on("focus", function(){ localStorage.removeItem('cb_once'); localStorage.removeItem('cb_blurred') }).on("blur", function(){ localStorage.cb_blurred=1; });
 
    var play_sound = function(){
      if(a.paused || a.ended) {
        if(a.readyState > 0) a.currentTime=0;
        if(!a.src) {
          a.src = localStorage.cb_sound||default_sound;
          a.load()
        }
        a.play()
      }
    };
    var overrided = Chatbox.prototype.refresh;
    Chatbox.prototype.refresh = function(data) {
      if (data.messages && data.messages.length) {
        var lm = data.messages.slice(-1)[0];
        var last_message = lm.time+','+lm.action+','+lm.msg;
        if(this.last_message_sound != last_message) {
          var user = $.grep(data.users, function(v){return v.id==chatbox.userId});
          user = user.length ? user[0] : [{}];
          if(this.last_message_sound!==undefined) {
            var freq = (localStorage.cb_freq||default_freq);
            var when = (localStorage.cb_when||default_when);
            if(when != "never" && (when != "off" || localStorage.cb_blurred) && (when != "on" || !localStorage.cb_blurred) && (when != "once" || (localStorage.cb_blurred && !localStorage.cb_once))) {
              if(freq =="all" || (lm.userId!=chatbox.userId && user.username!=lm.username)) {
                if(when!="once" || !localStorage.cb_once) {
                  play_sound();
                  localStorage.cb_once = 1;
                }
              }
            }
          }
          this.last_message_sound = lm;
        }
      }
      overrided.call(this, data);
    };
  };
  var s=document.createElement('script');s.text="("+chatbox_script.toString()+")();";$('object[data^="/chatbox/index.forum"],iframe[src^="/chatbox/index.forum"]').each(function(){try{$(this.contentDocument||this.contentWindow.document).find("#chatbox").closest("html").find("head").first().each(function(){this.appendChild(s.cloneNode(true))})}catch(a){}})
});

Just replace your script with the above. Wink
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Chatbox: Sound Notification Issue

Post by Nayashima Tokóro July 16th 2015, 12:04 pm

It's still not working..?
Nayashima Tokóro
Nayashima Tokóro
New Member

Male Posts : 20
Reputation : 1
Language : English, Swedish, Danish,
Location : Sweden

http://sscp.forumotion.com/

Back to top Go down

Solved Re: Chatbox: Sound Notification Issue

Post by Ange Tuteur July 16th 2015, 2:39 pm

It is installed on the forum you provided in the first post, is it not ? For some reason I do not see any sources relating to JavaScript codes management in the devtools. blackeye
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Chatbox: Sound Notification Issue

Post by Nayashima Tokóro July 16th 2015, 2:41 pm

Ange Tuteur wrote:It is installed on the forum you provided in the first post, is it not ? For some reason I do not see any sources relating to JavaScript codes management in the devtools. blackeye

Wait, lemme check again.
Nayashima Tokóro
Nayashima Tokóro
New Member

Male Posts : 20
Reputation : 1
Language : English, Swedish, Danish,
Location : Sweden

http://sscp.forumotion.com/

Back to top Go down

Solved Re: Chatbox: Sound Notification Issue

Post by Nayashima Tokóro July 16th 2015, 3:26 pm

Nayashima wrote:
Ange Tuteur wrote:It is installed on the forum you provided in the first post, is it not ? For some reason I do not see any sources relating to JavaScript codes management in the devtools. blackeye

Wait, lemme check again.

Well, should be and it still doesn't work..
Nayashima Tokóro
Nayashima Tokóro
New Member

Male Posts : 20
Reputation : 1
Language : English, Swedish, Danish,
Location : Sweden

http://sscp.forumotion.com/

Back to top Go down

Solved Re: Chatbox: Sound Notification Issue

Post by Ange Tuteur July 16th 2015, 3:29 pm

Ah, yes. I see it now. Smile

Are you just typing by yourself in the chatbox ? It'll need to be someone other than yourself sending a message for it to work.
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Chatbox: Sound Notification Issue

Post by Nayashima Tokóro July 16th 2015, 3:53 pm

Ange Tuteur wrote:Ah, yes. I see it now. Smile

Are you just typing by yourself in the chatbox ? It'll need to be someone other than yourself sending a message for it to work.

Well, I've tried that too. Asked a member of the forum to try the chat, doesn't work.
Nayashima Tokóro
Nayashima Tokóro
New Member

Male Posts : 20
Reputation : 1
Language : English, Swedish, Danish,
Location : Sweden

http://sscp.forumotion.com/

Back to top Go down

Solved Re: Chatbox: Sound Notification Issue

Post by Ange Tuteur July 16th 2015, 5:58 pm

That's weird, because it's working on my forum.. blackeye

I can't think of much else other than your browser. Are you using a specific one to view your forum ?
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Chatbox: Sound Notification Issue

Post by Nayashima Tokóro July 16th 2015, 7:20 pm

Ange Tuteur wrote:That's weird, because it's working on my forum.. blackeye

I can't think of much else other than your browser. Are you using a specific one to view your forum ?

Well, I'm using two browsers.
My primairy one is Mozilla Firefox and my optional one is Google Chrome. However the notification doesn't work on either of them.
Nayashima Tokóro
Nayashima Tokóro
New Member

Male Posts : 20
Reputation : 1
Language : English, Swedish, Danish,
Location : Sweden

http://sscp.forumotion.com/

Back to top Go down

Solved Re: Chatbox: Sound Notification Issue

Post by Nayashima Tokóro July 16th 2015, 7:39 pm

Well, it works now xD
Thanks alot for the help!
Nayashima Tokóro
Nayashima Tokóro
New Member

Male Posts : 20
Reputation : 1
Language : English, Swedish, Danish,
Location : Sweden

http://sscp.forumotion.com/

Back to top Go down

Solved Re: Chatbox: Sound Notification Issue

Post by Ape July 16th 2015, 7:41 pm

Topic solved and archived


Chatbox:  Sound Notification Issue Left1212Chatbox:  Sound Notification Issue Center11Chatbox:  Sound Notification Issue Right112
Chatbox:  Sound Notification Issue Ape_b110
Chatbox:  Sound Notification Issue Ape1010
Ape
Ape
Administrator
Administrator

Male Posts : 19434
Reputation : 2010
Language : fluent in dork / mumbojumbo & English haha

http://chatworld.forumotion.co.uk/

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum