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

Commit

Permalink
gitweb (SyntaxHighlighter): interpret #l<line-number>
Browse files Browse the repository at this point in the history
It is pretty convenient to refer to a line number by appending, say,
highlighter, too.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
dscho authored and kblees committed Aug 16, 2014
1 parent 2d8053b commit c61f812
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion gitweb/gitweb.perl
Original file line number Diff line number Diff line change
Expand Up @@ -7188,7 +7188,21 @@ sub git_blob {
$lang =~ s! (\S+)$! $brush_prefix$1!;
print "'".$lang.qq!.js',!;
}
print qq!''); SyntaxHighlighter.all();</script>!;
print qq!''); SyntaxHighlighter.all();!
.qq!function scrollTo(number) {!
.qq! var elements = document.getElementsByClassName(number);!
.qq! if (elements.length == 0) setTimeout('scrollTo("' + number + '");', 50);!
.qq! else {!
.qq! window.scroll(0, elements[0].offsetTop);!
.qq! window.scrollTo(0, elements[0].offsetTop);!
.qq! elements[0].style.color = '#ff0000';!
.qq! }!
.qq!}!
.qq!var lineRegex = /#l(\\d+)\$/;!
.qq!var lineNumber = lineRegex.exec(document.URL);!
.qq!if (lineNumber)!
.qq! scrollTo('number' + lineNumber[1]);!
.qq!</script>!;
} else {
my $nr;
while (my $line = <$fd>) {
Expand Down

0 comments on commit c61f812

Please sign in to comment.