vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.6 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=194)
-   -   Private Messages Enhancements - Ajax notification of a new personal message (https://vborg.vbsupport.ru/showthread.php?t=152683)

pedigree 07-18-2007 10:00 PM

Ajax notification of a new personal message
 
A small mod that puts a flashing envelope in the top right corner of your screen when you get a new personal message, even if youre sitting idle. You dont have to open / reload any pages to see the notification

My default, it checks once per minute but its configurable in the javascript

PLEASE - Read the instructions, anything in there that is asked here will be ignored or simply a RTFM reply.

Ive tried it with FF2 / IE6 and Opera 9.21. Ive tried it on two forums running 3.6.5 but it should work on 3.6.0-3.6.7

Edit footer template, add this to the very bottom
HTML Code:

<if condition="$bbuserinfo[userid] > 0">
<if condition="$vboptions['ajaxchecknewpmactive']">
<script>
        sessionurl = '$session[sessionurl]';
        checkNewPM()
</script>

<if condition="$vboptions[ajaxchecknewpm_position]=='F'">
<div id="ajaxnewpmdiv" style="
    position:absolute;
    display:none;
    width:32px;height:32px;left:0px;top:0px;
    padding:0px;background:transparent;
    border:0px solid #ffffff"
>
<a href="private.php?$session[sessionurl_q]"><img src="images/newpm.gif" alt="You have a new PM" border="0"></a></div>

<script type="text/javascript"><!--
/* Script by: www.jtricks.com
 * Version: 20060303
 * Latest version:
 * www.jtricks.com/javascript/navigation/floating.html
 */
var target_x = -60;
var target_y = 12;

var has_inner = typeof(window.innerWidth) == 'number';
var has_element = document.documentElement && document.documentElement.clientWidth;

var fm_id='ajaxnewpmdiv';
var floating_menu =
    document.getElementById
    ? document.getElementById(fm_id)
    : document.all
      ? document.all[fm_id]
      : document.layers[fm_id];

var fm_shift_x, fm_shift_y, fm_next_x, fm_next_y;

function move_menu()
{
    if (document.layers)
    {
        floating_menu.left = fm_next_x;
        floating_menu.top = fm_next_y;
    }
    else
    {
        floating_menu.style.left = fm_next_x + 'px';
        floating_menu.style.top = fm_next_y + 'px';
    }
}

function compute_shifts()
{
    fm_shift_x = has_inner
        ? pageXOffset
        : has_element
          ? document.documentElement.scrollLeft
          : document.body.scrollLeft;
    if (target_x < 0)
        fm_shift_x += has_inner
            ? window.innerWidth
            : has_element
              ? document.documentElement.clientWidth
              : document.body.clientWidth;

    fm_shift_y = has_inner
        ? pageYOffset
        : has_element
          ? document.documentElement.scrollTop
          : document.body.scrollTop;
    if (target_y < 0)
        fm_shift_y += has_inner
            ? window.innerHeight
            : has_element
              ? document.documentElement.clientHeight
              : document.body.clientHeight;
}

function float_menu()
{
    var step_x, step_y;

    compute_shifts();

    step_x = (fm_shift_x + target_x - fm_next_x) ;
    if (Math.abs(step_x) < .5)
        step_x = fm_shift_x + target_x - fm_next_x;

    step_y = (fm_shift_y + target_y - fm_next_y) ;
    if (Math.abs(step_y) < .5)
        step_y = fm_shift_y + target_y - fm_next_y;

    if (Math.abs(step_x) >
0 ||
        Math.abs(step_y) > 0)
    {
        fm_next_x += step_x;
        fm_next_y += step_y;
        move_menu();
    }

    setTimeout('float_menu()', 20);
};

compute_shifts();
if (document.layers)
{
    // Netscape 4 cannot perform init move
    // when the page loads.
    fm_next_x = 0;
    fm_next_y = 0;
}
else
{
    fm_next_x = fm_shift_x + target_x;
    fm_next_y = fm_shift_y + target_y;
    move_menu();
}
float_menu();
//-->
</script>
</if>
</if>
</if>

Edit headerinclude and add this to the bottom
HTML Code:

<script type="text/javascript" src="clientscript/vbulletin_ajax_checknewpm.js"></script>
Edit template navbar

Find this
HTML Code:

<strong><phrase 1="$vbphrase[pmpercent_nav_compiled]">$vbphrase[your_pm_box_is_x_full]</phrase></strong></if>
                </div>
                </td>

And below that, add this
HTML Code:

<if condition="$vboptions[ajaxchecknewpm_position]=='N'">
<td class="alt2" valign="top" nowrap="nowrap"><div id="ajaxnewpmdiv" style="
    display:none;
    width:32px;height:32px;left:0px;top:0px;
    padding:0px;background:transparent;
    border:0px solid #ffffff"
>
<a href="private.php?$session[sessionurl_q]"><img src="images/newpm.gif" alt="You have a new PM" border="0"></a></div></td>
</if>

NOTICE : If you have the New PM Notification mod installed (https://vborg.vbsupport.ru/showthread.php?t=124056) you will need to remove it by searching for and deleting this text in the navbar template
HTML Code:

<if condition="$bbuserinfo['pmunread']">
                <td class="alt2" valign="top" nowrap="nowrap">
        <a href="/forum/private.php?$session[sessionurl]"><img src="$stylevar[imgdir_misc]/newpm.gif" alt="You have a new PM" border="0"></a>
                </td>
        </if>

If you want the floating notifier on a new page load and not the ajax checking, edit the JS file and delete

HTML Code:

setTimeout("checkNewPM()", checkdelay);
Youll need to:
Upload 1 GIF file
Upload 1 Javascript file
Import 1 XML product

Makes 1 plugin hook into misc.php (adds ajaxchecknewpm function)

History 19 July 2007
Version 1.1
  • Bug fix, IE complains when a guest gets a permission denied response when it expects XML. Removed Guests from checking for PMs via Ajax
  • Added options to have the Notification in the navbar as well as floating.

if you have 1.0 installed, youll need to upload the Jaavscript file again, uninstall / reinstall the XML product and make the template changes to footer (not headerinc) and add 1 to navbar

pedigree 07-18-2007 11:59 PM

First post reserved

FreshFroot 07-19-2007 02:22 AM

now this seems really usefull.. I'm going to try it out :D

great hack!

Yours 07-19-2007 02:34 AM

I shall test this out!

Thanks mate!

Hornstar 07-19-2007 04:41 AM

Cool, something similar to what vb.org has but ajax ^^ i like :)

Mecho 07-19-2007 09:53 AM

as i read the instruction , it check the pm box each X min ( we can change it ) . is there anyway that JUST when we get a new pm it works and it inform us that we get new pm ? i think it s better for load the server in each X min or ..

Thanks

PoetJA-1975 07-19-2007 12:34 PM

Now this seems nice! Question though - I've already installed New PM Notification - would love to implement the ajax feature... Anyway - that I could have the blinking notification of your hack appear in the navbar like the New PM Notification mod?

Thanx,

Jacquii.

Invalid ID 07-19-2007 03:58 PM

Good work

pedigree 07-19-2007 06:09 PM

You can put the hack anywhere you like. most of the template change is to have it float but will I was working on the code, it did actually start in the navbar :)

Ill give people a couple of options, floating or in the navbar, you can pick in the options for it. Poet - Ill do that but it looks a bit strange "You have no new PMs" and then a flashing envelope :)

I did find a bug this morning though, after posting this of course :( If youre a guest, it still asks the server for your PM count. As youre a guest, you get permission denied that causes two things. Firstly, IE borks on it if you have Microsoft Script Debugger installed (go figure, IE sucks) and it ups your bandwidth bill.

Ill upload v1.1 tonight that will fix all that.

If you dont want it to hit the server but still want the flashing floating icon, set the timer to 5 million or something insane. It still checks everytime the page is loaded.

pedigree 07-19-2007 09:00 PM

As promised, 1.1 attached.

projectego 07-21-2007 08:59 AM

More AJAX is always a good thing! Thanks. :)

ssslippy 07-22-2007 04:47 AM

When you click logout the icon hovers in the up right corner of your page.

pedigree 07-22-2007 10:25 AM

Oh, Ill look at that one.

SemperFideles 11-12-2007 06:40 AM

Nice mod. I just found out from a user and confirmed this problem.

When the user logs out, the mailbox icon appears in the upper right hand corner immediately following log out. This makes them think there is a PM when, in fact, there is no PM but it is somehow appearing during logout.

ibuddy 12-10-2007 05:31 AM

how can we make it so it just flashes red text, I dont like this lil graphic to the right, would rather have blinking red font saying "New Private Message"

mastertek2000 12-28-2007 07:24 PM

works great thanks

Doctor Dan 03-22-2008 10:38 PM

Quote:

Originally Posted by PoetJA-1975 (Post 1295633)
Now this seems nice! Question though - I've already installed New PM Notification - would love to implement the ajax feature... Anyway - that I could have the blinking notification of your hack appear in the navbar like the New PM Notification mod?

Yes, this is possible by changing the "New PM Notification" code in the navbar template to:

HTML Code:

<td class="alt2" valign="top" nowrap="nowrap">
    <span id="ajaxnewpmdiv">
        <a href="/forum/private.php?$session[sessionurl]"><img src="$stylevar[imgdir_misc]/newpm.gif" alt="You have a new PM" border="0"></a>
    </span>
</td>


Since the visibility of the ajaxnewpmdiv element is controlled by JavaScript code, anything within the <span id="ajaxnewpmdiv"> ... </span> block will be "revealed" when a new private message arrives.

- Dan

Doctor Dan 03-22-2008 10:54 PM

I've extended this mod so when a new PM arrives, the "Unread" and "Total" counts are updated dynamically via Ajax as well.

If enough people are interested, I'll post how to do it.

- Dan

co0kz 03-25-2008 06:15 PM

i would be interested in how you get the unread and total counts to update as well as the flashing indication

dancue 03-29-2008 05:35 AM

Interested here as well.

Also, I'd love for this to go on the left side of the welcome box. In the navbits, I believe?

Is that possible?

pedigree 04-16-2008 10:01 PM

yeah, thats in navbar. Ive got my head deep in an integration of vb and stopforumspam.com but Ill sort them all when Im done :)

pedigree 04-21-2008 12:38 PM

you can place the <DIV>code</div> anywhere you want in the navbar template, or replace the GIF with anything you like

pedigree 04-21-2008 12:40 PM

Quote:

Originally Posted by dancue (Post 1477382)
Interested here as well.
Also, I'd love for this to go on the left side of the welcome box. In the navbits, I believe?
Is that possible?

Take a screenshot of where you want it to go and put a circle or an arrow and Ill knock something up for you.

dancue 05-01-2008 12:25 PM

Sorry for the wait.

Hopefully this helps.

EhsanAhmad 05-24-2008 11:11 PM

Installed it but it shows up at the top right corner of my forum is there anyway so it appears just beside the your notifications or Private Messages Link ?

Deepdog009 05-26-2008 02:19 AM

Beauts...

dancue 06-05-2008 02:55 PM

Pedigree,
Have you figured out how to do what's mentioned in posts #23,24?

I'd really appreciate it!

pedigree 06-09-2008 01:29 PM

Dancue, PM me a link to your forum so I can look at the HTML for your template.

Coding around template / theme changes can be a real pain in the a** sometimes. You cant code for every template :(

Boofo 06-09-2008 01:34 PM

Why not make a js file and just link to it? It would save adding so much code to the footer.

pedigree 06-09-2008 01:36 PM

Could link to a js file but Ive had other people hot linking to js files on my site before, no thanks. If people want to do that, then they can do that.

Boofo 06-09-2008 01:38 PM

If they are linking to it then you are not doing it properly.

NolimitMike 08-20-2008 01:12 PM

I just got 3.7 will this work on that forum software? Really like this mod

DieselMinded 07-17-2010 12:48 AM

I would like to add this mod to my Live Page

http://www.dieselbombers.com/vaispy.php

Can i just add the code to the php file ?


All times are GMT. The time now is 05:49 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01250 seconds
  • Memory Usage 1,823KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (7)bbcode_html_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (33)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete