forked from HTTPArchive/legacy.httparchive.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.inc
230 lines (199 loc) · 6.73 KB
/
ui.inc
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<?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("utils.inc");
function genTitle($addl = "") {
global $gbMobile, $gbAndroid, $gbChrome, $gbIe, $gbIphone;
return "HTTP Archive " .
( $gbMobile ? "Mobile " : "" ) .
( $gbAndroid ? "Android " : "" ) .
( $gbChrome ? "Chrome " : "" ) .
( $gbIphone ? "iPhone " : "" ) .
( $gbIe ? "IE " : "" ) .
( $addl ? " - $addl" : "" );
}
function globalCss() {
return <<<OUTPUT
<style>
BODY { font-family: Arial; }
.header { border-bottom: 4px groove #17598F; font-size: 3em; color: #17598F; }
.preheader { font-size: 0.8em; }
.notification { color: #C00; }
.tdnum { text-align: right; }
</style>
OUTPUT;
}
// HTML to insert first inside the HEAD element.
function headfirst() {
$sHtml = "";
// Google Analytics
if ( ! isPrivateInstance() ) {
$sHtml = <<<OUTPUT
<script type="text/javascript">
// Google Analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-22381566-1']);
_gaq.push(['_setDomainName', '.httparchive.org']);
_gaq.push(['_trackPageview']);
_gaq.push(['_trackPageLoadTime']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script src="//cdn.speedcurve.com/js/lux.js?id=37921102" async></script>
OUTPUT;
}
$sHtml .= <<<OUTPUT
<script type="text/javascript">
function loadScript(url, callback) {
var sNew = document.createElement("script");
sNew.async = true;
sNew.src = url;
if ( "function" === typeof(callback) ) {
sNew.onload = function() {
callback();
sNew.onload = sNew.onreadystatechange = undefined; // clear it out to avoid getting called twice
};
sNew.onreadystatechange = function() {
if ( "loaded" === sNew.readyState || "complete" === sNew.readyState ) {
sNew.onload();
}
}
}
var s0 = document.getElementsByTagName('script')[0];
s0.parentNode.insertBefore(sNew, s0);
}
var _jqueryq = [];
function doJquery() {
for ( var i=0; i < _jqueryq.length; i++ ) {
var cmd = _jqueryq[i];
doCommand(cmd);
}
_jqueryq = undefined; // as a flat that future commands should be done immediately
}
function addCommand(cmd) {
if ( "undefined" === typeof(_jqueryq) ) {
doCommand(cmd);
}
else {
_jqueryq.push(cmd);
}
}
function doCommand(cmd) {
if ( "function" === typeof(cmd) ) {
cmd();
}
else if ( "string" === typeof(cmd) ) {
// Eval a string of JavaScript in the proper context.
if (window.execScript) {
window.execScript(cmd);
}
else {
var fn = function() {
window.eval.call(window, cmd);
};
fn();
}
}
}
loadScript("//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js");
</script>
<!--[if lt IE 9]>
<script>
// we use some new HTML tags - make them work in IE<9 - hrrmphf
var e = ("abbr,article,aside,audio,canvas,datalist,details,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,time,video").split(',');
for (var i = 0; i < e.length; i++) {
document.createElement(e[i]);
}
</script>
<![endif]-->
OUTPUT;
return $sHtml;
}
function uiHeader($title = "HTTP Archive", $bNavlinks = true, $extraNav='') {
global $gbMobile, $gbAndroid, $gbChrome, $gbDev, $gbDesktop, $gbIe, $gbIphone;
$navlinks = "";
if ( $bNavlinks ) {
// Make sure to echo the drop down list of "About" links in about.php.
$navlinks = '
<nav>
<ul>
<li> <a id="trendsnav" href="trends.php">Trends</a>
<li> <a id="statsnav" href="interesting.php">Stats</a>
<li><a id="websitesnav" href="websites.php">Websites</a>
<li><a id="discussnav" href="https://discuss.httparchive.org/">Discuss</a>
<li id="aboutnav" onmouseover="document.getElementById(\'aboutdropdown\').style.display=\'block\';" onmouseout="document.getElementById(\'aboutdropdown\').style.display=\'none\';"><a href="about.php">About</a>
<ul id="aboutdropdown">
<li><a href="about.php#mission">Mission</a></li>
<li><a href="about.php#faq">FAQ</a></li>
<li><a href="downloads.php">Download Data</a></li>
<li><a href="urls.php">URLs</a></li>
<li><a href="https://github.com/HTTPArchive/httparchive">Source Code</a></li>
<li><a href="https://github.com/HTTPArchive/httparchive/issues">Bugs</a></li>
<li><a href="https://discuss.httparchive.org/">Contact Us</a></li>
</ul>
</li>
</ul>
</nav>';
}
$sSelected = "style='border: 1px solid;'";
$sublogo = "<div class=sublogo>" .
"<a href=" . ( $gbDesktop ? "'/' $sSelected" : "'//legacy.httparchive.org'" ) . ">DESKTOP</a>" .
"<a href=" . ( $gbMobile ? "'/' $sSelected" : "'//mobile.httparchive.org'" ) . ">MOBILE</a>";
if ( $gbChrome ) {
$sublogo .= "<a href='/' $sSelected>Chrome</a>";
}
else if ( $gbAndroid ) {
$sublogo .= "<a href='/' $sSelected>Android</a>";
}
else if ( $gbIe ) {
$sublogo .= "<a href='/' $sSelected>IE</a>";
}
else if ( $gbIphone ) {
$sublogo .= "<a href='/' $sSelected>iPhone</a>";
}
$sublogo .= "</div>";
return <<<OUTPUT
<header>
<a href="index.php" id="logo" style="line-height: 0.7em;">HTTP Archive</a>
$sublogo
$navlinks
</header>
OUTPUT;
}
function uiFooter() {
return <<<OUTPUT
<footer style="text-align: center; margin-left: 8em; margin-right: 8em;">
<a href="about.php#sponsors">sponsors</a>:
<a title="Google" href="http://www.google.com/">Google</a>,
<a title="Mozilla" href="http://www.mozilla.org/firefox">Mozilla</a>,
<a title="New Relic" href="http://www.newrelic.com/">New Relic</a>,
<a title="O'Reilly Media" href="http://oreilly.com/">O’Reilly Media</a>,
<a href="http://www.etsy.com/">Etsy</a>,
<a title="dynaTrace Software" href="http://www.dynatrace.com/">dynaTrace</a>,
<a title="Instart Logic" href="http://instartlogic.com/">Instart Logic</a>,
<a title="Catchpoint Systems" href="http://www.catchpoint.com/">Catchpoint Systems</a>,
<a title="Fastly" href="http://bit.ly/1nWd1oL">Fastly</a>,
<a title="SOASTA mPulse" href="https://www.soasta.com/mpulse/sign-up/">SOASTA mPulse</a>,
<a title="Hosting Facts" href="https://hostingfacts.com/">Hosting Facts</a>,
<a title="TheBestVPN" href="https://thebestvpn.com/">TheBestVPN</a>,
and
<a title="Akamai" href="https://www.akamai.com/">Akamai</a>
.
<br>
powered by <a href="http://www.webpagetest.org">WebPagetest</a>
</footer>
OUTPUT;
}
?>