Francois Gouget : testbot/cgi: Only refresh pages when the top is visible.
Alexandre Julliard
julliard at winehq.org
Thu Apr 14 16:39:55 CDT 2022
Module: tools
Branch: master
Commit: 16ac37ae118b6116f8eb1fdef255a1439e300917
URL: https://source.winehq.org/git/tools.git/?a=commit;h=16ac37ae118b6116f8eb1fdef255a1439e300917
Author: Francois Gouget <fgouget at codeweavers.com>
Date: Thu Apr 14 18:54:21 2022 +0200
testbot/cgi: Only refresh pages when the top is visible.
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>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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 47f2da5..6e55316 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>
More information about the wine-cvs
mailing list