/* This file is part of Wi-viz (http://wiviz.natetrue.com). Wi-viz is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License v2 as published by the Free Software Foundation. Wi-viz 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 Wi-viz; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ var mv = 353; var stupid = eval('window.attachEvent') ? 1 : 0; var hosts; var idle_timeout = 20; var erase_timeout = 35; var skew_x = 0; skew_y = 0; var listening = 1; var wiviz_cgi_url = "/cgi-bin/wiviz/get.cgi"; //What? You mean the POSIX thread API hasn't been ported to Javascript? Bugger. function scan_thread() { var loc = document.getElementById('wivizGetFrame').contentWindow.location; if (!listening) return; if (loc.href != wiviz_cgi_url) { loc.replace(wiviz_cgi_url); } else { loc.reload(true); } setTimeout("scan_thread()", 5000); } function toggleListen() { statusel = document.getElementById('status'); statusbutton = document.getElementById('togglelisten'); listening = 1 - listening; if (listening) { statusel.innerHTML = "Monitoring"; statusbutton.value = "Stop monitoring"; document.getElementById('content').innerHTML = ''; scan_thread(); } else { statusel.innerHTML = "Stopped"; statusbutton.value = "Start monitoring"; } } function channelSet() { channelset = document.getElementById('channelsel').value; if (channelset == 'hop') { document.getElementById('hopoptions').style.display = 'inline'; } else { document.getElementById('hopoptions').style.display = 'none'; if (channelset != 'nochange') document.forms[0].submit(); } } function mousenter(e) { if (stupid) e = event; el = stupid ? e.srcElement : e.currentTarget; el.parentNode.parentNode.className = 'hostdiv_hov'; el.nextSibling.nextSibling.nextSibling.style.visibility = 'visible'; } function mouseout(e) { if (stupid) e = event; el = stupid ? e.srcElement : e.currentTarget; el.parentNode.parentNode.className = 'hostdiv'; el.nextSibling.nextSibling.nextSibling.style.visibility = 'hidden'; } function generate_mnemonic(hash) { c = new Array('b','c','d','f','g','h','j','k','l','m','n','p','qu','r','s', 't','v','w','y','z','th','ch','sh','cc','rr'); v = new Array('a','e','i','o','u','ae','ai','ao','au','eo','ei','eu','iu','oa','oe'); var i, a; var p = hash & 1; var n = ''; for (i = 0; i < 4; i++) { a = p ? c : v; n += a[hash % a.length]; hash += a.length << 3 + a.length / 2; hash *= hash; p = 1 - p; } return n; } function mkhash(mac) { var macarr = mac.split(/:/); var hash = 0; for (j = 0; j < 6; j++) { hash += parseInt(macarr[j]) * j << j; hash += 11; } if (hash < 0) hash = -hash; return hash; } function wiviz_callback(mhosts, cfgstring) { var nh = ''; hosts = mhosts; for (i = 0; i < hosts.length; i++) { hs = hosts[i]; if (hs.length == 0) break; hs.mac = hs[0]; hs.rssi = hs[1]; hs.desc = hs[2]; hs.descarr = hs.desc.split(/-/) hs.age = hs[3]; hs.hash = mkhash(hs.mac); hs.mnem = generate_mnemonic(hs.hash) hs.name = hs.mnem; el = document.getElementById(hs.mnem); if (el) { if (hs.age > erase_timeout) { el.parentNode.removeChild(el); continue; } el.innerHTML = genHTML(hs); } else { if (hs.age > erase_timeout) continue; hs.x = Math.sin(hs.hash / mv) * hs.rssi * 2 - 67; hs.y = Math.cos(hs.hash / mv) * hs.rssi * 2; nh += "