// Copyright 2017, 2018 Max H. Parke KA1RBI // // This file is part of OP25 // // OP25 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 3, or (at your option) // any later version. // // OP25 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 OP25; see the file COPYING. If not, write to the Free // Software Foundation, Inc., 51 Franklin Street, Boston, MA // 02110-1301, USA. function find_parent(ele, tagname) { while (ele) { if (ele.nodeName == tagname) return (ele); else if (ele.nodeName == "HTML") return null; ele = ele.parentNode; } return null; } function f_command(ele, command) { var myrow = find_parent(ele, "TR"); if (command == "delete") { var ok = confirm ("Confirm delete"); if (ok) myrow.parentNode.removeChild(myrow); } else if (command == "clone") { var newrow = myrow.cloneNode(true); if (myrow.nextSibling) myrow.parentNode.insertBefore(newrow, myrow.nextSibling); else myrow.parentNode.appendChild(newrow); } else if (command == "new") { var mytbl = find_parent(ele, "TABLE"); var newrow = null; if (mytbl.id == "chtable") newrow = document.getElementById("chrow").cloneNode(true); else if (mytbl.id == "devtable") newrow = document.getElementById("devrow").cloneNode(true); else return; mytbl.appendChild(newrow); } } function nav_update(command) { var names = ["b1", "b2", "b3"]; var bmap = { "status": "b1", "plot": "b2", "about": "b3" }; var id = bmap[command]; for (var id1 in names) { b = document.getElementById(names[id1]); if (names[id1] == id) { b.className = "nav-button-active"; } else { b.className = "nav-button"; } } } function f_select(command) { var div_list = ["status", "plot", "about"]; for (var i=0; i= "0" && s <= "9") return true; else return false; } function rx_update(d) { if (d["files"].length > 0) { for (var i=0; iFrequency: " + d['freq'] / 1000000.0; html += "  " + d['system'] + " "; if (d['tgid'] != null) { html += "Talkgroup ID: " + d['tgid']; html += "  " + d['tag'] + " "; } html += "
"; var div_s2 = document.getElementById("div_s2"); div_s2.innerHTML = html; div_s2.style["display"] = ""; if (d['tgid'] != null) current_tgid = d['tgid']; if (current_tgid != null) { var div_s3 = document.getElementById("div_s3"); div_s3.style["display"] = ""; } } // adjacent sites table function adjacent_data(d) { if (Object.keys(d).length < 1) { var html = ""; return html; } var html = "
"; html += ""; html += ""; html += ""; var ct = 0; for (var freq in d) { var color = "#d0d0d0"; if ((ct & 1) == 0) color = "#c0c0c0"; ct += 1; html += ""; } html += "
Adjacent Sites
FrequencyRFSSSiteUplink
" + freq / 1000000.0 + "" + d[freq]["rfid"] + "" + d[freq]["stid"] + "" + (d[freq]["uplink"] / 1000000.0) + "


"; // end adjacent sites table return html; } // additional system info: wacn, sysID, rfss, site id, secondary control channels, freq error function trunk_update(d) { var do_hex = {"syid":0, "sysid":0, "wacn": 0}; var do_float = {"rxchan":0, "txchan":0}; var html = ""; for (var nac in d) { if (!is_digit(nac.charAt(0))) continue; html += ""; html += "NAC " + "0x" + parseInt(nac).toString(16) + " "; html += d[nac]['rxchan'] / 1000000.0; html += " / "; html += d[nac]['txchan'] / 1000000.0; html += " tsbks " + d[nac]['tsbks']; html += "
"; html += "WACN: " + "0x" + parseInt(d[nac]['wacn']).toString(16) + " "; html += "System ID: " + "0x" + parseInt(d[nac]['sysid']).toString(16) + " "; html += "RFSS ID: " + d[nac]['rfid'] + " "; html += "Site ID: " + d[nac]['stid'] + "
"; if (d[nac]["secondary"].length) { html += "Secondary control channel(s): "; for (i=0; iFrequency error: " + error_val + " Hz. (approx) "; } // system frequencies table html += "

"; html += ""; // was width=350 html += ""; html += ""; var ct = 0; for (var freq in d[nac]['frequency_data']) { tg2 = d[nac]['frequency_data'][freq]['tgids'][1]; if (tg2 == null) tg2 = " "; var color = "#d0d0d0"; if ((ct & 1) == 0) color = "#c0c0c0"; ct += 1; html += ""; } html += "
System Frequencies
FrequencyLast SeenTalkgoup IDCount
" + parseInt(freq) / 1000000.0 + "" + d[nac]['frequency_data'][freq]['last_activity'] + "" + d[nac]['frequency_data'][freq]['tgids'][0] + "" + tg2 + "" + d[nac]['frequency_data'][freq]['counter'] + "
"; // end system freqencies table html += adjacent_data(d[nac]['adjacent_data']); } var div_s1 = document.getElementById("div_s1"); div_s1.innerHTML = html; } function http_req_cb() { s = http_req.readyState; if (s != 4) return; if (http_req.status != 200) return; var dl = JSON.parse(http_req.responseText); var dispatch = {'trunk_update': trunk_update, 'change_freq': change_freq, 'rx_update': rx_update} for (var i=0; i