• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

events not always processed in correct order

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    events not always processed in correct order

    So I thought this was going to be dead simple and take me 10 minutes

    A page with 2 buttons - tells you which was pressed first (designed for using on a phone/tablet on the table where two players are sitting together buzzing in with an answer - think countdown conundrums!)

    http://topffl.co.uk/fiona/buzzer.html

    I originally just had a popup message saying which button was pressed first, but that got messy where there were very close together presses, so I'm redirecting away which works ok and does what I want, except when they are very, very close together it doesn't always get the right one first - given many of our event finalist buzzes (the current system involves tapping the table!) are filmed and played back for VAR, very close buzzes aren't unusual.

    Is there an easy fix, or shall I just bin it?

    Why won't this let me paste source code? It's dead simple - see view-source:http://topffl.co.uk/fiona/buzzer.html


    #2
    Are you issuing a redirect to the "winner" page

    That's going to be the problem because browsers won't care which redirect is the one they respond to - you need all the logic including the bit showing who won on a single page - why do you think single page apps are so popular?

    Even then I would have step 1 after the button us press being set a timestamp for player 1/2 and add a sanity check as to which value is first when displaying the winner in the case the display winner routine gets called twice...

    merely at clientco for the entertainment

    Comment


      #3
      Yeah it won't let me paste the source

      button1 event handler says redirect to winner1
      button2 event hander says redirect to winner2

      I had the same issues with it all on one page - where the buttons are pressed near simultaneously, it doesn't always process the right one first.

      Comment


        #4
        My idea is completely stupid, but that's never stopped me before:
        Option A:
        1. Create a table where there is a blank field (actually, probably don't need a table, just a variable that can be used by both buttons).
        2. Put a simple bit of logic into the button press for each team:
        Red button:
        If field = <blank> set field to "RED"
        Blue button:
        If field = <blank> set field to "BLUE

        Option B:
        1. Create a table where there are two columns, one for red, one for blue (again, probably doesn't need to be a table, but I spend too long looking at databases)
        2. Put a simple bit of logic into the button press for each team so that when the button is pressed, that team's column is updated with a date/time stamp representing when the button was pressed
        3. Compare the two values. Lowest wins.
        …Maybe we ain’t that young anymore

        Comment


          #5
          Actually that might help - have added a check if a click happened thing and it seems better...

          Edit - No, still not great.
          Last edited by mudskipper; 3 July 2024, 07:42.

          Comment


            #6
            For my birthday a few years ago, my kids recreated Richard Osman's House of Games. My son did the programming while my daughters made the buzzers/lights. The first person to press had their buzzer light up - the others would then not light up until the buzzers were reset.

            I'll ask him what logic he used.
            Down with racism. Long live miscegenation!

            Comment


              #7
              Are you running it on this website topffl? Via 4/5G? If so, latency (round-trip time) won't be helping.

              Try pinging topffl.co.uk to see how many milliseconds it takes.

              It might be better if you could run the webpage on the device (phone/tablet) itself. (But don't ask me how you do that)

              Thinking outside the box, I was also wondering if you could do something with a native application running on the device. Does Excel have buttons?

              Comment


                #8
                yeah I suspect timestamps are the way to go if you can't be sure one button press will be processed before the other but sounds like more effort than I wanted to expend

                Comment


                  #9
                  I got an answer from my son. The program polls each buzzer in turn to see if its pressed. If it is, it lights up that buzzer and cause it to buzz and tell the others to stop. It's possible for someone to press very shortly before someone else, but not get the buzz.

                  Relevant source code below.

                  Code:
                  var clicked = false;
                  function clicked1()
                    {
                      if (!clicked)
                      {
                         // disablebutton;
                         clicked = true;
                        window.location.replace("player1.html");
                      }
                  }
                  
                  function clicked2()
                  {
                    if (!clicked)
                    {
                      // disablebutton1
                      clicked = true;
                      window.location.replace("player2.html");
                    }
                  }
                  Are the players using a single smartphone between them? If that's the case, I can't understand how you'd be able to get a noticeable discrepancy. The code is running on the phone. Maybe you need to upgrade your phone.
                  Down with racism. Long live miscegenation!

                  Comment


                    #10
                    Originally posted by NotAllThere View Post
                    It's possible for someone to press very shortly before someone else, but not get the buzz.
                    Yeah this is the scenario I need to address - with the top countdown players most conundrum solves are pretty much instant. Thanks for checking!

                    Comment

                    Working...
                    X