-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiffs.html
More file actions
61 lines (57 loc) · 2.22 KB
/
diffs.html
File metadata and controls
61 lines (57 loc) · 2.22 KB
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
61
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Git Diffs</title>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/github.min.css"
integrity="sha512-0aPQyyeZrWj9sCA46UlmWgKOP0mUipLQ6OZXu8l4IcAmD2u31EPEy9VcIMvl7SoAaKe8bLXZhYoMaE/in+gcgA=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<link
rel="stylesheet"
type="text/css"
href="https://cdn.jsdelivr.net/npm/diff2html@3.4.48/bundles/css/diff2html.min.css"
integrity="sha384-iBvSlI3tNrrSIy7s6mvLg+5B2Z/QXbR4L0Pzg1nRf8zkXrz5JF316MLm2igMIpi2"
crossorigin="anonymous"
/>
</head>
<body>
<div id="message">Loading diffs...</div>
<div id="diffs"></div>
<script
type="text/javascript"
src="https://cdn.jsdelivr.net/npm/diff2html@3.4.48/bundles/js/diff2html-ui.min.js"
integrity="sha384-99bAn+VpNpavq3FarkwuSuDPDHMeakTiNqxxz3ezwdGUr414srIXY3YmXjaAkYne"
crossorigin="anonymous"
></script>
<script>
const message = document.getElementById("message");
const diffs = document.getElementById("diffs");
let currentDiff = "";
async function fetchAndRender() {
try {
const response = await fetch("/diffs", {
headers: { Accept: "text/x-diff" },
});
const data = await response.text();
if (data !== currentDiff) {
currentDiff = data;
await new Diff2HtmlUI(diffs, currentDiff).draw();
message.innerHTML = "";
}
} catch (error) {
message.innerHTML =
"<div>Error fetching diffs: " +
error.message +
"</div>";
}
}
fetchAndRender();
setInterval(fetchAndRender, 10000);
</script>
</body>
</html>