<commit_before><html>
  <head>
    <title>Dashboard</title>
    <link rel="stylesheet" type="text/css" href="html/stylesheet.css">
  </head>
  <script>
    function change_size(size) {
      document.dash.action = "dashboard.php";
      document.dash.size.value=size;
      document.dash.submit();
    }
    function change_date(date,direction) {
      document.dash.action = "dashboard.php";
      document.dash.start_date.value=date;
      document.dash.direction.value=direction;
      document.dash.submit();
    }
    function go_calendar(sensor) {
      document.dash.action = "year_cal.php";
      document.dash.sensor.value=sensor;
      document.dash.submit();
    }
    function back_button() {
      document.home.action = "year_cal.php";
      document.home.submit();
    } 
    function home_button() {
      document.home.action = "index.php";
      document.home.submit();
    }    
    function go_graph() {
      document.home.action = "graphs/histogram.php";
      document.home.submit();
    }    
  </script>
  <body>
<?php
require_once ("Carbon/Carbon.php");
use Carbon\Carbon;
include 'globals.php';
$range_width=100;
$graph_width=1000;
$width_pix = array(300, 600, 1000);
$height_pix = array(150, 300, 500);

$start_date_param = htmlspecialchars($_GET["start_date"]);
$direction_param = htmlspecialchars($_GET["direction"]);
if(!isset($_GET["size"])) $size=1;
  else $size = htmlspecialchars($_GET["size"]);
if($size==0) $default_size_0="selected='selected'";
if($size==1) $default_size_1="selected='selected'";
if($size==2) $default_size_2="selected='selected'";

$conn=mysqli_connect("", "", "", $db_name);
if (mysqli_connect_errno()) {
  exit('Failed to connect to MySQL: ' . mysqli_connect_error());
} 

if(strlen($start_date_param)<=0) {
	$result=mysqli_query($conn,"SELECT MAX(ts) as ts from readings WHERE core_id=$id");
} else if(strcmp($direction_param, "next")==0) { // Next button pressed
	$dt = Carbon::createFromFormat($param_date_format, $start_date_param);
	$dt_utc = $dt->startOfDay()->format('U');
	$result=mysqli_query($conn,"SELECT MIN(ts) as ts from readings WHERE core_id=$id and ts > $dt_utc");
} else { // previous button pressed
	$dt = Carbon::createFromFormat($param_date_format, $start_date_param);
	$dt_utc = $dt->endOfDay()->format('U');
	$result=mysqli_query($conn,"SELECT MAX(ts) as ts from readings WHERE core_id=$id and ts < $dt_utc");
}
if(mysql_errno()) {
  exit('Error: '.mysqli_error($conn));
}
$row = mysqli_fetch_array($result);
if(!isset($row['ts'])) {
  echo "No records found";
} else {
  $date = Carbon::createFromTimeStamp($row['ts']);
  $start_day_utc = $date->startOfDay()->format('U');
  $prev_day_str = $date->copy()->subDay()->format($param_date_format);
  $next_day_str = $date->copy()->addDay()->format($param_date_format);
  $end_day_utc = $date->endOfDay()->format('U');
  
  echo "<div style='padding:10px;'>";
  echo "<table border=0>";
  echo "<tr><td width=$range_width></td><td width =$graph_width></td><td width=100></td></tr>";
  echo "<tr><td colspan=3>";
  echo "<table border=0 width=100%>";
  echo "<tr><td>";
  echo "<h2>Indoor Air Quality Dashboard</h2>";
  echo "</td><td width='400' style='vertical-align:top'>";

  $location_result=mysqli_query($conn,"SELECT location_name from locations WHERE core_id=$id and ts = ".
				  "(SELECT MAX(ts) as ts from locations WHERE core_id=$id and ts <= $end_day_utc and location_name is not null)");
  $location_row = mysqli_fetch_array($location_result);  
  $location_name=$location_row['location_name'];
  echo "<span style='padding:4px 10px 4px 10px;font-size:20px;font-weight:bold;color:#CC6666;vertical-align:top;'>";
  echo $sensor_name;  
  if(strlen($location_name)>0) 
    echo " - ".$location_name;
  echo "</span>";
  echo "</td>";
  echo "<td align=right><img src='images/back.png' onclick='back_button();' height=30 width=30 style='cursor:pointer;'>\n";    
  echo "<img src='images/home.png' onclick='home_button();' height=30 width=30 style='cursor:pointer;'></td>\n";  
  echo "</tr>";
  echo "</table>";  
  echo "<tr>";
  echo "<td colspan=2 width=$graph_width align=center>";
  echo "<table border=0>";
  echo "<tr>";
  echo "  <td align='right'><input type='button' value='&lt; Previous' onclick='change_date(\"$prev_day_str\",\"prev\")'></td>";
  echo "  <td width='300' align=center >";
  echo "  <input type='button' value='".$date->format('l, F jS Y')."' onclick='go_graph();'>";
  echo "  </td>";
  echo "  <td><input type='button' value='Next    &gt;' onclick='change_date(\"$next_day_str\",\"next\")'></td>";
  echo "</tr>";
  echo "</table>";<commit_msg>Add geographical information to top of page<commit_after><html>
  <head>
    <title>Dashboard</title>
    <link rel="stylesheet" type="text/css" href="html/stylesheet.css">
  </head>
  <script>
    function change_size(size) {
      document.dash.action = "dashboard.php";
      document.dash.size.value=size;
      document.dash.submit();
    }
    function change_date(date,direction) {
      document.dash.action = "dashboard.php";
      document.dash.start_date.value=date;
      document.dash.direction.value=direction;
      document.dash.submit();
    }
    function go_calendar(sensor) {
      document.dash.action = "year_cal.php";
      document.dash.sensor.value=sensor;
      document.dash.submit();
    }
    function back_button() {
      document.home.action = "year_cal.php";
      document.home.submit();
    } 
    function home_button() {
      document.home.action = "index.php";
      document.home.submit();
    }    
    function go_graph() {
      document.home.action = "graphs/histogram.php";
      document.home.submit();
    }    
  </script>
  <body>
<?php
require_once ("Carbon/Carbon.php");
use Carbon\Carbon;
include 'globals.php';
$range_width=100;
$graph_width=1000;
$width_pix = array(300, 600, 1000);
$height_pix = array(150, 300, 500);

$start_date_param = htmlspecialchars($_GET["start_date"]);
$direction_param = htmlspecialchars($_GET["direction"]);
if(!isset($_GET["size"])) $size=1;
  else $size = htmlspecialchars($_GET["size"]);
if($size==0) $default_size_0="selected='selected'";
if($size==1) $default_size_1="selected='selected'";
if($size==2) $default_size_2="selected='selected'";

$conn=mysqli_connect("", "", "", $db_name);
if (mysqli_connect_errno()) {
  exit('Failed to connect to MySQL: ' . mysqli_connect_error());
} 

if(strlen($start_date_param)<=0) {
	$result=mysqli_query($conn,"SELECT MAX(ts) as ts from readings WHERE core_id=$id");
} else if(strcmp($direction_param, "next")==0) { // Next button pressed
	$dt = Carbon::createFromFormat($param_date_format, $start_date_param);
	$dt_utc = $dt->startOfDay()->format('U');
	$result=mysqli_query($conn,"SELECT MIN(ts) as ts from readings WHERE core_id=$id and ts > $dt_utc");
} else { // previous button pressed
	$dt = Carbon::createFromFormat($param_date_format, $start_date_param);
	$dt_utc = $dt->endOfDay()->format('U');
	$result=mysqli_query($conn,"SELECT MAX(ts) as ts from readings WHERE core_id=$id and ts < $dt_utc");
}
if(mysql_errno()) {
  exit('Error: '.mysqli_error($conn));
}
$row = mysqli_fetch_array($result);
if(!isset($row['ts'])) {
  echo "No records found";
} else {
  $date = Carbon::createFromTimeStamp($row['ts']);
  $start_day_utc = $date->startOfDay()->format('U');
  $prev_day_str = $date->copy()->subDay()->format($param_date_format);
  $next_day_str = $date->copy()->addDay()->format($param_date_format);
  $end_day_utc = $date->endOfDay()->format('U');
  
  echo "<div style='padding:10px;'>";
  echo "<table border=0>";
  echo "<tr><td width=$range_width></td><td width =$graph_width></td><td width=100></td></tr>";
  echo "<tr><td colspan=3>";
  echo "<table border=0 width=100%>";
  echo "<tr><td>";
  echo "<h2>Indoor Air Quality Dashboard</h2>";
  echo "</td><td width='400' style='vertical-align:top'>";

  $geo_result=mysqli_query($conn,"SELECT name from geographical WHERE core_id=$id and ts = ".
				  "(SELECT MAX(ts) as ts from geographical WHERE core_id=$id and ts <= $end_day_utc)");
  $geo_row = mysqli_fetch_array($geo_result);  
  $geo_name=$geo_row['name'];
  echo "<span style='padding:4px 10px 4px 10px;font-size:20px;font-weight:bold;color:#CC6666;vertical-align:top;'>";
  echo $sensor_name;  
  if(strlen($geo_name)>0) 
    echo " - ".$geo_name;
  echo "</span>";
  echo "</td>";
  echo "<td align=right><img src='images/back.png' onclick='back_button();' height=30 width=30 style='cursor:pointer;'>\n";    
  echo "<img src='images/home.png' onclick='home_button();' height=30 width=30 style='cursor:pointer;'></td>\n";  
  echo "</tr>";
  echo "</table>";  
  echo "<tr>";
  echo "<td colspan=2 width=$graph_width align=center>";
  echo "<table border=0>";
  echo "<tr>";
  echo "  <td align='right'><input type='button' value='&lt; Previous' onclick='change_date(\"$prev_day_str\",\"prev\")'></td>";
  echo "  <td width='300' align=center >";
  echo "  <input type='button' value='".$date->format('l, F jS Y')."' onclick='go_graph();'>";
  echo "  </td>";
  echo "  <td><input type='button' value='Next    &gt;' onclick='change_date(\"$next_day_str\",\"next\")'></td>";
  echo "</tr>";
  echo "</table>";
{'fraction_non_alphanumeric': 0.20141689373297003, 'fraction_numerical': 0.01678474114441417, 'mean_word_length': 4.9661898569570875, 'pattern_counts': {'":': 0, '<': 115, '<?xml version=': 0, '>': 141, 'https://': 0, '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': '5171536', 'n_tokens_mistral': 3317, 'n_tokens_neox': 3191, 'n_words': 586}