first commit

This commit is contained in:
David Botton 2020-12-13 16:21:26 -05:00
commit e4731e2fa1
13 changed files with 543 additions and 0 deletions

108
static-files/js/boot.js Normal file
View file

@ -0,0 +1,108 @@
var ws;
var adr;
var params={};
var clog={};
var pingerid;
if (typeof clog_debug == 'undefined') {
clog_debug = false;
}
function Ping_ws() {
if (ws.readyState == 1) {
ws.send ("0");
}
}
function Shutdown_ws(event) {
ws.onerror = null;
ws.onclose = null;
ws.close ();
ws = null;
clearInterval (pingerid);
if (clog['html_on_close'] != "") {
$(document.body).html(clog['html_on_close']);
} else {
alert ("Server connection lost " + event.reason);
}
}
function Setup_ws() {
ws.onmessage = function (event) {
try {
if (clog_debug == true) {
console.log ("eval data = " + event.data);
}
eval (event.data);
} catch (e) {
console.error (e.message);
}
}
ws.onerror = function (event) {
console.log ("onerror: reconnect");
ws = null;
ws = new WebSocket (adr + "?" + clog['connection_id']);
ws.onopen = function (event) {
console.log ("onerror: reconnect successful");
Setup_ws();
}
ws.onclose = function (event) {
console.log ("onerror: reconnect failure");
Shutdown_ws(event);
}
}
ws.onclose = function (event) {
console.log ("onclose: reconnect");
ws = null;
ws = new WebSocket (adr + "?" + clog['connection_id']);
ws.onopen = function (event) {
console.log ("onclose: reconnect successful");
Setup_ws();
}
ws.onclose = function (event) {
console.log ("onclose: reconnect failure");
Shutdown_ws(event);
}
}
}
$( document ).ready(function() {
var s = document.location.search;
var tokens;
var r = /[?&]?([^=]+)=([^&]*)/g;
s = s.split("+").join(" ");
while (tokens = r.exec(s)) {
params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);
}
if (location.protocol == "https:") {
adr = "wss://" + location.hostname;
} else {
adr = "ws://" + location.hostname;
}
if (location.port != "") { adr = adr + ":" + location.port; }
adr = adr + "/clog";
try {
console.log ("connecting to " + adr);
ws = new WebSocket (adr);
} catch (e) {
console.log ("trying again, connecting to " + adr);
ws = new WebSocket (adr);
}
if (ws != null) {
ws.onopen = function (event) {
console.log ("connection successful");
Setup_ws();
}
pingerid = setInterval (function () {Ping_ws ();}, 10000);
} else {
document.writeln ("If you are seeing this your browser or your connection to the internet is blocking websockets.");
}
});

4
static-files/js/jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long