diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-11-08 12:24:46 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-11-08 14:15:20 +0000 |
| commit | 70e072b679a9d156102135dec78adea066147268 (patch) | |
| tree | dbd319e250e1d27bf27f5e6a6a24f97aacc1fe02 /pkg/html | |
| parent | 0571368b3bc37f92b06873e02342317006b0da60 (diff) | |
pkg/html/pages: move HTML code to a separate file
Diffstat (limited to 'pkg/html')
| -rw-r--r-- | pkg/html/pages/stats.go | 40 | ||||
| -rw-r--r-- | pkg/html/pages/stats.html | 40 |
2 files changed, 44 insertions, 36 deletions
diff --git a/pkg/html/pages/stats.go b/pkg/html/pages/stats.go index 3bc60cc5d..855ad0af8 100644 --- a/pkg/html/pages/stats.go +++ b/pkg/html/pages/stats.go @@ -5,6 +5,7 @@ package pages import ( "bytes" + _ "embed" "fmt" "html/template" @@ -20,40 +21,7 @@ func StatsHTML() (template.HTML, error) { return template.HTML(buf.String()), nil } -var statsTemplate = Create(` -<script type="text/javascript" src="https://www.google.com/jsapi"></script> -<script type="text/javascript"> - google.load("visualization", "1", {packages:["corechart"]}); - google.setOnLoadCallback(function() { - {{range $g := .}} - new google.visualization. {{if $g.Stacked}} AreaChart {{else}} LineChart {{end}} ( - document.getElementById('div_{{$g.ID}}')). - draw(google.visualization.arrayToDataTable([ - ["-" {{range $line := $g.Lines}} , '{{$line}}' {{end}}], - {{range $p := $g.Points}} [ {{$p.X}} {{range $y := $p.Y}} , {{$y}} {{end}} ], {{end}} - ]), { - title: '{{$g.Title}}', - titlePosition: 'in', - width: "95%", - height: "400", - chartArea: {width: '95%', height: '85%'}, - legend: {position: 'in'}, - lineWidth: 2, - focusTarget: "category", - {{if $g.Stacked}} isStacked: true, {{end}} - vAxis: {minValue: 1, textPosition: 'in', gridlines: {multiple: 1}, minorGridlines: {multiple: 1}}, - hAxis: {minValue: 1, textPosition: 'out', maxAlternation: 1, gridlines: {multiple: 1}, - minorGridlines: {multiple: 1}}, - }) - {{end}} +var statsTemplate = Create(statsHtml) - {{/* Preserve vertical scroll position after page reloads. Otherwise it's random. */}} - window.scroll(0, window.location.hash.substring(1)); - document.onscroll = function(e) { window.location.hash = Math.round(window.scrollY); }; - }); -</script> - -{{range $g := .}} - <div id="div_{{$g.ID}}"></div> -{{end}} -`) +//go:embed stats.html +var statsHtml string diff --git a/pkg/html/pages/stats.html b/pkg/html/pages/stats.html new file mode 100644 index 000000000..d535aac4d --- /dev/null +++ b/pkg/html/pages/stats.html @@ -0,0 +1,40 @@ +{{/* +Copyright 2024 syzkaller project authors. All rights reserved. +Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. +*/}} + +<script type="text/javascript" src="https://www.google.com/jsapi"></script> +<script type="text/javascript"> + google.load("visualization", "1", {packages:["corechart"]}); + google.setOnLoadCallback(function() { + {{range $g := .}} + new google.visualization. {{if $g.Stacked}} AreaChart {{else}} LineChart {{end}} ( + document.getElementById('div_{{$g.ID}}')). + draw(google.visualization.arrayToDataTable([ + ["-" {{range $line := $g.Lines}} , '{{$line}}' {{end}}], + {{range $p := $g.Points}} [ {{$p.X}} {{range $y := $p.Y}} , {{$y}} {{end}} ], {{end}} + ]), { + title: '{{$g.Title}}', + titlePosition: 'in', + width: "95%", + height: "400", + chartArea: {width: '95%', height: '85%'}, + legend: {position: 'in'}, + lineWidth: 2, + focusTarget: "category", + {{if $g.Stacked}} isStacked: true, {{end}} + vAxis: {minValue: 1, textPosition: 'in', gridlines: {multiple: 1}, minorGridlines: {multiple: 1}}, + hAxis: {minValue: 1, textPosition: 'out', maxAlternation: 1, gridlines: {multiple: 1}, + minorGridlines: {multiple: 1}}, + }) + {{end}} + + {{/* Preserve vertical scroll position after page reloads. Otherwise it's random. */}} + window.scroll(0, window.location.hash.substring(1)); + document.onscroll = function(e) { window.location.hash = Math.round(window.scrollY); }; + }); +</script> + +{{range $g := .}} + <div id="div_{{$g.ID}}"></div> +{{end}} |
