From 934734a85a1e4cb68d8c1aa68c518b511c7be190 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Mon, 20 Feb 2017 16:16:32 -0500 Subject: diff: able to highlight line with hashtag URL --- public/js/gogs.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'public/js') diff --git a/public/js/gogs.js b/public/js/gogs.js index b7770fde..2cd98d3b 100644 --- a/public/js/gogs.js +++ b/public/js/gogs.js @@ -542,6 +542,20 @@ function initRepository() { $item.find(".bar .add").css("width", addPercent + "%"); }); } + + $('.diff-file-box .lines-num').click(function () { + if ($(this).attr('id')) { + window.location.href = '#' + $(this).attr('id'); + } + }); + + $(window).on('hashchange', function (e) { + $('.diff-file-box .lines-code.active').removeClass('active'); + var m = window.location.hash.match(/^#diff-.+$/); + if (m) { + $(m[0]).siblings('.lines-code').addClass('active'); + } + }).trigger('hashchange'); } // Quick start and repository home -- cgit v1.2.3