FM Design
Would you like to react to this message? Create an account in a few clicks or log in to continue.

IMPORTANT

FM Design is in read-only mode, please click here for more information.

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

Recent Tutorials
Top posting users this month

Who is online?
In total there are 12 users online :: 0 Registered, 0 Hidden and 12 Guests :: 1 Bot

None

[ View the whole list ]


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

View previous topic View next topic Go down

Michael_vx
Michael_vx

Gender : Male
Age : 32
Posts : 302
Points : 4307
Reputation : 76
Language : Arabic
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
http://miccsoft.net https://www.facebook.com/Michaelvx2008

PostMichael_vx Mon 18 Jul 2016, 21:05

is there auto topic update - refresh to see new posts with out refresh the page


Last edited by Michael_vx on Sat 27 Aug 2016, 01:08; edited 1 time in total
Ange Tuteur
Ange Tuteur
Administrator
Gender : Male
Posts : 4741
Points : 12255
Reputation : 2376
Location : Pennsylvania
Language : EN, JA, FR
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
https://sethclydesdale.github.io/ https://twitter.com/sethc1995

PostAnge Tuteur Mon 18 Jul 2016, 21:47

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 :
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';
});
It's a rough draft, so I don't know how well it'll work.
Michael_vx
Michael_vx

Gender : Male
Age : 32
Posts : 302
Points : 4307
Reputation : 76
Language : Arabic
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
http://miccsoft.net https://www.facebook.com/Michaelvx2008

PostMichael_vx Tue 19 Jul 2016, 04:42

im not sure about array of all the posts on the page
but ill do my best
thanks for now
cheers
Ange Tuteur
Ange Tuteur
Administrator
Gender : Male
Posts : 4741
Points : 12255
Reputation : 2376
Location : Pennsylvania
Language : EN, JA, FR
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
https://sethclydesdale.github.io/ https://twitter.com/sethc1995

PostAnge Tuteur Tue 19 Jul 2016, 11:21

What I mean by array, is creating an element array of the posts on the page. Calling
Code:
$('SELECTOR')
in jQuery automatically returns an element array of all the elements that match your selector query. Same with
Code:
document.querySelectorAll('SELECTOR')
which is a native function of javascript. For example, this will return all posts in a topic and caches them to a variable :
Code:
var current_posts = $('.post');

Running the above in the console will return this element array :
is there auto topic update - refresh to see new posts with out refresh the page Captur15
Which is three posts at the time I was typing this message. Razz

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:
current_posts.length
, 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:
if (current_posts.length < new_posts.length) {
  // update the topic and current_posts variable
}
Obviously new_posts is undefined since this is an example, but my script I posted earlier should show you what to do. xD
Anonymous
Guest
Guest

PostGuest Tue 23 Aug 2016, 18:05

*** This topic will be closed soon if we don't get any feedback. @Michael_vx Is this solved / still needed? ***
Michael_vx
Michael_vx

Gender : Male
Age : 32
Posts : 302
Points : 4307
Reputation : 76
Language : Arabic
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
http://miccsoft.net https://www.facebook.com/Michaelvx2008

PostMichael_vx Tue 23 Aug 2016, 21:10

im still working with the answer
cant tell yet if its solved or not
Michael_vx
Michael_vx

Gender : Male
Age : 32
Posts : 302
Points : 4307
Reputation : 76
Language : Arabic
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
http://miccsoft.net https://www.facebook.com/Michaelvx2008

PostMichael_vx Wed 24 Aug 2016, 09:39

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 Sad
if not possible
then just forget about it Sad
Ange Tuteur
Ange Tuteur
Administrator
Gender : Male
Posts : 4741
Points : 12255
Reputation : 2376
Location : Pennsylvania
Language : EN, JA, FR
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
https://sethclydesdale.github.io/ https://twitter.com/sethc1995

PostAnge Tuteur Wed 24 Aug 2016, 10:24

@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';
});
Michael_vx
Michael_vx

Gender : Male
Age : 32
Posts : 302
Points : 4307
Reputation : 76
Language : Arabic
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
http://miccsoft.net https://www.facebook.com/Michaelvx2008

PostMichael_vx Wed 24 Aug 2016, 21:51

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
Anonymous
Guest
Guest

PostGuest Thu 25 Aug 2016, 01:53

@Michael_vx, was that latest answer given by Ange helpful to you? Can we close this case now?
Ange Tuteur
Ange Tuteur
Administrator
Gender : Male
Posts : 4741
Points : 12255
Reputation : 2376
Location : Pennsylvania
Language : EN, JA, FR
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
https://sethclydesdale.github.io/ https://twitter.com/sethc1995

PostAnge Tuteur Thu 25 Aug 2016, 13:15

@Michael_vx hmm what if you change the selector
Code:
.post
to
Code:
tr.post
for phpbb2 ?
Michael_vx
Michael_vx

Gender : Male
Age : 32
Posts : 302
Points : 4307
Reputation : 76
Language : Arabic
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
http://miccsoft.net https://www.facebook.com/Michaelvx2008

PostMichael_vx Sat 27 Aug 2016, 01:13

yes its working fine
ill just look in my old files to find the tags of
punbb and invision Smile
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 Sad
then my forum was almost lost but i fixed that
and some fights with my older brother
Michael_vx
Michael_vx

Gender : Male
Age : 32
Posts : 302
Points : 4307
Reputation : 76
Language : Arabic
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
http://miccsoft.net https://www.facebook.com/Michaelvx2008

PostMichael_vx Sat 27 Aug 2016, 01:17

i forget to say
its not working with multi pages
Ange Tuteur
Ange Tuteur
Administrator
Gender : Male
Posts : 4741
Points : 12255
Reputation : 2376
Location : Pennsylvania
Language : EN, JA, FR
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
https://sethclydesdale.github.io/ https://twitter.com/sethc1995

PostAnge Tuteur Sat 27 Aug 2016, 10:44

@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';
});
Michael_vx
Michael_vx

Gender : Male
Age : 32
Posts : 302
Points : 4307
Reputation : 76
Language : Arabic
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
http://miccsoft.net https://www.facebook.com/Michaelvx2008

PostMichael_vx Sat 27 Aug 2016, 18:32

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
Thumb right
Ange Tuteur
Ange Tuteur
Administrator
Gender : Male
Posts : 4741
Points : 12255
Reputation : 2376
Location : Pennsylvania
Language : EN, JA, FR
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
https://sethclydesdale.github.io/ https://twitter.com/sethc1995

PostAnge Tuteur Sun 28 Aug 2016, 07:23

@Michael_vx oops, give it one more try :
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
Michael_vx
Michael_vx

Gender : Male
Age : 32
Posts : 302
Points : 4307
Reputation : 76
Language : Arabic
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
http://miccsoft.net https://www.facebook.com/Michaelvx2008

PostMichael_vx Sun 28 Aug 2016, 14:32

Zen
i guess its still the same im testin right now on phpbb3
Ange Tuteur
Ange Tuteur
Administrator
Gender : Male
Posts : 4741
Points : 12255
Reputation : 2376
Location : Pennsylvania
Language : EN, JA, FR
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
https://sethclydesdale.github.io/ https://twitter.com/sethc1995

PostAnge Tuteur Sun 28 Aug 2016, 15:43

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.. Face palm The stock script only works on the currently page, unfortunately.
Michael_vx
Michael_vx

Gender : Male
Age : 32
Posts : 302
Points : 4307
Reputation : 76
Language : Arabic
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
http://miccsoft.net https://www.facebook.com/Michaelvx2008

PostMichael_vx Sun 28 Aug 2016, 15:54

its okay consder it solved and archive it
who need the mutil pages any way we have more better Scripts to deal with
Ange Tuteur
Ange Tuteur
Administrator
Gender : Male
Posts : 4741
Points : 12255
Reputation : 2376
Location : Pennsylvania
Language : EN, JA, FR
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
https://sethclydesdale.github.io/ https://twitter.com/sethc1995

PostAnge Tuteur Sun 28 Aug 2016, 15:56

Haha, yes. At least it works to some degree. Wink

Anyway you're welcome. Smile

Topic archived
Sponsored content

PostSponsored content

View previous topic View next topic Back to top

Create an account or log in to leave a reply

You need to be a member in order to leave a reply.

Create an account

Join our community by creating a new account. It's easy!


Create a new account

Log in

Already have an account? No problem, log in here.


Log in

 
Permissions in this forum:
You cannot reply to topics in this forum