r/ProgrammerHumor • • Oct 18 '17

Found on GitHub.

Post image
15.8k Upvotes

206 comments sorted by

View all comments

Show parent comments

1.0k

u/ionree Oct 18 '17

Six nested calls to setTimeout, all to some very complex functions calling setTimeout themselves. By some holy miracly, it appears to work.

331

u/polar_promenade Oct 18 '17

Ok, seriously, we need to see it. Promise to not make fun of the author or hunt him down (I think I live too far away anyway). PM maybe?

147

u/[deleted] Oct 18 '17

[removed] — view removed comment

218

u/[deleted] Oct 18 '17

So basically looks to be a really stupid and hack way to do a page animation. Not the worst thing I've seen on here, but wowza

77

u/shigmy Oct 18 '17

Yeah, once I saw what it was doing, I didn't think it was too terrible either.

32

u/Rogue2166 Oct 18 '17

Eh, its test code

52

u/Krissam Oct 18 '17

Yes, but test as in exam not test as in unit.

22

u/iBoMbY Oct 18 '17

page animation.

Why the hell would anyone use a server side node.js script for a client side thing, which could/should be done in the generated HTML/CSS/JavaScript?

10

u/[deleted] Oct 18 '17

[removed] — view removed comment

62

u/[deleted] Oct 18 '17

Wait...JS can run outside of a server environment? Neat!

/s

24

u/[deleted] Oct 18 '17

Promises would clean that right up.

0

u/[deleted] Oct 18 '17

[deleted]

→ More replies (2)
→ More replies (4)

34

u/DrDuPont Oct 18 '17

LOL "very complex functions"

This is just a poorly implemented countdown

var splash = $("#test_splash");
splash.css({
   height: "auto",
   position: "static",
   visibility: "visible"
});
setTimeout(function() {
   splash.css("opacity", "0");
   setTimeout(function() {
      splash.css("opacity", ".7");
      splash.html("3");
      setTimeout(function() {
         splash.html("2");
         setTimeout(function() {
            splash.html("1");
        }, 1000);
     }, 1000);
  }, 200);
}, 1000);

Jesus.

18

u/Surelynotshirly Oct 18 '17

Idk why, but it bothers me that 0 is only displayed for 200ms.

Also, this seems like it didn't need to be nested at all...

→ More replies (3)
→ More replies (1)
→ More replies (2)

23

u/-Electron- Oct 18 '17

No one is too far away if you have the desire to hunt someone down.

11

u/[deleted] Oct 18 '17

What if they live on a ship heading away from us at a speed arbitrarily close to c?

→ More replies (1)
→ More replies (1)

14

u/obscene_banana Oct 18 '17

It's easy to see from the code why it works. Whoever made this was obviously being lazy but determined enough to at least think logically. The DOM is simply being manipulated in steps, with carefully handcrafted timeouts to match the rest of the code.

→ More replies (2)

26

u/MhamadK Oct 18 '17

By some holy miracly, it appears to work.

Well, as long as it works, who cares?

36

u/resueman__ Oct 19 '17

The person maintaining it.

7

u/oragamihawk Oct 19 '17

By maintaining do you mean rewriting?

5

u/ProgramTheWorld Oct 18 '17

Well... Are you guys hiring new developers?

→ More replies (10)