<% content_for :head do %>
  <%= stylesheet_link_tag 'https://api.jirafe.com/dashboard/css/spree_ui.css', :media => 'all' %>
  <%= javascript_include_tag 'https://jirafe.com/dashboard/js/spree_namespaced_ui.js' %>
<% end %>

<% if Spree::Dash::Config.configured? %>
  <h1><%= t(:overview) %></h1>
  <div id="jirafe"></div>
  <%= javascript_tag :defer => 'defer' do %>
    jirafe.jQuery('#jirafe').jirafe({
       api_url: 'https://api.jirafe.com/v1',
       api_token: '<%= Spree::Dash::Config.token %>',
       app_id: '<%= Spree::Dash::Config.app_id %>',
       version: 'spree-v0.1.0',
       locale: '<%= Spree::Dash::Config.locale %>' });
    setTimeout(function() {
      if ($('mod-jirafe') == undefined) {
        $('messages').insert ("<ul class=\"messages\"><li class=\"error-msg\">We're unable to connect with the Jirafe service for the moment. Please wait a few minutes and refresh this page later.</li></ul>");
        }
    }, 10000);
  <% end %>
  <div id="jirafe_locales">
    <%= raw jirafe_locale_links.join(' | ') %>
  </div>
<% else %>
  <div class="analytics_splash">
    <%= image_tag 'analytics_dashboard_preview.png', :alt => 'Spree Analytics' %>
  </div>
  <br/>
  <div class="preview-buttons">
    <%= link_to content_tag(:span, t(:activate)), admin_analytics_sign_up_path, :class => 'button green' %>
    <%= t(:or) %> &nbsp;
    <%= link_to content_tag(:span, t(:learn_more)), "http://spreecommerce.com/blog/2012/01/31/introducing-spree-analytics/", :class => 'button', :target => '_blank' %>
  </div>
<% end %>