update boot.js remove old code and add to test to use static version

This commit is contained in:
David Botton 2021-03-19 06:18:46 -04:00
parent e32113d8c1
commit 8edd6e8c84
3 changed files with 22 additions and 36 deletions

View file

@ -51,7 +51,6 @@ script."
(debug-mode function) (debug-mode function)
(set-html-on-close function)) (set-html-on-close function))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Implemetation - clog-connection ;; Implemetation - clog-connection
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -470,7 +469,6 @@ the browser contents in case of connection loss."
"Returns a compiled version of current version of boot.js (private)" "Returns a compiled version of current version of boot.js (private)"
"var ws; "var ws;
var adr; var adr;
var params={};
var clog={}; var clog={};
var pingerid; var pingerid;
@ -551,12 +549,6 @@ $( document ).ready(function() {
clog['document']=window.document; clog['document']=window.document;
clog['location']=window.location; clog['location']=window.location;
s = s.split('+').join(' ');
while (tokens = r.exec(s)) {
params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);
}
if (location.protocol == 'https:') { if (location.protocol == 'https:') {
adr = 'wss://' + location.hostname; adr = 'wss://' + location.hostname;
} else { } else {

View file

@ -1,6 +1,6 @@
/*static version*/
var ws; var ws;
var adr; var adr;
var params={};
var clog={}; var clog={};
var pingerid; var pingerid;
@ -10,7 +10,7 @@ if (typeof clog_debug == 'undefined') {
function Ping_ws() { function Ping_ws() {
if (ws.readyState == 1) { if (ws.readyState == 1) {
ws.send ("0"); ws.send ('0');
} }
} }
@ -22,7 +22,7 @@ function Shutdown_ws(event) {
ws = null; ws = null;
} }
clearInterval (pingerid); clearInterval (pingerid);
if (clog['html_on_close'] != "") { if (clog['html_on_close'] != '') {
$(document.body).html(clog['html_on_close']); $(document.body).html(clog['html_on_close']);
} }
} }
@ -31,7 +31,7 @@ function Setup_ws() {
ws.onmessage = function (event) { ws.onmessage = function (event) {
try { try {
if (clog_debug == true) { if (clog_debug == true) {
console.log ("eval data = " + event.data); console.log ('eval data = ' + event.data);
} }
eval (event.data); eval (event.data);
} catch (e) { } catch (e) {
@ -40,29 +40,29 @@ function Setup_ws() {
} }
ws.onerror = function (event) { ws.onerror = function (event) {
console.log ("onerror: reconnect"); console.log ('onerror: reconnect');
ws = null; ws = null;
ws = new WebSocket (adr + "?r=" + clog['connection_id']); ws = new WebSocket (adr + '?r=' + clog['connection_id']);
ws.onopen = function (event) { ws.onopen = function (event) {
console.log ("onerror: reconnect successful"); console.log ('onerror: reconnect successful');
Setup_ws(); Setup_ws();
} }
ws.onclose = function (event) { ws.onclose = function (event) {
console.log ("onerror: reconnect failure"); console.log ('onerror: reconnect failure');
Shutdown_ws(event); Shutdown_ws(event);
} }
} }
ws.onclose = function (event) { ws.onclose = function (event) {
console.log ("onclose: reconnect"); console.log ('onclose: reconnect');
ws = null; ws = null;
ws = new WebSocket (adr + "?r=" + clog['connection_id']); ws = new WebSocket (adr + '?r=' + clog['connection_id']);
ws.onopen = function (event) { ws.onopen = function (event) {
console.log ("onclose: reconnect successful"); console.log ('onclose: reconnect successful');
Setup_ws(); Setup_ws();
} }
ws.onclose = function (event) { ws.onclose = function (event) {
console.log ("onclose: reconnect failure"); console.log ('onclose: reconnect failure');
Shutdown_ws(event); Shutdown_ws(event);
} }
} }
@ -81,36 +81,30 @@ $( document ).ready(function() {
clog['document']=window.document; clog['document']=window.document;
clog['location']=window.location; clog['location']=window.location;
s = s.split("+").join(" "); if (location.protocol == 'https:') {
adr = 'wss://' + location.hostname;
while (tokens = r.exec(s)) {
params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);
}
if (location.protocol == "https:") {
adr = "wss://" + location.hostname;
} else { } else {
adr = "ws://" + location.hostname; adr = 'ws://' + location.hostname;
} }
if (location.port != "") { adr = adr + ":" + location.port; } if (location.port != '') { adr = adr + ':' + location.port; }
adr = adr + "/clog"; adr = adr + '/clog';
try { try {
console.log ("connecting to " + adr); console.log ('connecting to ' + adr);
ws = new WebSocket (adr); ws = new WebSocket (adr);
} catch (e) { } catch (e) {
console.log ("trying again, connecting to " + adr); console.log ('trying again, connecting to ' + adr);
ws = new WebSocket (adr); ws = new WebSocket (adr);
} }
if (ws != null) { if (ws != null) {
ws.onopen = function (event) { ws.onopen = function (event) {
console.log ("connection successful"); console.log ('connection successful');
Setup_ws(); Setup_ws();
} }
pingerid = setInterval (function () {Ping_ws ();}, 10000); pingerid = setInterval (function () {Ping_ws ();}, 10000);
} else { } else {
document.writeln ("If you are seeing this your browser or your connection to the internet is blocking websockets."); document.writeln ('If you are seeing this your browser or your connection to the internet is blocking websockets.');
} }
}); });

View file

@ -83,6 +83,6 @@
(defun test () (defun test ()
(print "Init connection") (print "Init connection")
(initialize #'on-new-window :boot-file "/debug.html") (initialize #'on-new-window :boot-file "/debug.html" :static-boot-js t)
(print "Open browser") (print "Open browser")
(open-browser)) (open-browser))