-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
402 lines (319 loc) · 12.7 KB
/
index.html
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
<html lang="en"><script type="text/javascript">window["_gaUserPrefs"] = { ioo : function() { return true; } }</script><head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<title class="title">Results overview</title>
<!-- Bootstrap core CSS -->
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="bootstrap/css/bootstrap-theme.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="stylesheets/main.css" rel="stylesheet">
<link href="stylesheets/default.css" rel="stylesheet">
</head>
<body>
<!-- Fixed navbar -->
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="?">Web caching analysis</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="?cache=proxycaches">Proxy Caches</a></li>
<li><a href="?cache=cdns">CDNs</a></li>
<li><a href="?site=testsuite">Test Suite</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<!-- Begin page content -->
<div class="container-fluid">
<div class="row">
<div class="col-sm-4 col-md-3" id="sidebar">
<div id="navi">
<ul class="nav nav-sidebar">
</ul>
</div>
</div>
<div class="col-sm-8 col-sm-offset-4 col-md-9 col-md-offset-3" id="content">
<div class="page-header" id="content-header">
<h1 class="title">
</h1>
<div class="description">
</div>
</div>
<div id="main"></div>
</div>
</div>
</div>
<!-- <footer class="footer">
<div class="container">
<p class="text-muted">Place sticky footer content here.</p>
</div>
</footer> -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="javascripts/jquery.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="javascripts/collapseList.js"></script>
<script src="javascripts/testSuiteRenderer.js"></script>
<script src="javascripts/javascript.js"></script>
<script src="javascripts/highlight.js"></script>
<script type="text/javascript">
var symbols = {
"[ok]" : '<span class="glyphicon glyphicon-ok" style="color:green" aria-hidden="true"></span>',
"[fail]" : "<span class='glyphicon glyphicon-remove' style='color:red' aria-hidden='true'></span>",
"[x]" : "<span class='glyphicon glyphicon-minus' style='color:orange' aria-hidden='true'></span>"
}
var keywords = ["ok","fail","x","(ok)"];
var cacheDirectives = ["max-age","s-maxage","Expires","no-cache","no-store","ETag","Last-Modified","max-stale","Set-Cookie","must-revalidate","proxy-revalidate","ETag","Date","Cache-Control:", "Cache-Control","public","min-fresh","only-if-cached","304 Not Modified","504 Gateway Time-out","502 Bad Gateway"]
var webCaches = ["proxycaches","browsercaches","cdns"];
var topicsProxyCaches = ["efl","exva","exvastale","ifl","imvastored","imvastale","stale","imvastored","cop","cachekey","iv","partial","auth","cookie","attacks"];
var topicsCDNs = ["efl","exva","exvastale","ifl","imvastored","imvastale","stale","imvastored","cop","cachekey","iv","partial","auth","cookie","attacks"];
var cdns = [];
var topicsCaches = {
"proxycaches" : topicsProxyCaches,
"cdns" : topicsCDNs
}
var cache = "proxycaches";
if(getParameterByName("site") == "testsuite" && getParameterByName("cache") == null){
renderTestSuite();
} else if(getParameterByName("site") == null && webCaches.includes(getParameterByName("cache"))) {
renderCacheSite();
} else {
$.get('snippets/welcome.html', function(data) {
$('#content-header').html(data);
$("#sidebar").remove();
$("#content").removeClass('col-sm-8 col-sm-offset-4 col-md-9 col-md-offset-3')
$("#content").addClass("col-md-12");
});
}
$("body").on("mouseenter","[data-toggle='popover']",function(){
$(this).popover({html: true})
$(this).popover('show');
});
$("body").on("mouseleave","[data-toggle='popover']",function(){
$(this).popover('hide');
});
$("body").on("click",".collapseReferences",function(){
var collapseId = $(this).attr("data-target");
$(collapseId).collapse("toggle");
});
hljs.registerLanguage("javascript",javascript);
hljs.registerLanguage("cachetest",function(hljs){
var syntax = {
case_insensitive: true,
// language is case-insensitive
keywords: {
keyword: 'GET PATCH POST',
literal: "p s c e es ep",
},
contains: [
{
className: 'string',
begin: "'", end: "'"
},
{
className: 'link',
begin : "/\\w+",
},
hljs.COMMENT(
'#', // begin
'\n',
{
contains: [
{
className: 'doc', begin: '@\\w+'
}
]
}
)
]
}
return syntax;
});
function renderTestSuite(){
$(".title").text("Test Suite");
$.get("snippets/testsuiteheader.html",function(data){
var contentHeader = $("#content-header").html(data);
$("#content-header").find("pre code").each(function(i, block){
hljs.highlightBlock(block);
});
});
$.getJSON("testsuite.json",function(testsuite){
var navi = $("#navi");
navi.html(renderTestSuiteNavi(testsuite));
var main = $("#main").html(renderTestSuiteMain(testsuite));
$("#main").find("pre code").each(function(i, block){
hljs.highlightBlock(block);
});
})
}
function renderCacheSite(){
$.get('snippets/resultsOverview.html', function(data) {
$("#content-header .description").html(data);
});
var cacheQuery = getParameterByName("cache") ? getParameterByName("cache") : "proxycaches";
var topics = [];
if(topicsCaches[cacheQuery]){
if(cacheQuery == "proxycaches"){
$(".title").text("Proxy Caches")
} else if(cacheQuery == "cdns"){
$(".title").text("Content Delivery Network");
} else if(cacheQuery == "browsercaches"){
$(".title").text("Web Browser Caches");
}
topics = topicsCaches[cacheQuery];
cache = cacheQuery;
}
for (var i = 0; i < topics.length; i++) {
var html = `<section id="${topics[i]}" class="resultsTable"><h2 class='headline'></h2><p class="description"></p><div class="tableDiv"></div></section><hr/>`
$("#main").append(html);
getSnippets(topics[i]);
if(topics[i] == "partial" || topics[i] == "cachekey"){
getCSV(topics[i],false);
} else {
getCSV(topics[i],true);
}
}
}
function getSnippets(name){
$.get(`snippets/${name}.html`,function(data){
var snippets = data.split("\n");
if(snippets.length > 1){
var headline = snippets[0];
var description = snippets[1];
var naviItem = `<li role="presentation"><a href="#${name}">${headline}</a></li>`;
$("#navi .nav").append(naviItem);
$(`#${name} .headline`).html(headline);
var description = description.replace(/\[ok\]/g,symbols["[ok]"]);
description = description.replace(/\[fail\]/g,symbols["[fail]"]);
description = description.replace(/\[x\]/g,symbols["[x]"]);
$(`#${name} .description`).html(description);
}
});
}
function getCSV(name,descColumn){
$.get(`csv/${cache}/${name}.csv`,function(data){
var table1 = csvToArray(data);
var html = renderTable(table1,descColumn);
$(`#${name} .tableDiv`).html(html);
//return html;
});
}
function csvToArray(csv){
var data = csv.split("\n");
var columns = [];
var rows = [];
for (var i = 0; i < data.length; i++) {
columns = data[i].split(";");
rows.push(columns);
}
return rows;
}
function renderSymbol(result){
if(result == "ok"){
result = symbols["[ok]"];
} else if(result == "(ok)"){
result = "(" + symbols["[ok]"] + ")";
} else if(result == "fail"){
result = symbols["[fail]"];
} else if(result == "x"){
result = symbols["[x]"];
}
return result;
}
function renderCellValue(cell){
var cellArray = cell.split(" ");
var value = "";
var danger = false;
if(cellArray.length > 0){
if(keywords.includes(cellArray[0].trim())){
var result = cellArray.shift().trim();
result = renderSymbol(result);
value = result;
if(cellArray.length > 0){
if(cellArray[0] == "red"){
danger = true;
cellArray.shift();
}
var comment = cellArray.join(" ");
//value += ` <br><br><span class="label label-info">${cellArray.join(" ")}</span>`;
var comments = comment.split(",");
//value += "<br><a href=# class='btn btn-info btn-xs'>Show details</a>"
var commentList = "<ul class='commentList'>";
for (var i = 0; i < comments.length; i++) {
commentList += "<li>" + convertHTTPdirectives(comments[i]) + "</li>";
};
commentList +="</ul>";
value += `<br><br><span class="glyphicon glyphicon-info-sign" data-toggle="popover" data-container="body" data-placement="left" data-content="${commentList}"></span>`;
}
} else {
value = convertHTTPdirectives(cell);
}
}
var cellObject = {
value : value,
danger : danger
}
return cellObject;
}
function renderTable(array,descColumn){
var html = "<table class='table table-striped table-bordered'>";
for (var i = 0; i < array.length; i++) {
html +="<tr>";
var columns = array[i];
for (var j = 0; j < columns.length; j++) {
if(i == 0 || j == 0){
if(i > 0 &&j == 0 && !descColumn){
var cell = renderCellValue(columns[j]);
html +=`<td>${cell.value}</td>`;
} else {
cellValue = convertHTTPdirectives(columns[j])
html +=`<th>${cellValue}</th>`;
}
} else {
var cell = renderCellValue(columns[j]);
html +=`<td ${cell.danger ? "class='danger'":""}>${cell.value}</td>`;
}
}
html +="</tr>"
}
html +="</table>";
return html;
}
function convertHTTPdirectives(text){
var regex = new RegExp(cacheDirectives.join("|"),"gi");
var textConverted = text.replace(regex, function(matched){
if(cacheDirectives.includes(matched)){
return "<code>"+ matched + "</code>";
} else {
return matched;
}
});
return textConverted;
}
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
function countTestCases(testCases){
return(testCases.match(/##/g) || []).length
}
</script>
</body></html>