Skip to content

Commit

Permalink
Added Counter next to buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
cpapplefamily committed Jun 9, 2024
1 parent 5c61150 commit 0c65a4a
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 30 deletions.
8 changes: 8 additions & 0 deletions static/js/scoring_panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ const handleRealtimeScore = function(data) {
$("#amplificationActive").attr("data-value", realtimeScore.AmplifiedTimePostWindow);
$("#amplificationActive").css("background-color", !(realtimeScore.AmplifiedTimeRemainingSec > 0) && realtimeScore.AmplifiedTimePostWindow? "yellow" : "");
$("#amplificationActive").css("color", !(realtimeScore.AmplifiedTimeRemainingSec > 0) && realtimeScore.AmplifiedTimePostWindow ? "black" : "");

$("#autoSpeakerNotes").text(score.AmpSpeaker.AutoSpeakerNotes);
$("#autoSpeakerNotes").text(score.AmpSpeaker.AutoSpeakerNotes);
$("#teleopAmplifiedSpeakerNotes").text(score.AmpSpeaker.TeleopAmplifiedSpeakerNotes);
$("#teleopUnamplifiedSpeakerNotes").text(score.AmpSpeaker.TeleopUnamplifiedSpeakerNotes);
$("#autoAmpNotes").text(score.AmpSpeaker.AutoAmpNotes);
$("#teleopAmpNotes").text(score.AmpSpeaker.TeleopAmpNotes);
$("#bankedAmpNotes").text(score.AmpSpeaker.BankedAmpNotes);
};

// Handles an element click and sends the appropriate websocket message.
Expand Down
24 changes: 15 additions & 9 deletions templates/scoring_panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@

<div id="elements">
<div class="goal-header" >Speaker
{{template "goaladd" dict "plus" "S" }}
{{template "2goal" dict "btn1" "O" "icon1" "Auto+" "btn2" "P" "icon2" "Auto-"}}
{{template "2goal" dict "btn1" "K" "icon1" "Amped+" "btn2" "L" "icon2" "Amped-"}}
{{template "2goal" dict "btn1" "k" "icon1" "Teliop+" "btn2" "l" "icon2" "Teliop-"}}
{{template "goaladd" dict "plus" "S" "icon1" "Auto+"}}
{{template "2goal" dict "btn1" "O" "icon1" "Auto+" "btn2" "o" "icon2" "Auto-" "count" "autoSpeakerNotes"}}
{{template "2goal" dict "btn1" "P" "icon1" "Amped+" "btn2" "p" "icon2" "Amped-" "count" "teleopAmplifiedSpeakerNotes"}}
{{template "2goal" dict "btn1" "I" "icon1" "Teliop+" "btn2" "i" "icon2" "Teliop-" "count" "teleopUnamplifiedSpeakerNotes"}}
</div>
<div class="goal-header">AMP
{{template "goaladd" dict "plus" "A" }}
{{template "2goal" dict "btn1" "U" "icon1" "Amped+" "btn2" "I" "icon2" "Amped-"}}
{{template "2goal" dict "btn1" "u" "icon1" "Teliop+" "btn2" "i" "icon2" "Teliop-"}}
{{template "goaladd" dict "plus" "A" "icon1" "Sensor"}}
{{template "2goal" dict "btn1" "U" "icon1" "Amped+" "btn2" "u" "icon2" "Amped-" "count" "autoAmpNotes"}}
{{template "2goal" dict "btn1" "Y" "icon1" "Teliop+" "btn2" "y" "icon2" "Teliop-" "count" "teleopAmpNotes"}}
{{template "2goal" dict "btn1" "B" "icon1" "bank+" "btn2" "b" "icon2" "bank-" "count" "bankedAmpNotes"}}
</div>
<div class="goal-header">Coop Button
<div id="coopertitionStatus" class="boolean robot-field" onclick="handleClick('coopButton');">
Expand Down Expand Up @@ -126,7 +127,9 @@
<div class="goal">
<div class="number-button plus" onclick="handleClick('{{.plus}}');">
<div class="shortcut">{{.plus}}</div>
Sensor
<div class="icon">
{{.icon1}}
</div>
<div class="shortcut" style="opacity: 0;">{{.plus}}</div>
</div>
</div>
Expand All @@ -135,7 +138,9 @@
<div class="goal">
<div class="number-button minus" onclick="handleClick('{{.minus}}');">
<div class="shortcut">{{.minus}}</div>
-
<div class="icon">
{{.icon1}}
</div>
<div class="shortcut" style="opacity: 0;">{{.minus}}</div>
</div>
</div>
Expand All @@ -152,6 +157,7 @@
</div>
<div class="shortcut" style="opacity: 0;">{{.btn1}}</div>
</div>
<div id={{.count}}></div>
<div class="number-button btn2" onclick="handleClick('{{.btn2}}');">
<div class="shortcut">{{.btn2}}</div>
<div class="icon">
Expand Down
64 changes: 43 additions & 21 deletions web/scoring_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,25 +174,31 @@ func (web *Web) scoringPanelWebsocketHandler(w http.ResponseWriter, r *http.Requ
score.AmpSpeaker.AutoSpeakerNotes = score.AmpSpeaker.AutoSpeakerNotes+1
log.Printf("O Pressed")
scoreChanged = true
case "P":
score.AmpSpeaker.AutoSpeakerNotes = score.AmpSpeaker.AutoSpeakerNotes-1
log.Printf("P Pressed")
case "o":
if score.AmpSpeaker.AutoSpeakerNotes > 0 {
score.AmpSpeaker.AutoSpeakerNotes = score.AmpSpeaker.AutoSpeakerNotes-1
}
log.Printf("o Pressed")
scoreChanged = true
case "K":
case "P":
score.AmpSpeaker.TeleopAmplifiedSpeakerNotes = score.AmpSpeaker.TeleopAmplifiedSpeakerNotes+1
log.Printf("K Pressed")
log.Printf("P Pressed")
scoreChanged = true
case "L":
score.AmpSpeaker.TeleopAmplifiedSpeakerNotes = score.AmpSpeaker.TeleopAmplifiedSpeakerNotes-1
log.Printf("L Pressed")
case "p":
if score.AmpSpeaker.TeleopAmplifiedSpeakerNotes > 0{
score.AmpSpeaker.TeleopAmplifiedSpeakerNotes = score.AmpSpeaker.TeleopAmplifiedSpeakerNotes-1
}
log.Printf("p Pressed")
scoreChanged = true
case "k":
case "I":
score.AmpSpeaker.TeleopUnamplifiedSpeakerNotes = score.AmpSpeaker.TeleopUnamplifiedSpeakerNotes+1
log.Printf("k Pressed")
log.Printf("I Pressed")
scoreChanged = true
case "l":
score.AmpSpeaker.TeleopUnamplifiedSpeakerNotes = score.AmpSpeaker.TeleopUnamplifiedSpeakerNotes-1
log.Printf("l Pressed")
case "i":
if score.AmpSpeaker.TeleopUnamplifiedSpeakerNotes > 0{
score.AmpSpeaker.TeleopUnamplifiedSpeakerNotes = score.AmpSpeaker.TeleopUnamplifiedSpeakerNotes-1
}
log.Printf("i Pressed")
scoreChanged = true
case "A":
var _matchStartTime = web.arena.MatchStartTime
Expand All @@ -217,17 +223,33 @@ func (web *Web) scoringPanelWebsocketHandler(w http.ResponseWriter, r *http.Requ
score.AmpSpeaker.AutoAmpNotes = score.AmpSpeaker.AutoAmpNotes+1
log.Printf("U Pressed")
scoreChanged = true
case "I":
score.AmpSpeaker.AutoAmpNotes = score.AmpSpeaker.AutoAmpNotes-1
log.Printf("I Pressed")
scoreChanged = true
case "u":
score.AmpSpeaker.TeleopAmpNotes = score.AmpSpeaker.TeleopAmpNotes+1
if score.AmpSpeaker.AutoAmpNotes > 0 {
score.AmpSpeaker.AutoAmpNotes = score.AmpSpeaker.AutoAmpNotes-1
}
log.Printf("u Pressed")
scoreChanged = true
case "i":
score.AmpSpeaker.TeleopAmpNotes = score.AmpSpeaker.TeleopAmpNotes-1
log.Printf("i Pressed")
case "Y":
score.AmpSpeaker.TeleopAmpNotes = score.AmpSpeaker.TeleopAmpNotes+1
log.Printf("Y Pressed")
scoreChanged = true
case "y":
if score.AmpSpeaker.TeleopAmpNotes > 0 {
score.AmpSpeaker.TeleopAmpNotes = score.AmpSpeaker.TeleopAmpNotes-1
}
log.Printf("y Pressed")
scoreChanged = true
case "B":
if score.AmpSpeaker.BankedAmpNotes < 2{
score.AmpSpeaker.BankedAmpNotes = score.AmpSpeaker.BankedAmpNotes+1
}
log.Printf("B Pressed")
scoreChanged = true
case "b":
if score.AmpSpeaker.BankedAmpNotes > 0 {
score.AmpSpeaker.BankedAmpNotes = score.AmpSpeaker.BankedAmpNotes-1
}
log.Printf("b Pressed")
scoreChanged = true
case "amplifyButton":
var _matchStartTime = web.arena.MatchStartTime
Expand Down

0 comments on commit 0c65a4a

Please sign in to comment.