Open

$value) { foreach ($bins[$key] as $bin) { $url = formatURL($bin['url'], $bin['revision']); preg_match('/(.*?)<\/title>/', $bin['html'], $match); preg_match('/<body.*?>(.*)/s', $bin['html'], $body); $title = ''; if (count($body)) { $title = $body[1]; if (get_magic_quotes_gpc() && $body[1]) { $title = stripslashes($body[1]); } $title = trim(preg_replace('/\s+/', ' ', strip_tags($title))); } if (!$title && $bin['javascript']) { $title = preg_replace('/\s+/', ' ', $bin['javascript']); } if (!$title && count($match)) { $title = get_magic_quotes_gpc() ? stripslashes($match[1]) : $match[1]; } $firstTime = $bin['url'] != $last; if ($firstTime && $last !== null) : ?> <tr data-type="spacer"><td colspan=3></td></tr> <?php endif ?> <tr data-url="<?=$url?>"> <td class="url"><a href="<?=$url?>edit"><span<?=($firstTime ? ' class="first"' : '') . '>' . $bin['url']?>/</span><?=$bin['revision']?>/</a></td> <td class="created"><a pubdate="<?=$bin['created']?>" href="<?=$url?>edit"><?=getRelativeTime($bin['created'])?></a></td> <td class="title"><a href="<?=$url?>edit"><?=substr($title, 0, 200)?></a></td> </tr> <?php $last = $bin['url']; } } ?> </tbody> </table> </div> <div id="preview"> <h2>Preview</h2> <p id="viewing"></p> <iframe id="iframe" hidden></iframe> </div> <script> function render(url) { iframe.src = url + 'quiet'; iframe.removeAttribute('hidden'); viewing.innerHTML = url; } function matchNode(el, nodeName) { if (el.nodeName == nodeName) { return el; } else if (el.nodeName == 'BODY') { return false; } else { return matchNode(el.parentNode, nodeName); } } function removeHighlight() { var i = trs.length; while (i--) { trs[i].className = ''; } } function visit() { window.location = this.getAttribute('data-url') + 'edit'; } var preview = document.getElementById('preview'), iframe = document.getElementById('iframe'); bins = document.getElementById('bins'), trs = document.getElementsByTagName('tr'), current = null, viewing = document.getElementById('viewing'), hoverTimer = null; // this is some nasty code - just because I couldn't be // bothered to bring jQuery to the party. bins.onmouseover = function (event) { clearTimeout(hoverTimer); event = event || window.event; var url, target = event.target || event.srcElement; if (target = matchNode(event.target, 'TR')) { removeHighlight(); if (target.getAttribute('data-type') !== 'spacer') { target.className = 'hover'; // target.onclick = visit; url = target.getAttribute('data-url'); if (current !== url) { hoverTimer = setTimeout(function () { current = url; render(url); }, 200); } } } }; </script> </body> </html>