JBAS-1132 success page; activity timeout
authorBill Erickson <berickxx@gmail.com>
Mon, 14 Mar 2016 18:46:30 +0000 (14:46 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
On success hide the registration form for privacy and provide link to
docs on what forms of identification will be necessary.

Support inacitivty timeout during registration and for automatic
redirect after successfull registration.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/openils/var/templates_kcls/opac/register.tt2
Open-ILS/web/js/ui/default/opac/register.js

index ce8e746..8123e73 100644 (file)
@@ -6,7 +6,7 @@
 
 # for privacy, reload the page after (default) 5 minutes
 refresh_time = ctx.register.settings.refresh_timeout || 300; 
-ctx.refresh = refresh_time _ '; ' _ ctx.opac_root _ '/home';
+ctx.refresh = refresh_time _ '; ' _ 'https://www.kcls.org';
 
 # some useful variables and MACROs for display, 
 # field validation, and added info display
@@ -115,35 +115,24 @@ END; # input_field()
 
   [% IF ctx.register.success %]
     <h2>[% l('Registration successful!') %]<h3>
-    <h3>[% l('Please see library staff to complete your registration.') %]</h4>
+    <p>
+      To fully activate your card you will need to visit a KCLS library
+      with proof of address and photo ID that shows your date of
+      birth. Parents/guardians can assist with proof of address for full
+      activation for applicants under 18. Find a list of the documents
+      you may use to provide proof of address on our
+      <a href='https://www.kcls.org/usingthelibrary/card/applications/KCLS%20600%20ENG.pdf'>
+        downloadable application.
+      </a>
+    </p>
+    <br/>
     <div>
-      <button onclick="location.href='https://kcls.bibliocms.com/'">
-        Return to KCLS
-      </button>
+      You will be automatically redirected to 
+      <a href="https://www.kcls.org">www.kcls.org</a>...
     </div>
     <hr/>
-  [% END %]
-
-  <!--DO WE NEED THIS?
-  <ul>
-    <li>
-      To fully activate your card you will need to visit a KCLS 
-      library with proof of address and photo ID that shows your 
-      date of birth. Parents/guardians can assist with proof of 
-      address for full activation for applicants under 18. Find a 
-      list of the documents you may use to provide proof of address 
-      on our 
-      <a href="https://www.kcls.org/usingthelibrary/card/applications/KCLS%20600%20ENG.pdf">
-          downloadable application.</a>
-    </li>
-    <li>
-      Want your card right away? Apply in person at any 
-      <a href="https://www.kcls.org/usingthelibrary/locations/">KCLS library.</a>
-      In-person applicants can also choose from more card 
-      designs, while supplies last.
-    </li>
-  </ul>
-  -->
+    <input type='hidden' id='register-success' value='yep'/>
+  [% ELSE %]
 
   <form method='POST' onsubmit="return onsub()">
     <ul>
@@ -454,6 +443,7 @@ END; # input_field()
       </li>
     </ul>
   </form>
+  [% END # IF ctx.success %]
   </div>
 </div>
 
index 3f52174..6dd4e0f 100644 (file)
@@ -15,10 +15,14 @@ var required_fields = [
     'stgba.post_code',
 ];
 
-var copy_addr_fields = ['street1','street2','city','state','post_code'];
+var last_activity = new Date();
+var activity_timeout = 30000;  // 30 seconds
+var post_success_timeout = 15000; // 15 seconds
+var timeout_redirect = 'https://www.kcls.org';
 
 /* show/hide card options depending on the selected type. */
 function show_card_types(type) {
+    last_activity = new Date();
     var wal = document.getElementById('wallet-cards');
     var key = document.getElementById('keychain-cards');
     if (type == 'wallet') {
@@ -52,6 +56,7 @@ function show_hide_mailing(hide) {
 }
 
 function validate(dom_id) {
+    last_activity = new Date();
     var element = document.getElementById(dom_id);
     var value = element ? element.value : '';
     var valid = true;
@@ -207,4 +212,26 @@ function onsub() {
     return true;
 }
 
+function activity_checker_thread() {
+    var start = last_activity.getTime();
+    var end = new Date().getTime();
+    var diff = end - start;
+
+    var timeout = 
+      document.getElementById('register-success') ?
+      post_success_timeout : activity_timeout;
+
+    console.debug('checking activity timeout=' + 
+      timeout + ' : time range (ms) = ' + diff);
+
+    if (diff > timeout) {
+        location.href = timeout_redirect;
+        return;
+    }
+
+    setTimeout(activity_checker_thread, 2000);
+}
+
+
+activity_checker_thread();