blob: 8c61b5ad521b59e7e97250ff348acaf14a6fc17e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
$(function() {
// Insert line numbers for all playground elements.
$('.playground').each(function() {
var $spans = $(this).find('> pre > span');
// Compute width of number column (including trailing space).
var max = 0;
$spans.each(function() {
var n = $(this).attr('num')*1;
if (n > max) max = n;
});
var width = 2;
while (max > 10) {
max = max / 10;
width++;
}
// Insert line numbers with space padding.
$spans.each(function() {
var n = $(this).attr('num')+" ";
while (n.length < width) n = " "+n;
$('<span class="number">').text(n).insertBefore(this);
});
});
});
|