• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ General Support (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

pop-up alert

Moderators: OldWolf, re*s.t.a.r.s.*2

Post a reply
4 posts • Page 1 of 1

Postby devans » Fri Dec 08, 2006 10:51 am

Hi Kerphi

Could you tell me if there's a good place to check if there's new messages in the active chat window? roschler asked a similar question here:
http://www.phpfreechat.net/forum/viewtopic.php?id=742 (notifyTab not firing)
http://www.phpfreechat.net/forum/viewtopic.php?id=726 (Pop up a new window when a new guest arrives?)

I checked the notifyTab function in src/client/pfcgui.js, but this requires two tabs, where the one is inactive. The idea is to pop up a little alert (ala googletalk, etc) if the chat window isn't in focus. I could go down the new guest route, but if you've got a tip to where I can check for updates to the message window, I'd rather test there... :/

p.s. phpfreechat kicks butt, keep up the good work!
devans
New member
 
Posts: 4
Joined: Fri Dec 08, 2006 9:54 am
Top

Postby devans » Mon Dec 11, 2006 10:48 am

Hi again

I finally caught on to the obvious, what I was looking for was a few lines up in the notifyWindow function. =)
devans
New member
 
Posts: 4
Joined: Fri Dec 08, 2006 9:54 am
Top

Postby devans » Mon Dec 11, 2006 1:58 pm

Quick question. If I wanted the msg text, or nick of person posting, could you tell me the var name(s) to pass from the notifyWindow function?
devans
New member
 
Posts: 4
Joined: Fri Dec 08, 2006 9:54 am
Top

Postby devans » Mon Dec 11, 2006 3:54 pm

okay, I've written something that does what I want. Not very elegant, surely a better way, but it works.

In case anyone else is interested...

changed line 827 in pfcclient to
Code: Select all
this.gui.notifyWindow(sender);

changed notifyWindow function in pfcgui.js to
Code: Select all
notifyWindow: function(sender)
  {
    this.windownotifynb += 1;
    var rx = new RegExp('^\[[0-9]+\](.*)','ig');
    document.title = document.title.replace(rx,'$1');
    document.title = '['+this.windownotifynb+']'+document.title;
    // build popup
   this.alertWindow(sender);
  },

then finally added this function below the notifyWindow function in pfcgui.js
Code: Select all
alertWindow: function(sender)
  {
   // Define vars
   var newwindow = '';
   var url = 'chat.php?who='+sender;
   var popwidth = 160;
   var popheigth = 20;
   var fudgex = 10;
   var fudgey = 100; // move popup up (due to windows taskbar)
   // get screen resolution
   var resx = screen.width;
   var resy = screen.height;
   // Position of popup on screen
   var posx = resx - popwidth - fudgex;
   var posy = resy - popheigth - fudgey;
   
   //alert ( "someone trying to chat with you!" ); // temp test
   
   // open new window
   if(document.getElementById('alertme').checked=='0') { // check if the alertbox is off (on by default)
      // alert windows turned off
   }else{
      if (!newwindow.closed && newwindow.location) {
         newwindow.location.href = url;
      }
      else {
         newwindow=window.open(url,'new_chat','width='+popwidth+',height='+popheigth+',left='+posx+',top='+posy+',screenX='+posx+',screenY='+posy+',scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no');
         if (!newwindow.opener) newwindow.opener = self;
      }
      if (!newwindow.focus()) {newwindow.focus()}
   }   
  },

to give people the option of turning off the popups, I put a little checkbox in the chat page html...
Code: Select all
Allow Alertboxes: <input name="alertme" id="alertme" type="checkbox" checked="1" />

Sorry for the sloppy code, basically self-taught... =)

edit: I should add that the url points at a php file, but you could just as easily make it html
Last edited by devans on Mon Dec 11, 2006 3:56 pm, edited 1 time in total.
devans
New member
 
Posts: 4
Joined: Fri Dec 08, 2006 9:54 am
Top


Post a reply
4 posts • Page 1 of 1

Return to General Support (v1.x)

Who is online

Users browsing this forum: No registered users and 13 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub