-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlivelog5.js
208 lines (185 loc) · 5.13 KB
/
livelog5.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
//
// ircDDB livelog
//
// Copyright (C) 2013 Michael Dirska, DL1BFF ([email protected])
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
var lastNum = 0;
var fNum = 0;
var infoShown = 0;
function ajaxSettings()
{
return {
url: "jj3.yaws",
data: "p=" + lastNum,
success: showData
};
}
$.ajax( ajaxSettings() );
setInterval( function() { $.ajax( ajaxSettings() ); }, 2000);
function showData(response)
{
var responsePattern = /^([0-9]+:.*\n)*([0-9]+:.*)\n$/m ;
if (response.match(responsePattern))
{
var lines = response.split("\n");
var maxNum = 0;
for (i=0; i < lines.length; i++)
{
if (lines[i].length > 10)
{
line = lines[i];
lineNum = line.split(":")[0];
num = parseInt(lineNum) ;
pos = lineNum.length + 1;
if (num > lastNum)
{
x_time = line.substr(8 + pos, 2) + ":" + line.substr(10 + pos, 2) + ":" +
line.substr(12 + pos, 2) ;
x_mycall = line.substr(14 + pos, 8);
x_rpt1 = line.substr(22 + pos, 8);
if (line.length >= (67 + pos))
{
x_urcall = line.substr(39 + pos, 8);
x_mycall = x_mycall + " " + line.substr(53 + pos, 4);
x_rpt2 = line.substr(31 + pos, 8);
x_flags = line.substr(47 + pos, 2) + " " + line.substr(49 + pos, 2) + " " +
line.substr(51 + pos, 2);
x_dest = line.substr(59 + pos, 8);
if (x_dest == "________")
{
x_dest = "·";
}
}
else
{
x_urcall = "·";
x_rpt2 = "·";
x_flags = "·";
x_dest = "·";
}
if (line.length >= (87 + pos))
{
x_txmsg = line.substr(67 + pos, 20).replace(/_/g, "\240");
}
else
{
x_txmsg = "\267";
}
type_flag = line.substr(30 + pos, 1);
type_flag2 = line.substr(57 + pos, 2);
txstats = "";
mycall_err = "";
urcall_err = "";
destcall_link = "";
if (type_flag == "1")
{
txstats = "yes";
}
else if (type_flag == "2")
{
mycall_err = " err";
}
if (type_flag2 == "01")
{
urcall_err = " err";
}
if (x_urcall == "CQCQCQ__" )
{
if (x_dest.substr(0,3) == "STN")
{
x_dest = "·";
}
else if (x_dest != "·")
{
destcall_link = " link";
}
}
if (txstats == "")
{
fNum++;
p = fNum % 2;
var newNode = $("<li style=\"display:none\">" +
"<span class=\"xlist time linebg" + p + "\">" + x_time + "</span>" +
"<span class=\"xlist mycall linebg" + p + mycall_err + "\">" + x_mycall + "</span>" +
"<span class=\"xlist urcall linebg" + p + urcall_err + "\">" + x_urcall + "</span>" +
"<span class=\"xlist rpt1 linebg" + p + "\">" + x_rpt1 + "</span>" +
"<span class=\"xlist rpt2 linebg" + p + "\">" + x_rpt2 + "</span>" +
"<span class=\"xlist dest linebg" + p + destcall_link +"\">" + x_dest + "</span>" +
"<span class=\"xlist txmsg linebg" + p + "\">·</span>" +
"<span class=\"xlist txs linebg" + p + "\">·</span>" +
"<span class=\"xlist flags linebg" + p + "\">" + x_flags + "</span>" +
"</li>");
$("#stream").append(newNode);
newNode.slideDown();
deleteOldest();
newNode.find("span.txmsg").text(x_txmsg);
if (x_rpt2 != x_urcall)
{
newNode.find("span.mycall").addClass("txactive");
newNode.find("span.txs").addClass("txactive").text("TX on");
}
}
else
{
var n = $("#stream").find("li:last");
var found = 0;
while (n.length > 0)
{
var myc = n.find("span.mycall");
var rpt1 = n.find("span.rpt1");
var txs = n.find("span.txs");
if ((rpt1.text() == x_rpt1) && (found == 0))
{
txs.text(x_txmsg);
found = 1;
myc.removeClass("txactive");
txs.removeClass("txactive");
}
else if ((rpt1.text() == x_rpt1) && (txs.text() == "TX on"))
{
txs.html("·");
myc.removeClass("txactive");
txs.removeClass("txactive");
}
n = n.prev();
}
}
}
if (num > maxNum)
{
maxNum = num;
}
}
}
lastNum = maxNum;
if ((lines.length < 4) && (infoShown == 0))
{
var newNode = $("<li style=\"display:none\">" +
"<span class=\"blueinfo\">" +
"You don't see your call sign here? Please read: " +
"<a href=\"http://ircddb.net/live-vis.html\" target=\"_blank\">http://ircddb.net/live-vis.html</a>" +
"</span></li>");
$("#stream").append(newNode);
newNode.slideDown();
infoShown = 1;
}
}
}
function deleteOldest()
{
if($("#stream").children().length > 110)
deleteOldest = function() { $("#stream").find("li:first").remove(); };
}