diff --git a/html_orig/js/app.js b/html_orig/js/app.js index 1a1f39d..1317573 100644 --- a/html_orig/js/app.js +++ b/html_orig/js/app.js @@ -1091,7 +1091,6 @@ function tr(key) { return _tr[key] || '?'+key+'?'; } ap.enc = parseInt(ap.enc); if (ap.enc > 4) return; // hide unsupported auths - WiFi.scan_url = '/cfg/wifi/scan'; var item = mk('div'); @@ -1145,7 +1144,7 @@ function tr(key) { return _tr[key] || '?'+key+'?'; } /** Ask the CGI what APs are visible (async) */ function scanAPs() { - $.get('http://'+_root+w.scan_url, onScan); + $.get('http://'+_root+'/cfg/wifi/scan', onScan); } function rescan(time) { @@ -1183,7 +1182,7 @@ function tr(key) { return _tr[key] || '?'+key+'?'; } w.startScanning = startScanning; })(window.WiFi = {}); var Screen = (function () { - var W, H; // dimensions + var W = 0, H = 0; // dimensions var inited = false; var cursor = { @@ -1338,21 +1337,21 @@ var Screen = (function () { if (!inited) _init(); // Set size - num = parse2B(str, i); i += 2; - num2 = parse2B(str, i); i += 2; + num = parse2B(str, i); i += 2; // height + num2 = parse2B(str, i); i += 2; // width if (num != H || num2 != W) { _rebuild(num, num2); } console.log("Size ",num, num2); // Cursor position - num = parse2B(str, i); i += 2; - num2 = parse2B(str, i); i += 2; + num = parse2B(str, i); i += 2; // row + num2 = parse2B(str, i); i += 2; // col cursorSet(num, num2); console.log("Cursor at ",num, num2); // Attributes - num = parse2B(str, i); i += 2; + num = parse2B(str, i); i += 2; // fg bg bold hidden cursor.fg = num & 0x0F; cursor.bg = (num & 0xF0) >> 4; cursor.bold = !!(num & 0x100); @@ -1444,12 +1443,19 @@ var Conn = (function() { } function init() { - ws = new WebSocket("ws://"+_root+"/ws/update.cgi"); + ws = new WebSocket("ws://"+_root+"/term/update.ws"); ws.onopen = onOpen; ws.onclose = onClose; ws.onmessage = onMessage; console.log("Opening socket."); + + // Ask for initial data + $.get('http://'+_root+'/term/init', function(resp, status) { + if (status !== 200) location.reload(true); + console.log("Data received!"); + Screen.load(resp); + }); } return { @@ -1511,8 +1517,7 @@ var Input = (function() { }; })(); -window.termInit = function (str) { - Screen.load(str); +window.termInit = function () { Conn.init(); Input.init(); }; diff --git a/html_orig/jssrc/term.js b/html_orig/jssrc/term.js index 31c3d9b..50d3377 100644 --- a/html_orig/jssrc/term.js +++ b/html_orig/jssrc/term.js @@ -1,5 +1,5 @@ var Screen = (function () { - var W, H; // dimensions + var W = 0, H = 0; // dimensions var inited = false; var cursor = { @@ -154,21 +154,21 @@ var Screen = (function () { if (!inited) _init(); // Set size - num = parse2B(str, i); i += 2; - num2 = parse2B(str, i); i += 2; + num = parse2B(str, i); i += 2; // height + num2 = parse2B(str, i); i += 2; // width if (num != H || num2 != W) { _rebuild(num, num2); } console.log("Size ",num, num2); // Cursor position - num = parse2B(str, i); i += 2; - num2 = parse2B(str, i); i += 2; + num = parse2B(str, i); i += 2; // row + num2 = parse2B(str, i); i += 2; // col cursorSet(num, num2); console.log("Cursor at ",num, num2); // Attributes - num = parse2B(str, i); i += 2; + num = parse2B(str, i); i += 2; // fg bg bold hidden cursor.fg = num & 0x0F; cursor.bg = (num & 0xF0) >> 4; cursor.bold = !!(num & 0x100); @@ -260,12 +260,19 @@ var Conn = (function() { } function init() { - ws = new WebSocket("ws://"+_root+"/ws/update.cgi"); + ws = new WebSocket("ws://"+_root+"/term/update.ws"); ws.onopen = onOpen; ws.onclose = onClose; ws.onmessage = onMessage; console.log("Opening socket."); + + // Ask for initial data + $.get('http://'+_root+'/term/init', function(resp, status) { + if (status !== 200) location.reload(true); + console.log("Data received!"); + Screen.load(resp); + }); } return { @@ -327,8 +334,7 @@ var Input = (function() { }; })(); -window.termInit = function (str) { - Screen.load(str); +window.termInit = function () { Conn.init(); Input.init(); }; diff --git a/html_orig/jssrc/wifi.js b/html_orig/jssrc/wifi.js index 6b8c238..71fb574 100644 --- a/html_orig/jssrc/wifi.js +++ b/html_orig/jssrc/wifi.js @@ -68,7 +68,6 @@ ap.enc = parseInt(ap.enc); if (ap.enc > 4) return; // hide unsupported auths - WiFi.scan_url = '/cfg/wifi/scan'; var item = mk('div'); @@ -122,7 +121,7 @@ /** Ask the CGI what APs are visible (async) */ function scanAPs() { - $.get('http://'+_root+w.scan_url, onScan); + $.get('http://'+_root+'/cfg/wifi/scan', onScan); } function rescan(time) { diff --git a/html_orig/pages/term.php b/html_orig/pages/term.php index 47d32bb..1f2480b 100644 --- a/html_orig/pages/term.php +++ b/html_orig/pages/term.php @@ -22,7 +22,7 @@ - +