diff options
author | Riyad Preukschas <riyad@informatik.uni-bremen.de> | 2012-11-10 00:03:46 +0100 |
---|---|---|
committer | Riyad Preukschas <riyad@informatik.uni-bremen.de> | 2012-11-10 00:03:46 +0100 |
commit | c42ada9bee6e95b6fd3ebdc55d4b269f7e18d9f6 (patch) | |
tree | fbc340bd503b5d670d58393bfeb05ff9dcbeaa26 /app/assets/javascripts/tree.js.coffee | |
parent | 45dcb1b5c4e765fa048492865d2664f52e0a11a9 (diff) | |
download | gitlab-ce-c42ada9bee6e95b6fd3ebdc55d4b269f7e18d9f6.tar.gz |
Allow linking to file lines
Supported formats: "L12" for single lines and "L12-34" for multiple lines
Diffstat (limited to 'app/assets/javascripts/tree.js.coffee')
-rw-r--r-- | app/assets/javascripts/tree.js.coffee | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/assets/javascripts/tree.js.coffee b/app/assets/javascripts/tree.js.coffee index 37adef70f35..8ef41e16853 100644 --- a/app/assets/javascripts/tree.js.coffee +++ b/app/assets/javascripts/tree.js.coffee @@ -35,3 +35,22 @@ $ -> state = History.getState() window.ajaxGet(state.url) )(window) + + # See if there are lines selected + # "#L12" and "#L34-56" supported + highlightBlobLines = -> + if window.location.hash isnt "" + matches = window.location.hash.match /\#L(\d+)(\-(\d+))?/ + first_line = parseInt matches[1] + last_line = parseInt matches[3] + + unless isNaN first_line + last_line = first_line if isNaN last_line + $("#tree-content-holder .highlight .line").removeClass("hll") + $("#LC#{line}").addClass("hll") for line in [first_line..last_line] + $("#L#{first_line}").ScrollTo() + + # Highlight the correct lines on load + highlightBlobLines() + # Highlight the correct lines when the hash part of the URL changes + $(window).on 'hashchange', highlightBlobLines |