Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit afcbb0f

Browse files
dschokasal
authored andcommitted
gitweb (SyntaxHighlighter): interpret #l<line-number>
It is pretty convenient to refer to a line number by appending, say, highlighter, too. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 71a8b52 commit afcbb0f

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

gitweb/gitweb.perl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7188,7 +7188,21 @@ sub git_blob {
71887188
$lang =~ s! (\S+)$! $brush_prefix$1!;
71897189
print "'".$lang.qq!.js',!;
71907190
}
7191-
print qq!''); SyntaxHighlighter.all();</script>!;
7191+
print qq!''); SyntaxHighlighter.all();!
7192+
.qq!function scrollTo(number) {!
7193+
.qq! var elements = document.getElementsByClassName(number);!
7194+
.qq! if (elements.length == 0) setTimeout('scrollTo("' + number + '");', 50);!
7195+
.qq! else {!
7196+
.qq! window.scroll(0, elements[0].offsetTop);!
7197+
.qq! window.scrollTo(0, elements[0].offsetTop);!
7198+
.qq! elements[0].style.color = '#ff0000';!
7199+
.qq! }!
7200+
.qq!}!
7201+
.qq!var lineRegex = /#l(\\d+)\$/;!
7202+
.qq!var lineNumber = lineRegex.exec(document.URL);!
7203+
.qq!if (lineNumber)!
7204+
.qq! scrollTo('number' + lineNumber[1]);!
7205+
.qq!</script>!;
71927206
} else {
71937207
my $nr;
71947208
while (my $line = <$fd>) {

0 commit comments

Comments
 (0)