Niko
  • Administrator

      Reputation : 318
      Registered on : 2012-02-22
      Posts : 2366
      School of codes courses: coming soon
    Change title receiving a message

    Note: Leeloo Gave us the permissions to share it... Official tutorial here
    If you want to share this tutorial you have to ask to Forumotion Wink


    Description


    This tip permits to have a change of the page title at the reception of a new message for the registered users connected to a background chatbox. That works only if the chatbox is included in another page.

    Set up


    You need to add the following code into a Javascript file:
    Code:
    $(function() {
      setTimeout(function() {
        for(var c = 0, a = 0;a < window.frames.length;a++) {
          try {
            "/chatbox/index.forum" == eval("window.frames[a].location.pathname") && ++c && window.frames[a].eval('function ajax_refresh_chatbox(b,c){if(""==b||void 0==b)b="?achives=0";if(window.XMLHttpRequest)var a=new XMLHttpRequest;else window.ActiveXObject&&(a=new ActiveXObject("Microsoft.XMLHTTP"));a.onreadystatechange=function(){if(4==a.readyState&&200==a.status&&(eval(a.responseText),chatbox_last_update>chatbox_updated||c))null!=document.getElementById("chatbox").innerHTML&&chatbox_messages_old!=chatbox_messages&&(my_setcookie("CNM",1,1,0),chatbox_messages_old=document.getElementById("chatbox").innerHTML=chatbox_messages,document.getElementById("chatbox").scrollTop=document.getElementById("chatbox").scrollHeight+document.getElementById("chatbox").offsetHeight,document.getElementById("chatbox").scrollTop=999999),null!=document.getElementById("chatbox_members").innerHTML&&(document.getElementById("chatbox_members").innerHTML=chatbox_memberlist),chatbox_updated=chatbox_last_update};a.open("GET","/chatbox/chatbox_actions.forum"+b+"&mode=refresh",!0);a.send(null)};$(window).focus(function(){my_setcookie("CHF",1,1,0);my_setcookie("CNM","",0,0)}).blur(function(){my_setcookie("CHF","",0,0);my_setcookie("CNM","",0,0)}).trigger("focus");')
          }catch(d) {
          }
        }
        0 < c && function() {
          $(window).focus(function() {
            my_setcookie("CHF", 1, 1, 0);
            my_setcookie("CNM", "", 0, 0)
          }).blur(function() {
            my_setcookie("CHF", "", 0, 0);
            my_setcookie("CNM", "", 0, 0)
          }).trigger("focus");
          var a = document.title, b = function() {
            !my_getcookie("CHF") && my_getcookie("CNM") ? (document.title = a == document.title ? "!! New message !!" : a, setTimeout(b, 300)) : (document.title = a, setTimeout(b, 5E3))
          };
          b()
        }()
      }, 5E3)
    });


    Technical problems



    The tutorial was tested on this forum and with the browser Google Chrome; If you notice that the tutorial doesn't work for a browser or for a version of forum (PhpBB2, PhpBB3, PunBB, Invision) contact an administrator and we will fill this field with your reporting.

    Thanks, the staff
    For every problem or question please, contact us in the section Support for the tutorials, The staff will answer you as soon as it is possible...

    Friendly,
    The team of the Forum of Codes.



    Last edited by Niko on Fri Apr 13, 2012 6:11 pm; edited 1 time in total



    Niko wants you in the team Guest

    Community manager and Administrator at Forumattivo.com

    MartinoPio
    • Veteran staff member

        Reputation : 14
        Registered on : 2012-02-25
        Posts : 98
      To me it does not work!

      Nathan
      • Veteran staff member

          Reputation : 7
          Registered on : 2012-06-26
          Posts : 108
        always any demo?

        abo_shab
        • I'm a new member :)


            Reputation : 0
            Registered on : 2013-06-22
            Posts : 8
          thank

          puppycheese
          • **


              Reputation : 1
              Registered on : 2013-08-31
              Posts : 14
              LG
            Does this work With AWC