rosa-build/app/assets/javascripts/extra/highlight.js

29 lines
744 B
JavaScript
Raw Normal View History

2013-03-27 21:10:34 +00:00
$(document).ready(function() {
jQuery(window).bind('hashchange', function(e) {
var hash = location.hash;
if (/^#diff-/.test(hash)) {
highlightDiff(hash);
} else if (/^#L[0-9]+/.test(hash)) {
highlightShow(hash);
}
});
2013-03-28 10:21:25 +00:00
$(window).load(function() {
// this code will run after all other $(document).ready() scripts
// have completely finished, AND all page elements are fully loaded.
jQuery(window).trigger('hashchange');
});
2013-03-27 21:10:34 +00:00
});
function highlightShow(id) {
$('.highlight-line').remove();
$(id).append('<div class="highlight-line"></div>');
}
function highlightDiff(id) {
$('.highlight-line').removeClass('highlight-line');
$(id).parent().find('td.code').addClass('highlight-line');
}