forked from DocNow/diffengine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiff.html
More file actions
114 lines (92 loc) · 2.22 KB
/
diff.html
File metadata and controls
114 lines (92 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<html>
<head>
<meta charset="UTF-8"></meta>
<title>{{ title }}</title>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script>
function clip() {
// get the best clip we can find
var c = getClip();
// if we can't find a clip leave the page alone
if (c.length == 0) {
return;
}
// hide everything
$('header').hide();
$('.diff').children().hide();
// show our clip and its immediate siblings
c.show();
c.next().show();
c.prev().show();
}
function getClip() {
var p = null;
var largest = 0;
$("p").each(function(i, e) {
var len = changesLength(e);
if (len > largest) {
p = e;
largest = len;
}
});
return $(p);
}
function changesLength(p) {
return count(p, 'del') + count(p, 'ins');
}
function count(e, sel) {
var length = 0;
$(e).children(sel).each(function(i, c) {
length += $(c).text().length;
});
return length;
}
</script>
<style>
body {
font-size: 15pt;
margin: 0px;
background-color: white;
}
del {
background-color: pink;
}
del p {
background-color: pink;
}
ins {
background-color: lightgreen;
}
ins p {
background-color: lightgreen;
}
.diff {
margin: 10%;
}
header {
text-align: center;
background-color: #eeeeee;
padding: 10px;
border-bottom: thin solid #dddddd;
}
header .archive {
margin-top: 10px;
vertical-align: middle;
}
.archive a {
text-decoration: none;
}
</style>
</head>
<body>
<header>
<div class="url"><a href="{{ url }}">{{ url }}</a></div>
<div class="archive">
<a href="{{ old_url }}">{{ old_time.strftime("%Y-%m-%d %H:%M:%S GMT") }}</a>
≠
<a href="{{ new_url }}">{{ new_time.strftime("%Y-%m-%d %H:%M:%S GMT") }}</a>
</div>
</header>
{{ diff|safe }}
</body>
</html>