dojo.requireLocalization('openils.circ', 'selfcheck');
var localeStrings = dojo.i18n.getLocalization('openils.circ', 'selfcheck');
+
+// set patron timeout default
+var patronTimeout = 180000; /* 3 minutes */
+var timerId = null;
+
var selfCheckMgr;
var itemsOutCirc = [];
var itemsOutMod = [];
var itemsOutCopy = [];
-var TIMEOUT = 60; // logout timer
-
const SET_BARCODE_REGEX = 'opac.barcode_regex';
const SET_PATRON_TIMEOUT = 'circ.selfcheck.patron_login_timeout';
// This setting only comes into play if COPY_NOT_AVAILABLE is in the SET_AUTO_OVERRIDE_EVENTS list
const SET_BLOCK_CHECKOUT_ON_COPY_STATUS = 'circ.selfcheck.block_checkout_on_copy_status';
+// set before the login dialog is rendered
+openils.User.default_login_agent = 'selfcheck';
+
+// start the logout timer
+function selfckStartTimer() {
+ timerId = setTimeout(
+ function() {
+ SelfCheckManager.prototype.logoutPatron();
+ },
+ patronTimeout
+ );
+}
+
+// reset the logout timer
+function selfckResetTimer() {
+ console.log('resetting timer');
+ clearTimeout(timerId);
+ selfckStartTimer();
+}
+
function SelfCheckManager() {
selfCheckMgr = this;
switchTo('step1');
this.initPrinter();
}
-SelfCheckManager.prototype.keepMeLoggedIn = function() {
- //alert(this.timer);
- if(this.timer) try {clearTimeout(this.timer)} catch(e){}
- this.timer = setTimeout('selfCheckMgr.logoutPatron();', TIMEOUT*1000);
-}
/**
* Fetch the org-unit settings, initialize the display, etc.
switchTo('step3','step3c');
openils.Util.hide('oils-selfck-fines-tbody');
openils.Util.show('pay_fines');
- self.keepMeLoggedIn();
self.drawPayFinesPage(
self.patron,
self.getSelectedFinesTotal(),
if(settings[SET_BARCODE_REGEX])
this.patronBarcodeRegex = new RegExp(settings[SET_BARCODE_REGEX].value);
+
+ if(settings[SET_PATRON_TIMEOUT])
+ patronTimeout = parseInt(settings[SET_PATRON_TIMEOUT].value) * 1000;
}
SelfCheckManager.prototype.drawLoginPage = function() {
* Login the patron.
*/
SelfCheckManager.prototype.loginPatron = function(barcode_or_usrname, passwd) {
+
+ // reset timeout
+ selfckResetTimer();
//if(this.orgSettings[SET_PATRON_PASSWORD_REQUIRED]) { // password always reqired, per KCLS - fail safe
if(!passwd) {
* Sets up the checkout/renewal interface
*/
SelfCheckManager.prototype.drawCircPage = function() {
- this.keepMeLoggedIn();
openils.Util.show('oils-selfck-circ-tbody', 'table-row-group');
switchTo('step3');
SelfCheckManager.prototype.drawItemsOutPage = function() {
- this.keepMeLoggedIn();
switchTo('step3','step3d');
// Reset items checked out in case it changed
openils.Util.hide('oils-selfck-holds-page');
openils.Util.hide('oils-selfck-circ-page');
openils.Util.hide('oils-selfck-pay-fines-link');
+
+ // reset timeout
+ selfckResetTimer();
switch(name) {
case 'checkout':
SelfCheckManager.prototype.printList = function(which) {
- this.keepMeLoggedIn();
+ // reset timeout
+ selfckResetTimer();
+
switch(which) {
case 'checkout':
this.printSessionReceipt();
SelfCheckManager.prototype.drawHoldsPage = function(bool) {
- this.keepMeLoggedIn();
if(bool) switchTo('step3','step3f'); else switchTo('step3','step3e');
this.holdTbody = dojo.byId('oils-selfck-hold-tbody');
* Fetch and add a single hold to the list of holds
*/
SelfCheckManager.prototype.drawHolds = function(holds) {
- //this.keepMeLoggedIn();
this.holds = holds;
progressDialog.hide();
SelfCheckManager.prototype.drawFinesPage = function() {
- this.keepMeLoggedIn();
// TODO add option to hid scanBox
// this.updateScanBox(...)
* out to the patron, redirect to renew()
*/
SelfCheckManager.prototype.checkout = function(barcode, override) {
- this.keepMeLoggedIn();
this.prevCirc = null;
if(!barcode) {
function checkLogin() {
- selfCheckMgr.keepMeLoggedIn();
if(selfCheckMgr.orgSettings[SET_PATRON_PASSWORD_REQUIRED]) {
switchTo('step2');
try{dojo.byId('patron-login-password').focus();}catch(e){}