forked from robustirc/robustirc
/
canary-header.html
142 lines (123 loc) · 3.51 KB
/
canary-header.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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<!DOCTYPE html>
<head>
<style type="text/css">
table {
font-family: monospace;
}
td {
vertical-align: top;
}
tr:nth-child(even) {
background: #ccc;
}
tr:nth-child(odd) {
background: #fff;
}
td.oldmsg, td.newmsg {
width: 50%;
}
.compacted {
background-color: #f00;
}
tr.interestingfordiff, tr.messagediff, tr.compactiondiff {
/* We need the !important to override <tr style="display: none">, which we
use to accelerate loading the page. */
display: table-row !important;
}
tr.interestingfordiff td.newmsg {
border-right: 4px solid #ff66ff;
}
tr.messagediff td.newmsg {
border-right: 4px solid #ff3333;
}
span.input::before {
content: "← ";
}
span.output::before {
content: "→ ";
}
.interestingfor:empty:after {
/* non-breaking space */
content: "\00a0";
}
.ifb {
color: green;
}
.ifbdiff {
color: red;
}
ins {
background-color: #00ff00;
}
del {
background-color: #ff0000;
}
</style>
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
</head>
<body>
<script type="text/javascript">
function resolveSessionid(el) {
var serverNickRe = new RegExp('^@ NICK ([^ ]+)');
var current = $(el).parents('tr');
var session = $(el).text();
console.log('resolving session', session);
var tr = $('tr[data-session="' + session + '"], tr[data-session="' + $(current).attr('data-session') + '"]');
var idx = $(tr).index(current);
var nick;
console.log('idx', idx, 'tr', tr);
for (i = idx; i >= 0; i--) {
var row = $(tr[i]);
if (row.attr('data-session') !== session) {
continue;
}
row.find('span.output').each(function(idx, el) {
var output = $(el).text();
// XXX: also consider @ :nick!user@robust/<session> NICK :<newnick> message (forced rename)
if (output.indexOf('@ NICK') === 0) {
var matches = serverNickRe.exec(output);
if (matches.length === 2) {
nick = matches[1];
return false;
}
}
});
if (nick !== undefined) {
break;
}
var input = row.find('td.oldmsg span.input').text();
if (input.toLowerCase().indexOf('nick ') === 0) {
nick = input.substring('nick '.length);
break;
}
}
// XXX: For correctness, we should NOT replace all sessions. After all,
// people can change their nickname mid-session. We might be able to use
// a triple (session, nick, resolved_at_line) to speed up searches, yet
// do a new search for every span.sessionid
$('.rawsessionid:contains("' + session + '")').text(nick + '/' + session).removeClass('rawsessionid');
}
$(document).ready(function() {
$('.ifb').click(function(ev) {
var msgid = $(this).parent().attr('id');
$('.interestingfor[data-for="' + msgid + '"]')
.show()
.children('.rawsessionid')
.each(function(idx, el) {
// resolveSessionid() replaces all .rawsessionid elements for the
// resolved session, so double-check this session needs resolving and
// save an unnecessary call/resolve if not.
if (el.classList.contains('rawsessionid')) {
resolveSessionid(el);
}
});
});
$('.sessionid').click(function(ev) {
resolveSessionid(this);
});
// TODO: add “display +1 +5 +50 +Session +All” markers above and below each diff to make the invisible-by-default non-diffs visible.
// the +Session should make visible everything that is sent to the session, describe that in the hover text
});
</script>
<!-- vim:ts=4:et
-->