This repository was archived by the owner on Jan 4, 2023. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathcompare.php
More file actions
172 lines (137 loc) · 4.26 KB
/
Copy pathcompare.php
File metadata and controls
172 lines (137 loc) · 4.26 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?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 = "Compare Stats";
$run1 = getParam("r1", null);
$slice1 = getParam("s1", null);
$run2 = getParam("r2", null);
$slice2 = getParam("s2", null);
function genForm($curLabel="", $curSlice="") {
global $gArchive;
$selectRun = selectArchiveLabel($gArchive, $curLabel, true, false);
$selectSlice = selectSlice($curSlice);
$sForm =<<<OUTPUT
<table cellpadding=0 cellspacing=0 border=0>
<tr>
<td> <label>Choose a run:</label> </td>
<td> $selectRun </td>
<td></td>
</tr>
<tr>
<td> <label>Choose URLs:</label> </td>
<td> $selectSlice </td>
<td>
<input type=submit value="Get Charts">
</td>
</tr>
</table>
OUTPUT;
return $sForm;
}
?>
<!doctype html>
<html>
<head>
<title><?php echo genTitle($gTitle) ?></title>
<meta charset="UTF-8">
<?php echo headfirst() ?>
<script type="text/javascript">
function doSubmit(num) {
var selectrun = document.getElementById("compare"+num).getElementsByTagName('select')[0];
var selectslice = document.getElementById("compare"+num).getElementsByTagName('select')[1];
var script = document.createElement('script');
script.src = "interesting-images.js?jsonp=interesting" + num +
"&l=" + escape(selectrun.options[selectrun.selectedIndex].value) +
"&s=" + escape(selectslice.options[selectslice.selectedIndex].value) +
"";
document.getElementsByTagName('head')[0].appendChild(script);
}
function interesting1(snippets) {
update("interesting1", snippets);
}
function interesting2(snippets) {
update("interesting2", snippets);
}
function update(id, snippets) {
var elem = document.getElementById(id);
if ( !elem || !snippets ) {
return;
}
var sHtml = "";
for ( var i=0, len=snippets.length; i < len; i++ ) {
sHtml += "<div>" + snippets[i] + "</div>";
}
elem.innerHTML = sHtml;
}
function getLink() {
var selectrun1 = document.getElementById("compare1").getElementsByTagName('select')[0];
var selectslice1 = document.getElementById("compare1").getElementsByTagName('select')[1];
var selectrun2 = document.getElementById("compare2").getElementsByTagName('select')[0];
var selectslice2 = document.getElementById("compare2").getElementsByTagName('select')[1];
var url = "compare.php?" +
"&r1=" + escape(selectrun1.options[selectrun1.selectedIndex].value) +
"&s1=" + escape(selectslice1.options[selectslice1.selectedIndex].value) +
"&r2=" + escape(selectrun2.options[selectrun2.selectedIndex].value) +
"&s2=" + escape(selectslice2.options[selectslice2.selectedIndex].value);
document.location = url;
}
</script>
<link type="text/css" rel="stylesheet" href="style.css" />
<style>
.chart {
border: 1px solid #BBB;
padding: 4px;
margin-bottom: 40px; }
</style>
</head>
<body>
<?php echo uiHeader($gTitle); ?>
<a style="float: right; font-size: 0.9em; margin-right: 20px;" href="javascript:getLink()" title="generate full URL">get link</a>
<h1>Compare stats</h1>
<style>
TABLE { border: 0; width: auto; }
tr:nth-child(2n+1) td { background: none; }
TD { padding-top: 0; padding-bottom: 0; }
</style>
<table cellpadding=0 cellspacing=0 border=0>
<tr>
<td id=compare1>
<form onsubmit="doSubmit('1'); return false;">
<?php echo genForm($run1, $slice1); ?>
</form>
<div id=interesting1 style="margin-top: 40px; min-width: 640px;">
</div>
</td>
<td id=compare2>
<form onsubmit="doSubmit('2'); return false;">
<?php echo genForm($run2, $slice2); ?>
</form>
<div id=interesting2 style="margin-top: 40px; min-width: 640px;">
</div>
</td>
</tr>
</table>
<?php echo uiFooter() ?>
<script type="text/javascript">
<?php
if ( $run1 && $slice1 ) {
echo "doSubmit(1);\n";
}
if ( $run2 && $slice2 ) {
echo "doSubmit(2);\n";
}
?>
</script>
</body>
</html>