$.initLineNumbers = function () {
var hash = window.location.hash.substring(1),
container = $.get('container'),
hasLines, node;
// Add ids for each line number in the file source view.
$('.linenums>li').each(function () {
$(this).set('id', 'l' + (index + 1));
$(this).addClass('file-line');
hasLines = true;
});
// Scroll to the desired line.
if (hasLines && /^l\d+$/.test(hash)) {
if ((node = $.get(hash))) {
win.scroll(0, node.offset().x);
}
}
};
本文介绍了一个JavaScript脚本,该脚本用于在文件源视图中为每一行添加行号,并实现根据URL哈希值滚动到指定行的功能。此脚本通过正则表达式判断哈希值是否符合行号格式,然后滚动到对应元素。
1221

被折叠的 条评论
为什么被折叠?



