still another bunch of cleanup (mainly missing semicolon) signaled by jshint

This was SVN commit r17046.
This commit is contained in:
mimo 2015-09-19 12:55:58 +00:00
parent 0b86bbd424
commit 4235c67764
18 changed files with 57 additions and 57 deletions

View File

@ -61,7 +61,7 @@ function heading(string, size)
function escapeChars(str) function escapeChars(str)
{ {
return str.replace(/"/g, "\\\""); return str.replace(/"/g, "\\\"");
}; }
function subHeading(obj) function subHeading(obj)
{ {

View File

@ -24,7 +24,7 @@ var g_messageBoxCallbackFunction = function(btnCode)
{ {
// Cache the variables to make it possible to call a messageBox from a callback function. // Cache the variables to make it possible to call a messageBox from a callback function.
var callbackFunction = g_messageBoxBtnFunctions[btnCode]; var callbackFunction = g_messageBoxBtnFunctions[btnCode];
var callbackArgs = g_messageBoxCallbackArgs[btnCode] var callbackArgs = g_messageBoxCallbackArgs[btnCode];
g_messageBoxBtnFunctions = []; g_messageBoxBtnFunctions = [];
g_messageBoxCallbackArgs = []; g_messageBoxCallbackArgs = [];
@ -37,7 +37,7 @@ var g_messageBoxCallbackFunction = function(btnCode)
g_messageBoxBtnFunctions = []; g_messageBoxBtnFunctions = [];
g_messageBoxCallbackArgs = []; g_messageBoxCallbackArgs = [];
} };
function messageBox (mbWidth, mbHeight, mbMessage, mbTitle, mbMode, mbButtonCaptions, mbBtnCode, mbCallbackArgs) function messageBox (mbWidth, mbHeight, mbMessage, mbTitle, mbMode, mbButtonCaptions, mbBtnCode, mbCallbackArgs)
{ {
@ -58,7 +58,7 @@ function messageBox (mbWidth, mbHeight, mbMessage, mbTitle, mbMode, mbButtonCapt
title: mbTitle, title: mbTitle,
mode: mbMode, mode: mbMode,
buttonCaptions: mbButtonCaptions, buttonCaptions: mbButtonCaptions,
} };
if (mbBtnCode) if (mbBtnCode)
initData.callback = "g_messageBoxCallbackFunction"; initData.callback = "g_messageBoxCallbackFunction";

View File

@ -243,7 +243,7 @@ function tryAutoComplete(text, autoCompleteList)
if (word.toLowerCase().indexOf(lastWord.toLowerCase()) != 0) if (word.toLowerCase().indexOf(lastWord.toLowerCase()) != 0)
continue; continue;
text = wordSplit.join(" ") text = wordSplit.join(" ");
if (text.length > 0) if (text.length > 0)
text += " "; text += " ";

View File

@ -172,7 +172,7 @@ function loadMapTypes()
*/ */
function loadVictoryConditions() function loadVictoryConditions()
{ {
const subdir = "victory_conditions/" const subdir = "victory_conditions/";
const files = Engine.BuildDirEntList(g_SettingsDirectory + subdir, "*.json", false).map( const files = Engine.BuildDirEntList(g_SettingsDirectory + subdir, "*.json", false).map(
file => file.substr(g_SettingsDirectory.length)); file => file.substr(g_SettingsDirectory.length));

View File

@ -195,7 +195,7 @@ function initMain()
g_GameAttributes.settings.PopulationCap = g_PopulationCapacities.Population[this.selected]; g_GameAttributes.settings.PopulationCap = g_PopulationCapacities.Population[this.selected];
updateGameAttributes(); updateGameAttributes();
} };
var startingResourcesL = Engine.GetGUIObjectByName("startingResources"); var startingResourcesL = Engine.GetGUIObjectByName("startingResources");
startingResourcesL.list = g_StartingResources.Title; startingResourcesL.list = g_StartingResources.Title;
@ -206,7 +206,7 @@ function initMain()
g_GameAttributes.settings.StartingResources = g_StartingResources.Resources[this.selected]; g_GameAttributes.settings.StartingResources = g_StartingResources.Resources[this.selected];
updateGameAttributes(); updateGameAttributes();
} };
var ceasefireL = Engine.GetGUIObjectByName("ceasefire"); var ceasefireL = Engine.GetGUIObjectByName("ceasefire");
ceasefireL.list = g_Ceasefire.Title; ceasefireL.list = g_Ceasefire.Title;
@ -217,7 +217,7 @@ function initMain()
g_GameAttributes.settings.Ceasefire = g_Ceasefire.Duration[this.selected]; g_GameAttributes.settings.Ceasefire = g_Ceasefire.Duration[this.selected];
updateGameAttributes(); updateGameAttributes();
} };
var victoryConditions = Engine.GetGUIObjectByName("victoryCondition"); var victoryConditions = Engine.GetGUIObjectByName("victoryCondition");
victoryConditions.list = g_VictoryConditions.Title; victoryConditions.list = g_VictoryConditions.Title;

View File

@ -33,7 +33,7 @@ function init(data)
Engine.GetGUIObjectByName("tipImage").sprite = sprite? sprite : ""; Engine.GetGUIObjectByName("tipImage").sprite = sprite? sprite : "";
} }
else else
error("Failed to find any matching tips for the loading screen.") error("Failed to find any matching tips for the loading screen.");
// janwas: main loop now sets progress / description, but that won't // janwas: main loop now sets progress / description, but that won't
// happen until the first timeslice completes, so set initial values. // happen until the first timeslice completes, so set initial values.

View File

@ -112,11 +112,11 @@ function formatUserReportStatus(status)
return translate("unknown"); return translate("unknown");
} }
var lastTickTime = new Date; var lastTickTime = new Date();
function onTick() function onTick()
{ {
var now = new Date; var now = new Date();
var tickLength = new Date - lastTickTime; var tickLength = new Date() - lastTickTime;
lastTickTime = now; lastTickTime = now;
// Animate backgrounds // Animate backgrounds

View File

@ -1661,7 +1661,7 @@ function transformWallToGate(template)
var selection = g_Selection.toList(); var selection = g_Selection.toList();
Engine.PostNetworkCommand({ Engine.PostNetworkCommand({
"type": "wall-to-gate", "type": "wall-to-gate",
"entities": selection.filter( function(e) { return getWallGateTemplate(e) == template } ), "entities": selection.filter( function(e) { return getWallGateTemplate(e) == template; } ),
"template": template, "template": template,
}); });
} }
@ -1742,7 +1742,7 @@ function findIdleUnit(classes)
{ {
lastIdleUnit = idleUnits[0]; lastIdleUnit = idleUnits[0];
if (!append && (!selectall || selectall && !matched)) if (!append && (!selectall || selectall && !matched))
g_Selection.reset() g_Selection.reset();
if (selectall) if (selectall)
g_Selection.addList(idleUnits); g_Selection.addList(idleUnits);
@ -1813,7 +1813,7 @@ function unloadSelection()
ents.push(ent); ents.push(ent);
} }
else if (state.turretParent == parent) else if (state.turretParent == parent)
ents.push(ent) ents.push(ent);
} }
if (parent) if (parent)
Engine.PostNetworkCommand({"type": "unload", "entities":ents, "garrisonHolder": parent}); Engine.PostNetworkCommand({"type": "unload", "entities":ents, "garrisonHolder": parent});

View File

@ -362,7 +362,7 @@ function openDiplomacy()
let button = Engine.GetGUIObjectByName("diplomacyPlayer"+setting+"["+(i-1)+"]"); let button = Engine.GetGUIObjectByName("diplomacyPlayer"+setting+"["+(i-1)+"]");
button.caption = g_Players[we]["is"+setting][i] ? translate("x") : ""; button.caption = g_Players[we]["is"+setting][i] ? translate("x") : "";
button.onpress = (function(e){ return function() { setDiplomacy(e) } })({"player": i, "to": setting.toLowerCase()}); button.onpress = (function(e){ return function() { setDiplomacy(e); } })({"player": i, "to": setting.toLowerCase()});
button.hidden = simState.ceasefireActive; button.hidden = simState.ceasefireActive;
} }
} }
@ -408,7 +408,7 @@ function openTrade()
button[res].dn.hidden = (proba[res] == 0 || proba[selec] == 100); button[res].dn.hidden = (proba[res] == 0 || proba[selec] == 100);
} }
} }
} };
var proba = Engine.GuiInterfaceCall("GetTradingGoods"); var proba = Engine.GuiInterfaceCall("GetTradingGoods");
var button = {}; var button = {};

View File

@ -61,7 +61,7 @@ var g_NotificationsTypes =
var message = { var message = {
"type": "message", "type": "message",
"text": notification.message "text": notification.message
} };
var guid = findGuidForPlayerID(g_PlayerAssignments, player); var guid = findGuidForPlayerID(g_PlayerAssignments, player);
if (guid == undefined) if (guid == undefined)
{ {
@ -77,7 +77,7 @@ var g_NotificationsTypes =
var message = { var message = {
"type": "message", "type": "message",
"text": notification.message "text": notification.message
} };
message["translate"] = true; message["translate"] = true;
if ("translateParameters" in notification) if ("translateParameters" in notification)
{ {
@ -171,13 +171,13 @@ function handleNotifications()
{ {
if (!notification.type) if (!notification.type)
{ {
error("Notification without type found.\n"+uneval(notification)) error("Notification without type found.\n"+uneval(notification));
continue; continue;
} }
if (!notification.players) if (!notification.players)
{ {
error("Notification without players found.\n"+uneval(notification)) error("Notification without players found.\n"+uneval(notification));
continue; continue;
} }
@ -307,7 +307,7 @@ function handleNetMessage(message)
if (g_IsController && Engine.HasXmppClient()) if (g_IsController && Engine.HasXmppClient())
{ {
var players = [ assignment.name for each (assignment in g_PlayerAssignments) ] var players = [ assignment.name for each (assignment in g_PlayerAssignments) ];
Engine.SendChangeStateGame(Object.keys(g_PlayerAssignments).length, players.join(", ")); Engine.SendChangeStateGame(Object.keys(g_PlayerAssignments).length, players.join(", "));
} }
@ -537,7 +537,7 @@ function addChatMessage(msg)
} }
else else
{ {
var userTag = sprintf(translate("<%(user)s>"), { "user": username }) var userTag = sprintf(translate("<%(user)s>"), { "user": username });
var formattedUserTag = sprintf(translate("<%(user)s>"), { "user": "[color=\"" + playerColor + "\"]" + username + "[/color]" }) var formattedUserTag = sprintf(translate("<%(user)s>"), { "user": "[color=\"" + playerColor + "\"]" + username + "[/color]" })
if (msg.context !== "") if (msg.context !== "")
{ {

View File

@ -100,7 +100,7 @@ EntityGroups.prototype.rebuildGroup = function(renamed)
toAdd.push(renamed[ent] ? renamed[ent] : +ent); toAdd.push(renamed[ent] ? renamed[ent] : +ent);
this.add(toAdd); this.add(toAdd);
} };
EntityGroups.prototype.getCount = function(templateName) EntityGroups.prototype.getCount = function(templateName)
{ {
@ -204,7 +204,7 @@ EntitySelection.prototype.makePrimarySelection = function(templateName, modifier
this.reset(); this.reset();
this.addList(ents); this.addList(ents);
} };
/** /**
* Get a list of the template names * Get a list of the template names
@ -220,7 +220,7 @@ EntitySelection.prototype.getTemplateNames = function()
templateNames.push(entState.template); templateNames.push(entState.template);
} }
return templateNames; return templateNames;
} };
/** /**
* Update the selection to take care of changes (like units that have been killed) * Update the selection to take care of changes (like units that have been killed)
@ -285,7 +285,7 @@ EntitySelection.prototype.checkRenamedEntities = function()
} }
} }
} }
} };
/** /**
* Add entities to selection. Play selection sound unless quiet is true * Add entities to selection. Play selection sound unless quiet is true
@ -377,7 +377,7 @@ EntitySelection.prototype.rebuildSelection = function(renamed)
toAdd.push(renamed[ent] ? renamed[ent] : ent); toAdd.push(renamed[ent] ? renamed[ent] : ent);
this.addList(toAdd, true); // don't play selection sounds this.addList(toAdd, true); // don't play selection sounds
} };
EntitySelection.prototype.toList = function() EntitySelection.prototype.toList = function()
{ {
@ -428,7 +428,7 @@ EntitySelection.prototype.onChange = function()
this.dirty = true; this.dirty = true;
if (this.isSelection) if (this.isSelection)
onSelectionChange(); onSelectionChange();
} };
/** /**
* Cache some quantities which depends only on selection * Cache some quantities which depends only on selection
@ -468,7 +468,7 @@ EntityGroupsContainer.prototype.addEntities = function(groupName, ents)
group.removeEnt(ent); group.removeEnt(ent);
this.groups[groupName].add(ents); this.groups[groupName].add(ents);
} };
EntityGroupsContainer.prototype.update = function() EntityGroupsContainer.prototype.update = function()
{ {
@ -483,7 +483,7 @@ EntityGroupsContainer.prototype.update = function()
group.removeEnt(ent); group.removeEnt(ent);
} }
} }
} };
/** /**
* Update control group if some entities in the group were renamed * Update control group if some entities in the group were renamed
@ -511,6 +511,6 @@ EntityGroupsContainer.prototype.checkRenamedEntities = function()
} }
} }
} }
} };
var g_Groups = new EntityGroupsContainer(); var g_Groups = new EntityGroupsContainer();

View File

@ -298,7 +298,7 @@ function displayMultiple(selection, template)
for (let i = 0; i < selection.length; i++) for (let i = 0; i < selection.length; i++)
{ {
let entState = GetEntityState(selection[i]) let entState = GetEntityState(selection[i]);
if (!entState) if (!entState)
continue; continue;
playerID = entState.player; // trust that all selected entities have the same owner playerID = entState.player; // trust that all selected entities have the same owner
@ -322,7 +322,7 @@ function displayMultiple(selection, template)
healthSize.rtop = 100-100*Math.max(0, Math.min(1, averageHealth / maxHealth)); healthSize.rtop = 100-100*Math.max(0, Math.min(1, averageHealth / maxHealth));
unitHealthBar.size = healthSize; unitHealthBar.size = healthSize;
var hitpointsLabel = "[font=\"sans-bold-13\"]" + translate("Hitpoints:") + "[/font]" var hitpointsLabel = "[font=\"sans-bold-13\"]" + translate("Hitpoints:") + "[/font]";
var hitpoints = sprintf(translate("%(label)s %(current)s / %(max)s"), { label: hitpointsLabel, current: averageHealth, max: maxHealth }); var hitpoints = sprintf(translate("%(label)s %(current)s / %(max)s"), { label: hitpointsLabel, current: averageHealth, max: maxHealth });
Engine.GetGUIObjectByName("healthMultiple").tooltip = hitpoints; Engine.GetGUIObjectByName("healthMultiple").tooltip = hitpoints;
} }
@ -342,7 +342,7 @@ function displayMultiple(selection, template)
unitCaptureBar.sprite = "color: " + rgbToGuiColor(g_Players[playerID].color, 128); unitCaptureBar.sprite = "color: " + rgbToGuiColor(g_Players[playerID].color, 128);
unitCaptureBar.hidden=false; unitCaptureBar.hidden=false;
return startSize + size; return startSize + size;
} };
let size = 0; let size = 0;
for (let i in capturePoints) for (let i in capturePoints)
@ -352,7 +352,7 @@ function displayMultiple(selection, template)
// last handle the owner's points, to keep those points on the bottom for clarity // last handle the owner's points, to keep those points on the bottom for clarity
setCaptureBarPart(playerID, size); setCaptureBarPart(playerID, size);
var capturePointsLabel = "[font=\"sans-bold-13\"]" + translate("Capture points:") + "[/font]" var capturePointsLabel = "[font=\"sans-bold-13\"]" + translate("Capture points:") + "[/font]";
var capturePointsTooltip = sprintf(translate("%(label)s %(current)s / %(max)s"), { label: capturePointsLabel, current: Math.ceil(capturePoints[playerID]), max: Math.ceil(maxCapturePoints) }); var capturePointsTooltip = sprintf(translate("%(label)s %(current)s / %(max)s"), { label: capturePointsLabel, current: Math.ceil(capturePoints[playerID]), max: Math.ceil(maxCapturePoints) });
Engine.GetGUIObjectByName("captureMultiple").tooltip = capturePointsTooltip; Engine.GetGUIObjectByName("captureMultiple").tooltip = capturePointsTooltip;
} }

View File

@ -356,7 +356,7 @@ g_SelectionPanels.Construction = {
g_SelectionPanels.Formation = { g_SelectionPanels.Formation = {
"getMaxNumberOfItems": function() "getMaxNumberOfItems": function()
{ {
return 16 return 16;
}, },
"rowLength": 4, "rowLength": 4,
"conflictsWith": ["Garrison"], "conflictsWith": ["Garrison"],
@ -416,7 +416,7 @@ g_SelectionPanels.Garrison = {
{ {
var state = GetEntityState(ent); var state = GetEntityState(ent);
if (state.garrisonHolder) if (state.garrisonHolder)
groups.add(state.garrisonHolder.entities) groups.add(state.garrisonHolder.entities);
} }
return groups.getEntsGrouped(); return groups.getEntsGrouped();
}, },
@ -560,7 +560,7 @@ g_SelectionPanels.Gate = {
// If already a gate, show locking actions // If already a gate, show locking actions
gateIcon = "icons/lock_" + GATE_ACTIONS[data.item.locked ? 0 : 1] + "ed.png"; gateIcon = "icons/lock_" + GATE_ACTIONS[data.item.locked ? 0 : 1] + "ed.png";
if (data.item.gate.locked === undefined) if (data.item.gate.locked === undefined)
data.guiSelection.hidden = false data.guiSelection.hidden = false;
else else
data.guiSelection.hidden = data.item.gate.locked != data.item.locked; data.guiSelection.hidden = data.item.gate.locked != data.item.locked;
} }
@ -738,7 +738,7 @@ g_SelectionPanels.Research = {
{ {
var entState = GetEntityState(ent); var entState = GetEntityState(ent);
if (entState.production && entState.production.technologies.length) if (entState.production && entState.production.technologies.length)
return entState.production.technologies return entState.production.technologies;
} }
return []; return [];
}, },
@ -910,7 +910,7 @@ g_SelectionPanels.Selection = {
return false; return false;
data.name = getEntityNames(data.template); data.name = getEntityNames(data.template);
var ents = g_Selection.groups.getEntsByName(data.item) var ents = g_Selection.groups.getEntsByName(data.item);
data.count = ents.length; data.count = ents.length;
for (var ent of ents) for (var ent of ents)
{ {

View File

@ -178,7 +178,7 @@ function init(initData, hotloadData)
gameSpeed.list_data = g_GameSpeeds.Speed; gameSpeed.list_data = g_GameSpeeds.Speed;
var gameSpeedIdx = g_GameSpeeds.Speed.indexOf(Engine.GetSimRate()); var gameSpeedIdx = g_GameSpeeds.Speed.indexOf(Engine.GetSimRate());
gameSpeed.selected = gameSpeedIdx != -1 ? gameSpeedIdx : g_GameSpeeds.Default; gameSpeed.selected = gameSpeedIdx != -1 ? gameSpeedIdx : g_GameSpeeds.Default;
gameSpeed.onSelectionChange = function() { changeGameSpeed(+this.list_data[this.selected]); } gameSpeed.onSelectionChange = function() { changeGameSpeed(+this.list_data[this.selected]); };
initMenuPosition(); // set initial position initMenuPosition(); // set initial position
// Populate player selection dropdown // Populate player selection dropdown
@ -236,7 +236,7 @@ function updateTopPanel()
var isPlayer = playerID > 0; var isPlayer = playerID > 0;
if (isPlayer) if (isPlayer)
{ {
var civName = g_CivData[g_Players[playerID].civ].Name var civName = g_CivData[g_Players[playerID].civ].Name;
Engine.GetGUIObjectByName("civIcon").sprite = "stretched:" + g_CivData[g_Players[playerID].civ].Emblem; Engine.GetGUIObjectByName("civIcon").sprite = "stretched:" + g_CivData[g_Players[playerID].civ].Emblem;
Engine.GetGUIObjectByName("civIconOverlay").tooltip = sprintf(translate("%(civ)s - Structure Tree"), {"civ": civName}); Engine.GetGUIObjectByName("civIconOverlay").tooltip = sprintf(translate("%(civ)s - Structure Tree"), {"civ": civName});
} }
@ -387,7 +387,7 @@ function restoreSavedGameData(data)
updateGroups(); updateGroups();
} }
var lastTickTime = new Date; var lastTickTime = new Date();
/** /**
* Called every frame. * Called every frame.
@ -397,8 +397,8 @@ function onTick()
if (!g_Settings) if (!g_Settings)
return; return;
var now = new Date; var now = new Date();
var tickLength = new Date - lastTickTime; var tickLength = new Date() - lastTickTime;
lastTickTime = now; lastTickTime = now;
checkPlayerState(); checkPlayerState();
@ -767,7 +767,7 @@ function updateResearchDisplay()
var button = Engine.GetGUIObjectByName("researchStartedButton[" + numButtons + "]"); var button = Engine.GetGUIObjectByName("researchStartedButton[" + numButtons + "]");
button.hidden = false; button.hidden = false;
button.tooltip = getEntityNames(template); button.tooltip = getEntityNames(template);
button.onpress = (function(e) { return function() { selectAndMoveTo(e) } })(researchStarted[tech].researcher); button.onpress = (function(e) { return function() { selectAndMoveTo(e); } })(researchStarted[tech].researcher);
var icon = "stretched:session/portraits/" + template.icon; var icon = "stretched:session/portraits/" + template.icon;
Engine.GetGUIObjectByName("researchStartedIcon[" + numButtons + "]").sprite = icon; Engine.GetGUIObjectByName("researchStartedIcon[" + numButtons + "]").sprite = icon;

View File

@ -128,7 +128,7 @@ var unitActions =
{ {
if (Engine.HotkeyIsPressed("session.attack") && getActionInfo("attack", target).possible) if (Engine.HotkeyIsPressed("session.attack") && getActionInfo("attack", target).possible)
return {"type": "attack", "cursor": "action-attack", "target": target}; return {"type": "attack", "cursor": "action-attack", "target": target};
return false return false;
}, },
"actionCheck": function(target) "actionCheck": function(target)
{ {
@ -324,7 +324,7 @@ var unitActions =
gain: getTradingTooltip(tradingDetails.gain) gain: getTradingTooltip(tradingDetails.gain)
}); });
else else
tooltip += "\n" + translate("Right-click on another market to set it as a destination trade market.") tooltip += "\n" + translate("Right-click on another market to set it as a destination trade market.");
break; break;
case "is second": case "is second":
tooltip = translate("Destination trade market.") + "\n" + sprintf(translate("Gain: %(gain)s"), { tooltip = translate("Destination trade market.") + "\n" + sprintf(translate("Gain: %(gain)s"), {
@ -935,4 +935,4 @@ function playerCheck(entState, targetState, validPlayers)
return true; return true;
} }
return false; return false;
}; }

View File

@ -49,7 +49,7 @@ function setupUnitPanel(guiName, unitEntState, playerState)
var garrisonGroups = new EntityGroups(); var garrisonGroups = new EntityGroups();
// Determine how many buttons there should be // Determine how many buttons there should be
var maxNumberOfItems = g_SelectionPanels[guiName].getMaxNumberOfItems() var maxNumberOfItems = g_SelectionPanels[guiName].getMaxNumberOfItems();
if (maxNumberOfItems < numberOfItems) if (maxNumberOfItems < numberOfItems)
numberOfItems = maxNumberOfItems; numberOfItems = maxNumberOfItems;

View File

@ -295,6 +295,6 @@ function updateObjectPlayerPosition()
boxSize.top += h * (PLAYER_BOX_Y_SIZE + PLAYER_BOX_GAP); boxSize.top += h * (PLAYER_BOX_Y_SIZE + PLAYER_BOX_GAP);
boxSize.bottom = boxSize.top + PLAYER_BOX_Y_SIZE; boxSize.bottom = boxSize.top + PLAYER_BOX_Y_SIZE;
playerBoxt.size = boxSize; playerBoxt.size = boxSize;
}; }
}; }
} }

View File

@ -122,7 +122,7 @@ function updatePanelData(panelInfo)
updateCountersPlayer(playerState, panelInfo.counters, playerCounterValue); updateCountersPlayer(playerState, panelInfo.counters, playerCounterValue);
} }
// Update team counters // Update team counters
var teamCounterFn = panelInfo.teamCounterFn var teamCounterFn = panelInfo.teamCounterFn;
if (g_Teams && teamCounterFn) if (g_Teams && teamCounterFn)
teamCounterFn(panelInfo.counters); teamCounterFn(panelInfo.counters);
} }