Cachearium\CacheAbstract::footerDebug PHP Method

footerDebug() public static method

Extensive footer debug code. Shows which parts of the HTML were cached or missed visually. Great!
public static footerDebug ( )
    public static function footerDebug()
    {
        if (!static::$debugOnPage) {
            return;
        }
        ?>
<script>
$(function() {
	var probes = $('.cachearium-debug-probe-begin');
	if (probes.length != $('.cachearium-debug-probe-end').length) {
		alert('Woooooooh! Cache starts do not match cache ends!');
	}

	for (var i = 0; i < probes.length; i++) {
		var p = $(probes[i]);
		var end = $('.cachearium-debug-probe-end[data-key="' + p.data('key') + '"]');
		var between = p.nextUntil(end);
		var bbox = {'top': 100000, 'left': 10000000, 'bottom': 0, 'right': 0 };

		for (var j = 0; j < between.length; j++) {
			var el = $(between[j]);
			var offset = el.offset();
			if (!el.is(':visible')) {
				continue;
			}
			if (bbox.top > offset.top) {
				bbox.top = offset.top;
			}
			if (bbox.left > offset.left) {
				bbox.left = offset.left;
			}
			if (bbox.bottom < (offset.top + el.height())) {
				bbox.bottom = offset.top + el.height();
			}
			if (bbox.right < (offset.left + el.width())) {
				bbox.right = offset.left + el.width();
			}
		}

		var style =
			"z-index: " + (1000 + p.parents().length) + ";" +
			"left: " + bbox.left + "px;" +
			"top: " + bbox.top + "px;" +
			"width: " + (bbox.right - bbox.left) + "px;" +
			"height: " + (bbox.bottom - bbox.top) + "px;";
		var debugel = $('<div class="cachearium-debug-view" style="' + style +
			'" data-key="' + p.data('key') + '"></div>');
		var innerdata = '<span class="cachearium-debug-view-innerdata">';
		$.each(p.data(), function (name, value) {
			debugel.attr("data-" + name, value);
			innerdata += name + ": " + value + "<br/>";
		});
		innerdata += '</span>';
		debugel.append(innerdata);
		$('body').append(debugel);
	}
	$('body').append(
		'<div class="cachearium-debug-overview">' +
			'<span><b>Cachearium</b></span><br/>' +
			'<span>' + probes.length + ' probes</span><br/>' +
			'<a id="cachearium-debug-toggle" href="#">Toggle</a>' +
		'</div>'
	);
	$('#cachearium-debug-toggle').click(function() {
		$('.cachearium-debug-view').toggle();
	});
});
</script>
<?php 
    }