mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
3ee8f505b7
The main benefit of this is so that authors who make use of .editorconfig don't end up with whitespace changes in their PRs. Spaces vs. tabs has been left alone, although that could do with a tidy-up in SS4 after the switch to PSR-1/2. The command used was this: for match in '*.ss' '*.css' '*.scss' '*.html' '*.yml' '*.php' '*.js' '*.csv' '*.inc' '*.php5'; do find . -path ./thirdparty -not -prune -o -path ./admin/thirdparty -not -prune -o -type f -name "$match" -exec sed -E -i '' 's/[[:space:]]+$//' {} \+ find . -path ./thirdparty -not -prune -o -path ./admin/thirdparty -not -prune -o -type f -name "$match" | xargs perl -pi -e 's/ +$//' done
51 lines
1.4 KiB
JavaScript
51 lines
1.4 KiB
JavaScript
/**
|
|
* File: LeftAndMain.Ping.js
|
|
*/
|
|
(function($) {
|
|
$.entwine('ss.ping', function($){
|
|
|
|
$('.cms-container').entwine(/** @lends ss.Form_EditForm */{
|
|
/**
|
|
* Variable: PingIntervalSeconds
|
|
* (Number) Interval in which /Security/ping will be checked for a valid login session.
|
|
*/
|
|
PingIntervalSeconds: 5*60,
|
|
|
|
onadd: function() {
|
|
this._setupPinging();
|
|
this._super();
|
|
},
|
|
|
|
/**
|
|
* Function: _setupPinging
|
|
*
|
|
* This function is called by prototype when it receives notification that the user was logged out.
|
|
* It uses /Security/ping for this purpose, which should return '1' if a valid user session exists.
|
|
* It redirects back to the login form if the URL is either unreachable, or returns '0'.
|
|
*/
|
|
_setupPinging: function() {
|
|
var onSessionLost = function(xmlhttp, status) {
|
|
if(xmlhttp.status > 400 || xmlhttp.responseText == 0) {
|
|
// TODO will pile up additional alerts when left unattended
|
|
if(window.open('Security/login')) {
|
|
alert('Please log in and then try again');
|
|
} else {
|
|
alert('Please enable pop-ups for this site');
|
|
}
|
|
}
|
|
};
|
|
|
|
// setup pinging for login expiry
|
|
setInterval(function() {
|
|
$.ajax({
|
|
url: 'Security/ping',
|
|
global: false,
|
|
type: 'POST',
|
|
complete: onSessionLost
|
|
});
|
|
}, this.getPingIntervalSeconds() * 1000);
|
|
}
|
|
});
|
|
});
|
|
}(jQuery));
|