2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/auto_session_timeout_helper.rb', line 2
def auto_session_timeout_js(options={})
frequency = options[:frequency] || 60
code = "if (typeof(Ajax) != 'undefined') {\nnew Ajax.PeriodicalUpdater('', '/active', {frequency:\#{frequency}, method:'get', onSuccess: function(e) {\n if (e.responseText == 'false') window.location.href = '/timeout';\n}});\n} else {\n$.PeriodicalUpdater('/active', {minTimeout:\#{frequency * 1000}, multiplier:0, method:'get', verbose:2}, function(remoteData, success) {\n if (success == 'success' && remoteData == 'false')\n window.location.href = '/timeout';\n});\n}\n"
javascript_tag(code)
end
|