<!-- top tiles -->
<div class="row tile_count">
  {% for k, v in blockArray[count]["top_tiles"].iteritems() %}
  <div class="animated flipInY col-md-2 col-sm-4 col-xs-4 tile_stats_count">
    <div class="left"></div>
    <div class="right">
      <span class="count_top"><i class="fa fa-{{v[2]}}"></i> {{k}}</span>
      <div class="count{% if v[2] == "On" %} green{% elif v[2] == "Off" %} red{% endif %} loading" id="top_tiles_block_{{count}}_{{v[1]}}_{% if v[3] %}{{v[3]}}{% else %}Data{% endif %}" style="white-space: nowrap;"></div>
    </div>
  </div>
  {% endfor %}
</div>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
  var updateDivs_block_{{count}}=[];
  var tilesPreviousArray_{{count}}=[];
  var updateDivsType_block_{{count}} = [];
  {% for k, v in blockArray[count]["top_tiles"].iteritems() %}
    updateDivs_block_{{count}}.push("{{v[1]}}");
    {% if v[3]|length > 3 %}
      updateDivsType_block_{{count}}.push("{{v[3]}}");
    {% else %}
      updateDivsType_block_{{count}}.push("Data");
    {% endif %}
  {% endfor %}

  tilesPreviousArray_{{count}} = refreshTopTiles(updateDivs_block_{{count}}, "top_tiles_block_{{count}}_", tilesPreviousArray_{{count}}, updateDivsType_block_{{count}});
  tilesPreviousArray_{{count}} = setInterval(refreshTopTiles, 9000, updateDivs_block_{{count}}, "top_tiles_block_{{count}}_", tilesPreviousArray_{{count}}, updateDivsType_block_{{count}});
  var counter = 0;
  for (var i in updateDivs_block_{{count}}) {
    $("#top_tiles_block_{{count}}_" + updateDivs_block_{{count}}[i] + "_" + updateDivsType_block_{{count}}[counter]).removeClass("loading");
    counter += 1;
  }
});
</script>
<!-- /top tiles -->
