Opened 9 years ago

Closed 8 years ago

Last modified 8 years ago

#3518 closed task (fixed)

[PATCH] Summary screen code style

Reported by: bb Owned by: elexis
Priority: Nice to Have Milestone: Alpha 20
Component: UI & Simulation Keywords: patch
Cc: Patch:

Description (last modified by bb)

The attached patch improves the code style from the javascript files in /public/gui/summary.

Attachments (4)

ticket3518_summarystyle.diff (15.7 KB ) - added by bb 9 years ago.
Some spaces and let to var changes
ticket3518_summarystyle_2.diff (22.9 KB ) - added by bb 8 years ago.
New version: changed global params into g_GlobalSomething
ticket3518_summarystyle_3.diff (9.1 KB ) - added by bb 8 years ago.
deprecate the for each to for in and treat "resourcestotal" the same as "unitstotal" and "buildingstotal"
ticket3518_summarystyle_3.1.diff (1.7 KB ) - added by bb 8 years ago.
splitted from last patch: 2* foreach deprecated

Download all attachments as: .zip

Change History (12)

by bb, 9 years ago

Some spaces and let to var changes

comment:1 by bb, 9 years ago

Description: modified (diff)

comment:2 by bb, 9 years ago

Milestone: BacklogAlpha 20
Type: defecttask

comment:3 by bb, 9 years ago

Priority: Should HaveIf Time Permits

by bb, 8 years ago

New version: changed global params into g_GlobalSomething

comment:4 by elexis, 8 years ago

In 17453:

Summary screen cleanup. Patch by bb, refs #3518.

Renames globals to g_Foo.
Uses let instead of for in loops.
Fixes indentation and some whitespace issues.

comment:5 by elexis, 8 years ago

Component: Core engineUI & Simulation
Keywords: review removed
Priority: If Time PermitsNice to Have

Thanks for the patch!

Before the ticket is closed, someone should replace the deprecated for-each with for-in. (For-of probably doesn't work mostly as it loops over objects).


Capital letters for constant globals

TLDR: We use g_Foo for GUI code.

Since we had some discussions recently about using CAPS or g_Foo for global consts:

Many JS sites recommend using capitals only for all globals (no matter if const or variable). This is not reflected in our wiki:Coding_Conventions:

global variables should be named with a g_ prefix.

so when following them strictly, they should be renamed to g_Foo or the documentation updated.

By searching for "const" in all "js" files of the gui directory, we can see that most GUI files meanwhile use the g_Foo naming. So it would be more coherent for the summary screen code to use it too. Hence the commit.

by bb, 8 years ago

deprecate the for each to for in and treat "resourcestotal" the same as "unitstotal" and "buildingstotal"

comment:6 by bb, 8 years ago

Keywords: review added

by bb, 8 years ago

splitted from last patch: 2* foreach deprecated

comment:7 by elexis, 8 years ago

Owner: set to elexis
Resolution: fixed
Status: newclosed

In 17503:

Summary screen cleanup. Based on patch by bb, fixes #3518.

comment:8 by elexis, 8 years ago

Keywords: simple review removed

Thanks for the patches.

Notice there was another for-each loop in another file. Also the variable names were wrong as we don't loop over the amount of resources anymore, but over the resource types.

Note: See TracTickets for help on using tickets.