aprsd 3.4.4__py3-none-any.whl → 4.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. aprsd/cli_helper.py +12 -5
  2. aprsd/client/aprsis.py +31 -9
  3. aprsd/client/base.py +13 -2
  4. aprsd/client/drivers/aprsis.py +6 -3
  5. aprsd/client/drivers/fake.py +15 -20
  6. aprsd/client/factory.py +0 -2
  7. aprsd/client/fake.py +0 -2
  8. aprsd/client/kiss.py +17 -2
  9. aprsd/client/stats.py +1 -3
  10. aprsd/cmds/completion.py +7 -4
  11. aprsd/cmds/dev.py +38 -42
  12. aprsd/cmds/fetch_stats.py +140 -143
  13. aprsd/cmds/healthcheck.py +5 -3
  14. aprsd/cmds/list_plugins.py +140 -134
  15. aprsd/cmds/listen.py +13 -9
  16. aprsd/cmds/server.py +53 -27
  17. aprsd/conf/__init__.py +1 -2
  18. aprsd/conf/client.py +3 -4
  19. aprsd/conf/common.py +19 -93
  20. aprsd/conf/log.py +2 -4
  21. aprsd/conf/opts.py +5 -4
  22. aprsd/conf/plugin_common.py +11 -121
  23. aprsd/exception.py +2 -0
  24. aprsd/log/log.py +7 -46
  25. aprsd/main.py +10 -4
  26. aprsd/packets/__init__.py +14 -4
  27. aprsd/packets/core.py +57 -67
  28. aprsd/packets/log.py +8 -8
  29. aprsd/packets/packet_list.py +9 -6
  30. aprsd/plugin.py +22 -11
  31. aprsd/plugins/notify.py +1 -4
  32. aprsd/plugins/weather.py +10 -8
  33. aprsd/stats/collector.py +5 -2
  34. aprsd/threads/__init__.py +3 -2
  35. aprsd/threads/aprsd.py +12 -7
  36. aprsd/threads/{keep_alive.py → keepalive.py} +14 -45
  37. aprsd/threads/registry.py +3 -3
  38. aprsd/threads/rx.py +9 -6
  39. aprsd/threads/stats.py +2 -2
  40. aprsd/threads/tx.py +3 -4
  41. aprsd/utils/__init__.py +42 -10
  42. aprsd/utils/json.py +9 -4
  43. aprsd/utils/keepalive_collector.py +55 -0
  44. aprsd/utils/trace.py +0 -2
  45. aprsd-4.0.1.dist-info/AUTHORS +1 -0
  46. {aprsd-3.4.4.dist-info → aprsd-4.0.1.dist-info}/METADATA +307 -408
  47. aprsd-4.0.1.dist-info/RECORD +74 -0
  48. {aprsd-3.4.4.dist-info → aprsd-4.0.1.dist-info}/WHEEL +1 -1
  49. aprsd/cmds/admin.py +0 -57
  50. aprsd/cmds/webchat.py +0 -662
  51. aprsd/conf/plugin_email.py +0 -105
  52. aprsd/plugins/email.py +0 -715
  53. aprsd/plugins/location.py +0 -181
  54. aprsd/threads/log_monitor.py +0 -121
  55. aprsd/web/__init__.py +0 -0
  56. aprsd/web/admin/__init__.py +0 -0
  57. aprsd/web/admin/static/css/index.css +0 -84
  58. aprsd/web/admin/static/css/prism.css +0 -4
  59. aprsd/web/admin/static/css/tabs.css +0 -35
  60. aprsd/web/admin/static/images/Untitled.png +0 -0
  61. aprsd/web/admin/static/images/aprs-symbols-16-0.png +0 -0
  62. aprsd/web/admin/static/images/aprs-symbols-16-1.png +0 -0
  63. aprsd/web/admin/static/images/aprs-symbols-64-0.png +0 -0
  64. aprsd/web/admin/static/images/aprs-symbols-64-1.png +0 -0
  65. aprsd/web/admin/static/images/aprs-symbols-64-2.png +0 -0
  66. aprsd/web/admin/static/js/charts.js +0 -235
  67. aprsd/web/admin/static/js/echarts.js +0 -465
  68. aprsd/web/admin/static/js/logs.js +0 -26
  69. aprsd/web/admin/static/js/main.js +0 -231
  70. aprsd/web/admin/static/js/prism.js +0 -12
  71. aprsd/web/admin/static/js/send-message.js +0 -114
  72. aprsd/web/admin/static/js/tabs.js +0 -28
  73. aprsd/web/admin/templates/index.html +0 -196
  74. aprsd/web/chat/static/css/chat.css +0 -115
  75. aprsd/web/chat/static/css/index.css +0 -66
  76. aprsd/web/chat/static/css/style.css.map +0 -1
  77. aprsd/web/chat/static/css/tabs.css +0 -41
  78. aprsd/web/chat/static/css/upstream/bootstrap.min.css +0 -6
  79. aprsd/web/chat/static/css/upstream/font.woff2 +0 -0
  80. aprsd/web/chat/static/css/upstream/google-fonts.css +0 -23
  81. aprsd/web/chat/static/css/upstream/jquery-ui.css +0 -1311
  82. aprsd/web/chat/static/css/upstream/jquery.toast.css +0 -28
  83. aprsd/web/chat/static/css/upstream/themes/default/assets/fonts/LatoLatin-Bold.woff +0 -0
  84. aprsd/web/chat/static/css/upstream/themes/default/assets/fonts/LatoLatin-Bold.woff2 +0 -0
  85. aprsd/web/chat/static/css/upstream/themes/default/assets/fonts/LatoLatin-Regular.woff +0 -0
  86. aprsd/web/chat/static/css/upstream/themes/default/assets/fonts/LatoLatin-Regular.woff2 +0 -0
  87. aprsd/web/chat/static/css/upstream/themes/default/assets/fonts/icons.woff +0 -0
  88. aprsd/web/chat/static/css/upstream/themes/default/assets/fonts/icons.woff2 +0 -0
  89. aprsd/web/chat/static/css/upstream/themes/default/assets/fonts/outline-icons.woff +0 -0
  90. aprsd/web/chat/static/css/upstream/themes/default/assets/fonts/outline-icons.woff2 +0 -0
  91. aprsd/web/chat/static/images/Untitled.png +0 -0
  92. aprsd/web/chat/static/images/aprs-symbols-16-0.png +0 -0
  93. aprsd/web/chat/static/images/aprs-symbols-16-1.png +0 -0
  94. aprsd/web/chat/static/images/aprs-symbols-64-0.png +0 -0
  95. aprsd/web/chat/static/images/aprs-symbols-64-1.png +0 -0
  96. aprsd/web/chat/static/images/aprs-symbols-64-2.png +0 -0
  97. aprsd/web/chat/static/images/globe.svg +0 -3
  98. aprsd/web/chat/static/js/gps.js +0 -84
  99. aprsd/web/chat/static/js/main.js +0 -45
  100. aprsd/web/chat/static/js/send-message.js +0 -612
  101. aprsd/web/chat/static/js/tabs.js +0 -28
  102. aprsd/web/chat/static/js/upstream/bootstrap.bundle.min.js +0 -7
  103. aprsd/web/chat/static/js/upstream/jquery-3.7.1.min.js +0 -2
  104. aprsd/web/chat/static/js/upstream/jquery-ui.min.js +0 -13
  105. aprsd/web/chat/static/js/upstream/jquery.toast.js +0 -374
  106. aprsd/web/chat/static/js/upstream/semantic.min.js +0 -11
  107. aprsd/web/chat/static/js/upstream/socket.io.min.js +0 -7
  108. aprsd/web/chat/templates/index.html +0 -139
  109. aprsd/wsgi.py +0 -322
  110. aprsd-3.4.4.dist-info/AUTHORS +0 -13
  111. aprsd-3.4.4.dist-info/RECORD +0 -134
  112. {aprsd-3.4.4.dist-info → aprsd-4.0.1.dist-info}/LICENSE +0 -0
  113. {aprsd-3.4.4.dist-info → aprsd-4.0.1.dist-info}/entry_points.txt +0 -0
  114. {aprsd-3.4.4.dist-info → aprsd-4.0.1.dist-info}/top_level.txt +0 -0
@@ -1,612 +0,0 @@
1
- var cleared = false;
2
- var callsign_list = {};
3
- var callsign_location = {};
4
- var message_list = {};
5
- var from_msg_list = {};
6
- var selected_tab_callsign = null;
7
- const socket = io("/sendmsg");
8
-
9
- MSG_TYPE_TX = "tx";
10
- MSG_TYPE_RX = "rx";
11
- MSG_TYPE_ACK = "ack";
12
-
13
- function reload_popovers() {
14
- $('[data-bs-toggle="popover"]').popover(
15
- {html: true, animation: true}
16
- );
17
- }
18
-
19
- function build_location_string(msg) {
20
- dt = new Date(parseInt(msg['lasttime']) * 1000);
21
- loc = "Last Location Update: " + dt.toLocaleString();
22
- loc += "<br>Latitude: " + msg['lat'] + "<br>Longitude: " + msg['lon'];
23
- loc += "<br>" + "Altitude: " + msg['altitude'] + " m";
24
- loc += "<br>" + "Speed: " + msg['speed'] + " kph";
25
- loc += "<br>" + "Bearing: " + msg['compass_bearing'];
26
- loc += "<br>" + "distance: " + msg['distance'] + " km";
27
- return loc;
28
- }
29
-
30
- function build_location_string_small(msg) {
31
- dt = new Date(parseInt(msg['lasttime']) * 1000);
32
- loc = "" + msg['distance'] + "km";
33
- //loc += "Lat " + msg['lat'] + "&nbsp;Lon " + msg['lon'];
34
- loc += "&nbsp;" + msg['compass_bearing'];
35
- //loc += "&nbsp;Distance " + msg['distance'] + " km";
36
- //loc += "&nbsp;" + dt.toLocaleString();
37
- loc += "&nbsp;" + msg['timeago'];
38
- return loc;
39
- }
40
-
41
- function size_dict(d){c=0; for (i in d) ++c; return c}
42
-
43
- function raise_error(msg) {
44
- $.toast({
45
- heading: 'Error',
46
- text: msg,
47
- loader: true,
48
- loaderBg: '#9EC600',
49
- position: 'top-center',
50
- });
51
- }
52
-
53
- function init_chat() {
54
- socket.on('connect', function () {
55
- console.log("Connected to socketio");
56
- });
57
- socket.on('connected', function(msg) {
58
- console.log("Connected!");
59
- console.log(msg);
60
- });
61
-
62
- socket.on("sent", function(msg) {
63
- if (cleared === false) {
64
- var msgsdiv = $("#msgsTabsDiv");
65
- msgsdiv.html('');
66
- cleared = true;
67
- }
68
- msg["type"] = MSG_TYPE_TX;
69
- sent_msg(msg);
70
- });
71
-
72
- socket.on("ack", function(msg) {
73
- msg["type"] = MSG_TYPE_ACK;
74
- ack_msg(msg);
75
- });
76
-
77
- socket.on("new", function(msg) {
78
- if (cleared === false) {
79
- var msgsdiv = $("#msgsTabsDiv");
80
- msgsdiv.html('')
81
- cleared = true;
82
- }
83
- msg["type"] = MSG_TYPE_RX;
84
- from_msg(msg);
85
- });
86
-
87
- socket.on("callsign_location", function(msg) {
88
- console.log("CALLSIGN Location!");
89
- console.log(msg);
90
- now = new Date();
91
- msg['last_updated'] = now;
92
- callsign_location[msg['callsign']] = msg;
93
-
94
- location_id = callsign_location_content(msg['callsign'], true);
95
- location_string = build_location_string_small(msg);
96
- $(location_id).html(location_string);
97
- $(location_id+"Spinner").addClass('d-none');
98
- save_data();
99
- });
100
-
101
- $("#sendform").submit(function(event) {
102
- event.preventDefault();
103
- to_call = $('#to_call').val().toUpperCase();
104
- message = $('#message').val();
105
- path = $('#pkt_path option:selected').val();
106
- if (to_call == "") {
107
- raise_error("You must enter a callsign to send a message")
108
- return false;
109
- } else {
110
- if (message == "") {
111
- raise_error("You must enter a message to send")
112
- return false;
113
- }
114
- msg = {'to': to_call, 'message': message, 'path': path};
115
- //console.log(msg);
116
- socket.emit("send", msg);
117
- $('#message').val('');
118
- callsign_select(to_call);
119
- activate_callsign_tab(to_call);
120
- }
121
- });
122
-
123
- init_gps();
124
- // Try and load any existing chat threads from last time
125
- init_messages();
126
- }
127
-
128
-
129
- function tab_string(callsign, id=false) {
130
- name = "msgs"+callsign;
131
- if (id) {
132
- return "#"+name;
133
- } else {
134
- return name;
135
- }
136
- }
137
-
138
- function tab_li_string(callsign, id=false) {
139
- //The id of the LI containing the tab
140
- return tab_string(callsign,id)+"Li";
141
- }
142
-
143
- function tab_notification_id(callsign, id=false) {
144
- // The ID of the span that contains the notification count
145
- return tab_string(callsign, id)+"notify";
146
- }
147
-
148
- function tab_content_name(callsign, id=false) {
149
- return tab_string(callsign, id)+"Content";
150
- }
151
-
152
- function tab_content_speech_wrapper(callsign, id=false) {
153
- return tab_string(callsign, id)+"SpeechWrapper";
154
- }
155
-
156
- function tab_content_speech_wrapper_id(callsign) {
157
- return "#"+tab_content_speech_wrapper(callsign);
158
- }
159
-
160
- function content_divname(callsign) {
161
- return "#"+tab_content_name(callsign);
162
- }
163
-
164
- function callsign_tab(callsign) {
165
- return "#"+tab_string(callsign);
166
- }
167
-
168
- function callsign_location_popover(callsign, id=false) {
169
- return tab_string(callsign, id)+"Location";
170
- }
171
-
172
- function callsign_location_content(callsign, id=false) {
173
- return tab_string(callsign, id)+"LocationContent";
174
- }
175
-
176
- function bubble_msg_id(msg, id=false) {
177
- // The id of the div that contains a specific message
178
- name = msg["from_call"] + "_" + msg["msgNo"];
179
- if (id) {
180
- return "#"+name;
181
- } else {
182
- return name;
183
- }
184
- }
185
-
186
- function message_ts_id(msg) {
187
- //Create a 'id' from the message timestamp
188
- ts_str = msg["timestamp"].toString();
189
- ts = ts_str.split(".")[0]*1000;
190
- id = ts_str.split('.')[0];
191
- return {'timestamp': ts, 'id': id};
192
- }
193
-
194
- function time_ack_from_msg(msg) {
195
- // Return the time and ack_id from a message
196
- ts_id = message_ts_id(msg);
197
- ts = ts_id['timestamp'];
198
- id = ts_id['id'];
199
- ack_id = "ack_" + id
200
-
201
- var d = new Date(ts).toLocaleDateString("en-US")
202
- var t = new Date(ts).toLocaleTimeString("en-US")
203
- return {'time': t, 'date': d, 'ack_id': ack_id};
204
- }
205
-
206
- function save_data() {
207
- // Save the relevant data to local storage
208
- localStorage.setItem('callsign_list', JSON.stringify(callsign_list));
209
- localStorage.setItem('message_list', JSON.stringify(message_list));
210
- localStorage.setItem('callsign_location', JSON.stringify(callsign_location));
211
- }
212
-
213
- function init_messages() {
214
- // This tries to load any previous conversations from local storage
215
- callsign_list = JSON.parse(localStorage.getItem('callsign_list'));
216
- message_list = JSON.parse(localStorage.getItem('message_list'));
217
- callsign_location = JSON.parse(localStorage.getItem('callsign_location'));
218
- if (callsign_list == null) {
219
- callsign_list = {};
220
- }
221
- if (message_list == null) {
222
- message_list = {};
223
- }
224
- if (callsign_location == null) {
225
- callsign_location = {};
226
- }
227
- console.log(callsign_list);
228
- console.log(message_list);
229
- console.log(callsign_location);
230
-
231
- // Now loop through each callsign and add the tabs
232
- first_callsign = null;
233
- for (callsign in callsign_list) {
234
- if (first_callsign === null) {
235
- first_callsign = callsign;
236
- active = true;
237
- } else {
238
- active = false;
239
- }
240
- create_callsign_tab(callsign, active);
241
- }
242
- // and then populate the messages in order
243
- for (callsign in message_list) {
244
- new_callsign = true;
245
- cleared = true;
246
- for (id in message_list[callsign]) {
247
- msg = message_list[callsign][id];
248
- info = time_ack_from_msg(msg);
249
- t = info['time'];
250
- d = info['date'];
251
- ack_id = false;
252
- acked = false;
253
- if (msg['type'] == MSG_TYPE_TX) {
254
- ack_id = info['ack_id'];
255
- acked = msg['ack'];
256
- }
257
- msg_html = create_message_html(d, t, msg['from_call'], msg['to_call'],
258
- msg['message_text'], ack_id, msg, acked);
259
- append_message_html(callsign, msg_html, new_callsign);
260
- new_callsign = false;
261
- }
262
- }
263
-
264
- if (first_callsign !== null) {
265
- callsign_select(first_callsign);
266
- }
267
- }
268
-
269
- function scroll_main_content(callsign=false) {
270
- var wc = $('#wc-content');
271
- var d = $('#msgsTabContent');
272
- var scrollHeight = wc.prop('scrollHeight');
273
- var clientHeight = wc.prop('clientHeight');
274
-
275
- if (callsign) {
276
- div_id = content_divname(callsign);
277
- c_div = $(content_divname(callsign));
278
- //console.log("c_div("+div_id+") " + c_div);
279
- c_height = c_div.height();
280
- c_scroll_height = c_div.prop('scrollHeight');
281
- //console.log("callsign height " + c_height + " scrollHeight " + c_scroll_height);
282
- if (c_height === undefined) {
283
- return false;
284
- }
285
- if (c_height > clientHeight) {
286
- wc.animate({ scrollTop: c_scroll_height }, 500);
287
- } else {
288
- wc.animate({ scrollTop: 0 }, 500);
289
- }
290
- } else {
291
- if (scrollHeight > clientHeight) {
292
- wc.animate({ scrollTop: wc.prop('scrollHeight') }, 500);
293
- } else {
294
- wc.animate({ scrollTop: 0 }, 500);
295
- }
296
- }
297
- }
298
-
299
- function create_callsign_tab(callsign, active=false) {
300
- //Create the html for the callsign tab and insert it into the DOM
301
- var callsignTabs = $("#msgsTabList");
302
- tab_id = tab_string(callsign);
303
- tab_id_li = tab_li_string(callsign);
304
- tab_notify_id = tab_notification_id(callsign);
305
- tab_content = tab_content_name(callsign);
306
- popover_id = callsign_location_popover(callsign);
307
- if (active) {
308
- active_str = "active";
309
- } else {
310
- active_str = "";
311
- }
312
-
313
- item_html = '<li class="nav-item" role="presentation" callsign="'+callsign+'" id="'+tab_id_li+'">';
314
- //item_html += '<button onClick="callsign_select(\''+callsign+'\');" callsign="'+callsign+'" class="nav-link '+active_str+'" id="'+tab_id+'" data-bs-toggle="tab" data-bs-target="#'+tab_content+'" type="button" role="tab" aria-controls="'+callsign+'" aria-selected="true">';
315
- item_html += '<button onClick="callsign_select(\''+callsign+'\');" callsign="'+callsign+'" class="nav-link position-relative '+active_str+'" id="'+tab_id+'" data-bs-toggle="tab" data-bs-target="#'+tab_content+'" type="button" role="tab" aria-controls="'+callsign+'" aria-selected="true">';
316
- item_html += callsign+'&nbsp;&nbsp;';
317
- item_html += '<span id="'+tab_notify_id+'" class="position-absolute top-0 start-80 translate-middle badge bg-danger border border-light rounded-pill visually-hidden">0</span>';
318
- item_html += '<span onclick="delete_tab(\''+callsign+'\');">×</span>';
319
- item_html += '</button></li>'
320
-
321
- callsignTabs.append(item_html);
322
- create_callsign_tab_content(callsign, active);
323
- }
324
-
325
- function create_callsign_tab_content(callsign, active=false) {
326
- var callsignTabsContent = $("#msgsTabContent");
327
- tab_id = tab_string(callsign);
328
- tab_content = tab_content_name(callsign);
329
- wrapper_id = tab_content_speech_wrapper(callsign);
330
- if (active) {
331
- active_str = "show active";
332
- } else {
333
- active_str = '';
334
- }
335
-
336
- location_str = "Unknown Location"
337
- if (callsign in callsign_location) {
338
- location_str = build_location_string_small(callsign_location[callsign]);
339
- location_class = '';
340
- }
341
-
342
- location_id = callsign_location_content(callsign);
343
-
344
- item_html = '<div class="tab-pane fade '+active_str+'" id="'+tab_content+'" role="tabpanel" aria-labelledby="'+tab_id+'">';
345
- item_html += '<div class="" style="border: 1px solid #999999;background-color:#aaaaaa;">';
346
- item_html += '<div class="row" style="padding-top:4px;padding-bottom:4px;background-color:#aaaaaa;margin:0px;">';
347
- item_html += '<div class="d-flex col-md-10 justify-content-left" style="padding:0px;margin:0px;">';
348
- item_html += '<button onclick="call_callsign_location(\''+callsign+'\');" style="margin-left:2px;padding: 0px 4px 0px 4px;font-size: .9rem" type="button" class="btn btn-primary">';
349
- item_html += '<span id="'+location_id+'Spinner" class="d-none spinner-border spinner-border-sm" role="status" aria-hidden="true" style="font-size: .9rem"></span>Update</button>';
350
- item_html += '&nbsp;<span id="'+location_id+'" style="font-size: .9rem">'+location_str+'</span></div>';
351
- item_html += '</div>';
352
- item_html += '<div class="speech-wrapper" id="'+wrapper_id+'"></div>';
353
- item_html += '</div>';
354
- callsignTabsContent.append(item_html);
355
- }
356
-
357
- function delete_tab(callsign) {
358
- // User asked to delete the tab and the conversation
359
- tab_id = tab_string(callsign, true);
360
- tab_id_li = tab_li_string(callsign, true);
361
- tab_content = tab_content_name(callsign, true);
362
- $(tab_id_li).remove();
363
- $(tab_content).remove();
364
- delete callsign_list[callsign];
365
- delete message_list[callsign];
366
- delete callsign_location[callsign];
367
-
368
- // Now select the first tab
369
- first_tab = $("#msgsTabList").children().first().children().first();
370
- console.log(first_tab);
371
- $(first_tab).click();
372
- save_data();
373
- }
374
-
375
- function add_callsign(callsign, msg) {
376
- /* Ensure a callsign exists in the left hand nav */
377
- if (callsign in callsign_list) {
378
- return false
379
- }
380
- len = Object.keys(callsign_list).length;
381
- if (len == 0) {
382
- active = true;
383
- } else {
384
- active = false;
385
- }
386
- create_callsign_tab(callsign, active);
387
- callsign_list[callsign] = '';
388
- return true;
389
- }
390
-
391
- function update_callsign_path(callsign, msg) {
392
- //Get the selected path to save for this callsign
393
- path = msg['path']
394
- $('#pkt_path').val(path);
395
- callsign_list[callsign] = path;
396
-
397
- }
398
-
399
- function append_message(callsign, msg, msg_html) {
400
- new_callsign = false
401
- if (!message_list.hasOwnProperty(callsign)) {
402
- message_list[callsign] = {};
403
- }
404
- ts_id = message_ts_id(msg);
405
- id = ts_id['id']
406
- message_list[callsign][id] = msg;
407
- if (selected_tab_callsign != callsign) {
408
- // We need to update the notification for the tab
409
- tab_notify_id = tab_notification_id(callsign, true);
410
- // get the current count of notifications
411
- count = parseInt($(tab_notify_id).text());
412
- if (isNaN(count)) {
413
- count = 0;
414
- }
415
- count += 1;
416
- $(tab_notify_id).text(count);
417
- $(tab_notify_id).removeClass('visually-hidden');
418
- }
419
-
420
- // Find the right div to place the html
421
- new_callsign = add_callsign(callsign, msg);
422
- //update_callsign_path(callsign, msg);
423
- append_message_html(callsign, msg_html, new_callsign);
424
- len = Object.keys(callsign_list).length;
425
- if (new_callsign) {
426
- //Now click the tab if and only if there is only one tab
427
- callsign_tab_id = callsign_tab(callsign);
428
- $(callsign_tab_id).click();
429
- callsign_select(callsign);
430
- }
431
- }
432
-
433
-
434
- function append_message_html(callsign, msg_html, new_callsign) {
435
- var msgsTabs = $('#msgsTabsDiv');
436
- divname_str = tab_content_name(callsign);
437
- divname = content_divname(callsign);
438
- tab_content = tab_content_name(callsign);
439
- wrapper_id = tab_content_speech_wrapper_id(callsign);
440
-
441
- $(wrapper_id).append(msg_html);
442
-
443
- if ($(wrapper_id).children().length > 0) {
444
- $(wrapper_id).animate({scrollTop: $(wrapper_id)[0].scrollHeight}, "fast");
445
- }
446
- }
447
-
448
- function create_message_html(date, time, from, to, message, ack_id, msg, acked=false) {
449
- div_id = from + "_" + msg.msgNo;
450
- if (ack_id) {
451
- alt = " alt"
452
- } else {
453
- alt = ""
454
- }
455
-
456
- bubble_class = "bubble" + alt + " text-nowrap"
457
- bubble_name_class = "bubble-name" + alt
458
- bubble_msgid = bubble_msg_id(msg);
459
- date_str = date + " " + time;
460
- sane_date_str = date_str.replace(/ /g,"").replaceAll("/","").replaceAll(":","");
461
-
462
- bubble_msg_class = "bubble-message";
463
- if (ack_id) {
464
- bubble_arrow_class = "bubble-arrow alt";
465
- popover_placement = "left";
466
- } else {
467
- bubble_arrow_class = "bubble-arrow";
468
- popover_placement = "right";
469
- }
470
-
471
- msg_html = '<div class="bubble-row'+alt+'">';
472
- msg_html += '<div id="'+bubble_msgid+'" class="'+ bubble_class + '" ';
473
- msg_html += 'title="APRS Raw Packet" data-bs-placement="'+popover_placement+'" data-bs-toggle="popover" ';
474
- msg_html += 'data-bs-trigger="hover" data-bs-content="'+msg['raw']+'">';
475
- msg_html += '<div class="bubble-text">';
476
- msg_html += '<p class="'+ bubble_name_class +'">'+from+'&nbsp;&nbsp;';
477
- msg_html += '<span class="bubble-timestamp">'+date_str+'</span>';
478
-
479
- if (ack_id) {
480
- if (acked) {
481
- msg_html += '<span class="material-symbols-rounded md-10" id="' + ack_id + '">thumb_up</span>';
482
- } else {
483
- msg_html += '<span class="material-symbols-rounded md-10" id="' + ack_id + '">thumb_down</span>';
484
- }
485
- }
486
- msg_html += "</p>";
487
- msg_html += '<p class="' +bubble_msg_class+ '">'+message+'</p>';
488
- msg_html += '<div class="'+ bubble_arrow_class + '"></div>';
489
- msg_html += "</div></div></div>";
490
-
491
- return msg_html
492
- }
493
-
494
- function flash_message(msg) {
495
- // Callback function to bring a hidden box back
496
- msg_id = bubble_msg_id(msg, true);
497
- $(msg_id).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);
498
- }
499
-
500
- function sent_msg(msg) {
501
- info = time_ack_from_msg(msg);
502
- t = info['time'];
503
- d = info['date'];
504
- ack_id = info['ack_id'];
505
-
506
- msg_html = create_message_html(d, t, msg['from_call'], msg['to_call'], msg['message_text'], ack_id, msg, false);
507
- append_message(msg['to_call'], msg, msg_html);
508
- save_data();
509
- scroll_main_content(msg['to_call']);
510
- reload_popovers();
511
- }
512
-
513
- function str_to_int(my_string) {
514
- total = 0
515
- for (let i = 0; i < my_string.length; i++) {
516
- total += my_string.charCodeAt(i);
517
- }
518
- return total
519
- }
520
-
521
- function from_msg(msg) {
522
- if (!from_msg_list.hasOwnProperty(msg["from_call"])) {
523
- from_msg_list[msg["from_call"]] = new Array();
524
- }
525
-
526
- // Try to account for messages that have no msgNo
527
- console.log(msg)
528
- if (msg["msgNo"] == null) {
529
- console.log("Need to add msgNO!!")
530
- // create an artificial msgNo
531
- total = str_to_int(msg["from_call"])
532
- total += str_to_int(msg["addresse"])
533
- total += str_to_int(msg["message_text"])
534
- msg["msgNo"] = total
535
- }
536
-
537
- if (msg["msgNo"] in from_msg_list[msg["from_call"]]) {
538
- // We already have this message
539
- //console.log("We already have this message msgNo=" + msg["msgNo"]);
540
- // Do some flashy thing?
541
- flash_message(msg);
542
- return false
543
- } else {
544
- from_msg_list[msg["from_call"]][msg["msgNo"]] = msg
545
- }
546
- info = time_ack_from_msg(msg);
547
- t = info['time'];
548
- d = info['date'];
549
- ack_id = info['ack_id'];
550
-
551
- from = msg['from_call']
552
- msg_html = create_message_html(d, t, from, false, msg['message_text'], false, msg, false);
553
- append_message(from, msg, msg_html);
554
- save_data();
555
- scroll_main_content(from);
556
- reload_popovers();
557
- }
558
-
559
- function ack_msg(msg) {
560
- // Acknowledge a message
561
- // We have an existing entry
562
- ts_id = message_ts_id(msg);
563
- id = ts_id['id'];
564
- //Mark the message as acked
565
- callsign = msg['to_call'];
566
- // Ensure the message_list has this callsign
567
- if (!message_list.hasOwnProperty(callsign)) {
568
- return false
569
- }
570
- // Ensure the message_list has this id
571
- if (!message_list[callsign].hasOwnProperty(id)) {
572
- return false
573
- }
574
- if (message_list[callsign][id]['ack'] == true) {
575
- return false;
576
- }
577
- message_list[callsign][id]['ack'] = true;
578
- ack_id = "ack_" + id
579
-
580
- if (msg['ack'] == true) {
581
- var ack_div = $('#' + ack_id);
582
- ack_div.html('thumb_up');
583
- }
584
-
585
- //$('.ui.accordion').accordion('refresh');
586
- save_data();
587
- scroll_main_content();
588
- }
589
-
590
- function activate_callsign_tab(callsign) {
591
- tab_content = tab_string(callsign, id=true);
592
- $(tab_content).click();
593
- }
594
-
595
- function callsign_select(callsign) {
596
- var tocall = $("#to_call");
597
- tocall.val(callsign.toUpperCase());
598
- scroll_main_content(callsign);
599
- selected_tab_callsign = callsign;
600
- tab_notify_id = tab_notification_id(callsign, true);
601
- $(tab_notify_id).addClass('visually-hidden');
602
- $(tab_notify_id).text(0);
603
- // Now update the path
604
- // $('#pkt_path').val(callsign_list[callsign]);
605
- }
606
-
607
- function call_callsign_location(callsign) {
608
- msg = {'callsign': callsign};
609
- socket.emit("get_callsign_location", msg);
610
- location_id = callsign_location_content(callsign, true)+"Spinner";
611
- $(location_id).removeClass('d-none');
612
- }
@@ -1,28 +0,0 @@
1
- function openTab(evt, tabName) {
2
- // Declare all variables
3
- var i, tabcontent, tablinks;
4
-
5
- if (typeof tabName == 'undefined') {
6
- return
7
- }
8
-
9
- // Get all elements with class="tabcontent" and hide them
10
- tabcontent = document.getElementsByClassName("tabcontent");
11
- for (i = 0; i < tabcontent.length; i++) {
12
- tabcontent[i].style.display = "none";
13
- }
14
-
15
- // Get all elements with class="tablinks" and remove the class "active"
16
- tablinks = document.getElementsByClassName("tablinks");
17
- for (i = 0; i < tablinks.length; i++) {
18
- tablinks[i].className = tablinks[i].className.replace(" active", "");
19
- }
20
-
21
- // Show the current tab, and add an "active" class to the button that opened the tab
22
- document.getElementById(tabName).style.display = "block";
23
- if (typeof evt.currentTarget == 'undefined') {
24
- return
25
- } else {
26
- evt.currentTarget.className += " active";
27
- }
28
- }