<commit_before><script>
  var tour = new Shepherd.Tour(<%= Rails.configuration.abraham.tour_options.html_safe unless Rails.configuration.abraham.tour_options.nil? %>);

  tour.on("complete", function() {
    // ajax
    return $.ajax({
      url: "/abraham_histories/",
      type: "POST",
      dataType: "json",
      contentType: "application/json",
      data: JSON.stringify({
        authenticity_token: '<%= form_authenticity_token %>',
        controller_name: '<%= controller_name %>',
        action_name: '<%= action_name %>',
        tour_name: '<%= tour_name %>'
      })
    });
  });

  tour.on("cancel", function() {
    Cookies.set('<%= abraham_cookie_prefix %>-<%= tour_name %>', 'later', { domain: '<%= abraham_domain %>' });
  });

  <% steps.each_with_index do |(key, step), index| %>
  tour.addStep({
    id: 'step-<%= key %>',
    <% if step.key?('title') %>
    title: "<%= step['title'] %>",
    <% end %>
    text: "<%= step['text'] %>",
    <% if step.key?('attachTo') %>
    attachTo: { element: "<%= step['attachTo']['element'] %>", on: "<%= step['attachTo']['placement'] %>" },
    showOn: function() {
      // Only display this step if its selector is present
      return document.querySelector("<%= step['attachTo']['element'] %>") ? true : false
    },
    <% end %>
    buttons: [
    <% if index == 0 %>
      { text: '<%= t('abraham.later') %>', action: tour.cancel, classes: 'shepherd-button-secondary' },
      { text: '<%= t('abraham.continue') %>', action: tour.next }
    <% else %>
        <% if index == steps.size - 1 %>
      { text: '<%= t('abraham.done') %>', action: tour.complete }
        <% else %>
      { text: '<%= t('abraham.exit') %>', action: tour.cancel, classes: 'shepherd-button-secondary' },
      { text: '<%= t('abraham.next') %>', action: tour.next }
        <% end %>
    <% end %>
    ]
  });
  <% end %>

  // Don't start the tour if the user dismissed it once this session
  if (!Cookies.get('<%= abraham_cookie_prefix %>-<%= tour_name %>', { domain: '<%= abraham_domain %>' })) {
    tour.start();
  }
</script>
<commit_msg>Include check for 'later' cookie within start method of tour (#27)<commit_after><script>
  var tour = new Shepherd.Tour(<%= Rails.configuration.abraham.tour_options.html_safe unless Rails.configuration.abraham.tour_options.nil? %>);

  tour.on("complete", function() {
    // ajax
    return $.ajax({
      url: "/abraham_histories/",
      type: "POST",
      dataType: "json",
      contentType: "application/json",
      data: JSON.stringify({
        authenticity_token: '<%= form_authenticity_token %>',
        controller_name: '<%= controller_name %>',
        action_name: '<%= action_name %>',
        tour_name: '<%= tour_name %>'
      })
    });
  });

  tour.on("cancel", function() {
    Cookies.set('<%= abraham_cookie_prefix %>-<%= tour_name %>', 'later', { domain: '<%= abraham_domain %>' });
  });

  <% steps.each_with_index do |(key, step), index| %>
  tour.addStep({
    id: 'step-<%= key %>',
    <% if step.key?('title') %>
    title: "<%= step['title'] %>",
    <% end %>
    text: "<%= step['text'] %>",
    <% if step.key?('attachTo') %>
    attachTo: { element: "<%= step['attachTo']['element'] %>", on: "<%= step['attachTo']['placement'] %>" },
    showOn: function() {
      // Only display this step if its selector is present
      return document.querySelector("<%= step['attachTo']['element'] %>") ? true : false
    },
    <% end %>
    buttons: [
    <% if index == 0 %>
      { text: '<%= t('abraham.later') %>', action: tour.cancel, classes: 'shepherd-button-secondary' },
      { text: '<%= t('abraham.continue') %>', action: tour.next }
    <% else %>
        <% if index == steps.size - 1 %>
      { text: '<%= t('abraham.done') %>', action: tour.complete }
        <% else %>
      { text: '<%= t('abraham.exit') %>', action: tour.cancel, classes: 'shepherd-button-secondary' },
      { text: '<%= t('abraham.next') %>', action: tour.next }
        <% end %>
    <% end %>
    ]
  });
  <% end %>

  tour.start = function (start) {
    return function () {
      // Don't start the tour if the user dismissed it once this session
      if (!Cookies.get('<%= abraham_cookie_prefix %>-<%= tour_name %>', {domain: '<%= abraham_domain %>'})) {
        start();
      }
    }
  }(tour.start)

  tour.start()
</script>

{'fraction_non_alphanumeric': 0.22303977925959992, 'fraction_numerical': 0.0013796275005748448, 'mean_word_length': 2.9259927797833933, 'pattern_counts': {'":': 0, '<': 75, '<?xml version=': 0, '>': 75, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3817809', 'n_tokens_mistral': 1525, 'n_tokens_neox': 1377, 'n_words': 289}