Skip to content

Commit

Permalink
web: Fixed text alignment and number formatting for statistics tables
Browse files Browse the repository at this point in the history
  • Loading branch information
YourMJK committed Aug 2, 2024
1 parent 95c8072 commit 4944eee
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 43 deletions.
10 changes: 8 additions & 2 deletions code/dreimetadaten/Web/StatisticsPageBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,18 @@ class StatisticsPageBuilder: PageBuilder {
private func replaceContentPlaceholder() throws {
var content = ""

let decimalFormatter = NumberFormatter()
decimalFormatter.numberStyle = .decimal
decimalFormatter.usesGroupingSeparator = false

func addLine(_ line: String) {
content.append(line)
content.append("\n")
}
func format(_ value: DatabaseValue) -> String {
switch value.storage {
case .string(let string): return string
case .double(let double): return decimalFormatter.string(from: NSNumber(value: double))!
default: return "\(value)"
}
}
Expand Down Expand Up @@ -77,8 +82,9 @@ class StatisticsPageBuilder: PageBuilder {
// Data
for row in rows {
table.startRow()
row.databaseValues.forEach {
table.addCell(class: .data, content: format($0))
row.databaseValues.enumerated().forEach {
let first = $0.offset == 0 && row.count != 1
table.addCell(class: first ? .nr : .data, content: format($0.element))
}
table.endRow()
}
Expand Down
82 changes: 41 additions & 41 deletions web/statistik.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,43 +62,43 @@ <h4>nach gesprochenen Sprechrollen</h4>
<th>Anzahl</td>
</tr>
<tr>
<td class="cell_data">Oliver Rohrbeck</td>
<td class="cell_nr">Oliver Rohrbeck</td>
<td class="cell_data">258</td>
</tr>
<tr>
<td class="cell_data">Andreas Fröhlich</td>
<td class="cell_nr">Andreas Fröhlich</td>
<td class="cell_data">257</td>
</tr>
<tr>
<td class="cell_data">Jens Wawrczeck</td>
<td class="cell_nr">Jens Wawrczeck</td>
<td class="cell_data">257</td>
</tr>
<tr>
<td class="cell_data">Thomas Fritsch</td>
<td class="cell_nr">Thomas Fritsch</td>
<td class="cell_data">102</td>
</tr>
<tr>
<td class="cell_data">Holger Mahlich</td>
<td class="cell_nr">Holger Mahlich</td>
<td class="cell_data">86</td>
</tr>
<tr>
<td class="cell_data">Karin Lieneweg</td>
<td class="cell_nr">Karin Lieneweg</td>
<td class="cell_data">76</td>
</tr>
<tr>
<td class="cell_data">Peter Pasetti</td>
<td class="cell_nr">Peter Pasetti</td>
<td class="cell_data">63</td>
</tr>
<tr>
<td class="cell_data">Axel Milberg</td>
<td class="cell_nr">Axel Milberg</td>
<td class="cell_data">47</td>
</tr>
<tr>
<td class="cell_data">Andreas von der Meden</td>
<td class="cell_nr">Andreas von der Meden</td>
<td class="cell_data">41</td>
</tr>
<tr>
<td class="cell_data">Matthias Fuchs</td>
<td class="cell_nr">Matthias Fuchs</td>
<td class="cell_data">39</td>
</tr>
</table>
Expand All @@ -119,43 +119,43 @@ <h4>nach vorkommenden Hörspielen</h4>
<th>Anzahl</td>
</tr>
<tr>
<td class="cell_data">Bob Andrews, Recherchen und Archiv</td>
<td class="cell_nr">Bob Andrews, Recherchen und Archiv</td>
<td class="cell_data">248</td>
</tr>
<tr>
<td class="cell_data">Justus Jonas, Erster Detektiv</td>
<td class="cell_nr">Justus Jonas, Erster Detektiv</td>
<td class="cell_data">248</td>
</tr>
<tr>
<td class="cell_data">Peter Shaw, Zweiter Detektiv</td>
<td class="cell_nr">Peter Shaw, Zweiter Detektiv</td>
<td class="cell_data">248</td>
</tr>
<tr>
<td class="cell_data">Erzähler</td>
<td class="cell_nr">Erzähler</td>
<td class="cell_data">176</td>
</tr>
<tr>
<td class="cell_data">Inspektor Cotta</td>
<td class="cell_nr">Inspektor Cotta</td>
<td class="cell_data">79</td>
</tr>
<tr>
<td class="cell_data">Hitchcock, Erzähler</td>
<td class="cell_nr">Hitchcock, Erzähler</td>
<td class="cell_data">75</td>
</tr>
<tr>
<td class="cell_data">Tante Mathilda</td>
<td class="cell_nr">Tante Mathilda</td>
<td class="cell_data">75</td>
</tr>
<tr>
<td class="cell_data">Onkel Titus</td>
<td class="cell_nr">Onkel Titus</td>
<td class="cell_data">48</td>
</tr>
<tr>
<td class="cell_data">Kommissar Reynolds</td>
<td class="cell_nr">Kommissar Reynolds</td>
<td class="cell_data">27</td>
</tr>
<tr>
<td class="cell_data">Morton</td>
<td class="cell_nr">Morton</td>
<td class="cell_data">27</td>
</tr>
</table>
Expand All @@ -176,43 +176,43 @@ <h4>nach geschriebenen Buchvorlagen</h4>
<th>Anzahl</td>
</tr>
<tr>
<td class="cell_data">Marco Sonnleitner</td>
<td class="cell_nr">Marco Sonnleitner</td>
<td class="cell_data">43</td>
</tr>
<tr>
<td class="cell_data">André Marx</td>
<td class="cell_nr">André Marx</td>
<td class="cell_data">41</td>
</tr>
<tr>
<td class="cell_data">Ben Nevis</td>
<td class="cell_nr">Ben Nevis</td>
<td class="cell_data">28</td>
</tr>
<tr>
<td class="cell_data">Hendrik Buchna</td>
<td class="cell_nr">Hendrik Buchna</td>
<td class="cell_data">24</td>
</tr>
<tr>
<td class="cell_data">Kari Erlhoff</td>
<td class="cell_nr">Kari Erlhoff</td>
<td class="cell_data">24</td>
</tr>
<tr>
<td class="cell_data">André Minninger</td>
<td class="cell_nr">André Minninger</td>
<td class="cell_data">21</td>
</tr>
<tr>
<td class="cell_data">Christoph Dittert</td>
<td class="cell_nr">Christoph Dittert</td>
<td class="cell_data">17</td>
</tr>
<tr>
<td class="cell_data">Brigitte Johanna Henkel-Waidhofer</td>
<td class="cell_nr">Brigitte Johanna Henkel-Waidhofer</td>
<td class="cell_data">16</td>
</tr>
<tr>
<td class="cell_data">M. V. Carey</td>
<td class="cell_nr">M. V. Carey</td>
<td class="cell_data">15</td>
</tr>
<tr>
<td class="cell_data">William Arden</td>
<td class="cell_nr">William Arden</td>
<td class="cell_data">15</td>
</tr>
</table>
Expand All @@ -233,43 +233,43 @@ <h4>nach Dauer</h4>
<th>Sekunden</td>
</tr>
<tr>
<td class="cell_data">Feuriges Auge</td>
<td class="cell_nr">Feuriges Auge</td>
<td class="cell_data">17712</td>
</tr>
<tr>
<td class="cell_data">Feuermond</td>
<td class="cell_nr">Feuermond</td>
<td class="cell_data">13119</td>
</tr>
<tr>
<td class="cell_data">und der dreiTag</td>
<td class="cell_nr">und der dreiTag</td>
<td class="cell_data">13078</td>
</tr>
<tr>
<td class="cell_data">Böser die Glocken nie klingen</td>
<td class="cell_nr">Böser die Glocken nie klingen</td>
<td class="cell_data">12210</td>
</tr>
<tr>
<td class="cell_data">Geisterbucht</td>
<td class="cell_nr">Geisterbucht</td>
<td class="cell_data">11918</td>
</tr>
<tr>
<td class="cell_data">und der schwarze Tag</td>
<td class="cell_nr">und der schwarze Tag</td>
<td class="cell_data">11729</td>
</tr>
<tr>
<td class="cell_data">Schattenwelt</td>
<td class="cell_nr">Schattenwelt</td>
<td class="cell_data">11249</td>
</tr>
<tr>
<td class="cell_data">und der Puppenmacher</td>
<td class="cell_nr">und der Puppenmacher</td>
<td class="cell_data">10696</td>
</tr>
<tr>
<td class="cell_data">und die Geisterlampe</td>
<td class="cell_nr">und die Geisterlampe</td>
<td class="cell_data">10299</td>
</tr>
<tr>
<td class="cell_data">und der 5. Advent</td>
<td class="cell_nr">und der 5. Advent</td>
<td class="cell_data">10281</td>
</tr>
</table>
Expand Down Expand Up @@ -307,7 +307,7 @@ <h4>in Stunden</h4>
<div>
<table class="datatable">
<tr>
<td class="cell_data">307.62</td>
<td class="cell_data">307,62</td>
</tr>
</table>
</div>
Expand Down

0 comments on commit 4944eee

Please sign in to comment.