|
@@ -83,7 +83,18 @@ var g_ctx = {
|
|
|
|
|
|
|
|
"status_html_text":"",
|
|
"status_html_text":"",
|
|
|
|
|
|
|
|
- "diu_status" : {},
|
|
|
|
|
|
|
+ "diu_status" : {
|
|
|
|
|
+ "last_update" : -1
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // system config
|
|
|
|
|
+ //
|
|
|
|
|
+ "config" : {
|
|
|
|
|
+ "last_update": -1,
|
|
|
|
|
+ "volume": 100,
|
|
|
|
|
+ "brightness": 100,
|
|
|
|
|
+ "showdimclock": 0
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
"x": ""
|
|
"x": ""
|
|
|
};
|
|
};
|
|
@@ -143,8 +154,6 @@ function _api_request(action, param, cb_ok, cb_fail, cb_neterr) {
|
|
|
|
|
|
|
|
req.addEventListener("error", _api_fail);
|
|
req.addEventListener("error", _api_fail);
|
|
|
req.addEventListener("abort", _api_fail);
|
|
req.addEventListener("abort", _api_fail);
|
|
|
- //req.addEventListener("load", _api_tick);
|
|
|
|
|
- //req.addEventListener("progress", _api_tick);
|
|
|
|
|
|
|
|
|
|
req.onerror = function() { console.log("network error"); };
|
|
req.onerror = function() { console.log("network error"); };
|
|
|
|
|
|
|
@@ -342,9 +351,23 @@ function _update_login_date() {
|
|
|
|
|
|
|
|
//------------
|
|
//------------
|
|
|
|
|
|
|
|
|
|
+function _update_dimclock_datetime() {
|
|
|
|
|
+ var ele = document.getElementById("ui_dimclock_clock");
|
|
|
|
|
+ if (typeof ele === "undefined") { return; }
|
|
|
|
|
+ var _time_str = _get_now_HH_MM();
|
|
|
|
|
+ ele.innerHTML = "<span style='white-space:nowrap;'>" + _time_str + "</span>";
|
|
|
|
|
+
|
|
|
|
|
+ var ele = document.getElementById("ui_dimclock_date");
|
|
|
|
|
+ if (typeof ele === "undefined") { return; }
|
|
|
|
|
+ var _date_str = _get_now_YYYY_MM_DD();
|
|
|
|
|
+ ele.innerHTML = "<span style='white-space:nowrap;'>" + _date_str + "</span>";
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+//------------
|
|
|
|
|
+
|
|
|
// value is from [0,1]
|
|
// value is from [0,1]
|
|
|
//
|
|
//
|
|
|
-function _process_brightness(brightness) {
|
|
|
|
|
|
|
+function _process_brightness(brightness, update_system) {
|
|
|
|
|
|
|
|
// 0 opacity is completely clear, so (1.0) brightness (100% brightness).
|
|
// 0 opacity is completely clear, so (1.0) brightness (100% brightness).
|
|
|
//
|
|
//
|
|
@@ -361,29 +384,55 @@ function _process_brightness(brightness) {
|
|
|
ele = document.getElementById("ui_configuration_displaybrightness");
|
|
ele = document.getElementById("ui_configuration_displaybrightness");
|
|
|
ival = Math.floor(f_brightness*100.0);
|
|
ival = Math.floor(f_brightness*100.0);
|
|
|
ele.innerHTML = "" + ival + "%";
|
|
ele.innerHTML = "" + ival + "%";
|
|
|
|
|
+
|
|
|
|
|
+ g_ctx.config.brightness = ival;
|
|
|
|
|
+
|
|
|
|
|
+ if (update_system) { _set_system_config(); }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//------------
|
|
//------------
|
|
|
|
|
|
|
|
// volume is from [0,1]
|
|
// volume is from [0,1]
|
|
|
//
|
|
//
|
|
|
-function _process_volume(vol) {
|
|
|
|
|
|
|
+function _process_volume(vol, update_system) {
|
|
|
var ele = document.getElementById("ui_configuration_displayvolume");
|
|
var ele = document.getElementById("ui_configuration_displayvolume");
|
|
|
ivol = Math.floor(vol*100.0);
|
|
ivol = Math.floor(vol*100.0);
|
|
|
|
|
+
|
|
|
|
|
+ if (ivol < 0) { ivol = 0; }
|
|
|
|
|
+ if (ivol > 100) { ivol = 100; }
|
|
|
|
|
+
|
|
|
ele.innerHTML = "" + ivol + "%";
|
|
ele.innerHTML = "" + ivol + "%";
|
|
|
|
|
+
|
|
|
|
|
+ g_ctx.config.volume = ivol;
|
|
|
|
|
+
|
|
|
|
|
+ if (update_system) { _set_system_config(); }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+var _rate_limit_beep_t = -1.0;
|
|
|
|
|
+var _rate_limit_beep_dt = 250;
|
|
|
|
|
+function _rate_limit_beep() {
|
|
|
|
|
+ if (_rate_limit_beep_t<0) {
|
|
|
|
|
+ _rate_limit_beep_t = Date.now();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (Date.now() > (_rate_limit_beep_t + _rate_limit_beep_dt)) {
|
|
|
|
|
+ _rate_limit_beep_t = Date.now();
|
|
|
|
|
+ _beep();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function _slider_change(name) {
|
|
function _slider_change(name) {
|
|
|
if (name == "configuration.volume") {
|
|
if (name == "configuration.volume") {
|
|
|
var val = document.getElementById("ui_configuration_volume").value;
|
|
var val = document.getElementById("ui_configuration_volume").value;
|
|
|
- _process_volume(val);
|
|
|
|
|
|
|
+ _process_volume(val, true);
|
|
|
|
|
|
|
|
ivol = Math.floor(val*100.0);
|
|
ivol = Math.floor(val*100.0);
|
|
|
_api_request("custom", {"function":"volume", "parameter":ivol});
|
|
_api_request("custom", {"function":"volume", "parameter":ivol});
|
|
|
|
|
+
|
|
|
|
|
+ _rate_limit_beep();
|
|
|
}
|
|
}
|
|
|
else if (name == "configuration.brightness") {
|
|
else if (name == "configuration.brightness") {
|
|
|
var val = document.getElementById("ui_configuration_brightness").value;
|
|
var val = document.getElementById("ui_configuration_brightness").value;
|
|
|
- _process_brightness(val);
|
|
|
|
|
|
|
+ _process_brightness(val, true);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -391,6 +440,30 @@ function _volume_test() {
|
|
|
_api_request("custom", {"function":"say", "parameter":"testing 1, 2, 3"});
|
|
_api_request("custom", {"function":"say", "parameter":"testing 1, 2, 3"});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function _btn_show_clock_on_dim_toggle() {
|
|
|
|
|
+ if (g_ctx.config.showdimclock == 0) {
|
|
|
|
|
+ g_ctx.config.showdimclock = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ g_ctx.config.showdimclock = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ _process_showdimclock(g_ctx.config.showdimclock, true);
|
|
|
|
|
+
|
|
|
|
|
+ _beep();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function _process_showdimclock(val, update_system) {
|
|
|
|
|
+ var ele = document.getElementById("ui_configuration_showclockondim");
|
|
|
|
|
+
|
|
|
|
|
+ if (val == 1) { ele.innerHTML = 'X'; }
|
|
|
|
|
+ else { ele.innerHTML = ''; }
|
|
|
|
|
+
|
|
|
|
|
+ if (update_system) {
|
|
|
|
|
+ _set_system_config();
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
//------------
|
|
//------------
|
|
|
|
|
|
|
|
function _clear_ui_driver() {
|
|
function _clear_ui_driver() {
|
|
@@ -653,9 +726,14 @@ function _main_nxt() {
|
|
|
|
|
|
|
|
function _main_dim() {
|
|
function _main_dim() {
|
|
|
console.log("dim...");
|
|
console.log("dim...");
|
|
|
- //_api_request("dim");
|
|
|
|
|
- _api_request("custom", {"function":"dim"});
|
|
|
|
|
- _switch_ui('ui_dim');
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (g_ctx.config.showdimclock) {
|
|
|
|
|
+ _switch_ui("ui_dimclock");
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ _api_request("custom", {"function":"dim"});
|
|
|
|
|
+ _switch_ui('ui_dim');
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function _dim_wakeup() {
|
|
function _dim_wakeup() {
|
|
@@ -664,6 +742,15 @@ function _dim_wakeup() {
|
|
|
_switch_ui("ui_main");
|
|
_switch_ui("ui_main");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function _dim_soft_wakeup() {
|
|
|
|
|
+ console.log("waking up from soft dim");
|
|
|
|
|
+ _switch_ui("ui_main");
|
|
|
|
|
+
|
|
|
|
|
+ // just in case
|
|
|
|
|
+ //
|
|
|
|
|
+ _api_request("custom", {"function": "undim" });
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function _fare_adult() {
|
|
function _fare_adult() {
|
|
|
console.log("fare adult");
|
|
console.log("fare adult");
|
|
|
_api_request("fare", {"rule":"CASH-ADULT", "param":"", "fare":"adult","count":1});
|
|
_api_request("fare", {"rule":"CASH-ADULT", "param":"", "fare":"adult","count":1});
|
|
@@ -806,6 +893,8 @@ function _cb_status(inp) {
|
|
|
if (valtok[0]!="msg=status") { return; }
|
|
if (valtok[0]!="msg=status") { return; }
|
|
|
|
|
|
|
|
g_ctx.diu_status = {};
|
|
g_ctx.diu_status = {};
|
|
|
|
|
+ g_ctx.diu_status.last_update = Date.now();
|
|
|
|
|
+
|
|
|
var fields = valtok[1].split("|");
|
|
var fields = valtok[1].split("|");
|
|
|
for (var ii=0; ii<fields.length; ii++) {
|
|
for (var ii=0; ii<fields.length; ii++) {
|
|
|
var kv = fields[ii].split("=");
|
|
var kv = fields[ii].split("=");
|
|
@@ -817,6 +906,10 @@ function _cb_status(inp) {
|
|
|
g_ctx.cur_eqnum = g_ctx.diu_status["equipno"];
|
|
g_ctx.cur_eqnum = g_ctx.diu_status["equipno"];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (g_ctx.config.last_update < 0) {
|
|
|
|
|
+ _get_system_config();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
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") {
|
|
|
|
|
|
|
@@ -1030,6 +1123,44 @@ function _main_message_add(msg, bg_color, text_color) {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//-------------
|
|
|
|
|
+
|
|
|
|
|
+// The status message has the config lines, if present,
|
|
|
|
|
+// so parse them into the 'config' sub-object.
|
|
|
|
|
+// This should be called after we feel confident the status
|
|
|
|
|
+// has been updated with the most current config.
|
|
|
|
|
+//
|
|
|
|
|
+function _get_system_config() {
|
|
|
|
|
+ var m = g_ctx.diu_status;
|
|
|
|
|
+ if (typeof m === 'undefined') { return; }
|
|
|
|
|
+
|
|
|
|
|
+ g_ctx.config.last_update = Date.now();
|
|
|
|
|
+
|
|
|
|
|
+ if ("brightness" in m) { g_ctx.config.brightness = m["brightness"]; }
|
|
|
|
|
+ if ("volume" in m) { g_ctx.config.volume = m["volume"]; }
|
|
|
|
|
+ if ("showdimclock" in m) { g_ctx.config.showdimclock = m["showdimclock"]; }
|
|
|
|
|
+
|
|
|
|
|
+ _process_volume(g_ctx.config.volume/100.0);
|
|
|
|
|
+ _process_brightness(g_ctx.config.brightness/100.0);
|
|
|
|
|
+ _process_showdimclock(g_ctx.config.showdimclock);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+//---
|
|
|
|
|
+
|
|
|
|
|
+function _set_system_config_ok(dat) { }
|
|
|
|
|
+function _set_system_config_fail(dat) { }
|
|
|
|
|
+function _set_system_config() {
|
|
|
|
|
+ var dat = {
|
|
|
|
|
+ "function" : "setconfig",
|
|
|
|
|
+ "parameter" : "volume " + g_ctx.config.volume + "," +
|
|
|
|
|
+ "brightness " + g_ctx.config.brightness + "," +
|
|
|
|
|
+ "showdimclock " + g_ctx.config.showdimclock
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ console.log(">>", dat);
|
|
|
|
|
+
|
|
|
|
|
+ _api_request("custom", dat, _set_system_config_ok, _set_system_config_fail);
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
//-------------
|
|
//-------------
|
|
|
//-------------
|
|
//-------------
|
|
@@ -1337,6 +1468,7 @@ function init() {
|
|
|
window.setInterval(_update_display_time, 200);
|
|
window.setInterval(_update_display_time, 200);
|
|
|
window.setInterval(_update_login_time, 200);
|
|
window.setInterval(_update_login_time, 200);
|
|
|
window.setInterval(_update_login_date, 200);
|
|
window.setInterval(_update_login_date, 200);
|
|
|
|
|
+ window.setInterval(_update_dimclock_datetime, 200);
|
|
|
|
|
|
|
|
// watchdog
|
|
// watchdog
|
|
|
//
|
|
//
|
|
@@ -1360,7 +1492,7 @@ function init() {
|
|
|
//
|
|
//
|
|
|
//document.getElementById('ui_configuration_back').onclick = _mainscreen;
|
|
//document.getElementById('ui_configuration_back').onclick = _mainscreen;
|
|
|
document.getElementById('ui_configuration_back').onclick = _configuration_back;
|
|
document.getElementById('ui_configuration_back').onclick = _configuration_back;
|
|
|
- document.getElementById('ui_configuration_volumetest').onclick = _volume_test;
|
|
|
|
|
|
|
+ //document.getElementById('ui_configuration_volumetest').onclick = _volume_test;
|
|
|
document.getElementById('ui_configuration_eqnum').onclick = _eqnum;
|
|
document.getElementById('ui_configuration_eqnum').onclick = _eqnum;
|
|
|
|
|
|
|
|
// equipment number change
|
|
// equipment number change
|
|
@@ -1390,6 +1522,8 @@ function init() {
|
|
|
//
|
|
//
|
|
|
document.getElementById('ui_dim_btn').onclick = _dim_wakeup;
|
|
document.getElementById('ui_dim_btn').onclick = _dim_wakeup;
|
|
|
|
|
|
|
|
|
|
+ document.getElementById('ui_dimclock_btn').onclick = _dim_soft_wakeup;
|
|
|
|
|
+
|
|
|
var simple_fares = [ "adult", "youth", "half", "bike", "wheelchair", "transfer"];
|
|
var simple_fares = [ "adult", "youth", "half", "bike", "wheelchair", "transfer"];
|
|
|
var simple_fares_f = [ _fare_adult, _fare_youth, _fare_half, _fare_bike, _fare_wheelchair, _fare_transfer];
|
|
var simple_fares_f = [ _fare_adult, _fare_youth, _fare_half, _fare_bike, _fare_wheelchair, _fare_transfer];
|
|
|
for (var ii=0; ii<simple_fares.length; ii++) {
|
|
for (var ii=0; ii<simple_fares.length; ii++) {
|