1<!-- Get and update the GCC regression tester's web page.
2     Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc.
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8Software Foundation; either version 3, or (at your option) any later
9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14for more details.
15
16You should have received a copy of the GNU General Public License
17along with GCC; see the file COPYING3.  If not see
18<http://www.gnu.org/licenses/>.  -->
19<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
20        "http://www.w3.org/TR/html4/strict.dtd">
21<head>
22<meta http-equiv="Content-Script-Type" content="text/javascript">
23<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
24<title>Regression Tester Status</title>
25<style type='text/css'>
26body {
27	margin: 0px;
28	padding: 0px;
29}
30pre {
31	font-family: Monaco;
32	font-size: 9px;
33	margin: 0px;
34	padding: 1px 2px 1px 2px;
35	color: black;
36	background-color: white;
37	opacity: 0.8;
38}
39</style>
40<script type='text/javascript' defer>
41// A string representing NUM, with a leading zero if it would be 1 digit long
42function dig2 (num) 
43{
44    var result = num.toString();
45    if (result.length == 1)
46	return '0' + result;
47    else
48	return result;
49}
50
51// Get DATE as a string in standard ISO format in UTC
52function getISO (date) 
53{
54    return (date.getUTCFullYear().toString() + '-'
55	    + dig2 (date.getUTCMonth() + 1) + '-'
56	    + dig2 (date.getUTCDate()) + 'T'
57	    + dig2 (date.getUTCHours()) + ':'
58	    + dig2 (date.getUTCMinutes()) + 'Z');
59}
60
61// STR is a bunch of lines of the form '<key>: <date>' where <date> is in
62// standard ISO UTC format.  Return a Date object corresponding to KEY, or null
63// if none is found.
64function fromISO (str, key)
65{
66    var rx = new RegExp (key + ": (\\d+)-(\\d+)-(\\d+)T(\\d+):(\\d+):(\\d+)Z");
67    var match = rx.exec (str);
68    if (match == null || match.length != 7)
69	return null;
70    var date = new Date(0);
71    date.setUTCFullYear (match[1], match[2] - 1, match[3]);
72    date.setUTCHours (match[4], match[5], match[6], 0);
73    return date;
74}
75
76// Update the data
77function updateContents () {
78    var url = 'http://gcc.gnu.org/regtest/HEAD/status.txt';
79    if (document.URL && document.URL.substring (0,5) == 'http:') {
80	url = document.URL.replace ('widget.html','status.txt');
81    }
82    var xml_request = new XMLHttpRequest();
83    
84    xml_request.onload = function(e) 
85	{
86	    gotContents(e, xml_request);
87	}
88    xml_request.open("GET", url);
89    xml_request.setRequestHeader("Cache-Control", "max-age=30");
90    xml_request.send(null);
91}
92
93function gotContents (event, request) {
94    if (request.status != 200)
95        return;
96
97    if (! request.responseText)
98	return;
99
100    var txt = request.responseText;
101    var today = new Date();
102    var date_r = fromISO (txt, "Date");
103    var completed_r = fromISO (txt, "Test-Completed");
104    var now_test_r = fromISO (txt, "Now-Testing");
105    var eta = "";
106    
107    if (date_r != null && completed_r != null && now_test_r != null)
108	{
109	    var eta_r = new Date (now_test_r.getTime() 
110				  + completed_r.getTime() - date_r.getTime());
111	    eta = "ETA: " + getISO (eta_r) + '\n';
112	}
113
114    var val = txt + "Now: " + getISO (today) + '\n' + eta;
115    var contEl = document.getElementById ("contents");
116    contEl.removeChild(contEl.firstChild);
117    contEl.appendChild (document.createTextNode (val));
118}
119
120var mainTimer = null;
121
122function myOnShow () 
123{
124    if (! mainTimer) {
125	mainTimer = setInterval (updateContents, 60000);
126    }
127    updateContents();
128}
129
130function myOnHide () 
131{
132    if (mainTimer) {
133	clearInterval (mainTimer);
134	mainTimer = null;
135    }
136}
137
138function myOnLoad ()
139{
140    if ( window.widget ) {
141	widget.onshow = myOnShow;
142	widget.onhide = myOnHide;
143    }
144    myOnShow();
145}
146</script>
147</head>
148
149<body onLoad='myOnLoad();'>
150<pre id="contents">Loading...</pre>
151</body>
152</html>
153