mirror of
https://github.com/golang/go
synced 2024-11-17 18:44:44 -07:00
cmd/cover: allow part selection to be retained across page refreshes
Usually, you are primarily interested to see the coverage of a particular file (e.g. when you're changing tests that affects a given source file), it is very valuable if you can just refresh the page and immediately see changes to the part you're already looking at (without selecting from the selector again.) Change-Id: I615207c9be6713f436e444771134fceaf4600ff3 Reviewed-on: https://go-review.googlesource.com/17238 Run-TryBot: Minux Ma <minux@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Andrew Gerrand <adg@golang.org>
This commit is contained in:
parent
adf4c38b6e
commit
98abf2937e
@ -258,21 +258,35 @@ const tmplHTML = `
|
||||
</div>
|
||||
<div id="content">
|
||||
{{range $i, $f := .Files}}
|
||||
<pre class="file" id="file{{$i}}" {{if $i}}style="display: none"{{end}}>{{$f.Body}}</pre>
|
||||
<pre class="file" id="file{{$i}}" style="display: none">{{$f.Body}}</pre>
|
||||
{{end}}
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
(function() {
|
||||
var files = document.getElementById('files');
|
||||
var visible = document.getElementById('file0');
|
||||
var visible;
|
||||
files.addEventListener('change', onChange, false);
|
||||
function onChange() {
|
||||
function select(part) {
|
||||
if (visible)
|
||||
visible.style.display = 'none';
|
||||
visible = document.getElementById(files.value);
|
||||
visible = document.getElementById(part);
|
||||
if (!visible)
|
||||
return;
|
||||
files.value = part;
|
||||
visible.style.display = 'block';
|
||||
location.hash = part;
|
||||
}
|
||||
function onChange() {
|
||||
select(files.value);
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
if (location.hash != "") {
|
||||
select(location.hash.substr(1));
|
||||
}
|
||||
if (!visible) {
|
||||
select("file0");
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user