浏览代码

Site specific UI infrastructure

* Added 'diu_ui_site_specific.js' to allow for UI customization
  (that specific file is under CC0 for ease of customer use)
* Added accept/reject sounds
Abram Connelly 6 年之前
父节点
当前提交
f6e0aaa7fd
共有 3 个文件被更改,包括 143 次插入39 次删除
  1. 1 1
      busunit/DIUv2/html/index-ORG.html
  2. 72 38
      busunit/DIUv2/html/js/diu_ui-ORG.js
  3. 70 0
      busunit/DIUv2/html/js/diu_ui_site_specific.js

+ 1 - 1
busunit/DIUv2/html/index-ORG.html

@@ -425,7 +425,6 @@ Diagnostic window...
 
       </div>
 
-      <!-- <div id="mainstatus">Rt 9900   Trip 1   Stop 0   GPS No   Tun Yes   2019-08-13 04:58</div> -->
       <div id="mainstatus"></div>
 
     </div> <!-- ui_main -->
@@ -645,6 +644,7 @@ Diagnostic window...
   </body>
 
   <script src='js/moment.js'></script>
+  <script src='js/diu_ui_site_specific.js'></script>
   <script src='js/diu_ui.js'></script>
 
 </html>

+ 72 - 38
busunit/DIUv2/html/js/diu_ui-ORG.js

@@ -27,13 +27,25 @@ 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" : "",
   "button_press" : ""
 };
 
+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();
@@ -633,6 +645,23 @@ function _main_message_replace(msg, bg_color, text_color) {
 
   g_ctx.status_text = lines.join("\n");
   ele.innerHTML = g_ctx.status_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();
+  }
+
 }
 
 function _main_message_add(msg, bg_color, text_color) {
@@ -656,6 +685,23 @@ function _main_message_add(msg, bg_color, text_color) {
 
   g_ctx.status_text = lines.join("\n");
   ele.innerHTML = g_ctx.status_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();
+  }
+
 }
 
 
@@ -758,34 +804,6 @@ function ui_pattern_mousedown(ev) {
   }
 
   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) {
@@ -805,8 +823,6 @@ function __ui_pattern_mouseup_depricated(ev) {
 
   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";
     }
@@ -818,9 +834,6 @@ function __ui_pattern_mouseup_depricated(ev) {
 
   else if (ui_pattern.state == "cross_1_start") {
 
-    console.log("cp1");
-
-
     if ((x < (width/4)) && (y > (3*height/4))) {
       _switch_ui("ui_diagnostic");
     }
@@ -958,6 +971,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 +982,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 +1013,6 @@ function init() {
     })(r, u);
   }
 
-
   // bulk accept fares
   //
   document.getElementById('ui_bulkaccept_ok').onclick = _bulkaccept_ok;
@@ -1094,7 +1124,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 +1141,17 @@ 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");
+
+  if (typeof PopufareSiteInit !== "undefined") {
+    PopufareSiteInit();
+  }
 
 }
 

+ 70 - 0
busunit/DIUv2/html/js/diu_ui_site_specific.js

@@ -0,0 +1,70 @@
+// Copyright (c) 2019 Clementine Computing LLC.
+//
+// License: CC0
+//
+// To the extent possible under law, the person who associated CC0 with
+// this file has waived all copyright and related or neighboring rights
+// to this file.
+//
+// You should have received a copy of the CC0 legalcode along with this
+// work.  If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
+//
+
+
+// Populate these values with your site specific information
+//
+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",
+                 "BULK-MISC-EVENT", "BULK-MISC-TRANSFER", "BULK-MISC-INTERLINE",
+                 "BULK-OVR-SCHOOLA", "BULK-OVR-SCHOOLB", "BULK-OVR-SCHOOLC",
+                 "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"];
+
+// This function can be used after the Popufare UI has been initialized to do
+// any work that couldn't be done otherwise.
+//
+function PopufareSiteInit(data) {
+  var ele = {};
+
+  var ele = document.getElementById("ui_bulk_schoola");
+  if (ele) { ele.innerHTML = "Uni A"; }
+
+  var ele = document.getElementById("ui_bulk_schoolb");
+  if (ele) { ele.innerHTML = "Uni B"; }
+
+  var ele = document.getElementById("ui_bulk_schoolc");
+  if (ele) { ele.innerHTML = "Uni C"; }
+
+  var ele = document.getElementById("ui_bulk_orga");
+  if (ele) { ele.innerHTML = "Orga A"; }
+
+  var ele = document.getElementById("ui_bulk_orgb");
+  if (ele) { ele.innerHTML = "Orga B"; }
+
+  var ele = document.getElementById("ui_bulk_orgc");
+  if (ele) { ele.innerHTML = "Orga C"; }
+
+  //--
+
+  var ele = document.getElementById("ui_fareoverride_schoola");
+  if (ele) { ele.innerHTML = "Univ A"; }
+
+  var ele = document.getElementById("ui_fareoverride_schoolb");
+  if (ele) { ele.innerHTML = "Univ B"; }
+
+  var ele = document.getElementById("ui_fareoverride_schoolc");
+  if (ele) { ele.innerHTML = "Univ C"; }
+
+  var ele = document.getElementById("ui_fareoverride_orga");
+  if (ele) { ele.innerHTML = "Orgi A"; }
+
+  var ele = document.getElementById("ui_fareoverride_orgb");
+  if (ele) { ele.innerHTML = "Orgi B"; }
+
+  var ele = document.getElementById("ui_fareoverride_orgc");
+  if (ele) { ele.innerHTML = "Orgi C"; }
+
+}
+