Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

How does 4chan's thread updater work?

Name: Anonymous 2012-10-24 2:39

How does 4chan's thread updater work?

In Futaba, their thread update function makes an XMLHttp request and reloads the new page and scrolls you back down to the spot of the screen you were viewing. However, this means that if you had any text in the form field, it'll be gone due to the reloading of the page.

However, in 4chan the form field is untouched when a thread is updated. Whatever it's doing, it seems a lot more fluid and seamless.

So how does it work, any ideas? I tried looking around the source but it's a little too zomgoptimized for me to make sense of it.

Name: Anonymous 2012-10-24 2:44

Load the page in an iframe, check for new post, insert into the DOM.

Though now it uses JSON.

Name: Anonymous 2012-10-24 3:40

One word, AJAX, thread over.

Name: Anonymous 2012-10-24 3:48

>>3
I don't know what you think AJAX means, but the use of Ajax techniques has already been established by OP.

Name: Anonymous 2012-10-24 3:57

>>1
I seriously hope that by "the source" you mean https://github.com/4chan/4chan-JS/blob/master/extension.js but your post reads dumb enough that you might not. Not that you need to read any code to guess what's it doing.

By the way and just out of curiosity, have you never visited Gmail (or any other webmail service in the last year) or Twitter or GitHub itself? Is this the first time this question pops in your head?

Name: Anonymous 2012-10-24 4:29

>>5
I am a novice trying to understand this particular function that interested me. I am sorry if my lack of expertise is very upsetting. However bad I am at programming, I'm even worse with JavaScript.

This part specifically I don't know what it's about:
    <a href="" data-cmd="update">Update</a>

I've never seen "data-cmd" before like this. I tried searching on Google, but... it doesn't lead anywhere.

Name: Anonymous 2012-10-24 4:40

>>5
>4579 line
Disgusting.

Name: Anonymous 2012-10-24 4:51

>>6
"data-cmd" is an arbitrary string, it could be anything. If you search and replace all its occurrences by the same value, the script will still work.

Again, please refer to https://github.com/4chan/4chan-JS/blob/master/extension.js

A friendly hint: the functions that actually do the updating are ThreadUpdater.update to send the request and ThreadUpdater.onload to process the server reply.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List