1 (edited by ShawnBrown 2005-01-27 02:39)

Topic: PunJS New Posts 1.0

##
##
##        Mod title:  PunJS New Posts
##
##      Mod version:  1.0
##   Works on PunBB:  1.2
##     Release date:  2005-01-22
##           Author:  Shawn Brown ( http://shawnbrown.com/contact )
##
##      Description:  Turns off new post indicators as messages are read.
##                    Also prevents unread messages from timing out.
##
##   Affected files:  include/template/main.tpl
##
##       Affects DB:  No
##
##            Notes:  This script tracks read/unread forums, topics and
##                    post id numbers. These numbers are derived from PunBB's
##                    HTML output and the web browser's environment variables.
##                    The information is managed in a multidimensional array
##                    which is serialized for storage in a cookie file. The
##                    read/unread indicators are manipulated using W3C DOM
##                    node references and methods. These are strictly
##                    client-side methods that require no extra work from
##                    the server once the script itself is downloaded.
##
##                    This is less of a traditional mod and more of a
##                    JavaScript add-on. The new_posts.js file is just
##                    under 26kb. A modern browser will cache this file so
##                    it is only retrieved once. As is, the script should
##                    lay seamlessly over an "out-of-the-box" install of
##                    PunBB 1.2.
##
##                    Note - If a members's ability to post replies in
##                    a forum is disabled, the script can not reliably
##                    turn off new post indicators for that forum.
##
##       DISCLAIMER:  Please note that "mods" are not officially supported by
##                    PunBB. Installation of this modification is done at your
##                    own risk. Backup your forum database and any and all
##                    applicable files before proceeding.
##

PunJS New Posts (for PunBB 1.2)

    Screenshot here

    Download v1.0 here (please use new_posts.js 1.0.1dev with this package instead of the included file)

    Working update: new_posts.js 1.0.1dev
        - New post tracking on index page implemented
        - "Sticky" topic handling implemented
        - Added support for "User has posted earlier" admin option--the "·" in front of the topics
        - For instalation instructions, download the 1.0 distribution

Latest Open Source project: [img=Templar PHP]http://code.google.com/p/templarphp/logo?logo_id=1251758459[/img]

TemplarPHP - A cascading template framework for PHP.

Re: PunJS New Posts 1.0

looks very very cool wink Well done!

(i'm going to put it on mypunbb with instructions for how to add it to your forum)
edit actually i can't put it on mypunbb (at least not as it is, mypunbb generates the cookie name for each forum)

Re: PunJS New Posts 1.0

Great, i have try in my forum, and it works very well

Thx

4

Re: PunJS New Posts 1.0

Very cool. I'll have to install it tonight.

"You start coding. I'll go find out what they want." - Computer Analyst to Programmer

Re: PunJS New Posts 1.0

I had a go at it just now and maybe I did something wrong, but it doesn't quite work for me. If a topic contains a new post and I read the topic, when I return to the forum, the whole subject cell is empty. It doesn't show anything. Any idea what might be causing this ShawnBrown?

I should note that I tested this on the latest source, but viewforum.php hardly contains any changes worth mentioning.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

6

Re: PunJS New Posts 1.0

One quick request: 26Kb is a bit heavy, so off I went to http://dean.edwards.name/packer/ to pack it up. Sure enough, it packed to 6Kb. Unfortunately it didn't work, because Packer needs everything terminated properly. Would it be possible for you to go through the code and terminate as per the requirements for the packer, so we can have a much lighter-weight (and very cool) addon? smile

7

Re: PunJS New Posts 1.0

ps...My Javascript-Fu is weak...:(

8 (edited by ShawnBrown 2005-01-22 22:52)

Re: PunJS New Posts 1.0

Rickard wrote:

...when I return to the forum, the whole subject cell is empty. It doesn't show anything. Any idea what might be causing this ShawnBrown?

I should note that I tested this on the latest source, but viewforum.php hardly contains any changes worth mentioning.

The script should handle minor changes to most of the table cells robustly--but the first cell is more picky. A complete rebuild of the tclcon DIV takes place and the script needs to know what to look for in this DIV.

On this forum, viewforum.php is adding two non-breaking spaces that weren't there in my installed version of 1.2.0. The additional code between <div class="tclcon">
and the link alters the node tree for the content there. One thing I also noticed is that I forgot about the middot... this could be tripping up the tclcon rebuild.

Latest Open Source project: [img=Templar PHP]http://code.google.com/p/templarphp/logo?logo_id=1251758459[/img]

TemplarPHP - A cascading template framework for PHP.

Re: PunJS New Posts 1.0

Ah, OK. But that won't be a problem to update once 1.2.1 is out, right?

"Programming is like sex: one mistake and you have to support it for the rest of your life."

10 (edited by ShawnBrown 2005-01-22 22:58)

Re: PunJS New Posts 1.0

Mart wrote:

One quick request: 26Kb is a bit heavy, so off I went to http://dean.edwards.name/packer/ to pack it up. Sure enough, it packed to 6Kb. Unfortunately it didn't work, because Packer needs everything terminated properly. Would it be possible for you to go through the code and terminate as per the requirements for the packer, so we can have a much lighter-weight (and very cool) addon? smile

That's a good idea. When I was making the script I was concerned about execution time but it doesn't seem to be an issue. I'll use the packer you listed and another one then put the smallest result in the distribution (along with an uncompressed copy).

Latest Open Source project: [img=Templar PHP]http://code.google.com/p/templarphp/logo?logo_id=1251758459[/img]

TemplarPHP - A cascading template framework for PHP.

Re: PunJS New Posts 1.0

This mod is awesome smile
It seems to slow down the page a bit, which causes pages, but Im sure most of the problems are because im on a slow connection right now

Indocron
$theQuestion = (2*b) || !(2*b);

Re: PunJS New Posts 1.0

Mmm
For some reason, the thread updates but not the forum (there are no unread threads but the forum is still marked as unread)
Is that normal?

Re: PunJS New Posts 1.0

ShawnBrown wrote:

I forgot about the middot... this could be tripping up the tclcon rebuild.

Rickard wrote:

Ah, OK. But that won't be a problem to update once 1.2.1 is out, right?

It looks like the missing middot support alone was causing this. The non-breaking spaces I saw were those generated when the middot is turned on (i.e., the "User has posted earlier" option).

For an updated version with added middot support you can download the working update.

Rickard: Can you try this on the latest source and see if it works?

Latest Open Source project: [img=Templar PHP]http://code.google.com/p/templarphp/logo?logo_id=1251758459[/img]

TemplarPHP - A cascading template framework for PHP.

Re: PunJS New Posts 1.0

Smartys wrote:

...For some reason, the thread updates but not the forum (there are no unread threads but the forum is still marked as unread)
Is that normal?

No, that's not normal... but I know it can happen if you remove an unread post via the moderate forum link (moderate.php). Doing this leaves an unread mark in the array which turns the indicator on when you view index.php.

If that's not what happened, email me and I'll take a look at it.

Latest Open Source project: [img=Templar PHP]http://code.google.com/p/templarphp/logo?logo_id=1251758459[/img]

TemplarPHP - A cascading template framework for PHP.

Re: PunJS New Posts 1.0

ShawnBrown wrote:

When I was making the script I was concerned about execution time but it doesn't seem to be an issue.

Gary13579 wrote:

...It seems to slow down the page a bit .... but Im sure most of the problems are because im on a slow connection right now

When the script runs, the indicators are quickly flicked on or off--this used to cause a flicker especially in IE. To prevent this, the script immediately sets the visibility of the first column to hidden. Only after the browser receives the </body> tag, does the script run--updating the indicators and setting the first column's visibility back to visible.

I think the slow down you're seeing is caused by slow the connection (waiting to receive the </body> tag) rather than the script chugging away. I've been keeping the execution speed in mind from the beginning and have tried to make it as quick as possible.

Just in case this becomes an issue, I think I'll include different flavors of the script in the distribution package:
- small, packed version (default install)
- speedier copy (unpacked, comments & white space stripped)
- fully commented version (for modifications)

Latest Open Source project: [img=Templar PHP]http://code.google.com/p/templarphp/logo?logo_id=1251758459[/img]

TemplarPHP - A cascading template framework for PHP.

Re: PunJS New Posts 1.0

Shawn: I just tried it with the latest source and it appears to work flawlessly. Excellent work smile This deserves a news post. I'll let people test it out some more though.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

17

Re: PunJS New Posts 1.0

great mod! thanks

18

Re: PunJS New Posts 1.0

Great work!  ( I somehow think this should be punbb's feature in the firsthand. )

19 (edited by Gary13579 2005-01-24 00:53)

Re: PunJS New Posts 1.0

BUG!
I finnally found a bug smile
When someone posts in a sticky topic, I guess it removes the word 'sticky' from it
Screenshot


NOO sad
My one bug, and its already been fixed in a newer version.

Indocron
$theQuestion = (2*b) || !(2*b);

Re: PunJS New Posts 1.0

Gary13579 wrote:

NOO sad
My one bug, and its already been fixed in a newer version.

Ah I forgot to mention the added Sticky support in the 1.0.1dev announcement... it's there now. The Sticky support went hand-in-hand with the middot.

Latest Open Source project: [img=Templar PHP]http://code.google.com/p/templarphp/logo?logo_id=1251758459[/img]

TemplarPHP - A cascading template framework for PHP.

Re: PunJS New Posts 1.0

sad
Okay, for some odd reason the new post indicator isnt showing up at all anymore. I post, someone else replies, but the new post indicator isnt lit at all sad
This is all without anyone timing out, so maybe it isnt updating right?
Im gonna have to remove it till its fixed sad

Indocron
$theQuestion = (2*b) || !(2*b);

Re: PunJS New Posts 1.0

Gary13579: it sounds like the script is wrongly turning the new indicators off but I'm not sure why. I'd like to test this and see exactly what the script is doing. I'll IM you on ICQ and see if we can figure it out.

Latest Open Source project: [img=Templar PHP]http://code.google.com/p/templarphp/logo?logo_id=1251758459[/img]

TemplarPHP - A cascading template framework for PHP.

Re: PunJS New Posts 1.0

That would work, if I was logged into ICQ...

Okay, I logged in now. This mod is awesome, but its just this one problem thats stopping me from installing it..

Indocron
$theQuestion = (2*b) || !(2*b);

Re: PunJS New Posts 1.0

Update: I've completed a new update of the script. This version has been compressed with the packer script suggested by Mart--it's now ~8k. The script can be downloaded at the same location (Working Update: new_posts.js 1.0.1dev).

The issue Smartys was experiencing was simply the result of a mod he had made to his forum. On the other hand, the problem that Gary13579 reported was an oversight on my part and the issue has been fixed. (I had forgotten to integrate last-post tracking with the index page functions.) The index page indicators should work fine now.

Latest Open Source project: [img=Templar PHP]http://code.google.com/p/templarphp/logo?logo_id=1251758459[/img]

TemplarPHP - A cascading template framework for PHP.

25 (edited by Widell 2005-01-27 18:01)

Re: PunJS New Posts 1.0

I have a huge problem.. IE users can't read the forums. Is it problem with the script or my fault? i.e http://impegas.org/dump/JRC_001.jpg

And when i installled 1.0.1 the sticky disapered in the forums..