1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Remove poll_js and inline JS script, fixes #3133

This commit is contained in:
Mike Perham 2016-09-12 14:30:55 -07:00
parent 1c05404e82
commit 0c098787b0
5 changed files with 15 additions and 8 deletions

View file

@ -55,6 +55,14 @@ module Sidekiq
@head_html.join if defined?(@head_html)
end
def poll_path
if current_path != '' && params['poll']
root_path + current_path
else
""
end
end
# Given a browser request Accept-Language header like
# "fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4,ru;q=0.2", this function
# will return "fr" since that's the first code with a matching

View file

@ -305,7 +305,7 @@ class TestWeb < Sidekiq::Test
it 'calls updatePage() once when polling' do
get '/busy?poll=true'
assert_equal 200, last_response.status
assert_equal 1, last_response.body.scan('updatePage(').count
assert_equal 1, last_response.body.scan('data-poll-path="/busy').count
end
it 'escape job args and error messages' do

View file

@ -34,6 +34,11 @@ $(function() {
$.timeago.settings.refreshMillis = 0;
$("time").timeago();
var pollpath = $('body').data('poll-path');
if (pollpath != "") {
updatePage(pollpath);
}
$(document).on('click', '.check_all', function() {
var checked = $(this).attr('checked');
if (checked == 'checked') {

View file

@ -1,5 +0,0 @@
<% if current_path != '' && params[:poll] %>
<script>
updatePage('<%= root_path + current_path %>')
</script>
<% end %>

View file

@ -12,7 +12,7 @@
<meta name="google" content="notranslate" />
<%= display_custom_head %>
</head>
<body class="admin">
<body class="admin" data-poll-path="<%= poll_path %>">
<%= erb :_nav %>
<div id="page">
<div class="container">
@ -28,6 +28,5 @@
</div>
</div>
<%= erb :_footer %>
<%= erb :_poll_js %>
</body>
</html>