• (nodebb)

    You wait time is frist minutes.

  • Officer Johnny Holzkopf (unregistered) in reply to nerd4sale

    I waited 0 hour and secnod minutes. Erm, snecod minute.

  • (nodebb)
    if (minutes === thrid) { waitTime = "Your wait time is 12 quatloon"); }
    
  • (nodebb)

    Isn't x = parseInt(12, 10) the same as x = 12?

  • Darren (unregistered) in reply to jeremypnet

    That's what I thought. I looked up the 'parseInt' function and from my reading the 'minutes' value will always be 12.

  • Vera (unregistered)

    "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.

  • Smithers (unregistered)

    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.

    because who cares about pluralization?

    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 the else 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.

  • Pag (unregistered)

    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.

  • (nodebb) in reply to Smithers

    Just beat me to it.

    Note the line var minutes = parseInt( 12 , 10);. This is rendered from the backend, which is of course my least favorite way to send data from the server side to the client side.

    If you replace all of the instances of 12 and 0 with what the values would be if minutes was in the range checked by the if, the code makes more sense. It's still a major WTF, but at least it isn't just plain completely insane.

  • Malte (unregistered)

    The code does make sense. At this point we can reverse engineer the backend-code pretty easily. E.g. it starts with "if minutes < 2, the output is: 'Your waiting time is <minutes> minute.' " Which makes sense and pluralizes correctly.

  • (nodebb) in reply to Smithers

    TRWTF is Remy, who understood that the 12 in the parseInt() line is coming from the server, but does not recognize the same number 12 (and the 0==12/60) coming from the server inside the strings.

  • ttlanhil (unregistered)

    This is rendered from the backend, which is of course my least favorite way to send data from the server side to the client side

    least favourite common way, perhaps - I'm sure there are people out there trying to reinvent a triangular wheel of data transfer, probably to make it "more secure"

  • (author) in reply to huppenzuppen

    No, I get that, it just still makes no sense to me at all. Like sure, the "if < 2, output '12 minute'": I get that's server side rendered. I still don't understand why that's there?

  • (nodebb)

    Twelve numbers on a clock. Clocks strike four times every hour. TRWTF is not knowing what either of these things represent!

    Addendum 2026-07-07 09:58: EDIT: The other WTF is why anyone would set a variable to an arbitrary value and then test for seven possible conditions based on that value, which does not appear to change between the time it is set and the beginning of the test two lines later in the same code block.

  • Robin (unregistered)

    Almost lost in the giant pile of WTF here, is using parseInt (a function for parsing a number out of a string), on something that is always a number.

    Or, given that the main WTF is generating hardcoded JS code from some sort of server-side template (as opposed to doing it properly and just generating the correct HTML in the first place with no JS needed), perhaps that server-generated value (12 in this instance) isn't guaranteed to be purely numeric. Which would add even more WTF to the festering heap.

  • (nodebb)

    Was this coded by AI? And a terrible one at that? I don't see any other way this code could even exist.

  • GW (unregistered)

    What is going on today?! I just finished reading today's edition of The Daily Cartoonist, https://www.dailycartoonist.com/index.php/2026/07/07/csotd-the-red-menaces/ and it has a link to a video that compares "Airplane" with "Zero Hour"

  • (nodebb) in reply to sudgy

    You don't have much experience with bad programmers, do you?

  • Hmmmm (unregistered)

    Amazingly, I can agree that the code is fine (it tells you "Your estimated wait time is 12 minutes." when the minutes left are 12), and I can also agree the code is a WTF because there's some weird code-generation diarrhea going on...

  • (nodebb)

    But wait! There's more!

  • (nodebb)

    Or you could make it friendly. If the amount of minutes is 2 or less, you could say "Your wait is a couple of minutes". You could calculate the hours of it's over 60 - "your wait is about an hour" or "it's at least X hours".

    If it's between a couple of minutes and an hour you could separate it to "about half an hour" or "about 45 minutes".

    I'm not sure exact hours for waiting are terribly useful at this point - "your wait time is 37 minutes" doesn't seem very useful to me unless the wait is exactly that long.

  • mihi (unregistered) in reply to sudgy

    I'd say it is human and not AI. I know (too) many programmers who have not fully grasped the difference between client- and server-side code and would happily write code that looks a lot worse after being rendered server-side, and are happy when it works (and unhappy when it does not as you cannot code a server-side condition based on a client-side variable of course).

    I think we all agree is in this case, either do it all server side (and output just one string, with proper escaping if needed) or do it all client-side.

  • (nodebb)

    I take it by 'rendered', Remy means 'generated'. A small change in wording which makes this more comprehensible. It doesn't make it any less WTFy, but presumably the code in the server is something like

    {{
         var minutes = parseInt( {{estimate_hours * 60 + estimate_minutes}}  , 10);
          var time = document.getElementById('waitTime');
    
          if ( minutes < 2) {
            time.innerText = "Your estimated wait time is {{estimate_minutes}} minute."
          } else if (minutes < 60) {
            time.innerText = "Your estimated wait time is {{estimate_minutes}} minutes."
          } else if (minutes === 60) {
            time.innerText = "Your estimated wait time is {{estimate_hours}} hour."
          } else if (minutes < 120 && (minutes % 60 === 1)) {
            time.innerText = "Your estimated wait time is {{estimate_hours}} hour and {{estimate_minutes}} minute."
          } else if (minutes < 120) {
            time.innerText = "Your estimated wait time is {{estimate_hours}} hour and {{estimate_minutes}} minutes."
          } else if (minutes > (60 * 4)) {
            time.innerText = "Your estimated wait time is more than 4 hours."
          } else if (minutes % 60 === 0) {
            time.innerText = "Your estimated wait time is {{estimate_hours}} hours."
          } else {
            time.innerText = "Your estimated wait time is {{estimate_hours}} hours and {{estimate_minutes}} minutes."
          }
    }}
    

    And if it's like that, the way it generates is a WTF, not just what it generates

  • (nodebb) in reply to thosrtanner

    The term "rendered" is often applied to templates in web dev.

  • MaxiTB (unregistered)

    Wait times are to 99% implemented as part of dark patterns and the rest of thr time they exists to save cost. There is not technical reason, in both cases they exist to extract the maximum amount of value from the user. The best way to interact with a service like that is to block permanently the URI and never go back again :-)

  • 516052 (unregistered) in reply to MaxiTB

    Given that the purpose of a lot of software is in fact to extract the maximum amount of revenue from the user I would argue that is a very valid technical requirement.

  • (nodebb) in reply to mihi

    I'm not talking about client-side/server-side issues, I'm talking about the blatant mismatching between the numbers checked and the numbers output.

  • Malte (unregistered) in reply to Remy Porter

    That is the part that correctly pluralizes (well, singularizes, if that's a word) the min<2 case. Let's say minute is 1. Then the parseInt sets minute to 1, and this condition evaluates to true, and the output is "Your estimated wait time is 1 minute." Which is as correct as you can want it to be.

    I still consider the whole construction a WTF. If you can inject the number 12 into the strings in all these cases, you might as well build the sentence with the correct plural form. Or just shorten it to "Estimated waiting time: <hours> hours <minutes> minutes" and avoid all the language fiddling. Most users survive reading "1 minutes" even though that's slightly wrong grammar.

Leave a comment on “On Hold”

Log In or post as a guest

Replying to comment #701603:

« Return to Article