From 31174f58eeae8c8545b07e3edfc764f9fc1843d8 Mon Sep 17 00:00:00 2001 From: "John \"Elwin\" Edwards" Date: Thu, 2 Jan 2014 11:39:57 -0500 Subject: [PATCH] Right-align the numeric columns. The Game.printTable() method now right-aligns the name, rank, and score columns, by giving their cells a different CSS class. --- py/rlgalldb.py | 20 +++++++++++--------- web/scoring/scores.css | 6 ++++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/py/rlgalldb.py b/py/rlgalldb.py index 56eceb8..1130905 100644 --- a/py/rlgalldb.py +++ b/py/rlgalldb.py @@ -39,6 +39,7 @@ tblhead = '
\n' rowstart = '
\n' rowend = '
\n' cell = ' {0}\n' +rcell = ' {0}\n' hcell = ' {0}\n' tblend = '
\n' pend = "\n" @@ -112,24 +113,25 @@ def printTable(entries, fields, of): clist = [] for field in fields: if field == "rank": - clist.append("{0}".format(i + 1)) + clist.append(("{0}".format(i + 1), rcell)) elif field in entry: thing = entry[field] if field == "game": - clist.append(thing.name) + clist.append((thing.name, cell)) elif field == "xl" or field == "score": # Numerics - clist.append(str(thing)) + clist.append((str(thing), rcell)) elif field == "name": - clist.append(playerlink(thing)) + clist.append((playerlink(thing), cell)) elif field == "fate": - clist.append(thing) + clist.append((thing, cell)) elif field == "endt": - clist.append(linktoArchive(entry)) + clist.append((linktoArchive(entry), cell)) else: - clist.append("{0}".format(thing)) + clist.append(("{0}".format(thing), cell)) else: - clist.append("N/A") - of.write(maketablerow(clist)) + clist.append(("N/A", cell)) + rowstr = rowstart + "".join([ t.format(s) for (s, t) in clist ]) + rowend + of.write(rowstr) of.write(tblend) return diff --git a/web/scoring/scores.css b/web/scoring/scores.css index 526b93e..566ec5f 100644 --- a/web/scoring/scores.css +++ b/web/scoring/scores.css @@ -42,3 +42,9 @@ span.sdata { display: table-cell; padding: 0 1em; } + +span.sdatar { + display: table-cell; + padding: 0 1em; + text-align: right; +}