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.
This commit is contained in:
John "Elwin" Edwards 2014-01-02 11:39:57 -05:00
parent aef04a38e1
commit 31174f58ee
2 changed files with 17 additions and 9 deletions

View file

@ -39,6 +39,7 @@ tblhead = '<div class="stable">\n'
rowstart = '<div class="sentry">\n' rowstart = '<div class="sentry">\n'
rowend = '</div>\n' rowend = '</div>\n'
cell = ' <span class="sdata">{0}</span>\n' cell = ' <span class="sdata">{0}</span>\n'
rcell = ' <span class="sdatar">{0}</span>\n'
hcell = ' <span class="shdata">{0}</span>\n' hcell = ' <span class="shdata">{0}</span>\n'
tblend = '</div>\n' tblend = '</div>\n'
pend = "</body></html>\n" pend = "</body></html>\n"
@ -112,24 +113,25 @@ def printTable(entries, fields, of):
clist = [] clist = []
for field in fields: for field in fields:
if field == "rank": if field == "rank":
clist.append("{0}".format(i + 1)) clist.append(("{0}".format(i + 1), rcell))
elif field in entry: elif field in entry:
thing = entry[field] thing = entry[field]
if field == "game": if field == "game":
clist.append(thing.name) clist.append((thing.name, cell))
elif field == "xl" or field == "score": # Numerics elif field == "xl" or field == "score": # Numerics
clist.append(str(thing)) clist.append((str(thing), rcell))
elif field == "name": elif field == "name":
clist.append(playerlink(thing)) clist.append((playerlink(thing), cell))
elif field == "fate": elif field == "fate":
clist.append(thing) clist.append((thing, cell))
elif field == "endt": elif field == "endt":
clist.append(linktoArchive(entry)) clist.append((linktoArchive(entry), cell))
else: else:
clist.append("{0}".format(thing)) clist.append(("{0}".format(thing), cell))
else: else:
clist.append("N/A") clist.append(("N/A", cell))
of.write(maketablerow(clist)) rowstr = rowstart + "".join([ t.format(s) for (s, t) in clist ]) + rowend
of.write(rowstr)
of.write(tblend) of.write(tblend)
return return

View file

@ -42,3 +42,9 @@ span.sdata {
display: table-cell; display: table-cell;
padding: 0 1em; padding: 0 1em;
} }
span.sdatar {
display: table-cell;
padding: 0 1em;
text-align: right;
}