<commit_before><div id="hack">
  <div id="info">
    <select id="regional">
      <option value="Australia">Australia</option>
      <option value="Perth">Perth</option>
      <option value="Adelaide">Adelaide</option>
      <option value="Melbourne">Melbourne</option>
      <option value="Hobart">Hobart</option>
      <option value="Canberra">Canberra</option>
      <option value="Sydney">Sydney</option>
      <option value="Brisbane">Brisbane</option>
      <option value="Darwin">Darwin</option>
    </select>
    <button id="settings">..</button>
    <div id="counts">
      <div id="hm1"><p></p></div>
      <div id="hm2"><p></p></div>
      <div id="hm3"><p></p></div>
    </div>
    <button id="help">?</button>
    <div id="twitter"><a href="https://twitter.com/share" class="twitter-share-button" data-size="large" data-hashtags="govhack">Tweet</a></div>
  </div>
  <div class="map">
  </div>
</div>
<div id="welcome" title="Australian Government Exposed!">
  <p>Welcome to <a href="http://hackerspace.govhack.org/content/national-eyeball" target="_gh14">my entry</a> to GovHack 2014. You can</p>
  <ul>
    <li>create a heatmap to eyeball government data;</li>
    <li>share your heatmap on Twitter; and</li>
    <li>check out <a href="http://api.govdata.exposed/australia" target="_api">api.govdata.exposed/australia</a>.</li>
  </ul>
  <p>Sources: ABS, ATO, AIHW, WAEC, PTA, DoHA and DOE.</p>
</div>

<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<script>
  HeatMap = {};
  HeatMap.dirty = false;
  HeatMap.instances = [];

  if (!_.isUndefined(localStorage.heatmap)) {
    localStorage.heatmap = "{}";
  }

  HeatMap.state = JSON.parse(localStorage.heatmap);

  if (_.isUndefined(HeatMap.state.bounds)) {
    HeatMap.state.bounds = [0, 0, 0, 0];
  }
  if (_.isUndefined(HeatMap.state.zoom)) {
    HeatMap.state.zoom = 5;
  }
  if (_.isUndefined(HeatMap.state.view)) {
    HeatMap.state.view = "Australia";
  }
  if (_.isUndefined(HeatMap.state.welcomed)) {
    HeatMap.state.welcomed = false;
  }
  if (_.isUndefined(HeatMap.state.filters)) {
    HeatMap.state.filters = [
      {
        id: 295,
        colour: [255, 0, 0],
        visible: true
      },
      {
        id: 304,
        colour: [0, 255, 0],
        visible: true
      },
      {
        id: 5,
        colour: [0, 0, 255],
        visible: true
      }
    ];
  };

  ZOOMS = {
    "Australia": {
      center: new google.maps.LatLng(-28, 134),
      zoom: 5
    },
    "Perth": {
      center: new google.maps.LatLng(-32, 116),
      zoom: 10
    },
    "Adelaide": {
      center: new google.maps.LatLng(-35, 139),
      zoom: 10
    },
    "Melbourne": {
      center: new google.maps.LatLng(-38, 145),
      zoom: 9
    },
    "Hobart": {
      center: new google.maps.LatLng(-42.9, 147.2),
      zoom: 11
    },
    "Canberra": {
      center: new google.maps.LatLng(-35.3, 149),
      zoom: 11
    },
    "Sydney": {
      center: new google.maps.LatLng(-34, 151),
      zoom: 9
    },
    "Brisbane": {
      center: new google.maps.LatLng(-27, 153),
      zoom: 9
    },
    "Darwin": {
      center: new google.maps.LatLng(-12.4, 130.8),
      zoom: 11
    }
  }

  map_options = {
    panControl: false,
    zoomControl: true,
    mapTypeControl: true,
    scaleControl: true,
    streetViewControl: false,
    overviewMapControl: false,
    scrollwheel: false,
    center: ZOOMS[HeatMap.state.view].center,
    zoom: ZOOMS[HeatMap.state.view].zoom
  };

  function update_bounds() {
    if (!HeatMap.dirty) {
      return;
    }
    HeatMap.dirty = false;
    HeatMap.state.bounds[0] = map.getBounds().getSouthWest().lat();
    HeatMap.state.bounds[1] = map.getBounds().getSouthWest().lng();
    HeatMap.state.bounds[2] = map.getBounds().getNorthEast().lat();
    HeatMap.state.bounds[3] = map.getBounds().getNorthEast().lng();
    redraw_heatmaps();
  }

  function display_heatmaps() {
    _.each(HeatMap.points, function(points, index){
      if (_.isUndefined(HeatMap.instances[index])) {
        HeatMap.instances[index] = new google.maps.visualization.HeatmapLayer({
          map: null,
          radius: 0.03,
          dissipating: false,
          opacity: 0.8,
          maxIntensity: 1.0,
        });
      }
      gradient = [];
      _.times(14, function(i){
        c = HeatMap.state.filters[index].colour;
        a = i/13.0;
        gradient.push("rgba("+c[0]+","+c[1]+","+c[2]+","+a+")");
      });
      HeatMap.instances[index].set('gradient', gradient);
      points = _.map(HeatMap.points[index], function(point){
        if (point.type == 'bool') {
          HeatMap.instances[index].set('radius', 0.01);
          return new google.maps.LatLng(point.lat,point.lng);
        } else {
          HeatMap.instances[index].set('radius', 0.03);
          return {
            location: new google.maps.LatLng(point.lat,point.lng),
            weight: point.weight
          }
        }
      });
      HeatMap.instances[index].setData(points);
      if (map.zoom > 10) {
        HeatMap.instances[index].set('opacity', 0.8 - (map.zoom - 10) / 10.0);
      }
      else
      {
        HeatMap.instances[index].set('opacity', 0.8);
      }
      if (_.isNull(HeatMap.instances[index].map)) {
        HeatMap.instances[index].setMap(map);
      }
    });
  }

  function display_comments() {
    $("#hm1 p").text(HeatMap.comments[0].count);
    $("#hm1").attr('title', HeatMap.comments[0].comment);
    $("#hm2 p").text(HeatMap.comments[1].count);
    $("#hm2").attr('title', HeatMap.comments[1].comment);
    $("#hm3 p").text(HeatMap.comments[2].count);
    $("#hm3").attr('title', HeatMap.comments[2].comment);
  }

  function redraw_heatmaps() {
    localStorage.heatmap = JSON.stringify(HeatMap.state);
    if (HeatMap.state.filters.length > 0) {
      params = {
        bounds: HeatMap.state.bounds,
        filters: _.map(HeatMap.state.filters, function(f){ return f.id; })
      };
      $.getJSON("heatmaps/points", params, function(data){
        HeatMap.points = data;
        display_heatmaps();
      });
      $.getJSON("heatmaps/comments", params, function(data){
        HeatMap.comments = data;
        display_comments();
      });
    }
  }

  function initialize() {
    $("#controls").tabs();
    $("#info").tabs();
    $("#regional").selectmenu({
      width: 160,
      position: { collision: "flip" },
      change: function() {
        region = ZOOMS[$("#regional").val()];
        map.setCenter(region.center);
        map.setZoom(region.zoom);
      }
    });
    $("#hm1").tooltip();
    $("#hm2").tooltip();
    $("#hm3").tooltip();
    $("#settings").button({
    });
    $("#welcome").dialog({
      width: 600,
      height: 300,
      buttons: [
        {
          text: "OK",
          click: function() {
            $(this).dialog("close");
          }
        }
      ]
    });
    $("#help").button({
    });
    map = new google.maps.Map($("#hack .map")[0], map_options);
    google.maps.event.addListener(map, 'idle', update_bounds);
    google.maps.event.addListener(map, "bounds_changed", function(){
      HeatMap.dirty = true;
    });
  }

  google.maps.event.addDomListener(window, 'load', initialize);
</script>

<% content_for :head do %>
  <%= javascript_include_tag '//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js' %>
  <%= javascript_include_tag '//ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/jquery-ui.min.js' %>
  <%= javascript_include_tag "//maps.googleapis.com/maps/api/js?libraries=geometry,drawing,visualization&sensor=false&key=<KEY>" %>
  <%= javascript_include_tag "//underscorejs.org/underscore-min.js" %>
  <%= stylesheet_link_tag "//ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/themes/smoothness/jquery-ui.css" %>
  <style>
    html {
      height: 100%;
      margin: 0px;
      padding: 0px;
    }
    body {
      height: 100%;
      margin: 0px;
      padding: 0px;
    }
    div#hack {
      width: 100%;
      height: 100%;
      margin: 0px;
    }
    div.map {
      width: 100%;
      height: 100%;
      margin: 0px;
    }
    div#info {
      position: fixed;
      bottom: 30px;
      left: 0px;
      width: 100%;
      height: 42px;
      z-index: 999;
      opacity: 0.7;
    }
    div#twitter {
      position: fixed;
      right: 10px;
      bottom: 38px;
      width: 120px;
    }
    div#counts {
      position: fixed;
      left: 225px;
      right: 190px;
      bottom: 34px;
      height: 43px;
      font-size: 22px;
      color: white;
      font-weight: bold; 
      text-align: center;
      line-height: 0;
    }
    #counts #hm1 {
      background-color: red;
      float: left;
      width: 33%;
      height: 100%;
    }
    #counts #hm2 {
      background-color: green;
      width: 34%;
      float: left;
      height: 100%;
    }
    #counts #hm3 {
      position: relative;
      background-color: blue;
      width: 33%;
      float: left;
      height: 100%;
    }
    span#blurb {
      width: 100%;
    }
    span#red {
      width: 33%;
      background-color: #FAA;
    }
    span#green {
      width: 33%;
      background-color: #AFA;
    }
    span#blue {
      width: 33%;
      background-color: #AAF;
    }
    button#settings {
      position: fixed;
      bottom: 35px;
      height: 41px;
      left: 170px;
    }
    button#help {
      position: fixed;
      bottom: 35px;
      height: 41px;
      right: 135px;
    }
  </style>
<% end %>
<commit_msg>better bools<commit_after><div id="hack">
  <div id="info">
    <select id="regional">
      <option value="Australia">Australia</option>
      <option value="Perth">Perth</option>
      <option value="Adelaide">Adelaide</option>
      <option value="Melbourne">Melbourne</option>
      <option value="Hobart">Hobart</option>
      <option value="Canberra">Canberra</option>
      <option value="Sydney">Sydney</option>
      <option value="Brisbane">Brisbane</option>
      <option value="Darwin">Darwin</option>
    </select>
    <button id="settings">..</button>
    <div id="counts">
      <div id="hm1"><p></p></div>
      <div id="hm2"><p></p></div>
      <div id="hm3"><p></p></div>
    </div>
    <button id="help">?</button>
    <div id="twitter"><a href="https://twitter.com/share" class="twitter-share-button" data-size="large" data-hashtags="govhack">Tweet</a></div>
  </div>
  <div class="map">
  </div>
</div>
<div id="welcome" title="Australian Government Exposed!">
  <p>Welcome to <a href="http://hackerspace.govhack.org/content/national-eyeball" target="_gh14">my entry</a> to GovHack 2014. You can</p>
  <ul>
    <li>create a heatmap to eyeball government data;</li>
    <li>share your heatmap on Twitter; and</li>
    <li>check out <a href="http://api.govdata.exposed/australia" target="_api">api.govdata.exposed/australia</a>.</li>
  </ul>
  <p>Sources: ABS, ATO, AIHW, WAEC, PTA, DoHA and DOE.</p>
</div>

<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<script>
  HeatMap = {};
  HeatMap.dirty = false;
  HeatMap.instances = [];

  if (!_.isUndefined(localStorage.heatmap)) {
    localStorage.heatmap = "{}";
  }

  HeatMap.state = JSON.parse(localStorage.heatmap);

  if (_.isUndefined(HeatMap.state.bounds)) {
    HeatMap.state.bounds = [0, 0, 0, 0];
  }
  if (_.isUndefined(HeatMap.state.view)) {
    HeatMap.state.view = "Perth";
  }
  if (_.isUndefined(HeatMap.state.welcomed)) {
    HeatMap.state.welcomed = false;
  }
  if (_.isUndefined(HeatMap.state.filters)) {
    HeatMap.state.filters = [
      {
        id: 295,
        colour: [255, 0, 0],
        visible: true
      },
      {
        id: 304,
        colour: [0, 255, 0],
        visible: true
      },
      {
        id: 5,
        colour: [0, 0, 255],
        visible: true
      }
    ];
  };

  ZOOMS = {
    "Perth": {
      center: new google.maps.LatLng(-32, 116),
      zoom: 10
    },
    "Adelaide": {
      center: new google.maps.LatLng(-35, 139),
      zoom: 10
    },
    "Melbourne": {
      center: new google.maps.LatLng(-38, 145),
      zoom: 9
    },
    "Hobart": {
      center: new google.maps.LatLng(-42.9, 147.2),
      zoom: 11
    },
    "Canberra": {
      center: new google.maps.LatLng(-35.3, 149),
      zoom: 11
    },
    "Sydney": {
      center: new google.maps.LatLng(-34, 151),
      zoom: 9
    },
    "Brisbane": {
      center: new google.maps.LatLng(-27, 153),
      zoom: 9
    },
    "Darwin": {
      center: new google.maps.LatLng(-12.4, 130.8),
      zoom: 11
    }
  }

  map_options = {
    panControl: false,
    zoomControl: true,
    mapTypeControl: true,
    scaleControl: true,
    streetViewControl: false,
    overviewMapControl: false,
    scrollwheel: false,
    center: ZOOMS[HeatMap.state.view].center,
    zoom: ZOOMS[HeatMap.state.view].zoom
  };

  function update_bounds() {
    if (!HeatMap.dirty) {
      return;
    }
    HeatMap.dirty = false;
    HeatMap.state.bounds[0] = map.getBounds().getSouthWest().lat();
    HeatMap.state.bounds[1] = map.getBounds().getSouthWest().lng();
    HeatMap.state.bounds[2] = map.getBounds().getNorthEast().lat();
    HeatMap.state.bounds[3] = map.getBounds().getNorthEast().lng();
    redraw_heatmaps();
  }

  function display_heatmaps() {
    _.each(HeatMap.points, function(points, index){
      if (_.isUndefined(HeatMap.instances[index])) {
        HeatMap.instances[index] = new google.maps.visualization.HeatmapLayer({
          map: null,
          radius: 0.03,
          dissipating: false,
          opacity: 0.8,
          maxIntensity: 1.0,
        });
      }
      gradient = [];
      _.times(14, function(i){
        c = HeatMap.state.filters[index].colour;
        a = i/13.0;
        gradient.push("rgba("+c[0]+","+c[1]+","+c[2]+","+a+")");
      });
      HeatMap.instances[index].set('gradient', gradient);
      points = _.map(HeatMap.points[index], function(point){
        if (point.type == 'bool') {
          HeatMap.instances[index].set('radius', 0.005);
          return new google.maps.LatLng(point.lat,point.lng);
        } else {
          HeatMap.instances[index].set('radius', 0.03);
          return {
            location: new google.maps.LatLng(point.lat,point.lng),
            weight: point.weight
          }
        }
      });
      HeatMap.instances[index].setData(points);
      if (map.zoom > 10) {
        HeatMap.instances[index].set('opacity', 0.8 - (map.zoom - 10) / 10.0);
      }
      else
      {
        HeatMap.instances[index].set('opacity', 0.8);
      }
      if (_.isNull(HeatMap.instances[index].map)) {
        HeatMap.instances[index].setMap(map);
      }
    });
  }

  function display_comments() {
    $("#hm1 p").text(HeatMap.comments[0].count);
    $("#hm1").attr('title', HeatMap.comments[0].comment);
    $("#hm2 p").text(HeatMap.comments[1].count);
    $("#hm2").attr('title', HeatMap.comments[1].comment);
    $("#hm3 p").text(HeatMap.comments[2].count);
    $("#hm3").attr('title', HeatMap.comments[2].comment);
  }

  function redraw_heatmaps() {
    localStorage.heatmap = JSON.stringify(HeatMap.state);
    if (HeatMap.state.filters.length > 0) {
      params = {
        bounds: HeatMap.state.bounds,
        filters: _.map(HeatMap.state.filters, function(f){ return f.id; })
      };
      $.getJSON("heatmaps/points", params, function(data){
        HeatMap.points = data;
        display_heatmaps();
      });
      $.getJSON("heatmaps/comments", params, function(data){
        HeatMap.comments = data;
        display_comments();
      });
    }
  }

  function initialize() {
    $("#controls").tabs();
    $("#info").tabs();
    $("#regional").selectmenu({
      width: 160,
      position: { collision: "flip" },
      change: function() {
        region = ZOOMS[$("#regional").val()];
        map.setCenter(region.center);
        map.setZoom(region.zoom);
      }
    });
    $("#hm1").tooltip();
    $("#hm2").tooltip();
    $("#hm3").tooltip();
    $("#settings").button({
    });
    $("#welcome").dialog({
      width: 600,
      height: 300,
      buttons: [
        {
          text: "OK",
          click: function() {
            $(this).dialog("close");
          }
        }
      ]
    });
    $("#help").button({
    });
    map = new google.maps.Map($("#hack .map")[0], map_options);
    google.maps.event.addListener(map, 'idle', update_bounds);
    google.maps.event.addListener(map, "bounds_changed", function(){
      HeatMap.dirty = true;
    });
  }

  google.maps.event.addDomListener(window, 'load', initialize);
</script>

<% content_for :head do %>
  <%= javascript_include_tag '//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js' %>
  <%= javascript_include_tag '//ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/jquery-ui.min.js' %>
  <%= javascript_include_tag "//maps.googleapis.com/maps/api/js?libraries=geometry,drawing,visualization&sensor=false&key=AIzaSyCl65XtmFvV5XRc8Lw42NC0AFlbl9xjHS0" %>
  <%= javascript_include_tag "//underscorejs.org/underscore-min.js" %>
  <%= stylesheet_link_tag "//ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/themes/smoothness/jquery-ui.css" %>
  <style>
    html {
      height: 100%;
      margin: 0px;
      padding: 0px;
    }
    body {
      height: 100%;
      margin: 0px;
      padding: 0px;
    }
    div#hack {
      width: 100%;
      height: 100%;
      margin: 0px;
    }
    div.map {
      width: 100%;
      height: 100%;
      margin: 0px;
    }
    div#info {
      position: fixed;
      bottom: 30px;
      left: 0px;
      width: 100%;
      height: 42px;
      z-index: 999;
      opacity: 0.7;
    }
    div#twitter {
      position: fixed;
      right: 10px;
      bottom: 38px;
      width: 120px;
    }
    div#counts {
      position: fixed;
      left: 225px;
      right: 190px;
      bottom: 34px;
      height: 43px;
      font-size: 22px;
      color: white;
      font-weight: bold; 
      text-align: center;
      line-height: 0;
    }
    #counts #hm1 {
      background-color: red;
      float: left;
      width: 33%;
      height: 100%;
    }
    #counts #hm2 {
      background-color: green;
      width: 34%;
      float: left;
      height: 100%;
    }
    #counts #hm3 {
      position: relative;
      background-color: blue;
      width: 33%;
      float: left;
      height: 100%;
    }
    span#blurb {
      width: 100%;
    }
    span#red {
      width: 33%;
      background-color: #FAA;
    }
    span#green {
      width: 33%;
      background-color: #AFA;
    }
    span#blue {
      width: 33%;
      background-color: #AAF;
    }
    button#settings {
      position: fixed;
      bottom: 35px;
      height: 41px;
      left: 170px;
    }
    button#help {
      position: fixed;
      bottom: 35px;
      height: 41px;
      right: 135px;
    }
  </style>
<% end %>

{'fraction_non_alphanumeric': 0.17989252360828506, 'fraction_numerical': 0.028538634110711118, 'mean_word_length': 2.391365888181175, 'pattern_counts': {'":': 17, '<': 162, '<?xml version=': 0, '>': 166, 'https://': 2, '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': '4532797', 'n_tokens_mistral': 7266, 'n_tokens_neox': 6694, 'n_words': 1122}