<commit_before>package waveguide

import "html/template"

var tmpl = template.Must(template.New("").Parse(`
{{define "header"}}
<html>
        <head>
                <title>Waveguide</title>
                <style>
                        body {
                                font-family: monospace;
                        }
                        table {
                                border-collapse: separate;
                                font-size: 12pt;
                        }
                        th {
                                text-align: left;
                        }
                        th, td {
                                padding: 0 1em 0.5ex 0;
                        }
                        form {
                        	margin: 0
                        }
                </style>
        </head>
        <body>
{{end}}

{{define "footer"}}
	</body>
</html>
{{end}}

{{define "root"}}
{{template "header"}}
                <table>
                	{{if .Spots}}
				<thead>
					<th>Location</th>
					<th>Coordinates</th>
					<th>Conditions</th>
					<th>Wave Height</th>
					<th>Last Updated</th>
				</thead>
				<tbody>
					{{range .Spots}}
						<tr>
							<td><a href="{{.MapURL}}">{{.HTMLName}}</a></td>
							<td>
								{{if .HasCoordinates}}
									<a href="{{.ClearCoordsURL}}">❌</a>
									<a href="{{.MapsURL}}">{{.FormattedCoordinates}}</a>
								{{else}}
									<form action="/coords" method="post">
										<input type="hidden" name="path" value="{{.MswPath}}" />
										<input name="coordinates" />
										<button type="submit">Submit</button>
									</form>
								{{end}}
							</td>
							<td><a href="{{.ReportURL}}">{{.Cond.Stars}}</a></td>
							<td>{{.Cond.WaveHeight}}</td>
							<td>{{.Cond.HowLong}} ago</td>
						</tr>
					{{end}}
				</tbody>
			{{else}}
				There's no data yet. You can get some by visiting <a href="/update_all">/update_all</a>.
			{{end}}
                </table>
{{template "footer"}}
{{end}}

{{define "action_response"}}
{{template "header"}}
		<div><a href="/">← home</a></div>
		<div id="message">{{.Message}}</div>
{{template "footer"}}
{{end}}

{{define "map"}}
<!DOCTYPE html>
<html>
  <head>
    <title>Waveguide</title>
    <meta name="viewport" content="initial-scale=1.0">
    <meta charset="utf-8">
    <style>
      /* Always set the map height explicitly to define the size of the div
       * element that contains the map. */
      #map {
        height: 100%;
      }
      /* Optional: Makes the sample page fill the window. */
      html, body {
        height: 100%;
        margin: 0;
        padding: 0;
      }
    </style>
  </head>
  <body>
    <div id="map"></div>
    <script>
      var map;
      function initMap() {
        map = new google.maps.Map(document.getElementById('map'), {
          center: {lat: 20.8020856, lng: -156.8984559},
          zoom: 2
        });

	var spots = [
		{{range .}}
			{title: '{{.Name}} {{.Cond.Stars}}', lat: {{.Coordinates.Lat}}, lng: {{.Coordinates.Lng}}, rating: {{.Cond.Rating}} },
		{{end}}
	]
	for (var i = 0; i < spots.length; i++) {
		var s = spots[i]
		if (s.lat == 0 && s.lng == 0) {
			continue;
		}
		var marker = new google.maps.Marker({
		  position: {lat: s.lat, lng: s.lng},
		  map: map,
		  title: s.title,
  		});
	}
      }
    </script>
    <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDZ8Bm6MbFrfZ37ko8UTCDErLVQa5DBn8M&callback=initMap"
    async defer></script>
  </body>
</html>
{{end}}
`))<commit_msg>Map: bring up infowindows on click.<commit_after>package waveguide

import "html/template"

var tmpl = template.Must(template.New("").Parse(`
{{define "header"}}
<html>
        <head>
                <title>Waveguide</title>
                <style>
                        body {
                                font-family: monospace;
                        }
                        table {
                                border-collapse: separate;
                                font-size: 12pt;
                        }
                        th {
                                text-align: left;
                        }
                        th, td {
                                padding: 0 1em 0.5ex 0;
                        }
                        form {
                        	margin: 0
                        }
                </style>
        </head>
        <body>
{{end}}

{{define "footer"}}
	</body>
</html>
{{end}}

{{define "root"}}
{{template "header"}}
                <table>
                	{{if .Spots}}
				<thead>
					<th>Location</th>
					<th>Coordinates</th>
					<th>Conditions</th>
					<th>Wave Height</th>
					<th>Last Updated</th>
				</thead>
				<tbody>
					{{range .Spots}}
						<tr>
							<td><a href="{{.MapURL}}">{{.HTMLName}}</a></td>
							<td>
								{{if .HasCoordinates}}
									<a href="{{.ClearCoordsURL}}">❌</a>
									<a href="{{.MapsURL}}">{{.FormattedCoordinates}}</a>
								{{else}}
									<form action="/coords" method="post">
										<input type="hidden" name="path" value="{{.MswPath}}" />
										<input name="coordinates" />
										<button type="submit">Submit</button>
									</form>
								{{end}}
							</td>
							<td><a href="{{.ReportURL}}">{{.Cond.Stars}}</a></td>
							<td>{{.Cond.WaveHeight}}</td>
							<td>{{.Cond.HowLong}} ago</td>
						</tr>
					{{end}}
				</tbody>
			{{else}}
				There's no data yet. You can get some by visiting <a href="/update_all">/update_all</a>.
			{{end}}
                </table>
{{template "footer"}}
{{end}}

{{define "action_response"}}
{{template "header"}}
		<div><a href="/">← home</a></div>
		<div id="message">{{.Message}}</div>
{{template "footer"}}
{{end}}

{{define "map"}}
<!DOCTYPE html>
<!-- TODO: factor out header and footer. -->
<html>
	<head>
		<title>Waveguide</title>
		<meta name="viewport" content="initial-scale=1.0">
		<meta charset="utf-8">
		<style>
#map {
	height: 100%;
}
html, body {
      height: 100%;
      margin: 0;
      padding: 0;
}
		</style>
	</head>
	<body>
		<div id="map"></div>
		<script>
var map;

var addSpot = function(s) {
	if (s.lat == 0 && s.lng == 0) {
		return;
	}
	var latLng = {lat: s.lat, lng: s.lng}
	var marker = new google.maps.Marker({
		position: latLng,
		map: map,
		title: s.title,
	});
	var infowindow = new google.maps.InfoWindow({
		content: s.title + '\n' + s.stars,
		map: map,
		position: latLng,
	});
	infowindow.close();
	marker.addListener('click', function() {
		infowindow.open(map, marker);
	});
};

function initMap() {
	map = new google.maps.Map(document.getElementById('map'), {
		center: {lat: 20.8020856, lng: -156.8984559},
		zoom: 2
	});

	{{range .}}
		var s = {title: '{{.Name}}', stars: "{{.Cond.Stars}}", lat: {{.Coordinates.Lat}}, lng: {{.Coordinates.Lng}}, rating: {{.Cond.Rating}} };
		addSpot(s);
	{{end}}
}
		</script>
		<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDZ8Bm6MbFrfZ37ko8UTCDErLVQa5DBn8M&callback=initMap" async defer></script>
	</body>
</html>
{{end}}
`))
{'fraction_non_alphanumeric': 0.1905166312809625, 'fraction_numerical': 0.01372965322009908, 'mean_word_length': 1.6866920152091254, 'pattern_counts': {'":': 0, '<': 163, '<?xml version=': 0, '>': 162, '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': '708078', 'n_tokens_mistral': 2876, 'n_tokens_neox': 2323, 'n_words': 490}