# HG changeset patch # User Matti Hamalainen # Date 1676735466 -7200 # Node ID 4541c68e1ebf2d91aa3343ad8c755ae7d37a24d1 # Parent 5402702015ccb886ac1aeb562dc41660e4503564 Improve WebSocket failure mode handling. diff -r 5402702015cc -r 4541c68e1ebf www/search.js --- a/www/search.js Fri Feb 10 02:47:54 2023 +0200 +++ b/www/search.js Sat Feb 18 17:51:06 2023 +0200 @@ -113,6 +113,7 @@ } } + function mapCapitalize(str) { return str.substr(0, 1).toUpperCase() + str.substr(1); @@ -231,14 +232,6 @@ if (mlobj) mlobj.innerHTML = "Contacting server ..."; - var mlhelp1 = document.getElementById("help1"); - if (mlhelp1) - mlhelp1.style.display = "none"; - - var mlhelp2 = document.getElementById("help2"); - if (mlhelp2) - mlhelp2.style.display = "none"; - dataWS.onopen = function() { if (mlobj) @@ -590,7 +583,19 @@ if (verr) verr.parentNode.removeChild(verr); - mapGetData(); + var mlhelp1 = document.getElementById("help1"); + if (mlhelp1) + mlhelp1.style.display = "none"; + + var mlhelp2 = document.getElementById("help2"); + if (mlhelp2) + mlhelp2.style.display = "none"; + + if (!("WebSocket" in window)) + { + mapResult("Your browser does not support WebSockets!"); + return; + } fieldPattern = document.getElementById("mapPattern"); btnMapSearch = document.getElementById("btnMapSearch"); @@ -618,6 +623,8 @@ mapResult("Cleared search pattern and results."); }); + mapGetData(); + // Reset or clear map list button mapAddEvent("btnMaps", "click", function ()