[tools] testbot/cgi: Only refresh pages when the top is visible.
Francois Gouget
fgouget at codeweavers.com
Thu Apr 14 11:54:21 CDT 2022
This stops pages from refreshing and losing the scroll position while
one is inspecting a log file, looking at old job results, etc.
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
testbot/lib/WineTestBot/CGI/PageBase.pm | 33 ++++++++++++++++++-------
1 file changed, 24 insertions(+), 9 deletions(-)
diff --git a/testbot/lib/WineTestBot/CGI/PageBase.pm b/testbot/lib/WineTestBot/CGI/PageBase.pm
index 55e015d58..477a2ff15 100644
--- a/testbot/lib/WineTestBot/CGI/PageBase.pm
+++ b/testbot/lib/WineTestBot/CGI/PageBase.pm
@@ -416,11 +416,6 @@ sub GenerateHttpHeaders($)
# HTTP/1.0
$Request->headers_out->add("Pragma", "no-cache");
- if ($self->{Refresh})
- {
- $self->{Request}->headers_out->add("Refresh", $self->{Refresh});
- }
-
# Force char set
$Request->content_type("text/html; charset=UTF-8");
@@ -462,12 +457,32 @@ EOF
}
print ">\n";
- print <<EOF;
+ print "<div id='logo_blurb'>${ProjectName} Test Bot</div>\n";
+ if ($self->{Refresh})
+ {
+ print <<EOF;
+<script type='text/javascript'>
+<!--
+var Reloader;
+var Observer = new IntersectionObserver(function(entries) {
+ if (Reloader)
+ {
+ clearTimeout(Reloader);
+ Reloader = undefined;
+ }
+ if (entries[0].isIntersecting === true)
+ {
+ Reloader = setTimeout(function() { location.reload(); }, $self->{Refresh} * 1000);
+ }
+}, { threshold: [0] });
-<div id="logo_blurb">
-${ProjectName} Test Bot
-</div>
+Observer.observe(document.querySelector("#logo_blurb"));
+//-->
+</script>
+EOF
+ }
+ print <<EOF;
<div id='tabs'>
<ul>
<li><a href='//www.winehq.org/'>WineHQ</a></li>
--
2.30.2
More information about the wine-devel
mailing list