From patchwork Sat Jun 1 18:09:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3,of,4,V3] hgweb: highlight the line which is linked at From: Alexander Plavin X-Patchwork-Id: 1694 Message-Id: To: mercurial-devel@selenic.com Date: Sat, 01 Jun 2013 22:09:53 +0400 # HG changeset patch # User Alexander Plavin # Date 1369991128 -14400 # Fri May 31 13:05:28 2013 +0400 # Node ID c6bbbc51246371efc23644a4dbbf75df14dc384b # Parent 52ac6e0376d90af868b87d89d2a9e86228cba812 hgweb: highlight the line which is linked at Line corresponding to the URL hash (#l) is highlighted in the views which show file(s) content. diff -r 52ac6e0376d9 -r c6bbbc512463 mercurial/templates/paper/footer.tmpl --- a/mercurial/templates/paper/footer.tmpl Thu May 30 20:23:50 2013 +0400 +++ b/mercurial/templates/paper/footer.tmpl Fri May 31 13:05:28 2013 +0400 @@ -1,5 +1,6 @@ {motd} diff -r 52ac6e0376d9 -r c6bbbc512463 mercurial/templates/paper/map --- a/mercurial/templates/paper/map Thu May 30 20:23:50 2013 +0400 +++ b/mercurial/templates/paper/map Fri May 31 13:05:28 2013 +0400 @@ -95,9 +95,9 @@ {lines} ' comparisonline = ' - - {leftlinenumber} {leftline|escape} - {rightlinenumber} {rightline|escape} + + {leftlinenumber} {leftline|escape} + {rightlinenumber} {rightline|escape} ' changelogparent = ' diff -r 52ac6e0376d9 -r c6bbbc512463 mercurial/templates/static/mercurial.js --- a/mercurial/templates/static/mercurial.js Thu May 30 20:23:50 2013 +0400 +++ b/mercurial/templates/static/mercurial.js Fri May 31 13:05:28 2013 +0400 @@ -4,6 +4,7 @@ // Display of elapsed time // Show or hide diffstat // Link to a line when clicking on it +// Highlight source lines // // Copyright 2008 Dirkjan Ochtman // Copyright 2006 Alexander Schremmer @@ -277,6 +278,38 @@ } +function highlightLine(elem) { + switch (elem.tagName) { + case 'A': + elem.parentNode.parentNode.className += ' linkedline'; + break; + case 'TR': + var nodes = elem.childNodes; + for (var i = 0; i < nodes.length; i++) { + highlightLine(nodes[i]); + } + break; + default: + elem.className += ' linkedline'; + break; + } +} + +function highlightLines() { + var nodes = document.getElementsByClassName('linkedline'); + while (nodes.length) { + nodes[0].className = nodes[0].className.replace(/(?:^|\s)linkedline(?!\S)/g, ''); + } + + var hash = window.location.hash; + if (/^#[^-]+/.test(hash)) { + var id = hash.substring(1); + highlightLine(document.getElementById(id)); + } +} + +window.addEventListener("hashchange", highlightLines, false); + function addOnclickSource() { var nodes = document.querySelectorAll('ol.sourcelines'); diff -r 52ac6e0376d9 -r c6bbbc512463 mercurial/templates/static/style-paper.css --- a/mercurial/templates/static/style-paper.css Thu May 30 20:23:50 2013 +0400 +++ b/mercurial/templates/static/style-paper.css Fri May 31 13:05:28 2013 +0400 @@ -96,6 +96,7 @@ .indexlinks { white-space:nowrap; } .parity0 { background-color: #f0f0f0; } .parity1 { background-color: white; } +:target, .linkedline { background-color: #ffff99 !important; } .plusline { color: green !important; } .minusline { color: #dc143c !important; } /* crimson */ .atline { color: purple !important; } diff -r 52ac6e0376d9 -r c6bbbc512463 tests/test-help.t --- a/tests/test-help.t Thu May 30 20:23:50 2013 +0400 +++ b/tests/test-help.t Fri May 31 13:05:28 2013 +0400 @@ -1458,6 +1458,7 @@ @@ -1627,6 +1628,7 @@ @@ -1826,6 +1828,7 @@ @@ -1924,6 +1927,7 @@ diff -r 52ac6e0376d9 -r c6bbbc512463 tests/test-hgweb-commands.t --- a/tests/test-hgweb-commands.t Thu May 30 20:23:50 2013 +0400 +++ b/tests/test-hgweb-commands.t Fri May 31 13:05:28 2013 +0400 @@ -340,6 +340,7 @@ @@ -470,6 +471,7 @@ @@ -565,6 +567,7 @@ @@ -689,6 +692,7 @@ diff -r 52ac6e0376d9 -r c6bbbc512463 tests/test-hgweb-descend-empties.t --- a/tests/test-hgweb-descend-empties.t Thu May 30 20:23:50 2013 +0400 +++ b/tests/test-hgweb-descend-empties.t Fri May 31 13:05:28 2013 +0400 @@ -134,6 +134,7 @@ diff -r 52ac6e0376d9 -r c6bbbc512463 tests/test-hgweb-diffs.t --- a/tests/test-hgweb-diffs.t Thu May 30 20:23:50 2013 +0400 +++ b/tests/test-hgweb-diffs.t Fri May 31 13:05:28 2013 +0400 @@ -159,6 +159,7 @@ @@ -287,6 +288,7 @@ @@ -428,6 +430,7 @@ @@ -556,6 +559,7 @@ @@ -664,9 +668,9 @@ - - - 1 a + + + 1 a @@ -677,6 +681,7 @@ @@ -789,13 +794,13 @@ - - 1 a - 1 a + + 1 a + 1 a - - - 2 a + + + 2 a @@ -806,6 +811,7 @@ @@ -916,13 +922,13 @@ - - 1 a - + + 1 a + - - 2 a - + + 2 a + @@ -933,6 +939,7 @@ diff -r 52ac6e0376d9 -r c6bbbc512463 tests/test-hgweb-empty.t --- a/tests/test-hgweb-empty.t Thu May 30 20:23:50 2013 +0400 +++ b/tests/test-hgweb-empty.t Fri May 31 13:05:28 2013 +0400 @@ -93,6 +93,7 @@ @@ -189,6 +190,7 @@ @@ -336,6 +338,7 @@ @@ -412,6 +415,7 @@ diff -r 52ac6e0376d9 -r c6bbbc512463 tests/test-hgweb-filelog.t --- a/tests/test-hgweb-filelog.t Thu May 30 20:23:50 2013 +0400 +++ b/tests/test-hgweb-filelog.t Fri May 31 13:05:28 2013 +0400 @@ -209,6 +209,7 @@ @@ -319,6 +320,7 @@ @@ -424,6 +426,7 @@ @@ -529,6 +532,7 @@ @@ -597,6 +601,7 @@ diff -r 52ac6e0376d9 -r c6bbbc512463 tests/test-hgweb-removed.t --- a/tests/test-hgweb-removed.t Thu May 30 20:23:50 2013 +0400 +++ b/tests/test-hgweb-removed.t Fri May 31 13:05:28 2013 +0400 @@ -128,6 +128,7 @@ @@ -231,6 +232,7 @@ diff -r 52ac6e0376d9 -r c6bbbc512463 tests/test-hgweb.t --- a/tests/test-hgweb.t Thu May 30 20:23:50 2013 +0400 +++ b/tests/test-hgweb.t Fri May 31 13:05:28 2013 +0400 @@ -98,6 +98,7 @@ @@ -191,6 +192,7 @@ @@ -298,6 +300,7 @@ diff -r 52ac6e0376d9 -r c6bbbc512463 tests/test-hgwebdir.t --- a/tests/test-hgwebdir.t Thu May 30 20:23:50 2013 +0400 +++ b/tests/test-hgwebdir.t Fri May 31 13:05:28 2013 +0400 @@ -657,6 +657,7 @@ @@ -727,6 +728,7 @@ @@ -1090,6 +1092,7 @@ diff -r 52ac6e0376d9 -r c6bbbc512463 tests/test-highlight.t --- a/tests/test-highlight.t Thu May 30 20:23:50 2013 +0400 +++ b/tests/test-highlight.t Fri May 31 13:05:28 2013 +0400 @@ -179,6 +179,7 @@ @@ -509,6 +510,7 @@