|
|
@@ -27,13 +27,31 @@ var _fqADDRESS = _ADDRESS + ":" + _PORT;
|
|
|
var BG_COLOR = "#f7f7f7";
|
|
|
var TEXT_COLOR = "#444444";
|
|
|
|
|
|
-var DIU_UI_VERSION = "0.1.0";
|
|
|
-var DIU_UI_VERSION_DATE = "2019-09-04 15:24:11";
|
|
|
+var DIU_UI_VERSION = "0.1.4";
|
|
|
+var DIU_UI_VERSION_DATE = "2019-11-24 11:29:00";
|
|
|
|
|
|
var g_snd = {
|
|
|
+ "reject_fare" : "",
|
|
|
+ "accept_fare" : "",
|
|
|
+ "rule_error" : "",
|
|
|
"button_press" : ""
|
|
|
};
|
|
|
|
|
|
+function _beep_error() {
|
|
|
+ g_snd.rule_error.currentTime=0;
|
|
|
+ g_snd.rule_error.play();
|
|
|
+}
|
|
|
+
|
|
|
+function _beep_reject() {
|
|
|
+ g_snd.reject_fare.currentTime=0;
|
|
|
+ g_snd.reject_fare.play();
|
|
|
+}
|
|
|
+
|
|
|
+function _beep_accept() {
|
|
|
+ g_snd.accept_fare.currentTime=0;
|
|
|
+ g_snd.accept_fare.play();
|
|
|
+}
|
|
|
+
|
|
|
function _beep() {
|
|
|
g_snd.button_press.currentTime=0;
|
|
|
g_snd.button_press.play();
|
|
|
@@ -55,8 +73,10 @@ var g_ctx = {
|
|
|
"bulkfare_count" : "",
|
|
|
|
|
|
"status_text": "",
|
|
|
- "status_text_w": 0,
|
|
|
- "status_text_h": 0,
|
|
|
+ "status_text_w": 32,
|
|
|
+ "status_text_h": 9,
|
|
|
+
|
|
|
+ "status_html_text":"",
|
|
|
|
|
|
"diu_status" : {},
|
|
|
|
|
|
@@ -548,8 +568,6 @@ function _cb_status(inp) {
|
|
|
var kv = fields[ii].split("=");
|
|
|
if (kv.length!=2) { continue; }
|
|
|
g_ctx.diu_status[kv[0].trim()] = kv[1].trim();
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
var m = g_ctx.diu_status;
|
|
|
@@ -565,20 +583,30 @@ function _cb_status(inp) {
|
|
|
var gps_str = ( ((lat.length>0) && (lon.length>0)) ? (" (" + lat + "/" + lon + ")") : "" );
|
|
|
|
|
|
var ele = document.getElementById("ui_login_status");
|
|
|
- var str = "";
|
|
|
- str += "Tunnel: " + has_tunn + " GPRS: " + has_gprs + " Eq#: " + m["equipno"] + " #Msg: " + m["nmsg"] + "\n";
|
|
|
- str += "Last Token Read (" + m["last_token"] + ")\n";
|
|
|
- str += "GPS: " + has_gps + gps_str + "\n";
|
|
|
- str += "\n";
|
|
|
- // 012345678012345678901234567890
|
|
|
- str += "Package Version Installed\n";
|
|
|
- //str += "-----------------------------\n";
|
|
|
- str += _sp("ui") + _sp(DIU_UI_VERSION) + _sp(DIU_UI_VERSION_DATE) + "\n";
|
|
|
- str += "\n";
|
|
|
-
|
|
|
- if ("IMEI" in m) { str += "IMEI = " + m["IMEI"] + "\n"; }
|
|
|
- if ("IMSI" in m) { str += "IMSI = " + m["IMSI"] + "\n"; }
|
|
|
- if ("ETH0" in m) { str += "ETH0 = " + m["ETH0"] + "\n"; }
|
|
|
+
|
|
|
+ var html_a = [];
|
|
|
+ html_a.push("Tunnel: " + has_tunn + " GPRS: " + has_gprs + " Eq#: " + m["equipno"] + " #Msg: " + m["nmsg"]);
|
|
|
+ html_a.push("Last Token Read (" + m["last_token"] + ")");
|
|
|
+ html_a.push("GPS: " + has_gps + gps_str + "");
|
|
|
+ html_a.push(" ");
|
|
|
+ html_a.push("Package Version Installed");
|
|
|
+ html_a.push(_sp("ui") + _sp(DIU_UI_VERSION) + _sp(DIU_UI_VERSION_DATE) + "");
|
|
|
+ html_a.push(" ");
|
|
|
+
|
|
|
+ if ("IMEI" in m) { html_a.push("IMEI = " + m["IMEI"] + ""); }
|
|
|
+ if ("IMSI" in m) { html_a.push("IMSI = " + m["IMSI"] + ""); }
|
|
|
+ if ("ETH0" in m) { html_a.push("ETH0 = " + m["ETH0"] + ""); }
|
|
|
+ html_a.push(" ");
|
|
|
+
|
|
|
+ for (var ii=0; ii<html_a.length; ii++) {
|
|
|
+ html_a[ii] = html_a[ii].replace(/ /g, ' ');
|
|
|
+ }
|
|
|
+
|
|
|
+ //span_str = "<div style='float:left; width: 100%; margin: 0 auto; display:block; text-align:left; background: #770000; color:#008800;'>";
|
|
|
+ //span_str = "<div style='float:left; width: 100%; text-align:left; background: #770000; color:#008800;'>";
|
|
|
+ //var div_hdr = "<div style='float:left; width: 100%; text-align:left; '>";
|
|
|
+ var div_hdr = "<div class='textrow'>";
|
|
|
+ var str = div_hdr + html_a.join("</div><br>" + div_hdr ) + "</div>";
|
|
|
|
|
|
ele.innerHTML = str;
|
|
|
}
|
|
|
@@ -611,10 +639,8 @@ function _main_message_clear() {
|
|
|
|
|
|
function _main_message_replace(msg, bg_color, text_color) {
|
|
|
var ele = document.getElementById("ui_main_status");
|
|
|
- g_ctx.status_text_w = ele.cols;
|
|
|
- g_ctx.status_text_h = ele.rows;
|
|
|
|
|
|
- bg_color = ((typeof bg_color === "undeinfed") ? BG_COLOR : bg_color);
|
|
|
+ bg_color = ((typeof bg_color === "undefined") ? BG_COLOR : bg_color);
|
|
|
text_color = ((typeof text_color === "undefined") ? TEXT_COLOR : text_color);
|
|
|
|
|
|
var lines = g_ctx.status_text.split("\n");
|
|
|
@@ -631,31 +657,118 @@ function _main_message_replace(msg, bg_color, text_color) {
|
|
|
|
|
|
lines[idx] = msg;
|
|
|
|
|
|
+ var html_lines = [];
|
|
|
+ for (var i=0; i<lines.length; i++) {
|
|
|
+ html_lines.push(lines[i].slice(0,g_ctx.status_text_w));
|
|
|
+
|
|
|
+ if (html_lines[i].match(/ACCEPT/)) {
|
|
|
+ html_lines[i] = "<div class='textrow accept'>" + html_lines[i] + "</div>";
|
|
|
+ }
|
|
|
+ else if (html_lines[i].match(/REJECT/)) {
|
|
|
+ html_lines[i] = "<div class='textrow reject'>" + html_lines[i] + "</div>";
|
|
|
+ }
|
|
|
+ else if (html_lines[i].match(/[Uu]nknown/)) {
|
|
|
+ html_lines[i] = "<div class='textrow reject'>" + html_lines[i] + "</div>";
|
|
|
+ }
|
|
|
+ else if (html_lines[i].match(/[Pp]assback/)) {
|
|
|
+ html_lines[i] = "<div class='textrow reject'>" + html_lines[i] + "</div>";
|
|
|
+ }
|
|
|
+ else if (html_lines[i].match(/Rule execution error/)) {
|
|
|
+ html_lines[i] = "<div class='textrow error'>" + html_lines[i] + "</div>";
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ html_lines[i] = "<div class='textrow'>" + html_lines[i] + "</div>";
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ g_ctx.status_text = lines.join("\n");
|
|
|
+
|
|
|
g_ctx.status_text = lines.join("\n");
|
|
|
- ele.innerHTML = g_ctx.status_text;
|
|
|
+ g_ctx.status_html_text = html_lines.join("<br>");
|
|
|
+ ele.innerHTML = g_ctx.status_html_text;
|
|
|
+
|
|
|
+ // sounds
|
|
|
+ //
|
|
|
+ if (msg.match(/ACCEPT/)) {
|
|
|
+ _beep_accept();
|
|
|
+ }
|
|
|
+ else if (msg.match(/REJECT/)) {
|
|
|
+ _beep_reject();
|
|
|
+ }
|
|
|
+ else if (msg.match(/[Uu]nknown/)) {
|
|
|
+ _beep_reject();
|
|
|
+ }
|
|
|
+ else if (msg.match(/[Pp]assback/)) {
|
|
|
+ _beep_reject();
|
|
|
+ }
|
|
|
+ else if (msg.match(/Rule execution error/)) {
|
|
|
+ _beep_error();
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
function _main_message_add(msg, bg_color, text_color) {
|
|
|
var ele = document.getElementById("ui_main_status");
|
|
|
- g_ctx.status_text_w = ele.cols;
|
|
|
- g_ctx.status_text_h = ele.rows;
|
|
|
|
|
|
- bg_color = ((typeof bg_color === "undeinfed") ? BG_COLOR : bg_color);
|
|
|
+ bg_color = ((typeof bg_color === "undefined") ? BG_COLOR : bg_color);
|
|
|
text_color = ((typeof text_color === "undefined") ? TEXT_COLOR : text_color);
|
|
|
|
|
|
var txt = g_ctx.status_text + "\n" + msg;
|
|
|
|
|
|
+ var html_lines = [];
|
|
|
+
|
|
|
var lines = txt.split("\n");
|
|
|
if (lines.length > g_ctx.status_text_h) {
|
|
|
var n = lines.length;
|
|
|
lines = lines.slice(n - g_ctx.status_text_h);
|
|
|
}
|
|
|
for (var i=0; i<lines.length; i++) {
|
|
|
- lines[i] = lines[i].slice(0,g_ctx.status_text_w);
|
|
|
+ html_lines.push(lines[i].slice(0,g_ctx.status_text_w));
|
|
|
+
|
|
|
+ if (html_lines[i].match(/ACCEPT/)) {
|
|
|
+ html_lines[i] = "<div class='textrow accept'>" + html_lines[i] + "</div>";
|
|
|
+ }
|
|
|
+ else if (html_lines[i].match(/REJECT/)) {
|
|
|
+ html_lines[i] = "<div class='textrow reject'>" + html_lines[i] + "</div>";
|
|
|
+ }
|
|
|
+ else if (html_lines[i].match(/[Uu]nknown/)) {
|
|
|
+ html_lines[i] = "<div class='textrow reject'>" + html_lines[i] + "</div>";
|
|
|
+ }
|
|
|
+ else if (html_lines[i].match(/[Pp]assback/)) {
|
|
|
+ html_lines[i] = "<div class='textrow reject'>" + html_lines[i] + "</div>";
|
|
|
+ }
|
|
|
+ else if (html_lines[i].match(/Rule execution error/)) {
|
|
|
+ html_lines[i] = "<div class='textrow error'>" + html_lines[i] + "</div>";
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ html_lines[i] = "<div class='textrow'>" + html_lines[i] + "</div>";
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
g_ctx.status_text = lines.join("\n");
|
|
|
- ele.innerHTML = g_ctx.status_text;
|
|
|
+ g_ctx.status_html_text = html_lines.join("<br>");
|
|
|
+ ele.innerHTML = g_ctx.status_html_text;
|
|
|
+
|
|
|
+ // sounds
|
|
|
+ //
|
|
|
+ if (msg.match(/ACCEPT/)) {
|
|
|
+ _beep_accept();
|
|
|
+ }
|
|
|
+ else if (msg.match(/REJECT/)) {
|
|
|
+ _beep_reject();
|
|
|
+ }
|
|
|
+ else if (msg.match(/[Uu]nknown/)) {
|
|
|
+ _beep_reject();
|
|
|
+ }
|
|
|
+ else if (msg.match(/[Pp]assback/)) {
|
|
|
+ _beep_reject();
|
|
|
+ }
|
|
|
+ else if (msg.match(/Rule execution error/)) {
|
|
|
+ _beep_error();
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -723,6 +836,7 @@ function ui_pattern_mousedown(ev) {
|
|
|
var height = rect.height;
|
|
|
|
|
|
if (ui_pattern.state == "idle") {
|
|
|
+
|
|
|
if (y < (height/4)) {
|
|
|
ui_pattern.state = "square_0";
|
|
|
}
|
|
|
@@ -752,63 +866,17 @@ function ui_pattern_mousedown(ev) {
|
|
|
|
|
|
else if (ui_pattern.state == "square_2") {
|
|
|
if (x < (width/4)) {
|
|
|
- _switch_ui("ui_diagnostic");
|
|
|
+ ui_pattern.state = "square_3";
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ ui_pattern.state = "idle"
|
|
|
}
|
|
|
- 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;
|
|
|
-}
|
|
|
-
|
|
|
-function __ui_pattern_mouseup_depricated(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 == "cross_0_start") {
|
|
|
|
|
|
- console.log("cp0");
|
|
|
+ }
|
|
|
|
|
|
- if ((x > (3*width/4)) && (y > (3*height/4))) {
|
|
|
- ui_pattern.state = "cross_0_end";
|
|
|
+ else if (ui_pattern.state == "square_3") {
|
|
|
+ if (y < (height/4)) {
|
|
|
+ ui_pattern.state = "square_4";
|
|
|
}
|
|
|
else {
|
|
|
ui_pattern.state = "idle"
|
|
|
@@ -816,25 +884,38 @@ function __ui_pattern_mouseup_depricated(ev) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- else if (ui_pattern.state == "cross_1_start") {
|
|
|
-
|
|
|
- console.log("cp1");
|
|
|
+ else if (ui_pattern.state == "square_4") {
|
|
|
+ if (x > (3*width/4)) {
|
|
|
+ ui_pattern.state = "square_5";
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ ui_pattern.state = "idle"
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ else if (ui_pattern.state == "square_5") {
|
|
|
+ if (y > (3*height/4)) {
|
|
|
+ ui_pattern.state = "square_6";
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ ui_pattern.state = "idle"
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if ((x < (width/4)) && (y > (3*height/4))) {
|
|
|
+ else if (ui_pattern.state == "square_6") {
|
|
|
+ if (x < (width/4)) {
|
|
|
_switch_ui("ui_diagnostic");
|
|
|
}
|
|
|
-
|
|
|
- ui_pattern.state = "idle";
|
|
|
-
|
|
|
- }
|
|
|
- else {
|
|
|
- ui_pattern.state = "idle";
|
|
|
+ ui_pattern.state = "idle"
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+function ui_pattern_mouseup(ev) {
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
//------------
|
|
|
|
|
|
function _mainscreen() {
|
|
|
@@ -958,6 +1039,9 @@ function init() {
|
|
|
|
|
|
document.getElementById('ui_bulk_menu').onclick = function() { _switch_ui("ui_main"); }
|
|
|
|
|
|
+ // Setup "Bulk" UI accept buttons to do proper screen switching and
|
|
|
+ // other tasks.
|
|
|
+ //
|
|
|
var bulk_pass = ["adult", "youth", "half", "event", "transfer", "interline",
|
|
|
"schoola", "schoolb", "schoolc", "orga", "orgb", "orgc"];
|
|
|
var bulk_rule = ["BULK-CASH-ADULT", "BULK-CASH-YOUTH", "BULK-CASH-HALF",
|
|
|
@@ -966,6 +1050,21 @@ function init() {
|
|
|
"BULK-OVR-ORGA", "BULK-OVR-ORGB", "BULK-OVR-ORGC"];
|
|
|
var bulk_pass_name = ["Adult Cash", "Youth Cash", "Half Cash", "Special Event", "Transfer", "Interline",
|
|
|
"School A", "Sschool B", "School C", "Org A", "Org B", "Org C"];
|
|
|
+
|
|
|
+ // use site specific values if available, otherwise default to the above
|
|
|
+ //
|
|
|
+ if ((typeof BULK_PASS !== "undefined") && (BULK_PASS.length > 0)) {
|
|
|
+ bulk_pass = BULK_PASS;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((typeof BULK_RULE !== "undefined") && (BULK_RULE.length > 0)) {
|
|
|
+ bulk_rule= BULK_RULE;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((typeof BULK_PASS_NAME !== "undefined") && (BULK_PASS_NAME.length > 0)) {
|
|
|
+ bulk_pass_name = BULK_PASS_NAME;
|
|
|
+ }
|
|
|
+
|
|
|
for (var i=0; i<bulk_pass.length; i++) {
|
|
|
var p = bulk_pass[i];
|
|
|
var u = bulk_pass_name[i];
|
|
|
@@ -982,7 +1081,6 @@ function init() {
|
|
|
})(r, u);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// bulk accept fares
|
|
|
//
|
|
|
document.getElementById('ui_bulkaccept_ok').onclick = _bulkaccept_ok;
|
|
|
@@ -1094,7 +1192,6 @@ function init() {
|
|
|
block_ele.style.x = rect.x;
|
|
|
block_ele.style.y = rect.y;
|
|
|
|
|
|
-
|
|
|
ele = document.getElementById("ui_main_status");
|
|
|
ele.ondragstart = function() { return false; }
|
|
|
ele.onselectstart = function() { return false; }
|
|
|
@@ -1112,12 +1209,18 @@ function init() {
|
|
|
block_ele.style.x = rect.x;
|
|
|
block_ele.style.y = rect.y;
|
|
|
|
|
|
-
|
|
|
ele = document.getElementById("body");
|
|
|
ele.onmousedown = ui_pattern_mousedown;
|
|
|
ele.onmouseup = ui_pattern_mouseup;
|
|
|
|
|
|
g_snd.button_press = new Audio("assets/459992_florianreichelt_beep_short.mp3");
|
|
|
+ g_snd.accept_fare = new Audio("assets/443026__qubodup__public-domain-beep-sound.mp3");
|
|
|
+ g_snd.reject_fare = new Audio("assets/368780__gurie__start-sound-beep.mp3");
|
|
|
+ g_snd.rule_error = new Audio("assets/363920__samsterbirdies__8-bit-error.mp3");
|
|
|
+
|
|
|
+ if (typeof PopufareSiteInit !== "undefined") {
|
|
|
+ PopufareSiteInit();
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|