This repository has been archived by the owner on Jan 4, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 84
/
runs.php
124 lines (96 loc) · 3.22 KB
/
runs.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
require_once("ui.inc");
require_once("utils.inc");
$gTitle = "Batch Runs";
?>
<!doctype html>
<html>
<head>
<title><?php echo genTitle($gTitle) ?></title>
<meta charset="UTF-8">
<?php echo headfirst() ?>
<link type="text/css" rel="stylesheet" href="style.css" />
<style>
DT { font-weight: bold; margin-top: 20px; }
DD { margin-left: 40px; }
</style>
</head>
<body>
<?php echo uiHeader($gTitle); ?>
<h1><?php echo $gTitle ?></h1>
<p>
Here are the most recent URLs collected:
</p>
<div id="urls" style="border: 2px solid #999; padding: 8px; white-space: pre; overflow: auto;"></div>
<div id=spinner style="visibility: hidden; text-align: center;">
<img src="images/busy.gif">
</div>
<script type="text/javascript">
var gFirstPageid, gLastPageid;
function addUrls(aUrls) {
sHtml = "";
for ( var i = 0; i < aUrls.length; i++ ) {
var aUrl = aUrls[i];
if ( ! gFirstPageid ) {
gFirstPageid = aUrl[0];
}
// TODO: hmmm - We can't push this to production because the crawl is done in dev and the results are
// copied in bulk when all done. Later we should investigate copying the results as the crawl progresses.
// For now, we'll watch the dev databases but NOT link to the results.
// sHtml += "<code style='font-size: 0.9em'>" + formatDate(aUrl[1]) + "</code> <a href='viewsite.php?pageid=" + aUrl[0] + "'>" +
sHtml += "<code style='font-size: 0.9em'>" + formatDate(aUrl[1]) + "</code> " +
"<a href='" + aUrl[2] + "' target='_blank'>" + aUrl[2] + "</a>" +
( aUrl[3] ? " - " + aUrl[3] : "" ) +
"\n";
gLastPageid = aUrl[0];
}
document.getElementById("urls").innerHTML += sHtml;
}
var gbFetching = false;
function fetchUrls(n) {
if ( ! gbFetching ) {
gbFetching = true;
document.getElementById('spinner').style.visibility = "visible";
n = n || 50;
var s = document.createElement("script");
s.onload = function() { gbFetching = false; document.getElementById('spinner').style.visibility = "hidden"; };
s.src = "runs.js?pageid=" + gLastPageid + "&n=" + n;
document.getElementsByTagName("head")[0].appendChild(s);
}
}
var gaMonths = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
function formatDate(epoch) {
var d = new Date(1000 * epoch);
var sDate = gaMonths[d.getMonth()] + " " + d.getDate() + " " + lpad(d.getHours(),2,"0") + ":" +
lpad(d.getMinutes(),2,"0") + ":" + lpad(d.getSeconds(),2,"0");
return sDate;
}
function lpad(s, n, c) {
c = c || " ";
return (c + c + c + c + s).slice(-n);
}
window.onscroll = function() {
if ( (window.scrollY + window.innerHeight + 400) > document.body.scrollHeight ) {
fetchUrls();
}
};
<?php
require_once("runs.js");
?>
// prefetch
fetchUrls(100);
</script>
<?php echo uiFooter() ?>
</body>
</html>