summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorRomain d'Alverny <rda@mageia.org>2012-09-10 08:07:15 +0000
committerRomain d'Alverny <rda@mageia.org>2012-09-10 08:07:15 +0000
commit14fc91fcb6eabfebf3103e89919f6ae606fe0321 (patch)
tree5a1a3a25d6b9327892679938eaae4a24b3bbf36f /js
parent8e44f84b9d02dd5b9c8458f439dc3e89679aa25c (diff)
downloadpkgsubmit-14fc91fcb6eabfebf3103e89919f6ae606fe0321.tar
pkgsubmit-14fc91fcb6eabfebf3103e89919f6ae606fe0321.tar.gz
pkgsubmit-14fc91fcb6eabfebf3103e89919f6ae606fe0321.tar.bz2
pkgsubmit-14fc91fcb6eabfebf3103e89919f6ae606fe0321.tar.xz
pkgsubmit-14fc91fcb6eabfebf3103e89919f6ae606fe0321.zip
highlight log text on some keywords
Diffstat (limited to 'js')
-rw-r--r--js/pkgsubmit.js43
1 files changed, 41 insertions, 2 deletions
diff --git a/js/pkgsubmit.js b/js/pkgsubmit.js
index d5f6931..6f161e4 100644
--- a/js/pkgsubmit.js
+++ b/js/pkgsubmit.js
@@ -21,6 +21,45 @@ function isShortFile(path) {
return false;
}
+/**
+ * Inject <span /> elements with appropriate classes into given text
+ * to allow for highlighting specific portions of a text file.
+ *
+ * Here, log files with ok|success|test|warning|info|error|fail|etc.
+ *
+ * @param string text
+ *
+ * @return string
+*/
+function highlight_text(text) {
+ return text.replace(/.*(ok|succe|test|warn|info|deprecat|error|fail).*/gi, function (match, p1, p2, offset, string) {
+ console.log([match, p1, offset, string]);
+ var cl = 'none';
+ switch (p1.toLowerCase()) {
+ case 'succe':
+ case 'ok':
+ cl = 'ok';
+ break
+
+ case 'test':
+ case 'info':
+ cl = 'info';
+ break;
+
+ case 'warn':
+ case 'deprecat':
+ cl = 'warn';
+ break;
+
+ case 'error':
+ case 'fail':
+ cl = 'error';
+ break;
+ }
+ return '<span class="hl hl-' + cl + '">' + match + '</span>';
+ });
+}
+
$(function () {
$('.status-link').on("click", function (ev) {
@@ -71,7 +110,7 @@ $(function () {
id: cId
})
.addClass(isShortFile($(this).attr("href")) ? "short" : "")
- .append($("<textarea />", {
+ .append($("<div />", {
id: elId,
class: "file-view",
html: "loading..."
@@ -82,7 +121,7 @@ $(function () {
"/" + $(this).attr("href"),
{},
function (data) {
- $("#" + elId).html(data)
+ $("#" + elId).html(highlight_text(data))
.before(
$("<div />", {
class: "controls"