forked from 0ad/0ad
still another bunch of cleanup (mainly missing semicolon) signaled by jshint
This was SVN commit r17046.
This commit is contained in:
parent
0b86bbd424
commit
4235c67764
@ -61,7 +61,7 @@ function heading(string, size)
|
||||
function escapeChars(str)
|
||||
{
|
||||
return str.replace(/"/g, "\\\"");
|
||||
};
|
||||
}
|
||||
|
||||
function subHeading(obj)
|
||||
{
|
||||
|
@ -24,7 +24,7 @@ var g_messageBoxCallbackFunction = function(btnCode)
|
||||
{
|
||||
// Cache the variables to make it possible to call a messageBox from a callback function.
|
||||
var callbackFunction = g_messageBoxBtnFunctions[btnCode];
|
||||
var callbackArgs = g_messageBoxCallbackArgs[btnCode]
|
||||
var callbackArgs = g_messageBoxCallbackArgs[btnCode];
|
||||
g_messageBoxBtnFunctions = [];
|
||||
g_messageBoxCallbackArgs = [];
|
||||
|
||||
@ -37,7 +37,7 @@ var g_messageBoxCallbackFunction = function(btnCode)
|
||||
|
||||
g_messageBoxBtnFunctions = [];
|
||||
g_messageBoxCallbackArgs = [];
|
||||
}
|
||||
};
|
||||
|
||||
function messageBox (mbWidth, mbHeight, mbMessage, mbTitle, mbMode, mbButtonCaptions, mbBtnCode, mbCallbackArgs)
|
||||
{
|
||||
@ -58,7 +58,7 @@ function messageBox (mbWidth, mbHeight, mbMessage, mbTitle, mbMode, mbButtonCapt
|
||||
title: mbTitle,
|
||||
mode: mbMode,
|
||||
buttonCaptions: mbButtonCaptions,
|
||||
}
|
||||
};
|
||||
if (mbBtnCode)
|
||||
initData.callback = "g_messageBoxCallbackFunction";
|
||||
|
||||
|
@ -243,7 +243,7 @@ function tryAutoComplete(text, autoCompleteList)
|
||||
if (word.toLowerCase().indexOf(lastWord.toLowerCase()) != 0)
|
||||
continue;
|
||||
|
||||
text = wordSplit.join(" ")
|
||||
text = wordSplit.join(" ");
|
||||
if (text.length > 0)
|
||||
text += " ";
|
||||
|
||||
|
@ -172,7 +172,7 @@ function loadMapTypes()
|
||||
*/
|
||||
function loadVictoryConditions()
|
||||
{
|
||||
const subdir = "victory_conditions/"
|
||||
const subdir = "victory_conditions/";
|
||||
|
||||
const files = Engine.BuildDirEntList(g_SettingsDirectory + subdir, "*.json", false).map(
|
||||
file => file.substr(g_SettingsDirectory.length));
|
||||
|
@ -195,7 +195,7 @@ function initMain()
|
||||
g_GameAttributes.settings.PopulationCap = g_PopulationCapacities.Population[this.selected];
|
||||
|
||||
updateGameAttributes();
|
||||
}
|
||||
};
|
||||
|
||||
var startingResourcesL = Engine.GetGUIObjectByName("startingResources");
|
||||
startingResourcesL.list = g_StartingResources.Title;
|
||||
@ -206,7 +206,7 @@ function initMain()
|
||||
g_GameAttributes.settings.StartingResources = g_StartingResources.Resources[this.selected];
|
||||
|
||||
updateGameAttributes();
|
||||
}
|
||||
};
|
||||
|
||||
var ceasefireL = Engine.GetGUIObjectByName("ceasefire");
|
||||
ceasefireL.list = g_Ceasefire.Title;
|
||||
@ -217,7 +217,7 @@ function initMain()
|
||||
g_GameAttributes.settings.Ceasefire = g_Ceasefire.Duration[this.selected];
|
||||
|
||||
updateGameAttributes();
|
||||
}
|
||||
};
|
||||
|
||||
var victoryConditions = Engine.GetGUIObjectByName("victoryCondition");
|
||||
victoryConditions.list = g_VictoryConditions.Title;
|
||||
|
@ -33,7 +33,7 @@ function init(data)
|
||||
Engine.GetGUIObjectByName("tipImage").sprite = sprite? sprite : "";
|
||||
}
|
||||
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
|
||||
// happen until the first timeslice completes, so set initial values.
|
||||
|
@ -112,11 +112,11 @@ function formatUserReportStatus(status)
|
||||
return translate("unknown");
|
||||
}
|
||||
|
||||
var lastTickTime = new Date;
|
||||
var lastTickTime = new Date();
|
||||
function onTick()
|
||||
{
|
||||
var now = new Date;
|
||||
var tickLength = new Date - lastTickTime;
|
||||
var now = new Date();
|
||||
var tickLength = new Date() - lastTickTime;
|
||||
lastTickTime = now;
|
||||
|
||||
// Animate backgrounds
|
||||
|
@ -1661,7 +1661,7 @@ function transformWallToGate(template)
|
||||
var selection = g_Selection.toList();
|
||||
Engine.PostNetworkCommand({
|
||||
"type": "wall-to-gate",
|
||||
"entities": selection.filter( function(e) { return getWallGateTemplate(e) == template } ),
|
||||
"entities": selection.filter( function(e) { return getWallGateTemplate(e) == template; } ),
|
||||
"template": template,
|
||||
});
|
||||
}
|
||||
@ -1742,7 +1742,7 @@ function findIdleUnit(classes)
|
||||
{
|
||||
lastIdleUnit = idleUnits[0];
|
||||
if (!append && (!selectall || selectall && !matched))
|
||||
g_Selection.reset()
|
||||
g_Selection.reset();
|
||||
|
||||
if (selectall)
|
||||
g_Selection.addList(idleUnits);
|
||||
@ -1813,7 +1813,7 @@ function unloadSelection()
|
||||
ents.push(ent);
|
||||
}
|
||||
else if (state.turretParent == parent)
|
||||
ents.push(ent)
|
||||
ents.push(ent);
|
||||
}
|
||||
if (parent)
|
||||
Engine.PostNetworkCommand({"type": "unload", "entities":ents, "garrisonHolder": parent});
|
||||
|
@ -362,7 +362,7 @@ function openDiplomacy()
|
||||
let button = Engine.GetGUIObjectByName("diplomacyPlayer"+setting+"["+(i-1)+"]");
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -408,7 +408,7 @@ function openTrade()
|
||||
button[res].dn.hidden = (proba[res] == 0 || proba[selec] == 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var proba = Engine.GuiInterfaceCall("GetTradingGoods");
|
||||
var button = {};
|
||||
|
@ -61,7 +61,7 @@ var g_NotificationsTypes =
|
||||
var message = {
|
||||
"type": "message",
|
||||
"text": notification.message
|
||||
}
|
||||
};
|
||||
var guid = findGuidForPlayerID(g_PlayerAssignments, player);
|
||||
if (guid == undefined)
|
||||
{
|
||||
@ -77,7 +77,7 @@ var g_NotificationsTypes =
|
||||
var message = {
|
||||
"type": "message",
|
||||
"text": notification.message
|
||||
}
|
||||
};
|
||||
message["translate"] = true;
|
||||
if ("translateParameters" in notification)
|
||||
{
|
||||
@ -171,13 +171,13 @@ function handleNotifications()
|
||||
{
|
||||
if (!notification.type)
|
||||
{
|
||||
error("Notification without type found.\n"+uneval(notification))
|
||||
error("Notification without type found.\n"+uneval(notification));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!notification.players)
|
||||
{
|
||||
error("Notification without players found.\n"+uneval(notification))
|
||||
error("Notification without players found.\n"+uneval(notification));
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -307,7 +307,7 @@ function handleNetMessage(message)
|
||||
|
||||
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(", "));
|
||||
}
|
||||
|
||||
@ -537,7 +537,7 @@ function addChatMessage(msg)
|
||||
}
|
||||
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]" })
|
||||
if (msg.context !== "")
|
||||
{
|
||||
|
@ -100,7 +100,7 @@ EntityGroups.prototype.rebuildGroup = function(renamed)
|
||||
toAdd.push(renamed[ent] ? renamed[ent] : +ent);
|
||||
|
||||
this.add(toAdd);
|
||||
}
|
||||
};
|
||||
|
||||
EntityGroups.prototype.getCount = function(templateName)
|
||||
{
|
||||
@ -204,7 +204,7 @@ EntitySelection.prototype.makePrimarySelection = function(templateName, modifier
|
||||
|
||||
this.reset();
|
||||
this.addList(ents);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a list of the template names
|
||||
@ -220,7 +220,7 @@ EntitySelection.prototype.getTemplateNames = function()
|
||||
templateNames.push(entState.template);
|
||||
}
|
||||
return templateNames;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -377,7 +377,7 @@ EntitySelection.prototype.rebuildSelection = function(renamed)
|
||||
toAdd.push(renamed[ent] ? renamed[ent] : ent);
|
||||
|
||||
this.addList(toAdd, true); // don't play selection sounds
|
||||
}
|
||||
};
|
||||
|
||||
EntitySelection.prototype.toList = function()
|
||||
{
|
||||
@ -428,7 +428,7 @@ EntitySelection.prototype.onChange = function()
|
||||
this.dirty = true;
|
||||
if (this.isSelection)
|
||||
onSelectionChange();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Cache some quantities which depends only on selection
|
||||
@ -468,7 +468,7 @@ EntityGroupsContainer.prototype.addEntities = function(groupName, ents)
|
||||
group.removeEnt(ent);
|
||||
|
||||
this.groups[groupName].add(ents);
|
||||
}
|
||||
};
|
||||
|
||||
EntityGroupsContainer.prototype.update = function()
|
||||
{
|
||||
@ -483,7 +483,7 @@ EntityGroupsContainer.prototype.update = function()
|
||||
group.removeEnt(ent);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Update control group if some entities in the group were renamed
|
||||
@ -511,6 +511,6 @@ EntityGroupsContainer.prototype.checkRenamedEntities = function()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var g_Groups = new EntityGroupsContainer();
|
||||
|
@ -298,7 +298,7 @@ function displayMultiple(selection, template)
|
||||
|
||||
for (let i = 0; i < selection.length; i++)
|
||||
{
|
||||
let entState = GetEntityState(selection[i])
|
||||
let entState = GetEntityState(selection[i]);
|
||||
if (!entState)
|
||||
continue;
|
||||
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));
|
||||
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 });
|
||||
Engine.GetGUIObjectByName("healthMultiple").tooltip = hitpoints;
|
||||
}
|
||||
@ -342,7 +342,7 @@ function displayMultiple(selection, template)
|
||||
unitCaptureBar.sprite = "color: " + rgbToGuiColor(g_Players[playerID].color, 128);
|
||||
unitCaptureBar.hidden=false;
|
||||
return startSize + size;
|
||||
}
|
||||
};
|
||||
|
||||
let size = 0;
|
||||
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
|
||||
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) });
|
||||
Engine.GetGUIObjectByName("captureMultiple").tooltip = capturePointsTooltip;
|
||||
}
|
||||
|
@ -356,7 +356,7 @@ g_SelectionPanels.Construction = {
|
||||
g_SelectionPanels.Formation = {
|
||||
"getMaxNumberOfItems": function()
|
||||
{
|
||||
return 16
|
||||
return 16;
|
||||
},
|
||||
"rowLength": 4,
|
||||
"conflictsWith": ["Garrison"],
|
||||
@ -416,7 +416,7 @@ g_SelectionPanels.Garrison = {
|
||||
{
|
||||
var state = GetEntityState(ent);
|
||||
if (state.garrisonHolder)
|
||||
groups.add(state.garrisonHolder.entities)
|
||||
groups.add(state.garrisonHolder.entities);
|
||||
}
|
||||
return groups.getEntsGrouped();
|
||||
},
|
||||
@ -560,7 +560,7 @@ g_SelectionPanels.Gate = {
|
||||
// If already a gate, show locking actions
|
||||
gateIcon = "icons/lock_" + GATE_ACTIONS[data.item.locked ? 0 : 1] + "ed.png";
|
||||
if (data.item.gate.locked === undefined)
|
||||
data.guiSelection.hidden = false
|
||||
data.guiSelection.hidden = false;
|
||||
else
|
||||
data.guiSelection.hidden = data.item.gate.locked != data.item.locked;
|
||||
}
|
||||
@ -738,7 +738,7 @@ g_SelectionPanels.Research = {
|
||||
{
|
||||
var entState = GetEntityState(ent);
|
||||
if (entState.production && entState.production.technologies.length)
|
||||
return entState.production.technologies
|
||||
return entState.production.technologies;
|
||||
}
|
||||
return [];
|
||||
},
|
||||
@ -910,7 +910,7 @@ g_SelectionPanels.Selection = {
|
||||
return false;
|
||||
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;
|
||||
for (var ent of ents)
|
||||
{
|
||||
|
@ -178,7 +178,7 @@ function init(initData, hotloadData)
|
||||
gameSpeed.list_data = g_GameSpeeds.Speed;
|
||||
var gameSpeedIdx = g_GameSpeeds.Speed.indexOf(Engine.GetSimRate());
|
||||
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
|
||||
|
||||
// Populate player selection dropdown
|
||||
@ -236,7 +236,7 @@ function updateTopPanel()
|
||||
var isPlayer = playerID > 0;
|
||||
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("civIconOverlay").tooltip = sprintf(translate("%(civ)s - Structure Tree"), {"civ": civName});
|
||||
}
|
||||
@ -387,7 +387,7 @@ function restoreSavedGameData(data)
|
||||
updateGroups();
|
||||
}
|
||||
|
||||
var lastTickTime = new Date;
|
||||
var lastTickTime = new Date();
|
||||
|
||||
/**
|
||||
* Called every frame.
|
||||
@ -397,8 +397,8 @@ function onTick()
|
||||
if (!g_Settings)
|
||||
return;
|
||||
|
||||
var now = new Date;
|
||||
var tickLength = new Date - lastTickTime;
|
||||
var now = new Date();
|
||||
var tickLength = new Date() - lastTickTime;
|
||||
lastTickTime = now;
|
||||
|
||||
checkPlayerState();
|
||||
@ -767,7 +767,7 @@ function updateResearchDisplay()
|
||||
var button = Engine.GetGUIObjectByName("researchStartedButton[" + numButtons + "]");
|
||||
button.hidden = false;
|
||||
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;
|
||||
Engine.GetGUIObjectByName("researchStartedIcon[" + numButtons + "]").sprite = icon;
|
||||
|
@ -128,7 +128,7 @@ var unitActions =
|
||||
{
|
||||
if (Engine.HotkeyIsPressed("session.attack") && getActionInfo("attack", target).possible)
|
||||
return {"type": "attack", "cursor": "action-attack", "target": target};
|
||||
return false
|
||||
return false;
|
||||
},
|
||||
"actionCheck": function(target)
|
||||
{
|
||||
@ -324,7 +324,7 @@ var unitActions =
|
||||
gain: getTradingTooltip(tradingDetails.gain)
|
||||
});
|
||||
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;
|
||||
case "is second":
|
||||
tooltip = translate("Destination trade market.") + "\n" + sprintf(translate("Gain: %(gain)s"), {
|
||||
@ -935,4 +935,4 @@ function playerCheck(entState, targetState, validPlayers)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ function setupUnitPanel(guiName, unitEntState, playerState)
|
||||
var garrisonGroups = new EntityGroups();
|
||||
|
||||
// Determine how many buttons there should be
|
||||
var maxNumberOfItems = g_SelectionPanels[guiName].getMaxNumberOfItems()
|
||||
var maxNumberOfItems = g_SelectionPanels[guiName].getMaxNumberOfItems();
|
||||
if (maxNumberOfItems < numberOfItems)
|
||||
numberOfItems = maxNumberOfItems;
|
||||
|
||||
|
@ -295,6 +295,6 @@ function updateObjectPlayerPosition()
|
||||
boxSize.top += h * (PLAYER_BOX_Y_SIZE + PLAYER_BOX_GAP);
|
||||
boxSize.bottom = boxSize.top + PLAYER_BOX_Y_SIZE;
|
||||
playerBoxt.size = boxSize;
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ function updatePanelData(panelInfo)
|
||||
updateCountersPlayer(playerState, panelInfo.counters, playerCounterValue);
|
||||
}
|
||||
// Update team counters
|
||||
var teamCounterFn = panelInfo.teamCounterFn
|
||||
var teamCounterFn = panelInfo.teamCounterFn;
|
||||
if (g_Teams && teamCounterFn)
|
||||
teamCounterFn(panelInfo.counters);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user