OSDN Git Service

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