Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <!--
- To use this:
- 1. Copy this entire HTML file from the "<html>" to the "</html>" (including both of these tags) and save it to a directory on the computer which will used at the Timekeeper's table.
- 2. Download the http://www.firstinspires.org/sites/default/files/uploads/rightimage/ftc-2016-post-kickoff-promo.jpg image and save it to the same directory.
- 3. Open a new browser window (IE or Chrome, not Firefox) and drag and drop the HTML file into it. IE may show you a button prompting you to 'Allow blocked content", which you should click.
- 4. Follow the instructions on the bottom of the page which opens.
- -->
- <head>
- <title>Particle Counter</title>
- </head>
- <body onkeypress="handleKeyPress(event)" onload="initialize();">
- <table border="1">
- <tr>
- <th colspan="2" style="color:blue">Blue</th>
- <th rowspan="2"><img src="ftc-2016-post-kickoff-promo.jpg" " width="100px" height="79px" /></th>
- <th colspan="2" style="color:red">Red</th>
- </tr>
- <tr>
- <th>Corner (;)</th>
- <th>Center (j)</th>
- <th>Center (f)</th>
- <th>Corner (a)</th>
- </tr>
- <tr>
- <td style="color: blue; text-align: center;" id="blue_corner" />
- <td style="color: blue; text-align: center;" id="blue_center" />
- <td width="100%" style="text-align: center;">Particles Scored</td>
- <td style="color: red; text-align: center;" id="red_center" />
- <td style="color: red; text-align: center;" id="red_corner" />
- </tr>
- <tr id="non_particle">
- <td colspan="2" style="background-color: cyan; text-align: center;"><input type="text" id="blue_other_auto" /></td>
- <td colspan="1" style="text-align: center" width="100%">Non-Particle Autonomous Points</td>
- <td colspan="2" style="background-color: lightpink; text-align: center;"><input type="text" id="red_other_auto" /></td>
- </tr>
- <tr height="45px">
- <td colspan="2" style="color: blue; text-align: center;"id="blue_score" /></td>
- <td colspan="1" style="text-align: center">Total Points Excluding Penalties and End Game</td>
- <td colspan="2" style="color: red; text-align: center;" id="red_score" /></td>
- </tr>
- </table>
- <div id='radio_buttons'>
- <input type="radio" name="mode" value="auto" id="auto" checked />
- <label for="auto">Autonomous</label>
- <input type="radio" name="mode" value="teleop" id="teleop" onchange="saveAutoValues();"></input>
- <label for="teleop" title="Click this after you have updated the non-Particle Autonomous Points">Driver-Controlled</label>
- </div>
- <table>
- <tr>
- <td><input type="button" onclick="startAutonomous();" value="Start Autonomous Period" id="start_auto"/></td>
- <td width="100%"><input type="button" onclick="startTeleop();" value="Start Driver-Controlled Period" id="start_teleop" /></td>
- <td align="right"><input type="button" onclick="skipAutonomous();" value="Skip Autonomous Period" id="skip_auto"/></td>
- </tr>
- </table>
- <input type="reset" onclick="resetAll();" title="Are you sure? This is your only warning." id='reset_all'/>
- <span style="text-align: center;" id="timer_div"></span>
- <br>
- <!-- This warns of invalid key presses --><p id="demo1" />
- <div id='ex'>
- <h3 onclick='document.getElementById("ex").style.visibility="hidden"'>Explanation (click to hide, refresh to show)</h3>
- <p id="explanation">
- This program is designed to use the keyboard to allow the Referees to show the live count of Particles scored and the Match Score (excluding penalties and End-Game points). To use this program:
- <ol>
- <li>Familiarize yourself with the table above and note the keys shown in the table in parentheses. The table is shown on a display which faces the audience, so the column for the Red Alliance is on the right; however, the program is designed to be used from the Timekeeper's table, with the Red Alliance on the user's left. In the table above, under the Alliance color is a cell which names the Vortex location and (in parentheses) the key to press when a Particle is scored in a Vortex. The keys should align from left-to-right with the locations of Vortexes on the Playing Field.</li>
- <li>Press the "Start Autonomous Period" button. The timer will begin counting down. If no team has an autonomous program, press the "Skip Autonomous Period" button and go to step 6.</li>
- <li>When a Particle is scored in Autonomous, press the key on the keyboard corresponding to the Vortex; the score will update. If you press a key that's not a digit or one shown in the table, a message will appear on the screen: "Ignored key with Unicode value of: ..."</li>
- <li>When the Autonomous Period is over, a "Non-Particle Autonomous Points" row will appear in the table. Add up the score each Allliance earned from the Beacons (0 or 30 points per Beacon), Cap Ball locations (0 or 5 points), and Robot locations (0, 5 or 10 points per Robot), and enter the score in the text boxes for the appropriate Alliance.</li>
- <li>When all the values are entered, press the "Driver-Controlled" radio button to save the values. The row which was just created will disappear.</li>
- <li>Press the "Start Driver-Controlled Period" button and again press the key on the keyboard corresponding to the Vortex where a Particle was scored.</li>
- <li>After each Match, click the "Reset" button to prepare for the next Match. To reset while the Timer is running, refresh the browser - this will pause the timer and when you confirm, all data will be erased.</li>
- <li>After you are familiar with these instructions, click the Explanation heading to hide them -- you can bring them back by refreshing the browser. You might also want to change the size of the text by pressing Ctrl-plus or Ctrl-minus.</li>
- </ol>
- <br>
- Note that the keys are 'live' even when the timer is <em>not</em> running! This is so that Particles can be counted after the Match ends.
- </p>
- </div>
- <script>
- var iCornerAuto=5 ;
- var iCornerTeleop=1;
- var iCenterAuto=15;
- var iCenterTeleop=5;
- /* ASCII codes */
- var A=97;
- var F=102;
- var J=106;
- var SEMICOLON=59;
- var iCount=0, iBlueCorner=0, iBlueCenter=0, iRedCorner=0, iRedCenter=0, iBlueScore=0, iRedScore=0, iBlueOtherAuto=0, iRedOtherAuto=0;
- function skipAutonomous()
- {
- saveAutoValues();
- }
- function saveAutoValues()
- {
- iBlueOtherAuto = parseInt(document.getElementById('blue_other_auto').value, 10);
- iRedOtherAuto = parseInt(document.getElementById('red_other_auto').value, 10);
- iBlueScore += iBlueOtherAuto;
- iRedScore += iRedOtherAuto;
- document.getElementById('auto').disabled = 'true';
- document.getElementById('teleop').disabled = 'true';
- document.getElementById('auto').checked = 'false';
- document.getElementById('teleop').checked = 'true';
- document.getElementById('blue_other_auto').disabled = true;
- document.getElementById('red_other_auto').disabled = true;
- document.getElementById('start_auto').style.display = 'none';
- document.getElementById('start_teleop').style.display = 'block';
- document.getElementById('skip_auto').style.display = 'none';
- document.getElementById("timer_div").innerHTML = '<div style="font-size: xx-large;">2:00</div>';
- document.getElementById('non_particle').style.display = 'none';
- document.getElementById('reset_all').style.display = 'none';
- updateAll();
- }
- function handleKeyPress(event)
- {
- iCount++;
- var x = event.keyCode;
- var mode = document.querySelector('input[name = "mode"]:checked').value;
- var iCornerIncrement = 0;
- var iCenterIncrement = 0;
- var keyDescription = '';
- if (mode == 'auto')
- {
- iCenterIncrement = iCenterAuto;
- iCornerIncrement = iCornerAuto;
- }
- else
- {
- iCenterIncrement = iCenterTeleop;
- iCornerIncrement = iCornerTeleop;
- }
- if (x >= 48 && x <= 57)
- { // number was pressed - probably in the not-particle boxes
- iBlueOtherAuto = parseInt(document.getElementById('blue_other_auto').value, 10);
- iRedOtherAuto = parseInt(document.getElementById('red_other_auto').value, 10);
- }
- else
- {
- switch (x)
- {
- case SEMICOLON:
- iBlueCorner++;
- iBlueScore += iCornerIncrement;
- break;
- case J:
- iBlueCenter++;
- iBlueScore += iCenterIncrement;
- break;
- case F:
- iRedCenter++;
- iRedScore += iCenterIncrement;
- break;
- case A:
- iRedCorner++;
- iRedScore += iCornerIncrement;
- break;
- default:
- document.getElementById("demo1").innerHTML = "Ignored key with Unicode value of: " + x + " in mode: " + mode;
- break;
- }
- //document.getElementById("demo1").innerHTML = "The Unicode value is: " + x + "---" + mode + '---' + keyDescription;
- updateAll();
- }
- }
- function updateAll()
- {
- //document.getElementById("total_count").innerHTML = iCount;
- document.getElementById("blue_corner").innerHTML = iBlueCorner;
- document.getElementById("blue_center").innerHTML = iBlueCenter;
- document.getElementById("red_corner").innerHTML = iRedCorner;
- document.getElementById("red_center").innerHTML = iRedCenter;
- // Bold the leading alliance's score
- if (iBlueScore > iRedScore)
- {
- document.getElementById("blue_score").innerHTML = '<b>' + iBlueScore + '</b>';
- document.getElementById("red_score").innerHTML = iRedScore;
- }
- else if (iBlueScore < iRedScore)
- {
- document.getElementById("blue_score").innerHTML = iBlueScore;
- document.getElementById("red_score").innerHTML = '<b>' + iRedScore + '</b>';
- }
- else
- {
- document.getElementById("blue_score").innerHTML = iBlueScore;
- document.getElementById("red_score").innerHTML = iRedScore;
- }
- }
- function resetAll()
- {
- iCount = iBlueCorner = iBlueCenter = iRedCorner = iRedCenter = iBlueScore = iRedScore = iBlueOtherAuto = iRedOtherAuto = 0;
- // t1.value = '';
- updateAll();
- document.getElementById('auto').disabled = true;
- document.getElementById('teleop').disabled = true;
- document.getElementById('auto').checked = true;
- document.getElementById('teleop').checked = false;
- document.getElementById('radio_buttons').style.display = 'block';
- document.getElementById("red_other_auto").value = document.getElementById("blue_other_auto").value = 0;
- document.getElementById('blue_other_auto').disabled = true;
- document.getElementById('red_other_auto').disabled = true;
- document.getElementById("demo1").innerHTML = '';
- document.getElementById('blue_other_auto').disabled = true;
- document.getElementById('red_other_auto').disabled = true;
- document.getElementById("timer_div").innerHTML = '<div style="font-size: xx-large;">30</div>';
- document.getElementById('start_auto').style.display = 'block';
- document.getElementById('start_teleop').style.display = 'none';
- document.getElementById('skip_auto').style.display = 'block';
- document.getElementById('non_particle').style.display = 'none';
- }
- function initialize()
- {
- resetAll();
- }
- function startAutonomous()
- {
- var seconds_left = 30; //FIXME should be 30
- document.getElementById('start_auto').style.display = 'none';
- document.getElementById('skip_auto').style.display = 'none';
- document.getElementById('reset_all').style.display = 'none';
- // TODO: play starting sound
- var interval = setInterval(function() {
- document.getElementById('timer_div').innerHTML = "<div style='font-size: xx-large;'>" + --seconds_left + "</div>";
- if (seconds_left <= 0)
- {
- //TODO: Play ending sound (wah-wah)
- document.getElementById('timer_div').innerHTML = 'Autonomous Period Over!';
- clearInterval(interval);
- document.getElementById('blue_other_auto').disabled = false;
- document.getElementById('red_other_auto').disabled = false;
- document.getElementById('teleop').disabled = false;
- document.getElementById('non_particle').style.display = 'table-row';
- }
- }, 1000);
- }
- function formatTime(iTime) /* Returns properly-formatted time, up to 179 seconds */
- {
- var strFormatted;
- var minutes;
- if (iTime > 119)
- {
- minutes = 2;
- }
- else if (iTime > 59)
- {
- minutes = 1;
- }
- else
- {
- minutes = 0;
- }
- var seconds = iTime % 60;
- if (seconds < 10)
- {
- return minutes + ":0" + seconds;
- }
- else
- {
- return minutes + ":" + seconds;
- }
- }
- function startTeleop()
- {
- document.getElementById('start_teleop').style.display = 'none';
- document.getElementById('radio_buttons').style.display = 'none';
- document.getElementById('reset_all').style.display = 'none';
- // TODO: play starting sound
- var seconds_left = 120; //FIXME should be 120; can set to lower values for debugging
- var interval = setInterval(function()
- {
- seconds_left-- ;
- var formattedTime = formatTime(seconds_left);
- if (seconds_left > 59)
- {
- document.getElementById('timer_div').innerHTML = '<div style="font-size: xx-large;">' + formattedTime + '</div>';
- }
- else
- {
- document.getElementById('timer_div').innerHTML = '<div style="font-size: xx-large;">' + formattedTime + '</div>';
- }
- if (seconds_left == 30)
- {
- //TODO: Play end-game whistle
- }
- if (seconds_left <= 30)
- {
- document.getElementById('timer_div').innerHTML = '<div style="color: red; font-weight: bold; text-align: center;">End Game! </div><div style="font-size: xx-large; text-align: center; color:red; font-weight: bold;">' + seconds_left + '</div>';
- }
- if (seconds_left <= 0)
- {
- //Play ending sound (wah-wah)
- document.getElementById('timer_div').innerHTML = '<div style="color: purple;font-size: xx-large; text-align: center;">Match Over!</div>';
- document.getElementById('reset_all').style.display = 'block';
- clearInterval(interval);
- }
- }, 1000);
- }
- window.addEventListener("beforeunload", function (e)
- {
- var confirmationMessage = 'Are you sure you want to leave? Nothing will be saved. ';
- (e || window.event).returnValue = confirmationMessage; //Gecko + IE
- return confirmationMessage; //Gecko + Webkit, Safari, Chrome etc.
- });
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment