/
index.html
60 lines (56 loc) · 2.15 KB
/
index.html
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Traceback JS</title>
<script src="dist/index.js"></script>
<script>
fetch('https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js')
.then(res => res.text())
.then(data => {
const $tracejs = document.querySelector('.traceback-js');
window.jQueryText = data;
$tracejs.textContent = data;
TracebackJS.init('.traceback-js', { highlightRow: 44, displayRows: '-10+8' });
const $container = $tracejs.cloneNode();
$container.innerHTML = TracebackJS.renderToString(data, { highlightRow: 10, start: 3 });
document.body.append($container);
});
function reset() {
const $tracejs = document.querySelector('.traceback-js');
const $dom = TracebackJS.render(window.jQueryText, { highlightRow: 44, displayRows: '-10+8' });
$tracejs.replaceChild($dom, $tracejs.firstElementChild);
}
function more() {
const $tracejs = document.querySelector('.traceback-js');
const $dom = TracebackJS.render(window.jQueryText, { highlightRow: 44, displayRows: '-25+25' });
$tracejs.replaceChild($dom, $tracejs.firstElementChild);
}
function all1() {
const $tracejs = document.querySelector('.traceback-js');
const $dom = TracebackJS.render(window.jQueryText, { highlightRow: 1743, displayRows: -1 });
$tracejs.replaceChild($dom, $tracejs.firstElementChild);
}
</script>
<style>
.traceback-js {
margin: 0 250px;
}
.actions {
position: fixed;
top: 10px;
left: 10px;
}
</style>
</head>
<body>
<div class="traceback-js"></div>
<hr>
<div class="actions">
<button onclick="reset()">重置</button>
<button onclick="more()">25行</button>
<button onclick="all1()">全部,高亮第1743行</button>
</div>
</body>
</html>