anchor.diff:      });
   
       /// end auto reload
  +
  +    //attach event handler to all tinymce editors
  +    tinyMCE.on('AddEditor', function(e) {
  +      e.editor.on('blur', function (e) {
  +        ed = e.target;
  +        if (ed.id.includes("comments")){
  +          json_review = JSON.stringify({ "review": ed.getContent({format : 'text'}) })
  +
  +          $.ajax({
  +            url: "http://localhost:3008/visualize_sentiment",
  +            type: "POST",
  +            crossDomain: true,
  +            contentType: "application/json",
  +            data: json_review,
  +            dataType: "html",
  +            success: function (response) {
  +              var toneAnalysisResult = '<div class="panel panel-default">' +
  +                                          '<div class="panel-heading">Tone analysis</div>' +
  +                                          '<div class="panel-body">' + response + '</div>' +
  +                                        '</div>'
  +              if(ed.id.includes("responses"))
  +                  $('#' + ed.id.replace("responses", "analysis")).html(toneAnalysisResult);
  +              else if(ed.id.includes('review_comments'))
  +                  $('#review_comments_analysis').html(toneAnalysisResult);
  +            },
  +            error: function (xhr, status) {
  +              alert("error");
  +            }
  +          });
  +        }
  +      });
  +    });
  +
     });
  +
   </script>
   
   
  -<!--including tinymce javascript-->
  -<%= tinymce_assets %>
  +
   <% if @map.survey? %>
       <h1><%= @header %> <%= @title %> for <%= @map.survey_parent.name %></h1>
   <% else %>
  
positive.code: <!-- <script type="text/javascript" src="/assets/response.js" ></script> -->
  <script>
    // todo: to be moved to assets, once it's fixed so that not every script is loaded in every page.
    //detect if the window is in foreground or background
  
negative.code:     <% if @next_action.eql?'update' %>
          <input name="_method" type="hidden" value="put" />
      <%end%>
      <table>
      <% i = 0 %>
      <%@questions.each do |question| %>
          <tr>
            <td>
             <% answer = Answer.where(question_id: question.id, response_id: @response.id).first if !@response.nil?%>
             <% if question.instance_of? Criterion%>
                  <%= question.complete(i, answer, @questionnaire.min_question_score, @questionnaire.max_question_score, @dropdown_or_scale) %>
             <% elsif question.instance_of? Scale %>
                  <%= question.complete(i, answer, @questionnaire.min_question_score, @questionnaire.max_question_score) %>
             <% else %>
                  <%= question.complete(i, answer) %>
             <% end %>
            </td>
            <td width="25%">
              <% if [Criterion, TextArea].include? question.class %>
                  <div id="analysis_<%= i.to_s %>_comments"></div>
              <% end %>
            </td>
          </tr>
          <% i += 1%>
      <% end %>
        <tr>
          <td>
            <label for="review_comments">Additional Comments</label><BR/>
            <textarea cols="70" rows="1" id="review_comments" name="review[comments]" style="overflow:hidden;" class="tinymce">
              <% if controller.action_name != 'new' and @response.additional_comment != nil %>
                  <%= @response.additional_comment.strip if !@response.nil?%>
              <% end %>
            </textarea>
          </td>
          <td width="25%">
            <div id="review_comments_analysis"></div>
          </td>
        </tr>
      </table>
      <%if @current_round%>
        <%= hidden_field_tag "review[round]", @current_round %>
      <%end%>
  