keepalive-uncompressed.js
1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
/**
* Keepalive javascript behavior
*
* Used for keeping the session alive
*
* @package Joomla
* @since 3.7.0
*/
!(function(){
'use strict';
document.addEventListener('DOMContentLoaded', function() {
var keepaliveOptions = Joomla.getOptions('system.keepalive'),
keepaliveUri = keepaliveOptions && keepaliveOptions.uri ? keepaliveOptions.uri.replace(/&/g, '&') : '',
keepaliveInterval = keepaliveOptions && keepaliveOptions.interval ? keepaliveOptions.interval : 45 * 1000;
// Fallback in case no keepalive uri was found.
if (keepaliveUri === '')
{
var systemPaths = Joomla.getOptions('system.paths');
keepaliveUri = (systemPaths ? systemPaths.root + '/index.php' : window.location.pathname) + '?option=com_ajax&format=json';
}
window.setInterval(function() {
Joomla.request({
url: keepaliveUri,
onSuccess: function(response, xhr)
{
// Do nothing
},
onError: function(xhr)
{
// Do nothing
}
});
}, keepaliveInterval);
});
})(window, document, Joomla);