2 var timeout = undefined;
4 var lock_interval = undefined;
6 function start_activity_tracking(){
7 timeout = setTimeout(timed_out,30000)
15 called whenever activity is detected. This function will prevent
16 the time_out function from being called
18 if (timeout!=undefined) {
19 clearTimeout(timeout);
21 timeout = setTimeout(timed_out,180000)
26 called when the owner of the lock times out
28 clearTimeout(lock_interval);
30 .unbind('mousemove',activity)
31 .unbind('keypress',activity)
32 .mousemove(reacquire_lock)
33 .keypress(reacquire_lock);
34 $errors.empty().append('<li>Your lock has timed out due to inactivity. If you become active again it will automatically be reacquired if the page is not in use by another user.</li>')
40 function reacquire_lock() {
42 called when a timed out user tries to reacquire the lock
47 .unbind('mousemove',reacquire_lock)
48 .unbind('keypress',reacquire_lock);
53 function acquire_lock() {
55 called by users wishing to obtain the lock. The result of this method
58 $.get('{{ROOT}}/plugin/lock/acquire', {}, process_lock);
61 function refresh_lock() {
63 called by owner of lock to maintain possession
65 $.get('{{ROOT}}/plugin/lock/refresh', {}, process_lock);
68 function process_lock(data){
70 processes response about lock possession
75 // only hide on lock acquire, otherwise you could hide an important error
76 start_activity_tracking()
80 lock_interval = setTimeout(refresh_lock, 10000);
82 $errors.empty().append('<li>You do not hold the lock. You cannot edit configuration until $USER is finished.<br/> Page will unlock when lock is acquired.</li>')
85 setTimeout(acquire_lock, 10000);