Browse Source

hover for years

master
Chris 6 years ago
parent
commit
c56437ebcc
  1. 4
      layouts/eventtypes/terms.html
  2. 4
      layouts/locations/terms.html
  3. 30
      layouts/partials/term-summary.html
  4. 4
      layouts/sports/terms.html

4
layouts/eventtypes/terms.html

@ -34,7 +34,9 @@
</div> </div>
<div class="flex pt1"> <div class="flex pt1">
{{ partial "term-summary.html" (dict "page" .Page "param_name" "eventtypes" ) }} {{ partial "term-summary.html" (dict "page" .Page "param_name" "eventtypes" "param_title" .Page.Title ) }}
</div>
<div id="{{ .Page.Title }}" class="flex justify-center pt1">
</div> </div>
</div> </div>

4
layouts/locations/terms.html

@ -35,7 +35,9 @@
</div> </div>
<div class="flex pt1"> <div class="flex pt1">
{{ partial "term-summary.html" (dict "page" .Page "param_name" "locations" ) }} {{ partial "term-summary.html" (dict "page" .Page "param_name" "locations" "param_title" .Page.Title ) }}
</div>
<div id="{{ .Page.Title }}" class="flex justify-center pt1">
</div> </div>
</div> </div>

30
layouts/partials/term-summary.html

@ -2,18 +2,34 @@
{{ $pages := where .page.Site.RegularPages "Type" "in" (slice "posts") }} {{ $pages := where .page.Site.RegularPages "Type" "in" (slice "posts") }}
{{ $count := len $pages }} {{ $count := len $pages }}
{{ $param_name := .param_name }} {{ $param_name := .param_name }}
{{ $param_title := .param_title }}
{{ $totalWidth := 100.0 }} {{ $totalWidth := 100.0 }}
{{ $totalHeight := 50.0 }} {{ $totalHeight := 50.0 }}
{{ $width := div $totalWidth ( len ( $pages.GroupByDate "2006" ) ) }} {{ $width := div $totalWidth ( len ( $pages.GroupByDate "2006" ) ) }}
{{ $color := "#357edd" }} {{ $color := "#a8c7f0" }}
{{ $strokecolor := "#d3e3f8" }}
<script>
function onyearover(year, key, count){
// alert( year + key + "!")
document.getElementById( key ).innerHTML = year + ": " + count;
}
function onyearout(key){
// alert( year + key + "!")
document.getElementById( key ).innerHTML = "";
}
</script>
<svg width="{{ $totalWidth }}%" height="{{ $totalHeight }}" <svg width="{{ $totalWidth }}%" height="{{ $totalHeight }}"
xmlns="http://www.w3.org/2000/svg"> xmlns="http://www.w3.org/2000/svg">
<rect height="100%" width="100%" opacity="0.1" fill="{{ $color }}"/> <rect height="100%" width="100%" opacity="0.1" fill="{{ $color }}"/>
{{ $x := 0 }} {{ $x := 0 }}
{{ $year := 0 }}
{{ range sort ( $pages.GroupByDate "2006" ) "Key" }} {{ range sort ( $pages.GroupByDate "2006" ) "Key" }}
{{ $maxCount := 0 }} {{ $maxCount := 0 }}
@ -21,7 +37,7 @@ xmlns="http://www.w3.org/2000/svg">
{{ range .Pages }} {{ range .Pages }}
{{ $maxCount = add 1 $maxCount }} {{ $maxCount = add 1 $maxCount }}
{{ $year = dateFormat "2006" .Date }}
{{ $isMember := false }} {{ $isMember := false }}
{{ if eq (.Param $param_name ) $key }} {{ if eq (.Param $param_name ) $key }}
@ -33,11 +49,9 @@ xmlns="http://www.w3.org/2000/svg">
{{ $height := 0 }} {{ $height := 0 }}
{{ $height = mul (float $totalHeight ) ( div (float $count ) ( float $maxCount ) ) }} {{ $height = mul (float $totalHeight ) ( div (float $count ) ( float $maxCount ) ) }}
{{/* {{ $dist }} */}} <rect onmouseover="onyearover({{ $year }}, {{ $param_title }}, {{ $count }} )" onmouseout="onyearout({{ $param_title }})" height="{{ $height }}" y="{{ sub $totalHeight $height }}" x="{{ $x }}%"
{{/* {{ $x }} */}} width="{{ $width }}%" fill="{{ $color }}" stroke-width="1.5" stroke="{{$strokecolor}}"
{{/* {{ $height }} */}} class="dim"/>
<rect opacity="0.2" height="{{ $height }}" y="{{ sub $totalHeight $height }}" x="{{ $x }}%"
width="{{ $width }}%" fill="{{ $color }}" stroke-width="1.5" stroke="{{$color}}"/>
{{ $x = add $x $width }} {{ $x = add $x $width }}
{{ end }} {{ end }}

4
layouts/sports/terms.html

@ -36,7 +36,9 @@
</div> </div>
<div class="flex pt1"> <div class="flex pt1">
{{ partial "term-summary.html" (dict "page" .Page "param_name" "sports" ) }} {{ partial "term-summary.html" (dict "page" .Page "param_name" "sports" "param_title" .Page.Title) }}
</div>
<div id="{{ .Page.Title }}" class="flex justify-center pt1">
</div> </div>
</div> </div>

Loading…
Cancel
Save