summaryrefslogtreecommitdiff
path: root/data/tpl/vnpage_stats
blob: 841fce3754a25cac75f0eacbaa6c0680cf805ce2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<ul id="stats">

[[
  my $max = 1; my $total = 0; my $sum = 0;
  for (0..$#{$d{votes}{graph}}) {
    $total += $d{votes}{graph}[$_];
    $max = $d{votes}{graph}[$_] if $d{votes}{graph}[$_] > $max;
    $sum += ($_+1) * $d{votes}{graph}[$_];
  }
]]
[[ if(!$d{user} || ($d{pv} && $d{user}{votes})) { ]]-
<li><h3>Vote graph <p class="actions">[[= $total ]]- vote[[= $total==1?'':'s' ]]- total
  [[= $total ? sprintf(', average: %.1f.', $sum/$total) : '' ]]</p></h3>
<table id="tvg">
[[ for (0..$#{$d{votes}{graph}}) { ]]-
 <tr>
  <td class="tc1">[[= $_+1 ]]</td>
  <td class="tc2"><div style="width: -[[= ($d{votes}{graph}[$_]/$max)*270 + 5 ]]px">&nbsp;</div>[[= $d{votes}{graph}[$_] ]]</td>
 </tr>
[[ } ]]-
</table></li>

[[ if($#{$d{votes}{latest}} >= 0) { ]]
<li><h3>Recent votes</h3>
<table id="tvr">
[[ for (@{$d{votes}{latest}}) { ]]-
 <tr>
 [[ if(!$d{user}) { ]]-
  <td class="tc1"><a href="/u[[= $_->{uid} ]]">[[: $_->{username} ]]</a></td>
 [[ } else { ]]-
  <td class="tc1"><a href="/v[[= $_->{vid} ]]">[[: length($_->{title})>30?substr($_->{title},0,27).'...':$_->{title} ]]</a></td>
 [[ } ]]-
  <td class="tc2">[[= $_->{vote} ]]</td>
  <td class="tc3">[[= formatdate('%Y-%m-%d %R', $_->{date}, 'dh') ]]</td>
 </tr>
[[ } ]]-
</table></li>
[[ } } ]]-

-[[ $max = 1; $total = 0;
  for (@{$d{lists}{graph}}) { $total += $_; $max = $_ if $_ > $max; } ]]
[[ if(!$d{user} || ($d{pl} && $d{user}{vnlist})) { ]]-
<li class="break"><h3>VN List stats <p class="actions">[[= $total ]]- -[[= $d{user}?'visual novel':'user' ]][[= $total==1?'':'s' ]]- total</p></h3>
<table id="tus">
 [[ for (0..$#$VNDB::LSTAT) { ]]-
 <tr>
  <td class="tc1">[[= $VNDB::LSTAT->[$_] ]]</td>
  <td class="tc2"><div style="width: -[[= ($d{lists}{graph}[$_]/$max)*235 + 5 ]]px">&nbsp;</div>[[= $d{lists}{graph}[$_] ]]</td>
 </tr>
 [[ } ]]-
</table></li>

[[ if($#{$d{lists}{latest}} >= 0) { ]]
<li><h3>Recent VN list additions</h3>
<table id="tur">
[[ for (@{$d{lists}{latest}}) { ]]-
 <tr>
 [[ if(!$d{user}) { ]]-
  <td class="tc1"><a href="/u[[= $_->{uid} ]]">[[: $_->{username} ]]</a></td>
 [[ } else { ]]-
  <td class="tc1"><a href="/v[[= $_->{vid} ]]">[[: length($_->{title})>25?substr($_->{title},0,23).'...':$_->{title} ]]</a></td>
 [[ } ]]-
  <td class="tc2">[[= $VNDB::LSTAT->[$_->{status}] ]]</td>
  <td class="tc3">[[= formatdate('%Y-%m-%d %R', $_->{date}, 'dh') ]]</td>
 </tr>
[[ } ]]-
</table></li>
[[ } } ]]-
</ul>