From 67578498c5de67fe2e821a3d91c1d2b7294df579 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Mon, 9 Jun 2014 16:57:50 -0400 Subject: [PATCH] 2961: Escaped erb used embedded in javascript. Updated comments in event_log.js. Removed debug put from ApplicationController. --- apps/workbench/app/assets/javascripts/event_log.js | 14 ++++++++------ .../app/controllers/application_controller.rb | 1 - .../app/views/application/_content.html.erb | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/apps/workbench/app/assets/javascripts/event_log.js b/apps/workbench/app/assets/javascripts/event_log.js index 0539021d83..8bfa1b0672 100644 --- a/apps/workbench/app/assets/javascripts/event_log.js +++ b/apps/workbench/app/assets/javascripts/event_log.js @@ -2,8 +2,7 @@ * This js establishes a websockets connection with the API Server. */ -/* The subscribe method takes a window element id and object id. - Any log events for that particular object id are sent to that window element. */ +/* Subscribe to websockets event log. Do nothing if already connected. */ function subscribeToEventLog () { // if websockets are not supported by browser, do not subscribe for events websocketsSupported = ('WebSocket' in window); @@ -11,10 +10,10 @@ function subscribeToEventLog () { return; } - // grab websocket connection from window, if one exists + // check if websocket connection is already stored on the window event_log_disp = $(window).data("arv-websocket"); if (event_log_disp == null) { - // create the event log dispatcher + // need to create new websocket and event log dispatcher websocket_url = $('meta[name=arv-websocket-url]').attr("content"); if (websocket_url == null) return; @@ -29,12 +28,13 @@ function subscribeToEventLog () { } } -/* send subscribe message to the websockets server */ +/* Send subscribe message to the websockets server. Without any filters + arguments, this subscribes to all events */ function onEventLogDispatcherOpen(event) { this.send('{"method":"subscribe"}'); } -/* trigger event for all applicable elements waiting for this event */ +/* Trigger event for all applicable elements waiting for this event */ function onEventLogDispatcherMessage(event) { parsedData = JSON.parse(event.data); object_uuid = parsedData.object_uuid; @@ -44,6 +44,8 @@ function onEventLogDispatcherMessage(event) { $(matches).trigger('arv-log-event', event.data); } +/* Automatically connect if there are any elements on the page that want to + received event log events. */ $(document).on('ajax:complete ready', function() { var a = $('.arv-log-event-listener'); if (a.length > 0) { diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb index 78884a020e..b77ce8d148 100644 --- a/apps/workbench/app/controllers/application_controller.rb +++ b/apps/workbench/app/controllers/application_controller.rb @@ -105,7 +105,6 @@ class ApplicationController < ActionController::Base return render_not_found("object not found") end respond_to do |f| - puts f f.json { render json: @object.attributes.merge(href: url_for(@object)) } f.html { if params['tab_pane'] diff --git a/apps/workbench/app/views/application/_content.html.erb b/apps/workbench/app/views/application/_content.html.erb index 494a3ab8ae..3b3ac6aa85 100644 --- a/apps/workbench/app/views/application/_content.html.erb +++ b/apps/workbench/app/views/application/_content.html.erb @@ -1,6 +1,6 @@ <% content_for :js do %> function ajaxRefreshTabPane(pane) { - $.ajax('<%= url_for @object %>?tab_pane='+pane, {dataType: 'html', type: 'GET'}). + $.ajax('<%=j url_for @object %>?tab_pane='+pane, {dataType: 'html', type: 'GET'}). done(function(data, status, jqxhr) { $('#' + pane + ' > div > div').html(data); $(document).trigger('ajax:complete') @@ -42,7 +42,7 @@ <% content_for :js do %> <% if i != 0 %> $(document).on('ready', function() { - ajaxRefreshTabPane('<%= pane %>'); + ajaxRefreshTabPane('<%=j pane %>'); }); <% end %> <% end %> -- 2.30.2