<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="robots" content="noindex,noarchive">
	<meta name="generator" content="Nette Tester">

	<title><?= $title ? htmlspecialchars("$title - ") : ''; ?>Code coverage</title>

	<style type="text/css">
	html {
		font: 14px/1.5 Verdana,"Geneva CE",lucida,sans-serif;
		border-top: 4.7em solid #f4ebdb;
	}

	body {
		max-width: 990px;
		margin: -4.7em auto 0;
		background: #fcfaf5;
		color: #333;
	}

	footer {
		margin-left: .5em;
	}

	h1 {
		font-family: "Trebuchet MS","Geneva CE",lucida,sans-serif;
		font-size: 1.9em;
		margin: .5em .5em 1.5em;
		color: #7a7772;
		text-shadow: 1px 1px 0 white;
	}

	div.code {
		background: white;
		border: 1px dotted silver;
		padding: .4em 0;
		display: none;
		color: #333;
		overflow: auto;
	}

	code,
	div.code {
		font: 13px/1.3 monospace;
	}

	div.code > div {
		float: left;
		min-width: 100%;
		position: relative;
	}

	aside {
		min-width: 100%;
		position: absolute;
	}

	aside div {
		white-space: pre;
		padding-left: .7em;
	}

	aside a {
		color: #c0c0c0;
	}

	aside a:hover {
		color: inherit;
		font-weight: bold;
		text-decoration: none;
	}

	code {
		display: block;
		white-space: nowrap;
		position: relative;
	}

	a {
		color: #006aeb;
		text-decoration: none;
	}

	a:active,
	a:hover {
		text-decoration: underline;
	}

	td {
		vertical-align: middle;
	}

	small {
		color: gray;
	}

	.number {
		text-align: right;
		width: 50px;
	}

	.bar {
		border: 1px solid #acacac;
		background: #e50400;
		width: 35px;
		height: 1em;
	}

	.bar div {
		background: #1a7e1e;
		height: 1em;
	}

	.light td {
		opacity: .5;
	}

	.light td * {
		color: gray;
	}

	.not-loaded td * {
		color: red;
	}

	.t { background-color: #e0ffe0; }
	.u { background-color: #ffe0e0; }

	code .hc { color: #929292; }
	code .hd { color: #333; }
	code .hh { color: #06B; }
	code .hk { color: #e71818; }
	code .hs { color: #008000; }
	</style>
</head>

<body>
	<h1><?= $title ? htmlspecialchars("$title - ") : ''; ?>Code coverage <?= round($coveredPercent) ?>&nbsp;%</h1>

	<?php foreach ($files as $id => $info): ?>
	<div>
		<table>
		<tr<?= $info->class ? " class='$info->class'" : '' ?>>
			<td class="number"><small><?= $info->coverage ?> %</small></td>
			<td><div class="bar"><div style="width: <?= $info->coverage ?>%"></div></div></td>
			<td><a href="#F<?= $id ?>" class="toggle"><?= $info->name ?></a></td>
		</tr>
		</table>

		<div class="code" id="F<?= $id ?>">
		<div>
			<aside>
			<?php
			$code = file_get_contents($info->file);
			$lineCount = substr_count($code, "\n") + 1;
			$digits = ceil(log10($lineCount)) + 1;

			$prevClass = null;
			$closeTag = $buffer = '';
			for ($i = 1; $i < $lineCount; $i++) {
				$class = isset($info->lines[$i]) && isset($classes[$info->lines[$i]]) ? $classes[$info->lines[$i]] : '';
				if ($class !== $prevClass) {
					echo rtrim($buffer) . $closeTag;
					$buffer = '';
					$closeTag = '</div>';
					echo '<div' . ($class ? " class='$class'" : '') . '>';
				}

				$buffer .= "<a href='#F{$id}L{$i}' id='F{$id}L{$i}'>" . sprintf("%{$digits}s", $i) . "</a>\n";
				$prevClass = $class;
			}
			echo $buffer . $closeTag;

			$code = strtr(highlight_string($code, true), [
				'<code>' => "<code style='margin-left: {$digits}em'>",
				'<span style="color: ' => '<span class="',
			]);
			?>
			</aside>
			<?= $code ?>
		</div>
		</div>
	</div>
	<?php endforeach ?>

	<footer>
		<p>Generated by <a href="https://tester.nette.org">Nette Tester</a> at <?= @date('Y/m/d H:i:s') // @ timezone may not be set ?></p>
	</footer>

	<script>
	document.body.addEventListener('click', function (e) {
		if (e.target.className === 'toggle') {
			var el = document.getElementById(e.target.href.split('#')[1]);
			if (el.style.display === 'block') {
				el.style.display = 'none';
			} else {
				el.style.display = 'block';
			}
			e.preventDefault();
		}
	});

	if (el = document.getElementById(window.location.hash.replace(/^#|L\d+$/g, ''))) {
		el.style.display = 'block';
	}
	</script>
</body>
</html>
