diff options
-rw-r--r-- | log_files.php | 4 | ||||
-rw-r--r-- | style.css | 30 | ||||
-rw-r--r-- | test_index.php | 54 |
3 files changed, 83 insertions, 5 deletions
diff --git a/log_files.php b/log_files.php index a2203d3..7c365b9 100644 --- a/log_files.php +++ b/log_files.php @@ -44,7 +44,7 @@ foreach (glob_recursive($glob) as $f) { $link = 'uploads' . str_replace($upload_dir, '', $f); $show = str_replace(array($path . '/', '/'), array('', ' / '), $f); - $s .= sprintf('<li><a href="%s" rel="nofollow">%s</a> (%s)</li>', + $s .= sprintf('<li><a href="%s" rel="nofollow" class="view-inline">%s</a> (%s)</li>', $link, $show, _format_bytes(filesize($f)) ); @@ -61,7 +61,7 @@ foreach ($others as $suffix) { $link = 'uploads' . str_replace($upload_dir, '', $f); $show = explode($path, $f); $show = $job . $suffix; - $s .= sprintf('<li><a href="%s" rel="nofollow">%s</a> (%s)</li>', + $s .= sprintf('<li><a href="%s" rel="nofollow" class="view-inline">%s</a> (%s)</li>', $link, $show, _format_bytes(filesize($f)) ); @@ -43,6 +43,32 @@ tr.partial td.status-box { background: blue; } .figure { font-size: 120%%; font-weight: bold; } -tr.build-files-list td { font-size: 85%; padding: 1em 0 2em 2em; color: #555; } +tr.build-files-list td { font-size: 85%; padding: 1em 0 2em 1em; color: #555; } tr.build-files-list td a { text-decoration: none; } - tr.build-files-list td h4 { margin: 0 0 0.6em 0; }
\ No newline at end of file + tr.build-files-list td h4 { margin: 0 0 0.6em 0; } + +.file-view { + white-space: pre; + resize: both; + display: block; + overflow: auto; + box-shadow: 0 0 4px #303030; + margin: 0.5em 0; + width: 800px; + height: 10em; + background: #202020; + color: #f0f0fa; + padding: 0.5em 1em 1em 0.7em; + font-family: "Andale Mono", "Courier New", fixed; + position: relative; +} + +.controls { + float: right; + display: block; + text-align: right; +} +.gotobo, .gototop { + margin-left: 0.5em; + font-size: 90%; +}
\ No newline at end of file diff --git a/test_index.php b/test_index.php index 7d51d9d..5865f36 100644 --- a/test_index.php +++ b/test_index.php @@ -256,7 +256,7 @@ if ($total > 0) { echo sprintf('<li><p><span class="figure">%d</span> packages submitted in the past %d hours:</p>', $total, $max_modified * 24); // Last submitted packages - echo '<table>', + echo '<table id="submitted-packages">', '<thead><tr><th>Submitted</th><th>User</th> <th>Package</th><th>Target</th><th>Media</th> <th colspan="2">Status</th><th>Build time</th></tr></thead>', @@ -341,6 +341,58 @@ else } }); + $("table#submitted-packages tbody").on("click", "tr td li a.view-inline", function (ev) { + + // only open text log files + var ext = $(this).attr("href").split(".").pop(); + if (["log", "done", "youri"].indexOf(ext) < 0) + return true; + + if (!ev.metaKey) { + ev.preventDefault(); + + var elId = 'view-' + $(this).attr("href").replace(/\/|\./g, '-'); + var el = $("#" + elId); + if (el.length == 0) { + $(this).after($("<textarea />", { + id: elId, + class: "file-view", + html: "loading..." + })); + + $.get( + "/" + $(this).attr("href"), + {}, + function (data) { + $("#" + elId).html(data) + .before( + $("<div />", { + class: "controls" + }) + .append($("<button />", { + class: "gototop", + html: "top" + }).on("click", function (ev) { + var d = $("#" + elId); + d.animate({ scrollTop: 0 }, 200); + }) + ) + .append($("<button />", { + class: "gotobo", + html: "bottom" + }).on("click", function (ev) { + var d = $("#" + elId); + d.animate({ scrollTop: d.prop("scrollHeight") }, 200); + }) + ) + ) + } + ); + } else { + el.toggle(); + } + } + }); }); </script> <div class="clear"></div> |