Debian Codegraph @

gopls/internal/server/assets/common.js

raw symbols SCIP
1 // Copyright 2024 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // httpGET requests a URL for its effects only.
6 // (It is needed for /open URLs; see objHTML.)
7 function httpGET(url) {
8 var x = new XMLHttpRequest();
9 x.open("GET", url, true);
10 x.send();
11 return false; // disable usual <a href=...> behavior
12 }
13
14 // disconnect banner
15 window.addEventListener('load', function() {
16 // Create a hidden <div id='disconnected'> element.
17 var banner = document.createElement("div");
18 banner.id = "disconnected";
19 banner.innerText = "Gopls server has terminated. Page is inactive.";
20 document.body.appendChild(banner);
21
22 // Start a GET /hang request. If it ever completes, the server
23 // has disconnected. Reveal the banner in that case.
24 var x = new XMLHttpRequest();
25 x.open("GET", "/hang", true);
26 x.onloadend = () => { banner.style.display = "block"; };
27 x.send();
28 });