summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlpha <ngcoder@live.com>2015-07-23 15:43:47 -0400
committerAlpha <ngcoder@live.com>2015-07-23 15:43:47 -0400
commit82cd41b2a7f154a7ade5b01a62c30fb244ece4ac (patch)
tree82c2eda0cdbf490a7ab94822bee5e4e68f11f6b6
parenta8beb5ae9f799c4832428cee14cb3b47d136176c (diff)
parent9c4333412f5ac71d19031c538a8711c1502f2207 (diff)
downloadwebgrind-82cd41b2a7f154a7ade5b01a62c30fb244ece4ac.zip
webgrind-82cd41b2a7f154a7ade5b01a62c30fb244ece4ac.tar.gz
webgrind-82cd41b2a7f154a7ade5b01a62c30fb244ece4ac.tar.bz2
Merge pull request #56 from bendoh/master (modified)
Myriad improvements to the fileviewer code.
-rw-r--r--styles/style.css13
-rw-r--r--templates/fileviewer.phtml56
2 files changed, 51 insertions, 18 deletions
diff --git a/styles/style.css b/styles/style.css
index 5006204..7b3fb0a 100644
--- a/styles/style.css
+++ b/styles/style.css
@@ -164,9 +164,18 @@ img.list_reload {
border-right: 1px solid gray;
}
-.line_emph {
- background-color: #bbbbff;
+.line {
+ display: block;
+}
+
+.line:hover {
+ background-color: #ffd;
}
+
+.line.emph {
+ background-color: #dff;
+}
+
a.load_invocations {
display: none;
background-color: #999;
diff --git a/templates/fileviewer.phtml b/templates/fileviewer.phtml
index c80d8bd..79a5492 100644
--- a/templates/fileviewer.phtml
+++ b/templates/fileviewer.phtml
@@ -11,7 +11,7 @@
</title>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
- $('div#'+location.hash.substr(1)).addClass('line_emph');
+ $('#'+location.hash.substr(1)).addClass('emph');
});
</script>
@@ -27,21 +27,45 @@
<div id="main">
<h2><?php echo $file?></h2>
<br>
- <?php if ($message==''):?>
- <?php $source = highlight_file($file, true); ?>
- <table border="0">
- <tr>
- <td align="right" valign="top"><code>
- <?php
- foreach ($lines = explode('<br />', $source) as $num => $line) {
- $num++;
- echo "<span class='num' name='line$num' id='line$num'>$num</span>";
- }
- ?>
- </code></td>
- <td valign="top" nowrap="nowrap"><?php echo $source; ?></td>
- </tr>
- </table>
+ <?php if ($message==''): ?>
+ <table border="0">
+ <tr>
+ <td align="right" valign="top"><code>
+ <?php
+ //Strip code and first span
+ $hl = highlight_file($file, true);
+ $code = substr($hl, 36, -15);
+ //Split lines
+ $lines = explode('<br />', $code);
+
+ foreach ($lines as $num => $line) {
+ $num++;
+ echo "<span class='num'>$num</span>";
+ }
+ ?>
+ </code></td>
+ <td valign="top" nowrap="nowrap">
+ <?php
+ $openSpan = '';
+ foreach ($lines as $num => $line) {
+ $num++;
+ if (!$line) {
+ $line = '<br />';
+ }
+ if (!preg_match('#</span>\s*$#', $line)) {
+ $line .= '</span>';
+ }
+
+ echo "<code id='line$num' class='line'>$openSpan$line</code>";
+
+ if (preg_match('#.*(<span[^>]+>)#', $line, $matches)) {
+ $openSpan = $matches[1];
+ }
+ }
+ ?>
+ </td>
+ </tr>
+ </table>
<?php else:?>
<p><b><?php echo $message?></b></p>
<?php endif?>