Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

47
LINES

< > BotCompany Repo | #1013839 // hSilentComputator (for sub bots) - place in <body>

JavaX fragment (include)

1  
sS hSilentComputator() {
2  
  ret hSilentComputator(hSilentComputator_defaultURI());
3  
}
4  
5  
sS hSilentComputator(S wsUri) {
6  
  ret hSilentComputator(wsUri, "");
7  
}
8  
9  
sS hSilentComputator(S wsUri, S flag) {
10  
  if (nempty(flag)) wsUri = addSlash(wsUri) + flag;
11  
  
12  
  ret div("Calculating", id := 'calcing)
13  
  + hcss([[#calcing {
14  
position: fixed;
15  
width: 100%;
16  
height: 100vh;
17  
z-index: 9999;
18  
visibility: hidden;
19  
}]])
20  
    + hMakeComputerID()
21  
    + hreconnectingWebSockets()
22  
    + hjavascript([[
23  
      function sendPing() {
24  
        ${PINGCMD}
25  
      }
26  
      
27  
      var working = false;
28  
      var benchResultl;
29  
      var ws = new ReconnectingWebSocket("${URI}");
30  
      ws.onopen = function(event) {
31  
        console.log("WebSocket opened.");
32  
      };
33  
      ws.onmessage = function(event) {
34  
        var d = event.data;
35  
        while (d.length > 0 && d.charCodeAt(d.length-1) == 0)
36  
          d = d.substring(0, d.length-1);
37  
        console.log("Evaluating: " + d);
38  
        var geval = eval; // use global scope
39  
        geval(d);
40  
        console.log("Evaluated.");
41  
      };
42  
      
43  
      //working = true; // XXX
44  
      //console.log("Eval test: " + eval('working'));
45  
  ]].replace("${URI}", wsUri)
46  
    .replace("${PINGCMD}", nodes_pingCmd()));
47  
}

Author comment

Began life as a copy of #1013835

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1013839
Snippet name: hSilentComputator (for sub bots) - place in <body>
Eternal ID of this version: #1013839/35
Text MD5: 5e1daf07a3ee0529080116e53e0249e3
Author: stefan
Category: javax / web
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-16 16:52:36
Source code size: 1263 bytes / 47 lines
Pitched / IR pitched: No / No
Views / Downloads: 536 / 579
Version history: 34 change(s)
Referenced in: [show references]