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.

Option to hide chatbox

3 posters

Go down

In progress Option to hide chatbox

Post by Tonight Fri 12 Dec - 18:15

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

Back to top Go down

In progress Re: Option to hide chatbox

Post by Tonight Mon 15 Dec - 17:42

Up. I want like a toggle option.
Tonight
Tonight
Forumember

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

Back to top Go down

In progress Re: Option to hide chatbox

Post by Ange Tuteur Mon 15 Dec - 21:31

Hello @Tonight,

Could you provide some information please ?

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


Thanks
Ange Tuteur
Ange Tuteur
Forumaster

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

https://fmdesign.forumotion.com

Back to top Go down

In progress Re: Option to hide chatbox

Post by Tonight Mon 15 Dec - 21:44

phpBB3
default chatbox
Tonight
Tonight
Forumember

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

Back to top Go down

In progress Re: Option to hide chatbox

Post by Ange Tuteur Mon 15 Dec - 22:01

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;
}
Ange Tuteur
Ange Tuteur
Forumaster

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

https://fmdesign.forumotion.com

Back to top Go down

In progress Re: Option to hide chatbox

Post by Fairfox1 Tue 16 Dec - 2:15

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

Posts : 18
Reputation : 1
Language : enlish

http://ffda.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