changeset 31:7303535b5a5d

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.
author John "Elwin" Edwards
date Thu, 02 Jan 2014 11:39:57 -0500
parents e8f3b7994d88
children 05a4afbe6299
files py/rlgalldb.py web/scoring/scores.css
diffstat 2 files changed, 17 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/py/rlgalldb.py	Tue Dec 31 13:36:19 2013 -0500
+++ b/py/rlgalldb.py	Thu Jan 02 11:39:57 2014 -0500
@@ -39,6 +39,7 @@
 rowstart = '<div class="sentry">\n'
 rowend = '</div>\n'
 cell = '  <span class="sdata">{0}</span>\n'
+rcell = '  <span class="sdatar">{0}</span>\n'
 hcell = '  <span class="shdata">{0}</span>\n'
 tblend = '</div>\n'
 pend = "</body></html>\n"
@@ -112,24 +113,25 @@
     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
 
--- a/web/scoring/scores.css	Tue Dec 31 13:36:19 2013 -0500
+++ b/web/scoring/scores.css	Thu Jan 02 11:39:57 2014 -0500
@@ -42,3 +42,9 @@
 	display: table-cell;
 	padding: 0 1em;
 }
+
+span.sdatar {
+	display: table-cell;
+	padding: 0 1em;
+	text-align: right;
+}