View | Details | Raw Unified | Return to bug 36586
Collapse All | Expand All

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sci/sci-main.tt (-6 / +19 lines)
Lines 254-259 Link Here
254
            $("#sci_barcodes_table").show();
254
            $("#sci_barcodes_table").show();
255
            $('#sci_checkin_button').show();
255
            $('#sci_checkin_button').show();
256
            $('#sci_refresh_button').show();
256
            $('#sci_refresh_button').show();
257
            login_timeout();
257
258
258
            // Add barcode to the array
259
            // Add barcode to the array
259
            barcodes.push(barcode);
260
            barcodes.push(barcode);
Lines 273-284 Link Here
273
    dofocus();
274
    dofocus();
274
});
275
});
275
276
276
277
    document.addEventListener("DOMContentLoaded",function(){
277
        let idleTimeout = [% Koha.Preference('SelfCheckInTimeOut') || 120 %];
278
        if ( document.querySelector('#sci_finish_button') ){
278
        let refresh_button = $("#sci_refresh_button");
279
            login_timeout();
279
        let finish_button = $("#sci_finish_button");
280
        }
280
        let home_href = "/cgi-bin/koha/sci/sci-main.pl";
281
    });
281
282
    function login_timeout(){
283
        //NOTE: There can only be 1 sci_login_timer at a time
284
        if ( ! window.sci_login_timer ){
285
            const idleTimeout = "[% Koha.Preference('SelfCheckInTimeOut') || 120 | html %]";
286
            const home_href = "/cgi-bin/koha/sci/sci-main.pl";
287
            const sci_timer = new sc_timer({
288
                "idle_timeout": idleTimeout,
289
                "redirect_url": home_href
290
            });
291
            window.sci_login_timer = sci_timer;
292
            sci_timer.start_timer();
293
        }
294
    }
282
295
283
        function checkBarcodeInput() {
296
        function checkBarcodeInput() {
284
            var inputField = document.getElementById("barcode_input");
297
            var inputField = document.getElementById("barcode_input");
(-)a/koha-tmpl/opac-tmpl/bootstrap/js/timeout.js (-18 / +34 lines)
Lines 1-22 Link Here
1
var idleTime = 0;
1
class sc_timer {
2
$(document).ready(function () {
2
    constructor(args) {
3
    //Increment the idle time counter every second
3
        const idle_timeout  = args['idle_timeout'];
4
    var idleInterval = setInterval(timerIncrement, 1000);
4
        const redirect_url  = args['redirect_url'];
5
        if (idle_timeout) {
6
            this.idle_timeout = idle_timeout;
7
        }
8
        if (redirect_url) {
9
            this.redirect_url = redirect_url;
10
        }
11
        this.idle_time = 0;
12
    }
5
13
6
    //Zero the idle timer on mouse movement.
14
    start_timer() {
7
    $(this).mousemove(function (e) {
15
        const self = this;
8
        idleTime = 0;
16
        //Increment the idle time counter every 1 second
9
    });
17
        const idle_interval = setInterval(function(){self._timer_increment()},1000);
10
    $(this).keypress(function (e) {
11
        idleTime = 0;
12
    });
13
});
14
18
15
function timerIncrement() {
19
        document.addEventListener("mousemove",function(){
16
    if ( finish_button.is(":visible") || refresh_button.is(":visible") ) {
20
            self.reset_timer();
17
        idleTime = idleTime + 1;
21
        });
18
        if (idleTime >= idleTimeout ) {
22
        document.addEventListener("keypress",function(){
19
            location.href = home_href;
23
            self.reset_timer();
24
        });
25
26
    }
27
28
    reset_timer() {
29
        this.idle_time = 0;
30
    }
31
32
    _timer_increment() {
33
        this.idle_time++;
34
        if (this.idle_time >= this.idle_timeout){
35
            location.href = this.redirect_url;
20
        }
36
        }
21
    }
37
    }
38
22
}
39
}
23
- 

Return to bug 36586