mirror of
https://github.com/Codiad/Codiad.git
synced 2026-03-18 15:06:50 +01:00
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
/*
|
|
* Copyright (c) Codiad & Kent Safranski (codiad.com), distributed
|
|
* as-is and without warranty under the MIT License. See
|
|
* [root]/license.txt for more. This information must remain intact.
|
|
*/
|
|
|
|
$(function(){ poller.init(); });
|
|
|
|
var poller = {
|
|
|
|
controller : 'components/poller/controller.php',
|
|
interval : 120000,
|
|
|
|
init : function(){
|
|
|
|
poller.check_auth();
|
|
|
|
},
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
// Poll authentication
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
check_auth : function(){
|
|
|
|
setInterval(function(){
|
|
|
|
// Run controller to check session (also acts as keep-alive)
|
|
$.get(poller.controller+'?action=check_auth',function(data){
|
|
|
|
if(data){
|
|
parsed = jsend.parse(data);
|
|
if(parsed!='error'){
|
|
// Session not set, reload
|
|
window.location.reload();
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
},poller.interval);
|
|
|
|
}
|
|
|
|
}; |