<commit_before><!DOCTYPE html>
<html lang="en">
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <%= favicon_link_tag "/favicons/favicon.ico" %>
    <title><%= @visualization.name.gsub(/_/," ") %> | CartoDB</title>
    <meta name="description" content="<%= @visualization.description || @visualization.name.gsub(/_/," ") %>">
    <meta name="keywords" content="Map,cartodb,<%= @visualization.name.gsub(/_/,",").gsub(/ /,",") %>">
    <meta name="author" content="CartoDB">
    <meta name="DC.title" content="<%= @visualization.description %> | CartoDB">
    <meta property="og:title" content="<%= @visualization.name.gsub(/_/," ") %> | CartoDB"/>
    <meta property="og:description" content="<%= @visualization.description || @visualization.name.gsub(/_/," ") %>"/>
    <meta property="og:type" content="Visualization"/>
    <meta property="og:url" content="<%= request.fullpath %>" />
    <meta property="og:image" content="<%= image_path "layout/cartofante_blue.png" %>"/>

    <%= stylesheet_link_tag 'embeds/public_map' %>
    <!--[if gt IE 8]><%= stylesheet_link_tag "fonts_ie" %><![endif]-->

    <style type="text/css">
      /* Styles showing up new cartodb text */
    <% if @visualization.user.remove_logo? && !Cartodb.config[:cartodb_com_hosted].present? %>
      <% if !params['cartodb_logo'] || params['cartodb_logo'] == "true" %>
        .cartodb-text {display:block;}
      <% end %>
    <% else %>
      .cartodb-text {display:block;}
    <% end %>

    </style>

    <% if !Rails.env.production? %>
      <%= stylesheet_link_tag 'embeds.css' %>
    <% else %>
      <link rel="stylesheet" href="//cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/themes/css/cartodb.css" />
    <% end %>

    <%= insert_trackjs() %>

    <!--[if lt IE 9]>
    <%= javascript_include_tag "respond.js" %>
    <![endif]-->

  </head>
  <body>
    <% if @visualization.public? || @visualization.public_with_link? || @visualization.password_protected? %>

      <div class="cartodb-public-wrapper">
        <div class="cartodb-public-header">
          <div class="inner">

            <a class="logo" href="http://www.cartodb.com">CartoDB</a>

            <div class="options">
              <a href="http://www.cartodb.com/login" class="signin green button" title="Sign In">Sign In</a>
            </div>

          </div>
        </div>

        <%= render(:partial => 'admin/pages/announcement') %>

        <div class="separator top"></div>

          <div id="map"></div>

        <div id="not_supported_dialog" style="display: none">
          <h2>CartoDB</h2>
          <p>This visualization only works in modern browsers. Upgrade yours and enjoy.</p>
          <ul>
            <li><a href="http://www.apple.com/safari/" class="safari">Safari</a></li>
            <li><a href="https://www.google.com/chrome/" class="chrome">Chrome</a></li>
            <li class="last"><a href="http://www.mozilla.org/en-US/firefox/all/‎" class="firefox">Firefox</a></li>
          </ul>
        </div>
      </div>

      <div class="separator bottom"></div>
      <div class="cartodb-map-data">
        <div class="cartodb-info">
          <div class="inner">

            <div class="details embed-left-col">
              <div class="content">
                <h1><%= @visualization.name %></h1>
                <p><%= @visualization.description %></p>
              </div>
            </div>

            <div class="user embed-right-col">
              <a href="/" title="Maps by <%= @visualization.user.username %>" class="content">
                <div class="user-info">
                  <h4>by <%= @visualization.user.username.truncate(20) %></h4>
                  <h5><%= "#{@public_tables_count} #{@public_tables_count != 1 ? "maps" :"map"} created" %></h5>
                </div>
                <img src="<%= @avatar_url %>" class="avatar" />
              </a>
            </div>

          </div>
        </div>

        <div class="cartodb-body">
          <div class="inner">

            <div class="map-info embed-right-col">
              <div class="content">

                <h2>Datasets used in this map</h2>
                <ul>

                  <% @related_tables.each do |table| %>
                    <% if (table.privacy_text == "PUBLIC") %>
                      <li><a href="/tables/<%= table.name %>/public" title="<%= table.name.gsub(/_/," ") %>"><%= table.name.gsub(/_/, " ") %></a><span><%= number_to_human_size(table.table_size) %></span></li>
                    <% end %>
                  <% end %>

                  <% if (@nonpublic_tables_count > 0) %>
                    <li class="private"><%= @nonpublic_tables_count %> private dataset<%= @nonpublic_tables_count != 1 ? 's' : '' %><span class="help" original-title="This map contains <%= @nonpublic_tables_count %> dataset<%= @nonpublic_tables_count != 1 ? 's' : '' %> made private by the publisher">(?)</span></li>
                  <% end %>
                </ul>

              </div>
            </div>

            <div class="comments embed-left-col">
              <div class="content">
                <div id="disqus_thread"></div>
                <script type="text/javascript">

                  var disqus_shortname  = '<%= @disqus_shortname %>';
                  var disqus_identifier = '<%= @visualization.id %>';

                  (function() {
                    var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
                    dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
                    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
                  })();

                </script>
                <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript" class="no_script">comments powered by Disqus.</a></noscript>
              </div>
            </div>

          </div>
        </div>

        <div class="cartodb-footer">
          <div class="inner">

            <div class="copyright embed-left-col">
              <div class="content">
                &copy; <%= Time.now.year %> CartoDB - <a href="https://cartodb.com/signup" title="Create your own maps with CartoDB">Create your own maps</a>
              </div>
            </div>

            <div class="terms embed-right-col">
              <div class="content">
                <a href="http://cartodb.com/terms" title="CartoDB's Terms of service">Terms of Service</a>
              </div>
            </div>

          </div>
        </div>
      </div>
    <% end %>

    <% if @visualization.map.provider == 'googlemaps' %>
      <script type="text/javascript" src="//maps.google.com/maps/api/js?sensor=false&v=3.12"></script>
    <% else %>
      <!-- if you are using google maps, uncomment the following line -->
      <!-- <script type="text/javascript" src="//maps.google.com/maps/api/js?sensor=false"></script> -->
    <% end %>

    <% if !Rails.env.production? %>
      <%= javascript_include_tag 'cdb.js', 'public_dashboard' %>
    <% else %>
      <script src="//cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/cartodb.js"></script>
      <%= javascript_include_tag 'public_dashboard' %>
    <% end %>

    <script>

      reset_disqus = function() {
        DISQUS.reset({
          reload: true
        });
      };

      if (!window.addEventListener) {
        window.attachEvent('orientationchange', reset_disqus, this);
      } else {
        window.addEventListener('orientationchange', reset_disqus);
      }

      function get_url_params(conversion) {

        conversion = conversion || {};

        var tokens = location.search.slice(1).split('&');
        var params = {};

        for (var i = 0; i < tokens.length; ++i) {

          var tk = tokens[i].split('=');
          var fn = conversion[tk[0]] || function(v) { return v };

          if (tk.length === 2) {
            params[tk[0]] = fn(decodeURIComponent(tk[1]));
          }
        }

        return params;
      }

      function manageError(err, layer) {
        if(layer && layer.get('type') === 'torque') {
          $('#not_supported_dialog').show();
          // hide all the overlays
          var overlays = vis.getOverlays()
          for (var i = 0; i < overlays.length; ++i) {
            var o = overlays[i];
            o.hide && o.hide();
          }
        }
      }

      function stats() {
        var browser;
        var ua = navigator.userAgent;
        var checks = [
          ['MSIE 10.0', 'ms10'],
          ['MSIE 9.0', 'ms9'],
          ['MSIE 8.0', 'ms8'],
          ['MSIE 7.0','ms7'],
          ['Chrome', 'chr'],
          ['Firefox', 'ff'],
          ['Safari', 'ff']
        ]
        for(var i = 0; i < checks.length && !browser; ++i) {
          if(ua.indexOf(checks[i][0]) !== -1) browser = checks[i][1];
        }
        browser = browser || 'none';
        cartodb.core.Profiler.metric('cartodb-js.embed.' + browser).inc();
      }

      $(document).ready(function(){


        var bool_fn = function(v) { return v == 'true' }
          , is_custom_install = <%= Cartodb.config[:cartodb_com_hosted].present? %>
          , logo_fn  = function(v) { return ( <%= !@visualization.user.remove_logo? %> || is_custom_install ) ? true : v == 'true' }
          , layer_fn = function(v) {
        if(!v || !v.length) {
          return null;
        }

        return _.map(v.split("|"), function(v) {
          return { visible: !!parseInt(v, 10) }
        });

          };

          var opt = get_url_params({
            'search':       bool_fn,
            'title':        bool_fn,
            'description':  bool_fn,
            'shareable':    bool_fn,
            'fullscreen':   bool_fn,
            'cartodb_logo': logo_fn,
            'scrollwheel':  bool_fn,
            'sublayer_options': layer_fn,
            'layer_selector': bool_fn,
            'legends': bool_fn
          });

          <% if (@visualization.password_protected?) %>
              opt.auth_token = '<%= @protected_map_token %>';
            opt.https = true; // when auth_token is used tiles should be fetch using https
          <% end %>

          <% if Rails.env.development? || Cartodb.config[:no_cdn] == true %>
              opt.no_cdn = true;
          <% end %>

          var scrollwheelEnabled = opt.scrollwheel;

          opt.title       = false;
          opt.description = false;
          opt.scrollwheel = false; 

          cartodb.config.set({
            cartodb_attributions: "CartoDB <a href='http://cartodb.com/attributions?utm_source=Footer_Link&utm_medium=referral&utm_campaign=Embed_v1&utm_content=Attributions&utm_term=<%= @visualization.user.username %>' target='_blank'>attribution</a>",
            cartodb_logo_link: "http://www.cartodb.com?utm_source=Footer_Link&utm_medium=referral&utm_campaign=Embed_v1&utm_content=Logo"
          })

          var loadingTime = cartodb.core.Profiler.metric('cartodb-js.embed.time_full_loaded').start();
          var visReadyTime = cartodb.core.Profiler.metric('cartodb-js.embed.time_vis_loaded').start();

          var onResize = function() {
            $("#map").css({ height: $(window).height() - 194 - 50 }); 
            $("#map").delay(500).animate({ opacity: 1 }, 250); 
          };

          var setupMapDimensions;

          var doOnOrientationChange = function() {

            switch(window.orientation)
            {
              case -90:
                case 90: setupMapDimensions(true, true);
              break;
              default: setupMapDimensions(true, true);
              break;
            }

          };

          $.extend( $.easing, {
            easeInQuad: function (x, t, b, c, d) {
              return c*(t/=d)*t + b;
            }
          })

          setupMapDimensions = function(mobileDevice, animated) {

            var windowHeight = $(window).height();
            var h, height, top;

            if (mobileDevice) {

              if (windowHeight > 670) {
                h = 180;
              } else { // iPhone, etc.
                h = 200;
              }

            } else {
              h = 260;
            }

            height = windowHeight - h;
            top    = windowHeight - (h - 67 - 50);

            if (animated) {
              $("#map").animate({ height: height }, { easing: "easeInQuad", duration: 150 }); 
            } else {

              if (mobileDevice) {
                $("#map").css({ height: height, opacity: 1 }); 
              }

              $("#map").trigger("resize");

            }

            window.vis.mapView.invalidateSize()

          };

          cartodb.createVis('map', <%=raw @visualization.to_vizjson.to_json %>, opt, function(vis) {

            visReadyTime.end();

            vis.on('load', function() {
              loadingTime.end();
            });

            // add here your code
            window.vis = vis;

            var fullscreen = vis.getOverlay("fullscreen");

            if (fullscreen) {

              fullscreen.options.doc = ".cartodb-public-wrapper";
              fullscreen.model.set("allowWheelOnFullscreen", scrollwheelEnabled);

            }

            // some stats
            stats();

            var mobileDevice = /Android|webOS|iPad|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);

            if (!mobileDevice) {
              $(window).on("resize", onResize);
            }

            setupMapDimensions(mobileDevice);

            // recalculate map position on orientation change
            if (!window.addEventListener) {
              window.attachEvent('orientationchange', doOnOrientationChange);
            } else {
              window.addEventListener('orientationchange', _.bind(doOnOrientationChange));
            }

          }).on('error', manageError);

          <% if Cartodb.config[:graphite_public] %>
            if (location.protocol.indexOf('https') === -1) {
              jQuery.getScript('<%= javascript_path "statsc.js" %>', function(ready) {
                statsc.connect('http://<%= Cartodb.config[:graphite_public]['host'] %>:<%= Cartodb.config[:graphite_public]['port'] %>/');
                  cartodb.core.Profiler.backend(function () {
                  statsc.send.apply(statsc, arguments);
                })
              })
            }
          <% end %>
      });

    </script>

    <%= javascript_include_tag "tipsy.js" %>

    <script type="text/javascript">
      $(function() {
        $("span.help").tipsy({ gravity: $.fn.tipsy.autoBounds(250, 's'), fade: true });

        if ($.browser.msie && parseInt($.browser.version) == 7 ) {
          $(".comments .content").html("<p>Your browser doesn't support comments.</p>")
        }
      });
    </script>

    <%= render partial: 'shared/analytics', locals: { 
      ua:     Cartodb.config[:google_analytics]['primary'],
      domain: Cartodb.config[:google_analytics]['domain'],
      page_owner: @visualization.user
    } %>

  </body>
</html>

<commit_msg>CDB-2743<commit_after><!DOCTYPE html>
<html lang="en">
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <%= favicon_link_tag "/favicons/favicon.ico" %>
    <title><%= @visualization.name.gsub(/_/," ") %> | CartoDB</title>
    <meta name="description" content="<%= @visualization.description || @visualization.name.gsub(/_/," ") %>">
    <meta name="keywords" content="Map,cartodb,<%= @visualization.name.gsub(/_/,",").gsub(/ /,",") %>">
    <meta name="author" content="CartoDB">
    <meta name="DC.title" content="<%= @visualization.description %> | CartoDB">
    <meta property="og:title" content="<%= @visualization.name.gsub(/_/," ") %> | CartoDB"/>
    <meta property="og:description" content="<%= @visualization.description || @visualization.name.gsub(/_/," ") %>"/>
    <meta property="og:type" content="Visualization"/>
    <meta property="og:url" content="<%= request.fullpath %>" />
    <meta property="og:image" content="<%= image_path "layout/cartofante_blue.png" %>"/>

    <%= stylesheet_link_tag 'embeds/public_map' %>
    <!--[if gt IE 8]><%= stylesheet_link_tag "fonts_ie" %><![endif]-->

    <style type="text/css">
      /* Styles showing up new cartodb text */
    <% if @visualization.user.remove_logo? && !Cartodb.config[:cartodb_com_hosted].present? %>
      <% if !params['cartodb_logo'] || params['cartodb_logo'] == "true" %>
        .cartodb-text {display:block;}
      <% end %>
    <% else %>
      .cartodb-text {display:block;}
    <% end %>

    </style>

    <% if !Rails.env.production? %>
      <%= stylesheet_link_tag 'embeds.css' %>
    <% else %>
      <link rel="stylesheet" href="//cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/themes/css/cartodb.css" />
    <% end %>

    <%= insert_trackjs() %>

    <!--[if lt IE 9]>
    <%= javascript_include_tag "respond.js" %>
    <![endif]-->

  </head>
  <body>
    <% if @visualization.public? || @visualization.public_with_link? || @visualization.password_protected? %>

      <div class="cartodb-public-wrapper">
        <div class="cartodb-public-header">
          <div class="inner">

            <a class="logo" href="http://www.cartodb.com">CartoDB</a>

            <div class="options">
              <a href="http://www.cartodb.com/login" class="signin green button" title="Sign In">Sign In</a>
            </div>

          </div>
        </div>

        <%= render(:partial => 'admin/pages/announcement') %>

        <div class="separator top"></div>

          <div id="map"></div>

        <div id="not_supported_dialog" style="display: none">
          <h2>CartoDB</h2>
          <p>This visualization only works in modern browsers. Upgrade yours and enjoy.</p>
          <ul>
            <li><a href="http://www.apple.com/safari/" class="safari">Safari</a></li>
            <li><a href="https://www.google.com/chrome/" class="chrome">Chrome</a></li>
            <li class="last"><a href="http://www.mozilla.org/en-US/firefox/all/‎" class="firefox">Firefox</a></li>
          </ul>
        </div>
      </div>

      <div class="separator bottom"></div>
      <div class="cartodb-map-data">
        <div class="cartodb-info">
          <div class="inner">

            <div class="details embed-left-col">
              <div class="content">
                <h1><%= @visualization.name %></h1>
                <p><%= @visualization.description %></p>
              </div>
            </div>

            <div class="user embed-right-col">
              <a href="/" title="Maps by <%= @visualization.user.username %>" class="content">
                <div class="user-info">
                  <h4>by <%= @visualization.user.username.truncate(20) %></h4>
                  <h5><%= "#{@visualization_count} #{@visualization_count != 1 ? "maps" :"map"} created" %></h5>
                </div>
                <img src="<%= @avatar_url %>" class="avatar" />
              </a>
            </div>

          </div>
        </div>

        <div class="cartodb-body">
          <div class="inner">

            <div class="map-info embed-right-col">
              <div class="content">

                <h2>Datasets used in this map</h2>
                <ul>

                  <% @related_tables.each do |table| %>
                    <% if (table.privacy_text == "PUBLIC") %>
                      <li><a href="/tables/<%= table.name %>/public" title="<%= table.name.gsub(/_/," ") %>"><%= table.name.gsub(/_/, " ") %></a><span><%= number_to_human_size(table.table_size) %></span></li>
                    <% end %>
                  <% end %>

                  <% if (@nonpublic_tables_count > 0) %>
                    <li class="private"><%= @nonpublic_tables_count %> private dataset<%= @nonpublic_tables_count != 1 ? 's' : '' %><span class="help" original-title="This map contains <%= @nonpublic_tables_count %> dataset<%= @nonpublic_tables_count != 1 ? 's' : '' %> made private by the publisher">(?)</span></li>
                  <% end %>
                </ul>

              </div>
            </div>

            <div class="comments embed-left-col">
              <div class="content">
                <div id="disqus_thread"></div>
                <script type="text/javascript">

                  var disqus_shortname  = '<%= @disqus_shortname %>';
                  var disqus_identifier = '<%= @visualization.id %>';

                  (function() {
                    var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
                    dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
                    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
                  })();

                </script>
                <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript" class="no_script">comments powered by Disqus.</a></noscript>
              </div>
            </div>

          </div>
        </div>

        <div class="cartodb-footer">
          <div class="inner">

            <div class="copyright embed-left-col">
              <div class="content">
                &copy; <%= Time.now.year %> CartoDB - <a href="https://cartodb.com/signup" title="Create your own maps with CartoDB">Create your own maps</a>
              </div>
            </div>

            <div class="terms embed-right-col">
              <div class="content">
                <a href="http://cartodb.com/terms" title="CartoDB's Terms of service">Terms of Service</a>
              </div>
            </div>

          </div>
        </div>
      </div>
    <% end %>

    <% if @visualization.map.provider == 'googlemaps' %>
      <script type="text/javascript" src="//maps.google.com/maps/api/js?sensor=false&v=3.12"></script>
    <% else %>
      <!-- if you are using google maps, uncomment the following line -->
      <!-- <script type="text/javascript" src="//maps.google.com/maps/api/js?sensor=false"></script> -->
    <% end %>

    <% if !Rails.env.production? %>
      <%= javascript_include_tag 'cdb.js', 'public_dashboard' %>
    <% else %>
      <script src="//cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/cartodb.js"></script>
      <%= javascript_include_tag 'public_dashboard' %>
    <% end %>

    <script>

      reset_disqus = function() {
        DISQUS.reset({
          reload: true
        });
      };

      if (!window.addEventListener) {
        window.attachEvent('orientationchange', reset_disqus, this);
      } else {
        window.addEventListener('orientationchange', reset_disqus);
      }

      function get_url_params(conversion) {

        conversion = conversion || {};

        var tokens = location.search.slice(1).split('&');
        var params = {};

        for (var i = 0; i < tokens.length; ++i) {

          var tk = tokens[i].split('=');
          var fn = conversion[tk[0]] || function(v) { return v };

          if (tk.length === 2) {
            params[tk[0]] = fn(decodeURIComponent(tk[1]));
          }
        }

        return params;
      }

      function manageError(err, layer) {
        if(layer && layer.get('type') === 'torque') {
          $('#not_supported_dialog').show();
          // hide all the overlays
          var overlays = vis.getOverlays()
          for (var i = 0; i < overlays.length; ++i) {
            var o = overlays[i];
            o.hide && o.hide();
          }
        }
      }

      function stats() {
        var browser;
        var ua = navigator.userAgent;
        var checks = [
          ['MSIE 10.0', 'ms10'],
          ['MSIE 9.0', 'ms9'],
          ['MSIE 8.0', 'ms8'],
          ['MSIE 7.0','ms7'],
          ['Chrome', 'chr'],
          ['Firefox', 'ff'],
          ['Safari', 'ff']
        ]
        for(var i = 0; i < checks.length && !browser; ++i) {
          if(ua.indexOf(checks[i][0]) !== -1) browser = checks[i][1];
        }
        browser = browser || 'none';
        cartodb.core.Profiler.metric('cartodb-js.embed.' + browser).inc();
      }

      $(document).ready(function(){


        var bool_fn = function(v) { return v == 'true' }
          , is_custom_install = <%= Cartodb.config[:cartodb_com_hosted].present? %>
          , logo_fn  = function(v) { return ( <%= !@visualization.user.remove_logo? %> || is_custom_install ) ? true : v == 'true' }
          , layer_fn = function(v) {
        if(!v || !v.length) {
          return null;
        }

        return _.map(v.split("|"), function(v) {
          return { visible: !!parseInt(v, 10) }
        });

          };

          var opt = get_url_params({
            'search':       bool_fn,
            'title':        bool_fn,
            'description':  bool_fn,
            'shareable':    bool_fn,
            'fullscreen':   bool_fn,
            'cartodb_logo': logo_fn,
            'scrollwheel':  bool_fn,
            'sublayer_options': layer_fn,
            'layer_selector': bool_fn,
            'legends': bool_fn
          });

          <% if (@visualization.password_protected?) %>
              opt.auth_token = '<%= @protected_map_token %>';
            opt.https = true; // when auth_token is used tiles should be fetch using https
          <% end %>

          <% if Rails.env.development? || Cartodb.config[:no_cdn] == true %>
              opt.no_cdn = true;
          <% end %>

          var scrollwheelEnabled = opt.scrollwheel;

          opt.title       = false;
          opt.description = false;
          opt.scrollwheel = false; 

          cartodb.config.set({
            cartodb_attributions: "CartoDB <a href='http://cartodb.com/attributions?utm_source=Footer_Link&utm_medium=referral&utm_campaign=Embed_v1&utm_content=Attributions&utm_term=<%= @visualization.user.username %>' target='_blank'>attribution</a>",
            cartodb_logo_link: "http://www.cartodb.com?utm_source=Footer_Link&utm_medium=referral&utm_campaign=Embed_v1&utm_content=Logo"
          })

          var loadingTime = cartodb.core.Profiler.metric('cartodb-js.embed.time_full_loaded').start();
          var visReadyTime = cartodb.core.Profiler.metric('cartodb-js.embed.time_vis_loaded').start();

          var onResize = function() {
            $("#map").css({ height: $(window).height() - 194 - 50 }); 
            $("#map").delay(500).animate({ opacity: 1 }, 250); 
          };

          var setupMapDimensions;

          var doOnOrientationChange = function() {

            switch(window.orientation)
            {
              case -90:
                case 90: setupMapDimensions(true, true);
              break;
              default: setupMapDimensions(true, true);
              break;
            }

          };

          $.extend( $.easing, {
            easeInQuad: function (x, t, b, c, d) {
              return c*(t/=d)*t + b;
            }
          })

          setupMapDimensions = function(mobileDevice, animated) {

            var windowHeight = $(window).height();
            var h, height, top;

            if (mobileDevice) {

              if (windowHeight > 670) {
                h = 180;
              } else { // iPhone, etc.
                h = 200;
              }

            } else {
              h = 260;
            }

            height = windowHeight - h;
            top    = windowHeight - (h - 67 - 50);

            if (animated) {
              $("#map").animate({ height: height }, { easing: "easeInQuad", duration: 150 }); 
            } else {

              if (mobileDevice) {
                $("#map").css({ height: height, opacity: 1 }); 
              }

              $("#map").trigger("resize");

            }

            window.vis.mapView.invalidateSize()

          };

          cartodb.createVis('map', <%=raw @visualization.to_vizjson.to_json %>, opt, function(vis) {

            visReadyTime.end();

            vis.on('load', function() {
              loadingTime.end();
            });

            // add here your code
            window.vis = vis;

            var fullscreen = vis.getOverlay("fullscreen");

            if (fullscreen) {

              fullscreen.options.doc = ".cartodb-public-wrapper";
              fullscreen.model.set("allowWheelOnFullscreen", scrollwheelEnabled);

            }

            // some stats
            stats();

            var mobileDevice = /Android|webOS|iPad|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);

            if (!mobileDevice) {
              $(window).on("resize", onResize);
            }

            setupMapDimensions(mobileDevice);

            // recalculate map position on orientation change
            if (!window.addEventListener) {
              window.attachEvent('orientationchange', doOnOrientationChange);
            } else {
              window.addEventListener('orientationchange', _.bind(doOnOrientationChange));
            }

          }).on('error', manageError);

          <% if Cartodb.config[:graphite_public] %>
            if (location.protocol.indexOf('https') === -1) {
              jQuery.getScript('<%= javascript_path "statsc.js" %>', function(ready) {
                statsc.connect('http://<%= Cartodb.config[:graphite_public]['host'] %>:<%= Cartodb.config[:graphite_public]['port'] %>/');
                  cartodb.core.Profiler.backend(function () {
                  statsc.send.apply(statsc, arguments);
                })
              })
            }
          <% end %>
      });

    </script>

    <%= javascript_include_tag "tipsy.js" %>

    <script type="text/javascript">
      $(function() {
        $("span.help").tipsy({ gravity: $.fn.tipsy.autoBounds(250, 's'), fade: true });

        if ($.browser.msie && parseInt($.browser.version) == 7 ) {
          $(".comments .content").html("<p>Your browser doesn't support comments.</p>")
        }
      });
    </script>

    <%= render partial: 'shared/analytics', locals: { 
      ua:     Cartodb.config[:google_analytics]['primary'],
      domain: Cartodb.config[:google_analytics]['domain'],
      page_owner: @visualization.user
    } %>

  </body>
</html>


{'fraction_non_alphanumeric': 0.17206391039367486, 'fraction_numerical': 0.006588700378850272, 'mean_word_length': 1.9143625192012288, 'pattern_counts': {'":': 0, '<': 465, '<?xml version=': 0, '>': 465, 'https://': 4, 'lorem ipsum': 0, 'www.': 12, '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': '4663416', 'n_tokens_mistral': 9835, 'n_tokens_neox': 8949, 'n_words': 1636}