summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--index.pl17
-rw-r--r--public/css/default.css6
-rw-r--r--templates/toplist.html.ep7
3 files changed, 23 insertions, 7 deletions
diff --git a/index.pl b/index.pl
index 6a7805f..9ae057d 100644
--- a/index.pl
+++ b/index.pl
@@ -512,13 +512,16 @@ get '/top' => sub {
}
my @argsort = reverse sort { $rates[$a] <=> $rates[$b] } ( 1 .. 99 );
- my @toplist = map {
- [
- $translation{$_} // $_,
- sprintf( '%.2f%%', $rates[$_] * 100 / $total ),
- $rates[$_]
- ]
- } @argsort;
+ my @toplist;
+ if ( $total > 0 ) {
+ @toplist = map {
+ [
+ $translation{$_} // $_,
+ sprintf( '%.2f%%', $rates[$_] * 100 / $total ),
+ $rates[$_]
+ ]
+ } @argsort;
+ }
$self->render(
'toplist',
diff --git a/public/css/default.css b/public/css/default.css
index 77964cd..cdbcf82 100644
--- a/public/css/default.css
+++ b/public/css/default.css
@@ -9,6 +9,12 @@ div.globalstats {
margin-bottom: 1em;
}
+div.error {
+ color: orangered;
+ font-weight: bold;
+ margin: 2em;
+}
+
div.about {
position: absolute;
top: 0.5em;
diff --git a/templates/toplist.html.ep b/templates/toplist.html.ep
index daead42..f639e36 100644
--- a/templates/toplist.html.ep
+++ b/templates/toplist.html.ep
@@ -1,5 +1,11 @@
%= include 'topform';
+% if (@{$toplist} == 0) {
+<div class="error">
+Keine Daten mit diesen Parametern gefunden.
+</div>
+% }
+% else {
<div class="toplist">
<table>
<tr><th>Meldung</th><th>Anteil</th><th>Anzahl</th></tr>
@@ -13,3 +19,4 @@
% }
</table>
</div>
+% }