Fix some IDE warnings.

This commit is contained in:
Patrick Fairbank
2018-09-03 12:51:52 -07:00
parent 27c38f7393
commit 9019425a2c
16 changed files with 53 additions and 54 deletions

View File

@@ -14,7 +14,6 @@ body {
height: 100%;
background: -moz-linear-gradient(top, #003375 1%, #3C679D 100%); /* FF3.6+ */
background: -webkit-linear-gradient(top, #003375 1%, #3C679D 100%); /* Chrome10+,Safari5.1+ */
background: -webkit-linear-gradient(top, #003375 1%, #3C679D 100%); /* Chrome10+,Safari5.1+ */
background-repeat: no-repeat;
font-family: "FuturaLT";
}

View File

@@ -11,7 +11,7 @@ var websocket;
// Handles a websocket message to set which alliance station this display represents.
var handleAllianceStation = function(station) {
allianceStation = station;
}
};
// Handles a websocket message to change which screen is displayed.
var handleAllianceStationDisplayMode = function(targetScreen) {
@@ -36,14 +36,14 @@ var handleAllianceStationDisplayMode = function(targetScreen) {
// Handles a websocket message to update the team to display.
var handleMatchLoad = function(data) {
if (allianceStation != "") {
if (allianceStation !== "") {
var team = data.Teams[allianceStation];
if (team) {
$("#teamNumber").text(team.Id);
$("#teamNameText").attr("data-alliance-bg", allianceStation[0]).text(team.Nickname);
var ranking = data.Rankings[team.Id];
if (ranking && data.MatchType == "Qualification") {
if (ranking && data.MatchType === "Qualification") {
var rankingText = ranking.Rank;
$("#teamRank").attr("data-alliance-bg", allianceStation[0]).text(rankingText);
} else {
@@ -73,7 +73,7 @@ var handleArenaStatus = function(data) {
if (!blinkInterval) {
blinkInterval = setInterval(function() {
var status = $("#match").attr("data-status");
$("#match").attr("data-status", (status == "") ? allianceStation[0] : "");
$("#match").attr("data-status", (status === "") ? allianceStation[0] : "");
}, 250);
}
} else {
@@ -91,7 +91,7 @@ var handleArenaStatus = function(data) {
var handleMatchTime = function(data) {
translateMatchTime(data, function(matchState, matchStateText, countdownSec) {
var countdownString = String(countdownSec % 60);
if (countdownString.length == 1) {
if (countdownString.length === 1) {
countdownString = "0" + countdownString;
}
countdownString = Math.floor(countdownSec / 60) + ":" + countdownString;
@@ -107,7 +107,7 @@ var handleRealtimeScore = function(data) {
};
$(function() {
if (displayId == "") {
if (displayId === "") {
displayId = Math.floor(Math.random() * 10000);
window.location = "/displays/alliance_station?displayId=" + displayId;
}

View File

@@ -18,7 +18,7 @@ Handlebars.registerHelper("eachMapEntry", function(context, options) {
// Handles a websocket message to hide the score dialog once the next match is being introduced.
var handleAudienceDisplayMode = function(targetScreen) {
// Hide the final results so that they aren't blocking the current teams when the announcer needs them most.
if (targetScreen == "intro" || targetScreen == "match") {
if (targetScreen === "intro" || targetScreen === "match") {
$("#matchResult").modal("hide");
}
};
@@ -82,7 +82,7 @@ $(function() {
// Make the score blink.
setInterval(function() {
var blinkOn = $("#savedMatchResult").attr("data-blink") == "true";
var blinkOn = $("#savedMatchResult").attr("data-blink") === "true";
$("#savedMatchResult").attr("data-blink", !blinkOn);
}, 500);
});

View File

@@ -11,7 +11,7 @@ var allianceSelectionTemplate = Handlebars.compile($("#allianceSelectionTemplate
// Handles a websocket message to change which screen is displayed.
var handleAudienceDisplayMode = function(targetScreen) {
if (targetScreen == currentScreen) {
if (targetScreen === currentScreen) {
return;
}
@@ -29,12 +29,12 @@ var handleAudienceDisplayMode = function(targetScreen) {
// Handles a websocket message to update the teams for the current match.
var handleMatchLoad = function(data) {
$("#redTeam1").text(data.Match.Red1)
$("#redTeam2").text(data.Match.Red2)
$("#redTeam3").text(data.Match.Red3)
$("#blueTeam1").text(data.Match.Blue1)
$("#blueTeam2").text(data.Match.Blue2)
$("#blueTeam3").text(data.Match.Blue3)
$("#redTeam1").text(data.Match.Red1);
$("#redTeam2").text(data.Match.Red2);
$("#redTeam3").text(data.Match.Red3);
$("#blueTeam1").text(data.Match.Blue1);
$("#blueTeam2").text(data.Match.Blue2);
$("#blueTeam3").text(data.Match.Blue3);
$("#matchName").text(data.MatchName + " " + data.Match.DisplayName);
};
@@ -42,7 +42,7 @@ var handleMatchLoad = function(data) {
var handleMatchTime = function(data) {
translateMatchTime(data, function(matchState, matchStateText, countdownSec) {
var countdownString = String(countdownSec % 60);
if (countdownString.length == 1) {
if (countdownString.length === 1) {
countdownString = "0" + countdownString;
}
countdownString = Math.floor(countdownSec / 60) + ":" + countdownString;
@@ -140,7 +140,7 @@ var handleAllianceSelection = function(alliances) {
// Handles a websocket message to populate and/or show/hide a lower third.
var handleLowerThird = function(data) {
if (data.BottomText == "") {
if (data.BottomText === "") {
$("#lowerThirdTop").hide();
$("#lowerThirdBottom").hide();
$("#lowerThirdSingle").text(data.TopText);
@@ -201,7 +201,7 @@ var transitionBlankToInMatch = function(callback) {
});
});
});
}
};
var transitionInMatchToIntro = function(callback) {
$(".score-number").transition({queue: false, opacity: 0}, 300, "linear");
@@ -385,7 +385,7 @@ var initializeSponsorDisplay = function() {
$('.carousel#sponsor').carousel('pause');
t = setTimeout("$('.carousel#sponsor').carousel();", duration-1000);
})
});
$('.carousel-control.right').on('click', function(){
clearTimeout(t);
@@ -396,7 +396,7 @@ var initializeSponsorDisplay = function() {
});
});
}
};
$(function() {
// Set up the websocket back to the server.

View File

@@ -6,11 +6,11 @@
var CheesyWebsocket = function(path, events) {
var that = this;
var protocol = "ws://";
if (window.location.protocol == "https:") {
if (window.location.protocol === "https:") {
protocol = "wss://";
}
var url = protocol + window.location.hostname;
if (window.location.port != "") {
if (window.location.port !== "") {
url += ":" + window.location.port;
}
url += path;

View File

@@ -28,7 +28,7 @@ var handleArenaStatus = function(data) {
$("#status" + station + " .robot-status").text("");
}
var lowBatteryThreshold = 6;
if (matchStates[data.MatchState] == "PRE_MATCH") {
if (matchStates[data.MatchState] === "PRE_MATCH") {
lowBatteryThreshold = 12;
}
$("#status" + station + " .battery-status").attr("data-status-ok",

View File

@@ -34,7 +34,7 @@ var reorderLowerThird = function(button, moveUp) {
var constructLowerThird = function(button) {
return { Id: parseInt(button.form.id.value), TopText: button.form.topText.value,
BottomText: button.form.bottomText.value, DisplayOrder: parseInt(button.form.displayOrder.value) }
}
};
$(function() {
// Set up the websocket back to the server.

View File

@@ -73,7 +73,7 @@ var handleArenaStatus = function(data) {
$("#status" + station + " .robot-status").text("");
}
var lowBatteryThreshold = 6;
if (matchStates[data.MatchState] == "PRE_MATCH") {
if (matchStates[data.MatchState] === "PRE_MATCH") {
lowBatteryThreshold = 12;
}
$("#status" + station + " .battery-status").attr("data-status-ok",
@@ -138,7 +138,7 @@ var handleArenaStatus = function(data) {
}
$("#fieldEstop").attr("data-ready", !data.FieldEstop);
if (matchStates[data.MatchState] != "PRE_MATCH") {
if (matchStates[data.MatchState] !== "PRE_MATCH") {
$("#gameSpecificData").val(data.GameSpecificData);
}
};

View File

@@ -60,12 +60,12 @@ var renderResults = function(alliance) {
$("input[name=" + alliance + "Team" + k + "Card][value=" + v + "]").prop("checked", true);
});
}
}
};
// Converts the current form values back into JSON structures and caches them.
var updateResults = function(alliance) {
var result = allianceResults[alliance];
var formData = {}
var formData = {};
$.each($("form").serializeArray(), function(k, v) {
formData[v.name] = v.value;
});
@@ -96,15 +96,15 @@ var updateResults = function(alliance) {
$.each([result.team1, result.team2, result.team3], function(i, team) {
result.cards[team] = formData[alliance + "Team" + team + "Card"];
});
}
};
// Appends a blank foul to the end of the list.
var addFoul = function(alliance) {
updateResults(alliance);
var result = allianceResults[alliance];
result.score.Fouls.push({TeamId: 0, Rule: "", TimeInMatchSec: 0})
result.score.Fouls.push({TeamId: 0, Rule: "", TimeInMatchSec: 0});
renderResults(alliance);
}
};
// Removes the given foul from the list.
var deleteFoul = function(alliance, index) {
@@ -112,4 +112,4 @@ var deleteFoul = function(alliance, index) {
var result = allianceResults[alliance];
result.score.Fouls.splice(index, 1);
renderResults(alliance);
}
};

View File

@@ -73,7 +73,7 @@ var cycleRankings = function() {
// Updates the "Standings as of" message with the given value, or blanks it out if there is no data yet.
var setHighestPlayedMatch = function(highestPlayedMatch) {
if (highestPlayedMatch == "") {
if (highestPlayedMatch === "") {
$("#highestPlayedMatch").text("");
} else {
$("#highestPlayedMatch").text("Standings as of Qualification Match " + highestPlayedMatch);

View File

@@ -33,11 +33,11 @@ var setFoulRule = function(ruleButton) {
// Sets button styles to match the selection cached in the global variables.
var setSelections = function() {
$("[data-team]").each(function(i, teamButton) {
$(teamButton).attr("data-selected", $(teamButton).attr("data-team") == foulTeam);
$(teamButton).attr("data-selected", $(teamButton).attr("data-team") === foulTeam);
});
$("[data-rule]").each(function(i, ruleButton) {
$(ruleButton).attr("data-selected", $(ruleButton).attr("data-rule") == foulRule);
$(ruleButton).attr("data-selected", $(ruleButton).attr("data-rule") === foulRule);
});
};
@@ -58,7 +58,7 @@ var clearFoul = function() {
var commitFoul = function() {
websocket.send("addFoul", {Alliance: foulTeamButton.attr("data-alliance"),
TeamId: parseInt(foulTeamButton.attr("data-team")), Rule: foulRuleButton.attr("data-rule"),
IsTechnical: foulRuleButton.attr("data-is-technical") == "true"});
IsTechnical: foulRuleButton.attr("data-is-technical") === "true"});
};
// Removes the foul with the given parameters from the list.
@@ -70,9 +70,9 @@ var deleteFoul = function(alliance, team, rule, isTechnical, timeSec) {
// Cycles through no card, yellow card, and red card.
var cycleCard = function(cardButton) {
var newCard = "";
if ($(cardButton).attr("data-card") == "") {
if ($(cardButton).attr("data-card") === "") {
newCard = "yellow";
} else if ($(cardButton).attr("data-card") == "yellow") {
} else if ($(cardButton).attr("data-card") === "yellow") {
newCard = "red";
}
websocket.send("card", {Alliance: $(cardButton).attr("data-alliance"),

View File

@@ -49,7 +49,7 @@ var handleKeyPress = function(event) {
// Handles a websocket message to update the match status.
var handleMatchTime = function(data) {
if (matchStates[data.MatchState] == "POST_MATCH" && !scoreCommitted) {
if (matchStates[data.MatchState] === "POST_MATCH" && !scoreCommitted) {
$("#commitMatchScore").show();
} else {
$("#commitMatchScore").hide();

View File

@@ -32,7 +32,7 @@ var addBlock = function(startTime, numMatches, matchSpacingSec) {
$("#endTimePicker" + lastBlockNumber).datetimepicker({useSeconds: true}).
data("DateTimePicker").setDate(endTime);
updateBlock(lastBlockNumber);
}
};
// Updates the per-block and global schedule statistics.
var updateBlock = function(blockNumber) {
@@ -42,7 +42,7 @@ var updateBlock = function(blockNumber) {
var numMatches = Math.floor((endTime - startTime) / matchSpacingSec / 1000);
var actualEndTime = moment(startTime + numMatches * matchSpacingSec * 1000).format("hh:mm:ss A");
blockMatches[blockNumber] = numMatches;
if (matchSpacingSec == "" || isNaN(numMatches) || numMatches <= 0) {
if (matchSpacingSec === "" || isNaN(numMatches) || numMatches <= 0) {
numMatches = "";
actualEndTime = "";
blockMatches[blockNumber] = 0;
@@ -51,7 +51,7 @@ var updateBlock = function(blockNumber) {
$("#actualEndTime" + blockNumber).text(actualEndTime);
updateStats();
}
};
var updateStats = function() {
// Update total number of matches.
@@ -85,7 +85,7 @@ var generateSchedule = function() {
field.attr("name", name);
field.attr("value", value);
form.append(field);
}
};
var i = 0;
$.each(blockMatches, function(k, v) {
addField("startTime" + i, $("#startTime" + k).val());

View File

@@ -246,7 +246,7 @@
{{define "script"}}
<script src="/static/js/match_review.js"></script>
<script>
var matchId = {{.Match.Id}}
var matchId = {{.Match.Id}};
var allianceResults = {};
allianceResults["red"] = {alliance: "red", team1: {{.Match.Red1}}, team2: {{.Match.Red2}},
team3: {{.Match.Red3}}, score: jQuery.parseJSON('{{.MatchResultJson.RedScoreJson}}'),

View File

@@ -66,17 +66,17 @@ func BuildRandomSchedule(teams []model.Team, scheduleBlocks []model.ScheduleBloc
matches[i].Type = matchType
matches[i].DisplayName = strconv.Itoa(i + 1)
matches[i].Red1 = teams[teamShuffle[anonMatch[0]-1]].Id
matches[i].Red1IsSurrogate = (anonMatch[1] == 1)
matches[i].Red1IsSurrogate = anonMatch[1] == 1
matches[i].Red2 = teams[teamShuffle[anonMatch[2]-1]].Id
matches[i].Red2IsSurrogate = (anonMatch[3] == 1)
matches[i].Red2IsSurrogate = anonMatch[3] == 1
matches[i].Red3 = teams[teamShuffle[anonMatch[4]-1]].Id
matches[i].Red3IsSurrogate = (anonMatch[5] == 1)
matches[i].Red3IsSurrogate = anonMatch[5] == 1
matches[i].Blue1 = teams[teamShuffle[anonMatch[6]-1]].Id
matches[i].Blue1IsSurrogate = (anonMatch[7] == 1)
matches[i].Blue1IsSurrogate = anonMatch[7] == 1
matches[i].Blue2 = teams[teamShuffle[anonMatch[8]-1]].Id
matches[i].Blue2IsSurrogate = (anonMatch[9] == 1)
matches[i].Blue2IsSurrogate = anonMatch[9] == 1
matches[i].Blue3 = teams[teamShuffle[anonMatch[10]-1]].Id
matches[i].Blue3IsSurrogate = (anonMatch[11] == 1)
matches[i].Blue3IsSurrogate = anonMatch[11] == 1
}
// Fill in the match times.

View File

@@ -24,7 +24,7 @@ type Websocket struct {
writeMutex *sync.Mutex
}
type WebsocketMessage struct {
type Message struct {
Type string `json:"type"`
Data interface{} `json:"data"`
}
@@ -49,7 +49,7 @@ func (ws *Websocket) Close() error {
}
func (ws *Websocket) Read() (string, interface{}, error) {
var message WebsocketMessage
var message Message
err := ws.conn.ReadJSON(&message)
if websocket.IsCloseError(err, websocket.CloseNoStatusReceived, websocket.CloseAbnormalClosure) {
// This error indicates that the browser terminated the connection normally; rewrite it so that clients don't
@@ -88,7 +88,7 @@ func (ws *Websocket) ReadWithTimeout(timeout time.Duration) (string, interface{}
func (ws *Websocket) Write(messageType string, data interface{}) error {
ws.writeMutex.Lock()
defer ws.writeMutex.Unlock()
err := ws.conn.WriteJSON(WebsocketMessage{messageType, data})
err := ws.conn.WriteJSON(Message{messageType, data})
if err != nil {
// Include the caller of this method in the error message.
_, file, line, _ := runtime.Caller(1)