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.
The forum of the forums
3 posters

    Option to hide chatbox

    Tonight
    Tonight
    Forumember


    Male Posts : 312
    Reputation : 80
    Language : Estonian, English, Russian
    Location : Estonia

    In progress Option to hide chatbox

    Post by Tonight December 12th 2014, 7:15 pm

    Is it possible to create an option to hide chatbox (with cookie)?

    Extra question: Also, is it possible to move the chatbox up and down the main page?
    Tonight
    Tonight
    Forumember


    Male Posts : 312
    Reputation : 80
    Language : Estonian, English, Russian
    Location : Estonia

    In progress Re: Option to hide chatbox

    Post by Tonight December 15th 2014, 6:42 pm

    Up. I want like a toggle option.
    Ange Tuteur
    Ange Tuteur
    Forumaster


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

    In progress Re: Option to hide chatbox

    Post by Ange Tuteur December 15th 2014, 10:31 pm

    Hello @Tonight,

    Could you provide some information please ?

    • The version of your forum
    • Are you using the default chatbox ?


    Thanks
    Tonight
    Tonight
    Forumember


    Male Posts : 312
    Reputation : 80
    Language : Estonian, English, Russian
    Location : Estonia

    In progress Re: Option to hide chatbox

    Post by Tonight December 15th 2014, 10:44 pm

    phpBB3
    default chatbox
    Ange Tuteur
    Ange Tuteur
    Forumaster


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

    In progress Re: Option to hide chatbox

    Post by Ange Tuteur December 15th 2014, 11:01 pm

    Go to Administration Panel > Modules > JavaScript codes management > Create a new script

    Title : Your choice
    Placement : In the homepage
    Paste the code below and submit :
    Code:
    $(function() {
      if (!document.getElementById('frame_chatbox')) return;
      var fa = document.getElementById('frame_chatbox'), frame;
     
      // create toggle buttons
      $('#chatbox_top').before('<div class="online-chat">Members in chat : <span id="members-chat" style="color:#F00;">0</span></div><div id="cbOpen" class="cbButton">Click to open chatbox</div><div id="cbClose" class="cbButton">Click to close chatbox</div>');
      $('#chatbox_top, #cbClose').hide();
     
      fa.onload = function() {
        if (fa.contentDocument) frame = fa.contentDocument;
        else if (fa.contentWindow) frame = fa.contentWindow.document;
       
        // kill the interval if archives are toggled
        var a = frame.getElementsByTagName('A');
        for (i=0; i<a.length; i++) if (/archives/.test(a[i].href)) a[i].onclick = function() { window.clearInterval(_chat_refresh) };
       
         // get the amount of members and compare change
        then = frame.getElementById('chatbox_members').getElementsByTagName('li').length;
         var members = document.getElementById('members-chat');
         members.innerHTML = then;
       
        _chat_refresh = window.setInterval(function() {
           var now = frame.getElementById('chatbox_members').getElementsByTagName('li').length;
        
           // change the chat member number
           if (now < 1 || then < 1) members.style.color = '#F00';
          else if (now > 0 || then > 0) members.style.color = '#39C';
        
           // check if there is a change in members
          if (now > then || now < then) {
            members.innerHTML = now;
              then = now;
          }
        },1);
      };
     
      // open chat function
      $('#cbOpen').click(function() {
          $('#chatbox_top, #cbClose').show();
          $('#cbOpen').hide();
        
         // adjust scroll
        if (fa.contentDocument) fa.contentDocument.getElementById('chatbox').scrollTop = 99999;
         else if (fa.contentWindow) fa.contentWindow.document.getElementById('chatbox').scrollTop = 99999;
      });
       
      // close chat function
      $('#cbClose').click(function() {
          $('#chatbox_top, #cbClose').hide();
          $('#cbOpen').show();
      });
    });

    Then add this to your stylesheet
    Display > Colors > CSS stylesheet
    Code:
    .cbButton {
      cursor:pointer;
      text-align:center;
      font-weight:bold;
      font-size:12px;
      margin:3px;
    }
    avatar
    Fairfox1
    New Member


    Posts : 18
    Reputation : 1
    Language : enlish

    In progress Re: Option to hide chatbox

    Post by Fairfox1 December 16th 2014, 3:15 am

    ange can you make this for phpbb2 defult browser 2.  seems like a cool thing to have

      Current date/time is November 11th 2024, 7:37 pm