- 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
Edit Admin
You wait time is frist minutes.
Admin
I waited 0 hour and secnod minutes. Erm, snecod minute.
Edit Admin
Edit Admin
Isn't
x = parseInt(12, 10)the same asx = 12?Admin
That's what I thought. I looked up the 'parseInt' function and from my reading the 'minutes' value will always be 12.
Admin
"12 minute" might have been intended as "1-2 minutes", which raises the question where the dash went. Eh, just add it to the mountain of questions about this piece of malware.
Admin
I think I get it. The split between client and server logic is the WTF (and the parseInt is pointless), but this does actually work.
This code does. This whole code exists for the express purpose of caring about pluralisation! Because (and I'm guessing here, but I'm fairly confident) ALL of the 12s and 0s in the text strings are rendered server-side.
So at 1 minute, it will put a 1 in all the text strings but the user only sees the
if ( minutes < 2) { time.innerText = "Your estimated wait time is 1 minute." }case, which has the correct singular. From 2 to 59 minutes you get theelse if (minutes < 60) { time.innerText = "Your estimated wait time is $n minutes." }case. At 60 minutes it will render 1 instead of 0 and you get told "1 hour."(minutes < 120 && (minutes % 60 === 1)), which could be shortened to(minutes === 61), gets "1 hour and 1 minute" and so on.Heck, the source code probably looks sane if you forget that there's a step in between executing the server-side code and the client-side.
Admin
Yes, 0 (hours) and 12 (minutes) are surely variables on the server side. It will output "1 hour", "1 hour and 1 minute", "1 hour and 2 minutes" and so on, depending on what numbers are slotted into the template.
Edit Admin
Just beat me to it.
If you replace all of the instances of
12and0with what the values would be ifminuteswas in the range checked by theif, the code makes more sense. It's still a major WTF, but at least it isn't just plain completely insane.