- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
The math in the first function isn't as terrible as it seems; in other words, the biggest change that's needed is adding a comment explaining what it's doing. It's not that bad of a way to display banner 0 from 0-10, 20-30, and 40-50 seconds of the current time, and banner 1 from 10-20, 30-40, and 50-60. Even the 2 * 10 can be slightly helpful, if there's a comment saying that it's 2 banners for 10 seconds each.
The second function, though, is definitely a WTFy way to simply swap between 0 and 1.
And Frist!
Addendum 2023-01-25 07:14: I forgot to say that the business requirement for displaying the banners at those specific times is probably the bigger WTF.
Admin
So you get a different banner every 20 seconds?
Probably started way more generic.
Admin
Admin
This implementation is clearly lacking. They should handle the case of
browserType == "old"
Admin
Joke aside , those hardcoded URLs hint that there's another WTF server-side: the code has to pass requests to CGI, and the banners have an id that probably is stored in some database.
If so, then that's overkill, because stuffs like flashy ad banners are probably more of a static resource that an HTTP daemon like Nginx can serve directly from a public folder, there's probably no need to get some logic executed by PHP or whatever's behing the CGI (unless the banners are actually made of stuffs restricted to authenticated users).
By the way, isn't CGI smelling a bit "legacy" in 2023?
Admin
Yes, how on earth would the Internet Explorer 6 users browse the site otherwise?!
Admin
If IndexOf(thisComment) < (2 -1), then writeLine("Comments are broken!");
Admin
Is this JavaScript server-side generated? The first explanation that comes to mind for the repeated hard-coded
2
is that it's the length of a server-side array of image + url objects.Admin
Bonus WTF: pointless string callback to setTimeout forces an eval(). Static analysis either can't (easily) tell what's happening there.
Admin
Bonus bonus WTF: The code dynamically changes the banner itself, but not the URL behind it.
Admin
Wouldn't be at all surprised to find out that the server side was generating the page using something like "modnum = @NumberOfBanners * @TimePerBanner"
Admin
I suspect there used to be code that set
browserType
dynamically, but they removed it. But they didn't bother removing the conditional. We've got lots of legacy code like that in our codebase, too.Admin
Also my first gut reaction that the browser type "new" and the "2" are inserted into the page server-side from some variable (from looking up avalilable banners from database and browser type from User Agent sniffing). And while it is technically possible to write something like
modnum =${imageCount}0;
instead of
modnum =${imageCount} * 10;
I guess the latter is the smaller WTF. Having a section on top of the script with all the server-generated variables would have been nicer, of course.