Latest topics
» Forumactif Edge - Releases
by Ange Tuteur Tue 03 Sep 2019, 11:49
» GIFActif - Giphy Button for the Editor
by Ange Tuteur Wed 08 May 2019, 17:21
» Forum Closure
by Ange Tuteur Mon 01 Jan 2018, 01:28
» Chit Chat Thread
by Valoish Sun 31 Dec 2017, 19:15
» Font/Text background color.
by Valoish Sun 31 Dec 2017, 19:11
» Forumactif Messenger - Instant Message Application for Forumotion
by Wolfuryo Sun 31 Dec 2017, 18:24
» [GAME] Count to One Million!
by brandon_g Fri 29 Dec 2017, 18:58
» Post Cards
by manikbiradar Wed 20 Dec 2017, 07:50
» [GAME] Countdown from 200,000
by Valoish Wed 13 Dec 2017, 23:22
» GeekPolice Tech Support Forums - GeekPolice.net
by Dr Jay Mon 11 Dec 2017, 19:12
» Asking about some plugin for Forumotion
by Dr Jay Mon 11 Dec 2017, 19:10
» [GAME] What are you thinking right now?
by Van-Helsing Sat 09 Dec 2017, 14:51
» Widget : Similar topics
by ranbac Wed 06 Dec 2017, 18:11
» Change the Background of the Forum and put an image and how to make prefixs?
by Clement Wed 06 Dec 2017, 15:19
» Hello from Western Australia
by SarkZKalie Wed 06 Dec 2017, 05:34
by Ange Tuteur Tue 03 Sep 2019, 11:49
» GIFActif - Giphy Button for the Editor
by Ange Tuteur Wed 08 May 2019, 17:21
» Forum Closure
by Ange Tuteur Mon 01 Jan 2018, 01:28
» Chit Chat Thread
by Valoish Sun 31 Dec 2017, 19:15
» Font/Text background color.
by Valoish Sun 31 Dec 2017, 19:11
» Forumactif Messenger - Instant Message Application for Forumotion
by Wolfuryo Sun 31 Dec 2017, 18:24
» [GAME] Count to One Million!
by brandon_g Fri 29 Dec 2017, 18:58
» Post Cards
by manikbiradar Wed 20 Dec 2017, 07:50
» [GAME] Countdown from 200,000
by Valoish Wed 13 Dec 2017, 23:22
» GeekPolice Tech Support Forums - GeekPolice.net
by Dr Jay Mon 11 Dec 2017, 19:12
» Asking about some plugin for Forumotion
by Dr Jay Mon 11 Dec 2017, 19:10
» [GAME] What are you thinking right now?
by Van-Helsing Sat 09 Dec 2017, 14:51
» Widget : Similar topics
by ranbac Wed 06 Dec 2017, 18:11
» Change the Background of the Forum and put an image and how to make prefixs?
by Clement Wed 06 Dec 2017, 15:19
» Hello from Western Australia
by SarkZKalie Wed 06 Dec 2017, 05:34
Recent Tutorials
Top posting users this month
Top Achievers
Who is online?
In total there are 4 users online :: 0 Registered, 0 Hidden and 4 Guests :: 2 Bots
None
Most users ever online was 515 on Tue 14 Sep 2021, 15:24
None
Most users ever online was 515 on Tue 14 Sep 2021, 15:24
is there auto topic update - refresh to see new posts with out refresh the page
Page 1 of 1 • Share
Yeah, it's possible. You'd just have to create an array of all the posts on the page, once you do this you can setup an interval which will poll for changes by sending a AJAX request to the page you're currently on.
Something like this for example :
Something like this for example :
- Code:
$(function() {
window.AJAX_TOPIC = {
poll_time : 3000,
post_then : $('.post'),
get : function() {
$.get(window.location.href, function(d) {
AJAX_TOPIC.post_now = $('.post', d);
if (AJAX_TOPIC.post_now.length > AJAX_TOPIC.post_then.length) {
AJAX_TOPIC.post_then.last().after(AJAX_TOPIC.post_now.slice(AJAX_TOPIC.post_now.length, AJAX_TOPIC.post_then.length));
AJAX_TOPIC.post_then = AJAX_TOPIC.post_now;
}
});
}
};
AJAX_TOPIC.poll = window.setInterval(AJAX_TOPIC.get, AJAX_TOPIC.poll_time);
'par ange tuteur';
});
What I mean by array, is creating an element array of the posts on the page. Calling
in jQuery automatically returns an element array of all the elements that match your selector query. Same with
which is a native function of javascript. For example, this will return all posts in a topic and caches them to a variable :
Running the above in the console will return this element array :
Which is three posts at the time I was typing this message.
Now since you cached the posts to a variable you'll be able to determine how many posts are on the page by writing
, which would return 3 in my case. After that you just need to use AJAX to get the new posts and make a comparison like this for example :
|
|
- Code:
var current_posts = $('.post');
Running the above in the console will return this element array :
Which is three posts at the time I was typing this message.
Now since you cached the posts to a variable you'll be able to determine how many posts are on the page by writing
|
- Code:
if (current_posts.length < new_posts.length) {
// update the topic and current_posts variable
}
- GuestGuest
*** This topic will be closed soon if we don't get any feedback. @Michael_vx Is this solved / still needed? ***
is there a general way
Object { length: 0, prevObject: Object, context: HTMLDocument → t7-topic, selector: "SELECTOR" }
this what i get
also if this worked in my testing forum it might not work with the ther users
if not possible
then just forget about it
Object { length: 0, prevObject: Object, context: HTMLDocument → t7-topic, selector: "SELECTOR" }
this what i get
also if this worked in my testing forum it might not work with the ther users
if not possible
then just forget about it
@Michael_vx I took a look over my example script and I noticed it was a bit incorrect. Try adding this script with placement in the topics :
- Code:
$(function() {
window.AJAX_TOPIC = {
poll_time : 3000,
post_then : $('.post'),
get : function() {
$.get(window.location.href, function(d) {
AJAX_TOPIC.post_now = $('.post', d);
if (AJAX_TOPIC.post_now.length > AJAX_TOPIC.post_then.length) {
AJAX_TOPIC.post_then.last().after(AJAX_TOPIC.post_now.slice(AJAX_TOPIC.post_then.length, AJAX_TOPIC.post_now.length));
AJAX_TOPIC.post_then = $('.post');
}
});
}
};
AJAX_TOPIC.poll = window.setInterval(AJAX_TOPIC.get, AJAX_TOPIC.poll_time);
'par ange tuteur';
});
wow
tested on phpbb3
working like a charm
phpbb2
not working
punbb
working like a charm
invision
working like a charm
most users use phpbb2
but some how phpbb2 looks a bit stupid in Scripts like that
i used 1000 instead of 3000 the reply appear in real time just like facebook LOL
tested on phpbb3
working like a charm
phpbb2
not working
punbb
working like a charm
invision
working like a charm
most users use phpbb2
but some how phpbb2 looks a bit stupid in Scripts like that
i used 1000 instead of 3000 the reply appear in real time just like facebook LOL
- GuestGuest
@Michael_vx, was that latest answer given by Ange helpful to you? Can we close this case now?
yes its working fine
ill just look in my old files to find the tags of
punbb and invision
i remarked the topic so you can close it
i also apologize for not marking solved topic
my head a little huzzy these days
since a few things one of them is i saw pic of someone broke my heart before on fb that made me remember all old times when i was in love with her
then my forum was almost lost but i fixed that
and some fights with my older brother
ill just look in my old files to find the tags of
punbb and invision
i remarked the topic so you can close it
i also apologize for not marking solved topic
my head a little huzzy these days
since a few things one of them is i saw pic of someone broke my heart before on fb that made me remember all old times when i was in love with her
then my forum was almost lost but i fixed that
and some fights with my older brother
@Michael_vx ah yes, I forgot to mention that it only updates the comments on the current page. Try this and see if it works regardless of your current page :
- Code:
$(function() {
window.AJAX_TOPIC = {
poll_time : 3000,
post_then : $('.post'),
get : function() {
$.get(window.location.href + '?view=newest', function(d) {
AJAX_TOPIC.post_now = $('.post', d);
if (AJAX_TOPIC.post_now.length > AJAX_TOPIC.post_then.length) {
AJAX_TOPIC.post_then.last().after(AJAX_TOPIC.post_now.slice(AJAX_TOPIC.post_then.length, AJAX_TOPIC.post_now.length));
AJAX_TOPIC.post_then = $('.post');
}
});
}
};
AJAX_TOPIC.poll = window.setInterval(AJAX_TOPIC.get, AJAX_TOPIC.poll_time);
'par ange tuteur';
});
im not sure right now
i have just used my internet speed is dropped to 256KB/s till 4th of the next month
any way
the multi pages still same
drop it for later
i think its would be good if we look into more better Scripts then this one
i have just used my internet speed is dropped to 256KB/s till 4th of the next month
any way
the multi pages still same
drop it for later
i think its would be good if we look into more better Scripts then this one
@Michael_vx oops, give it one more try :
I used window.location.href instead of window.location.pathname. href includes everything ; hash and queries included, so it may have voided the query that I added : ?view=newest. It checks for the newest post. For example this link, links to the first page in the topic, but will display the most recent post :
https://fmdesign.forumotion.com/t120-chit-chat-thread?view=newest
- Code:
$(function() {
window.AJAX_TOPIC = {
poll_time : 3000,
post_then : $('.post'),
get : function() {
$.get(window.location.pathname + '?view=newest', function(d) {
AJAX_TOPIC.post_now = $('.post', d);
if (AJAX_TOPIC.post_now.length > AJAX_TOPIC.post_then.length) {
AJAX_TOPIC.post_then.last().after(AJAX_TOPIC.post_now.slice(AJAX_TOPIC.post_then.length, AJAX_TOPIC.post_now.length));
AJAX_TOPIC.post_then = $('.post');
}
});
}
};
AJAX_TOPIC.poll = window.setInterval(AJAX_TOPIC.get, AJAX_TOPIC.poll_time);
'par ange tuteur';
});
I used window.location.href instead of window.location.pathname. href includes everything ; hash and queries included, so it may have voided the query that I added : ?view=newest. It checks for the newest post. For example this link, links to the first page in the topic, but will display the most recent post :
https://fmdesign.forumotion.com/t120-chit-chat-thread?view=newest
Oh right, you're correct. I didn't consider that the posts on the page you're currently on, would be lesser than the posts on the most recent page.. The stock script only works on the currently page, unfortunately.
- Sponsored content
Similar topics
Create an account or log in to leave a reply
You need to be a member in order to leave a reply.
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum