UBB.Dev
Posted By: JoshPet Private Messages... pop up or sound - 11/01/2002 2:15 AM
My users have once again asked for the ability to either have a sound play or a window pop up when they receive a private message.

This free Invision Board software (which you can see at www.moviejustice.com ) does this.

When I sign on there, if I've got a private message... as small new window pops up and says "You have X new private messages... click here to read".

I myself am on the fence if I want this handled any differently.... I personally wouldn't mind a sound... although I don't know if that's possible from a browser.

Pop ups could get annoying... especially since I get nine billion Private Messages.

Anyone else ever wish for enhancements to this?
Posted By: JustDave Re: Private Messages... pop up or sound - 11/01/2002 3:44 PM
As far as I know sounds are not supported in the browsers with the exception of imbedding windows media player (IE), RealPlayer (NS,IE,Mozilla?), Flash(NS,IE,Mozilla?) or perhaps a java applet that can load a sound playable by the applet in .au format. I could be wrong on some of this as it's not something I have looked into ver deeply. I do believe that such a use would be bulky, to say the least.

You could change the PM flasher that is used in the send_header function to open a popup window instead. This would be a simple task.

In your ubbt.inc.php file replace this:

if (($Privates) && (!$bypass)) {
$privateslink = "<a href="{$config['phpurl']}/viewmessages.php?Cat=$Cat&box=received" target="_top"><img src= "{$config['images']}/newpm.gif" border="0" alt="{$ubbt_lang['WEL_PRIV2']} $Privates {$ubbt_lang['WEL_PRIV3']}" /></a>";
}


with this:


if (($Privates) && (!$bypass)) {
$privateslink = "<script language="javascript" type="text/javascript">
window.open('{$config['phpurl']}/viewmessages.php?Cat=$Cat&box=recieved','shoutboxpal','width=200,height=200,top=100,left=150,screenX=1,screenY=1,scrollbars=yes,resizable=yes');
</script>";
}



I haven't tested this but it should give you an idea of what to do.

Posted By: JoshPet Re: Private Messages... pop up or sound - 11/01/2002 5:46 PM
Wow.

Thanks Dave.

Yes, that was the start I needed.

I'm working with this so that the flasher and the popup come up.
I've also customized a popup document.

When I get this all set, I'll post.

OK - I've got a Basic HTML question I'm sure.......

So I have the a popup (as you illustrate) come up.... it says "You have x new messages, click Here to view messages".

How do I have it when you click the link in that little window.... open in the threads window that the popup came from???

(As always, Dave you're a genius)
Posted By: JustDave Re: Private Messages... pop up or sound - 11/01/2002 5:57 PM
In the popup window use a link, something like this:

<a href="javascript: void(0)" onclick="window.opener.location='{$config['phpurl']}/viewmessages.php?Cat=$Cat&box=recieved'">View Messages</a>

Posted By: JoshPet Re: Private Messages... pop up or sound - 11/01/2002 6:42 PM
Thanks Dave!

Got this tweaked out very nicely.

Will post soon!!!!

T h a n k    Y o u !
Posted By: JoshPet Re: Private Messages... pop up or sound - 11/01/2002 6:51 PM
Now...

with this one I might be pushing my luck....

but is there a javascript thing to close that little popup window.

For example, when threads has no messages... can I have it kill the popup (which might still be open saying 'you have 1 new message').

Oh Dave the wizzard.... ?
Posted By: Gardener Re: Private Messages... pop up or sound - 11/01/2002 7:40 PM
It was a long time since I did any real work with javascript but from what I remember it isn't possible to close windows opened by other pages through javascript. I can be wrong though.

But it is possible to load a new html page in the popup window which in turn closes the window. All you need to do is set TARGET="shoutboxpal" and call a page which has <body onload="window.close()"> in it.
Posted By: JustDave Re: Private Messages... pop up or sound - 11/01/2002 7:44 PM
This link:

<a href="javascript:window.close()">Close Window</a>

Will close the window.

Also, you could have the popup window close automaticly after they click to view their messages:

<a href="javascript: void(0)" onclick="window.opener.location='{$config['phpurl']}/viewmessages.php?Cat=$Cat&box=recieved';window.close();">">View Messages</a>





Just a question, are you displaying the popup even when they have no messages? That would be annoying, lol.
Posted By: JoshPet Re: Private Messages... pop up or sound - 11/01/2002 7:54 PM
Thanks guys.

I will give that a go.

[]Just a question, are you displaying the popup even when they have no messages? That would be annoying, lol. [/]

No... I left $privateslink alone in ubbt.inc.php and created $privatespopup and added that into the menubar right after privates link. That opens the window only if there are private messages.

I could make it close when you click to view the messages... but then you get to the message screen (and if there's more than one message - it will pop up again... it functions just like the flasher - each page load it checks.).

So I thought I'd try to make it have the value to close the window if there was no flasher. That way if they left it open it wouldn't be outdated.

ie if the old thing is still sitting there saying you have 1 new message... and then they get a new message... it looks no different and is not effective.

I think I've taken your tidbits a long way.

I *guess* it would be possible to have that popup play a sound file.
Might play with that. I think I'd want to make that (maybe even the popup) a user option in their profile.

Will see how my users react. But each time we talk new features they talk about how sometimes they don't realize that they have new PMs etc and want a popup or something.

The few that I have sent PMs to this morning LOVE it.

Me too... I've found if I leave "who's online" open in the background... the PM popup box will come to the front. Thus "instant notification".

Thanks!
Posted By: JoshPet Re: Private Messages... pop up or sound - 11/01/2002 8:46 PM
Well....

I guess now I understand what Gardener.
The script on one page can't close another window? Right?

In other words... in threads I'm trying to call this:

$privatespopup = "<script language="javascript" type="text/javascript"> window.close('messagepopup');</script>";

To close my popup window named 'messagepopup'.... but it closes the current (threads) window instead.

I guess I would need to make my little message popup window query to see if there are private messages.... and close if there are none.

Unless I'm missing something with my javascript.
Posted By: JustDave Re: Private Messages... pop up or sound - 11/01/2002 8:53 PM
No, Gardener is right. This is do to the "sandbox" protection that keeps javascript from affecting other windows it was not related to in opening.

Also, I forgot that I should mention that WebTV may have problems with the popups in that they may be forced to the popup window and then to their messages and then back to browsing. Actually, the popup may not open at all for WebTV.

Posted By: Gardener Re: Private Messages... pop up or sound - 11/01/2002 9:07 PM
The page that opened the popup can close it as well, but not other pages.

Just change the opening script to this:
newwin = window.open(....

After that, you can close the popup later on the same page by doing this:
newwin.close();

But that won't help you much...

Making the popup page reload and query for messages sounds like the best way to go.
Posted By: JoshPet Re: Private Messages... pop up or sound - 11/01/2002 9:07 PM
[]No, Gardener is right. This is do to the "sandbox" protection that keeps javascript from affecting other windows it was not related to in opening.
[/]
So does that mean that there might be a way since Javascript opened this popup, that it can also close it?

Otherwise I'll make the popup page a little script that refreshes every once in a while and checks for Private Messages...and closes itself if there are none.

Thanks.
Posted By: JustDave Re: Private Messages... pop up or sound - 11/01/2002 9:09 PM
Only the page (parent) can access the popup (child) via javascript.
Posted By: JoshPet Re: Private Messages... pop up or sound - 11/01/2002 9:10 PM
[]

The page that opened the popup can close it as well, but not other pages.

Just change the opening script to this:
newwin = window.open(....

After that, you can close the popup later on the same page by doing this:
newwin.close();

But that won't help you much...

[/]

Ah, OK.
Yeah.. the threads page reloads to different pages. I'll try this.. but it's technically not the same page... I'm calling it from ubbt.inc.php and opening it in the navbar template.

Will try this... but otherwise I'll make a script.

Thanks guys.
Posted By: Aglavalin Re: Private Messages... pop up or sound - 11/01/2002 9:55 PM
You could change the flashing envelope gif to a flash file that has a sound playing. That would be pretty easy to do.
Posted By: JoshPet Re: Private Messages... pop up or sound - 11/01/2002 10:13 PM
Woooo Hooooo!!!

I've got this daddy working perfectly!!!!

It pops up when there are messages... refreshes every minute... and when there are no messages it closes the window. So even if it's in the background... it goes away when there are no more new messages!!!



Thanks guys!

Will write up all I did, and zip it (as I've got a new file) and post for all who are interested.

Posted By: JoshPet Re: Private Messages... pop up or sound - 11/02/2002 12:08 AM
Got all my instructions written up.... made it all pretty... language file and who's online savvy.

Posted here.

Enjoy!

Thanks again guys.
© UBB.Developers