-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix attachSelectToSendableChooser function to set the selected value
- Also add an example page that shows how to use it
- Loading branch information
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
</head> | ||
<body> | ||
|
||
<!-- This starts the NetworkTables websocket, it can be accessed from multiple | ||
pages simultaneously --> | ||
<script src="/networktables/networktables.js"></script> | ||
|
||
<!-- Obviously, you will want to copy this file locally in a real | ||
dashboard, as the Driver Station won't have internet access --> | ||
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.14/d3.min.js"></script> | ||
|
||
<!-- utility functions to attach to a sendable chooser --> | ||
<script src="/networktables/utils.js"></script> | ||
|
||
<div> | ||
Robot: <span id="robotstate">Unknown state</span> | ||
</div> | ||
|
||
Autonomous: <select id="autonomous"></select> | ||
|
||
<script type="text/javascript"> | ||
"use strict"; | ||
|
||
function onRobotConnection(connected) { | ||
$('#robotstate').text(connected ? "Connected!" : "Disconnected"); | ||
} | ||
|
||
$(document).ready(function(){ | ||
// sets a function that will be called when the robot connects/disconnects | ||
NetworkTables.addRobotConnectionListener(onRobotConnection, true); | ||
|
||
// attaches the select element to a SendableChooser object | ||
attachSelectToSendableChooser("#autonomous", "Autonomous Mode"); | ||
}); | ||
|
||
|
||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters