• Welcome to Simple Machines Community Forum. Please login or sign up.
January 29, 2022, 06:25:56 AM

News:

Wondering if this will always be free?  See why free is better.


Post Notifier

Started by live627, February 09, 2014, 08:25:22 PM

Previous topic - Next topic

live627

February 09, 2014, 08:25:22 PM Last Edit: February 09, 2014, 08:50:21 PM by live627
Link to Mod

Post Notifier 1.0 by live627



This mod will add a ribbon at the top of the topic display that will show only if there are new posts within that topic. This, as you may have guessed, uses AJAX.

It updates every 60 seconds. To change, go and open ./Themes/defautl/scripts/postnotifier.js. Replace

60000

with

30000

and that will set the timer to 30 seconds, or 30,000 milliseconds.

https://github.com/live627/smf-post-notifier

v1.0.1
- Extra whitespace before opening PHP tag
- MIT license added

ApplianceJunk


Gryzor

Very nice, should be built-in functionality... thanks!

GamePersia

Can you make this mod for only pm notify also ??
and this mod only notifies newly made topics ??

eric1234

What shall I do if I want to include additional exclamation mark on the tab of the browser when there are new post that has been make?

Just like in the pic which i taken from another forum which also got the same function. Thank you in advance :)


live627

Go and open ./Themes/defautl/scripts/postnotifier.js. Replace

oDiv.style.display = 'block';

with

oDiv.style.display = 'block';
document.title = '(!!)' + document.title;

eric1234

Quote from: live627 on February 26, 2014, 06:48:39 PM
Go and open ./Themes/defautl/scripts/postnotifier.js. Replace

oDiv.style.display = 'block';

with

oDiv.style.display = 'block';
document.title = '(!!)' + document.title;

Thank you so  much. 1 more question , if i change the number from 60000 to 5000 means it will update every 5 seconds, will it affects the loading time or the server load?

and i notice that it will continue to add the exclamation mark every time it updates. SO is it possible just remain the exclamation mark as 1 set which is (!!) , no matter how many times it updates? 

eric1234


eric1234


eric1234


Gryzor


Storman™

If no one replies then it's usually because no one knows the answer.

margarett

Themes/defautl/scripts/postnotifier.js.
Find:
oDiv.style.display = 'block';
Add after:
var title = document.title;
var prefix = title.slice(0,4);
if (prefix != '(!!)')
document.title = '(!!)' + document.title;

(undo the previous change suggested by live627)

Quoteif i change the number from 60000 to 5000 means it will update every 5 seconds, will it affects the loading time or the server load?
Yes. Each "n" seconds a query at the database will be performed.
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

eric1234

Quote from: margarett on March 05, 2014, 06:21:32 PM
Themes/defautl/scripts/postnotifier.js.
Find:
oDiv.style.display = 'block';
Add after:
var title = document.title;
var prefix = title.slice(0,4);
if (prefix != '(!!)')
document.title = '(!!)' + document.title;

(undo the previous change suggested by live627)

Quoteif i change the number from 60000 to 5000 means it will update every 5 seconds, will it affects the loading time or the server load?
Yes. Each "n" seconds a query at the database will be performed.
You the man, Thank you so much for it . :)

Actually mind to explain this part? Thank you in advance
var title = document.title;
var prefix = title.slice(0,4);

margarett

title is a string (actual window title). In JS, string.slice allows you to get a part of that string. So I got the first 4 characters. If they are not (!!), I add it. In the next cycle the first 4 characters are (!!) so I don't add anything anymore.
Just learned it while doing this :P I hate JS!
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

eric1234

Oh I see. Thank you so much for the explanation. Well, at least you learnt something new which I am glad that I asked this question. :)

kimyaci

I'm using SMF 2:07. But the mode does not work.Is there a setting? Thanks.

margarett

It does work, I'm using it (and for sure, other people too) ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

kimyaci

Quote from: margarett on March 23, 2014, 08:48:29 PM
It does work, I'm using it (and for sure, other people too) ;)

I'll follow.Thanks.

mikk

May 24, 2014, 08:59:17 PM #19 Last Edit: May 25, 2014, 07:09:32 AM by mikk
Hi!

Thanks for this mod, this is very good idea.

But I've got problem on SMF 2.0.7 with this mod. Ajax chat (smf version) is installed on my forum. If I install Post Notifier, the Ajax chat is not working anymore, I get error message, when I click to the chat button:

QuoteThis page contains the following errors:

error on line 1 at column 6: XML declaration allowed only at the start of the document

Below is a rendering of the page up to the first error.

chat button only execute this: http://my-web-page/chat
Without this mod, or after I uninstall this mod, the chat it works.

Any idea?

Thanks.

edit1.:
I found this: https://groups.google.com/forum/#!searchin/ajax-chat/XML$20declaration|sort:relevance/ajax-chat/YcYYA_Dn8tU/ge9huolFevUJ

OK, if I change in chat/lib/config.php
$config['contentType'] = null;
to
$config['contentType'] = 'text/html';

the result chat page is displayed without error, but it doesn't work.

edit2.:
I found what is the problem, and I solve it. In the "PostNotifier.php" file in this mod, the first char is space! Only this...

Advertisement: