This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
scripts.js
executable file
·118 lines (90 loc) · 3.31 KB
/
scripts.js
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
var doc = document,
qs = doc.querySelector;
// -- Sulaco -------------------------------------------------------------------
var Sulaco;
Sulaco = {
lineCache: {},
playbackMode: false,
coalesceMessages: function (lineNum) {
var lineEl = Sulaco.getLineEl(lineNum),
prevLineEl = lineEl && Sulaco.getLineEl(lineEl.previousElementSibling),
prevSender = Sulaco.getSenderNick(prevLineEl),
sender = Sulaco.getSenderNick(lineEl);
if (!sender || !prevSender) {
return;
}
if (sender === prevSender
&& Sulaco.getLineType(lineEl) === 'privmsg'
&& Sulaco.getLineType(prevLineEl) === 'privmsg') {
lineEl.classList.add('coalesced');
Sulaco.getSenderEl(lineEl).innerHTML = '';
}
},
getLineEl: function (lineNum) {
if (typeof lineNum === 'string') {
return doc.getElementById('line' + lineNum);
}
if (lineNum && lineNum.classList
&& lineNum.classList.contains('line')) {
return lineNum;
}
return null;
},
getLineType: function (line) {
line = Sulaco.getLineEl(line);
return line ? line.getAttribute('type') : null;
},
getMessage: function (line) {
line = Sulaco.getLineEl(line);
return line ? line.querySelector('.message').textContent.trim() : null;
},
getSenderEl: function (line) {
line = Sulaco.getLineEl(line);
return line ? line.querySelector('.sender') : null;
},
getSenderNick: function (line) {
var senderEl = Sulaco.getSenderEl(line);
return senderEl ? senderEl.getAttribute('nick') : null;
},
handleBufferPlayback: function (lineNum) {
var line = Sulaco.getLineEl(lineNum),
message;
if (Sulaco.getSenderNick(line) === '***') {
message = Sulaco.getMessage(line);
if (message === 'Buffer Playback...') {
line.classList.add('znc-playback-start');
Sulaco.playbackMode = true;
} else if (message === 'Playback Complete.') {
line.classList.add('znc-playback-end');
Sulaco.playbackMode = false;
}
return;
}
if (Sulaco.playbackMode) {
var match;
line.classList.add('znc-playback');
message = Sulaco.getMessage(line);
match = message.match(/^\[(\d\d:\d\d:\d\d)\] /);
if (match) {
var msgEl = line.querySelector('.message');
line.querySelector('.time').textContent = match[1];
msgEl.innerHTML = msgEl.innerHTML.replace(/^\s*\[\d\d:\d\d:\d\d\]/, '');
}
}
}
};
// -- Textual ------------------------------------------------------------------
// Defined in: "Textual.app -> Contents -> Resources -> JavaScript -> API -> core.js"
Textual.newMessagePostedToView = function (lineNum) {
Sulaco.handleBufferPlayback(lineNum);
Sulaco.coalesceMessages(lineNum);
};
Textual.viewFinishedLoading = function () {
Textual.fadeInLoadingScreen(1.00, 0.95);
setTimeout(function () {
Textual.scrollToBottomOfView();
}, 300);
};
Textual.viewFinishedReload = function () {
Textual.viewFinishedLoading();
};