|
@@ -252,7 +252,6 @@ function _login() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//------------
|
|
//------------
|
|
|
-//------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _verify_driver() {
|
|
function _verify_driver() {
|
|
@@ -531,11 +530,16 @@ function _cb_status(inp) {
|
|
|
|
|
|
|
|
var m = g_ctx.diu_status;
|
|
var m = g_ctx.diu_status;
|
|
|
if (g_ctx.current_ui === "ui_login") {
|
|
if (g_ctx.current_ui === "ui_login") {
|
|
|
|
|
+
|
|
|
|
|
+ has_tunn = ((m["tunnel"] == '1') ? 'YES' : 'NO');
|
|
|
|
|
+ has_gprs = ((m["gprs"] == '1') ? 'YES' : 'NO');
|
|
|
|
|
+ has_gps = ((m["gps"] == '1') ? 'YES' : 'NO');
|
|
|
|
|
+
|
|
|
var ele = document.getElementById("ui_login_status");
|
|
var ele = document.getElementById("ui_login_status");
|
|
|
var str = "";
|
|
var str = "";
|
|
|
- str += "Tunnel: " + m["tunnel"] + " GPRS: " + m["gprs"] + " Eq#: " + m["equipno"] + " #Msg: " + m["nmsg"] + "\n";
|
|
|
|
|
|
|
+ str += "Tunnel: " + has_tunn + " GPRS: " + has_gprs + " Eq#: " + m["equipno"] + " #Msg: " + m["nmsg"] + "\n";
|
|
|
str += "Last Token Read (" + m["last_token"] + ")\n";
|
|
str += "Last Token Read (" + m["last_token"] + ")\n";
|
|
|
- str += "GPS: " + m["gps"] + "\n";
|
|
|
|
|
|
|
+ str += "GPS: " + has_gps + "\n";
|
|
|
str += "\n";
|
|
str += "\n";
|
|
|
// 012345678012345678901234567890
|
|
// 012345678012345678901234567890
|
|
|
str += "Package Version Installed\n";
|
|
str += "Package Version Installed\n";
|
|
@@ -594,8 +598,6 @@ function _main_message_replace(msg, bg_color, text_color) {
|
|
|
|
|
|
|
|
g_ctx.status_text = lines.join("\n");
|
|
g_ctx.status_text = lines.join("\n");
|
|
|
ele.innerHTML = g_ctx.status_text;
|
|
ele.innerHTML = g_ctx.status_text;
|
|
|
-
|
|
|
|
|
- console.log(">>replace:", msg);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function _main_message_add(msg, bg_color, text_color) {
|
|
function _main_message_add(msg, bg_color, text_color) {
|
|
@@ -619,8 +621,6 @@ function _main_message_add(msg, bg_color, text_color) {
|
|
|
|
|
|
|
|
g_ctx.status_text = lines.join("\n");
|
|
g_ctx.status_text = lines.join("\n");
|
|
|
ele.innerHTML = g_ctx.status_text;
|
|
ele.innerHTML = g_ctx.status_text;
|
|
|
-
|
|
|
|
|
- console.log(">>add:", msg);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -666,12 +666,173 @@ function _init_websocket() {
|
|
|
sock.onerror = function(e) { console.log("error", e); }
|
|
sock.onerror = function(e) { console.log("error", e); }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//-------------
|
|
|
|
|
+
|
|
|
|
|
+var ui_pattern = {
|
|
|
|
|
+ "state" : "idle",
|
|
|
|
|
+ "lastX" : 0,
|
|
|
|
|
+ "lastY" : 0,
|
|
|
|
|
+ "curX" : 0,
|
|
|
|
|
+ "curY" : 0
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+function ui_pattern_mousedown(ev) {
|
|
|
|
|
+ var ele = document.getElementById("body");
|
|
|
|
|
+ var rect = ele.getBoundingClientRect();
|
|
|
|
|
+
|
|
|
|
|
+ var x = ev["x"];
|
|
|
|
|
+ var y = ev["y"];
|
|
|
|
|
+
|
|
|
|
|
+ var width = rect.width;
|
|
|
|
|
+ var height = rect.height;
|
|
|
|
|
+
|
|
|
|
|
+ if (ui_pattern.state == "idle") {
|
|
|
|
|
+ if (y < (height/4)) {
|
|
|
|
|
+ ui_pattern.state = "square_0";
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ ui_pattern.state = "idle"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ else if (ui_pattern.state == "square_0") {
|
|
|
|
|
+ if (x > (3*width/4)) {
|
|
|
|
|
+ ui_pattern.state = "square_1";
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ ui_pattern.state = "idle"
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ else if (ui_pattern.state == "square_1") {
|
|
|
|
|
+ if (y > (3*height/4)) {
|
|
|
|
|
+ ui_pattern.state = "square_2";
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ ui_pattern.state = "idle"
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ else if (ui_pattern.state == "square_2") {
|
|
|
|
|
+ if (x < (width/4)) {
|
|
|
|
|
+ _switch_ui("ui_diagnostic");
|
|
|
|
|
+ }
|
|
|
|
|
+ ui_pattern.state = "idle"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return false;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (ui_pattern.state == "idle") {
|
|
|
|
|
+
|
|
|
|
|
+ if ((x < (width/4)) && (y < (height/4))) {
|
|
|
|
|
+ ui_pattern.state = "cross_0_start";
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ ui_pattern.state = "idle"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (ui_pattern.state == "cross_0_end") {
|
|
|
|
|
+
|
|
|
|
|
+ if ((x > (3*width/4)) && (y < (height/4))) {
|
|
|
|
|
+ ui_pattern.state = "cross_1_start";
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ ui_pattern.state = "idle"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ ui_pattern.state = "idle";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return false;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function ui_pattern_mouseup(ev) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+
|
|
|
|
|
+ var ele = document.getElementById("body");
|
|
|
|
|
+ var rect = ele.getBoundingClientRect();
|
|
|
|
|
+
|
|
|
|
|
+ var x = ev["x"];
|
|
|
|
|
+ var y = ev["y"];
|
|
|
|
|
+
|
|
|
|
|
+ var width = rect.width;
|
|
|
|
|
+ var height = rect.height;
|
|
|
|
|
+
|
|
|
|
|
+ if (ui_pattern.state == "cross_0_start") {
|
|
|
|
|
+
|
|
|
|
|
+ if ((x > (3*width/4)) && (y > (3*height/4))) {
|
|
|
|
|
+ ui_pattern.state = "cross_0_end";
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ ui_pattern.state = "idle"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (ui_pattern.state == "cross_1_start") {
|
|
|
|
|
+
|
|
|
|
|
+ if ((x < (width/4)) && (y > (3*height/4))) {
|
|
|
|
|
+ _switch_ui("ui_diagnostic");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ui_pattern.state = "idle";
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ ui_pattern.state = "idle";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return false;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+//------------
|
|
|
|
|
+
|
|
|
|
|
+function _mainscreen() {
|
|
|
|
|
+ _switch_ui('ui_login');
|
|
|
|
|
+ g_ctx.driver_login_state = "driver";
|
|
|
|
|
+ _clear_ui_driver();
|
|
|
|
|
+ _clear_ui_paddle();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function _reset() {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ _switch_ui('ui_login');
|
|
|
|
|
+ g_ctx.driver_login_state = "driver";
|
|
|
|
|
+ _clear_ui_driver();
|
|
|
|
|
+ _clear_ui_paddle();
|
|
|
|
|
+
|
|
|
|
|
+ location.reload(true);
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function _reboot() {
|
|
|
|
|
+ _switch_ui('ui_login');
|
|
|
|
|
+ g_ctx.driver_login_state = "driver";
|
|
|
|
|
+ _clear_ui_driver();
|
|
|
|
|
+ _clear_ui_paddle();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+//------------
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
//-------------
|
|
//-------------
|
|
|
|
|
|
|
|
function init() {
|
|
function init() {
|
|
|
|
|
|
|
|
_init_websocket();
|
|
_init_websocket();
|
|
|
|
|
|
|
|
|
|
+ // diagnostics
|
|
|
|
|
+ //
|
|
|
|
|
+ document.getElementById('ui_diagnostic_mainscreen').onclick = _mainscreen;
|
|
|
|
|
+ document.getElementById('ui_diagnostic_reset').onclick = _reset;
|
|
|
|
|
+ document.getElementById('ui_diagnostic_reboot').onclick = _reboot;
|
|
|
|
|
+
|
|
|
// login
|
|
// login
|
|
|
//
|
|
//
|
|
|
document.getElementById('ui_login_login').onclick = _login;
|
|
document.getElementById('ui_login_login').onclick = _login;
|
|
@@ -832,7 +993,6 @@ function init() {
|
|
|
// set interval to check status every 1 second
|
|
// set interval to check status every 1 second
|
|
|
//
|
|
//
|
|
|
var x = window.setInterval(function() { _api_request("status", {}, _cb_status, _cb_status_err); }, 1000);
|
|
var x = window.setInterval(function() { _api_request("status", {}, _cb_status, _cb_status_err); }, 1000);
|
|
|
- console.log(">>>", x);
|
|
|
|
|
|
|
|
|
|
// try and reduce textarea highlighting, drag and drop/copy pasting,
|
|
// try and reduce textarea highlighting, drag and drop/copy pasting,
|
|
|
// and other bad behavor.
|
|
// and other bad behavor.
|
|
@@ -877,6 +1037,10 @@ function init() {
|
|
|
block_ele.style.y = rect.y;
|
|
block_ele.style.y = rect.y;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ ele = document.getElementById("body");
|
|
|
|
|
+ ele.onmousedown = ui_pattern_mousedown;
|
|
|
|
|
+ ele.onmouseup = ui_pattern_mouseup;
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
init();
|
|
init();
|