diff --git a/package.nw/gt_chat.html b/package.nw/gt_chat.html index a76f692..57df60d 100644 --- a/package.nw/gt_chat.html +++ b/package.nw/gt_chat.html @@ -204,6 +204,7 @@ function makeCallsignRow(callObj, show) { + var isNewObj = false; var obj = document.getElementById(callObj.cid); if (obj && obj.fCall != callObj.fCall) { @@ -213,6 +214,7 @@ } if (!obj) { + isNewObj = true; var low = 0; var mid = 0; var target = null; @@ -260,6 +262,65 @@ } obj.style.display = show ? "" : "none"; } + return isNewObj; + } + + function updateCallsign(id) + { + var count = parseInt(userCount.innerHTML); + var shouldCount = false; + if (id in window.opener.g_gtFlagPins) + { + var obj = window.opener.g_gtFlagPins[id]; + if (obj.call != "" && obj.call != "NOCALL") + { + var show = true; + try { + if (searchBox.value.length > 0 && !obj.call.match(searchBox.value)) + { + show = false; + } + } + catch (e) {} + + if (g_viewBand > 0 && window.opener.myBand != obj.band) show = false; + + if (g_viewMode > 0 && window.opener.myMode != obj.mode) show = false; + + if (obj.canmsg == false) show = false; + + if (makeCallsignRow(obj, show) && show) + { + count++; + } + + if (obj.cid == g_currentId && messageInput.disabled == true && obj.live == true) + { + messageTextDiv.innerHTML += makeViewMessage("system", "GT", "Session resumed", null); + messageInput.value = ""; + scrollDown(messageTextDiv); + messageInput.disabled = false; + } + } + if (id == g_currentId) + { + updateBar(g_currentId); + } + + } + else + { + var obj = document.getElementById(id); + if (obj) + { + if (obj.style.display == "") + { + count--; + } + allCallDiv.removeChild(obj); + } + } + userCount.innerHTML = count; } function showAllCallsigns() @@ -319,14 +380,18 @@ if (g_viewBand) { viewBand.innerHTML = window.opener.myBand; - } else { + } + else + { viewBand.innerHTML = "All"; } if (g_viewMode) { viewMode.innerHTML = window.opener.myMode; - } else { + } + else + { viewMode.innerHTML = "All"; } @@ -336,31 +401,32 @@ function showAllMessages() { + activeCallsignsDiv.innerHTML = "no message history"; if (Object.keys(window.opener.g_gtMessages).length > 0) { - var worker = ""; + var worker = ""; for (const key in window.opener.g_gtMessages) { - worker += ""; - worker += - ""; + worker += ""; + worker += ""; + } + } + if (worker.length > 0) + { + activeCallsignsDiv.innerHTML = "
"; - if (key in window.opener.g_gtUnread) worker += "🔥"; - else worker += "💬"; + if (key in window.opener.g_gtFlagPins) + { + worker += "
"; + if (key in window.opener.g_gtUnread) + { + worker += "🔥"; + } + else + { + worker += "💬"; + } - worker += - "" + - window.opener.g_gtFlagPins[key].call.formatCallsign() + - "
" + window.opener.g_gtFlagPins[key].call.formatCallsign() + "
" + worker + "
"; } - - worker += ""; - activeCallsignsDiv.innerHTML = worker; - } else { - activeCallsignsDiv.innerHTML = "no message history"; } } @@ -435,14 +501,6 @@ scrollDown(messageTextDiv); messageInput.disabled = true; } - else - { - var obj = document.getElementById(id); - if (obj) - { - allCallDiv.removeChild(obj); - } - } } function updateBar(id) diff --git a/package.nw/lib/gtws.js b/package.nw/lib/gtws.js index 666a57b..fe0bb2f 100644 --- a/package.nw/lib/gtws.js +++ b/package.nw/lib/gtws.js @@ -297,7 +297,7 @@ function gtChatRemoveCall(jsmesg) delete g_gtFlagPins[cid]; } - updateChatWindow(); + updateChatWindow(cid); } } delete g_gtIdToCid[id]; @@ -354,7 +354,7 @@ function gtChatUpdateCall(jsmesg) } g_gtChatlistChangeCount++; g_gtCallsigns[g_gtFlagPins[cid].call] = cid; - updateChatWindow(); + updateChatWindow(cid); } function gtChatGetList() @@ -693,13 +693,20 @@ function notifyNoChat(id) } } -function updateChatWindow() +function updateChatWindow(id = null) { if (g_chatWindowHandle != null) { try { - g_chatWindowHandle.window.updateEverything(); + if (id) + { + g_chatWindowHandle.window.updateCallsign(id); + } + else + { + g_chatWindowHandle.window.updateEverything(); + } } catch (e) {} }