<commit_before><?php
require_once('common/header.php');
require_once('common/navigation.php');
if($error) {
   return;
}
if(getYearForCurrentSeason($output) !== 1) {
   die('unable to get year for current season');
} else {
   $current_season = $output['season']['year'];
}
function getColor($regionID, $seasonID) {
   $r = intval((sin(($seasonID - 2004) * 0.4 + 0) + 1) / 2 * 15);
   $g = intval((sin(($seasonID - 2004) * 0.5 + 2) + 1) / 2 * 15);
   $b = intval((sin(($seasonID - 2004) * 0.6 + 4) + 1) / 2 * 15);
   return sprintf('#%x%x%x', $r, $g, $b);
}

//Epiweek info
if(getEpiweekInfo($output) !== 1) {
   fail('Error loading epiweek info');
}
//List of all regions
if(getRegionsExtended($output, $output['user_id']) !== 1) {
   fail('Error loading region details, history, or forecast');
}
if(isset($_REQUEST['skip_instructions'])) {
   $output['user_preferences']['skip_instructions'] = 1;
   if(saveUserPreferences($output, $output['user_id'], $output['user_preferences']) !== 1) {
      fail('Error updating preferences');
   }
}
if(isset($_REQUEST['region_id'])) {
   $regionID = intval(mysql_real_escape_string($_REQUEST['region_id']));
} else {
   //Default to USA National
   $regionID = 1;
}
//Specific region
if(!isset($output['regions'][$regionID])) {
   fail('Invalid region_id');
}
//Forecast from last round
if(loadForecast($output, $output['user_id'], $regionID, true) !== 1) {
   fail('Error loading last week forecast');
}
$lastForecast = $output['forecast'];
$region = $output['regions'][$regionID];
$num = count($output['regions']);
//History for this region
$output['history'] = &$output['regions'][$regionID]['history'];
//User's previous forecast for this region
$output['forecast'] = &$output['regions'][$regionID]['forecast'];
//Settings
$showPandemic = getPreference($output, 'advanced_pandemic', 'int');
//Calculate a few helpful stats
$firstWeekOfChart = 30;
$currentWeek = $output['epiweek']['round_epiweek'];
if(($currentWeek % 100) >= $firstWeekOfChart) {
   $yearStart = intval($currentWeek / 100);
} else {
   $yearStart = intval($currentWeek / 100) - 1;
}
$seasonStart = $yearStart * 100 + $firstWeekOfChart;
$seasonEnd = ($yearStart + 1) * 100 + ($firstWeekOfChart - 1);
$numPastWeeks = getDeltaWeeks($seasonStart, $currentWeek);
$numFutureWeeks = getDeltaWeeks($currentWeek, $seasonEnd);
$maxRegionalWILI = 0;
for($i = 0; $i < count($region['history']['wili']); $i++) {
   $epiweek = $region['history']['date'][$i];
   if($showPandemic || $epiweek < 200940 || $epiweek > 201020) {
      $maxRegionalWILI = max($maxRegionalWILI, $region['history']['wili'][$i]);
   }
}
max($region['history']['wili']);
$target = $seasonStart;
$seasonOffsets = array();
$seasonYears = array();
for($i = count($region['history']['date']) - 1; $i >= 0; $i--) {
   if($region['history']['date'][$i] <= $target) {
      array_push($seasonOffsets, $i);
      array_push($seasonYears, intval($target / 100));
      $target -= 100;
   }
}
if($seasonOffsets[count($seasonOffsets) - 1] != 0) {
   array_push($seasonOffsets, 0);
   array_push($seasonYears, intval($target / 100));
}
$seasonOffsets = array_reverse($seasonOffsets);
$seasonYears = array_reverse($seasonYears);
//Nowcast (may or may not be available)
getNowcast($output, addEpiweeks($currentWeek, 1), $regionID);
if(getPreference($output, 'skip_instructions', 'int') !== 1) {
   ?>
   <div class="box_section">
      <div class="box_section_title">
         How to Enter Your Forecast
         <div class="box_section_subtitle">Draw your forecast curve across the chart by clicking and dragging.</div>
      </div>
      <div class="centered">
         <p>
            <b></b><br />
            &nbsp;<i class="fa fa-angle-right"></i>&nbsp; You can draw <i>in one motion</i> the entire trajectory.<br />
            &nbsp;<i class="fa fa-angle-right"></i>&nbsp; You can edit any part of your forecast by redrawing just that part.<br />
            &nbsp;<i class="fa fa-angle-right"></i>&nbsp; You can adjust a single point by dragging it up or down.<br />
            The animation below demonstrates these actions.
            (If you don't see the animation, click <a target="_blank" href="images/tutorial.gif">here</a>.)
         </p>
         <video width="1112" height="480" controls autoplay loop>
            <source src="images/tutorial.mp4" type="video/mp4">
            Your browser does not support the video tag.
         </video>
         <p>
            <?php
            createForm('reload', 'forecast.php#top', array('region_id', $regionID, 'skip_instructions', '1'));
            button('fa-check', 'I Understand', "submit('reload')");
            ?>
         </p>
      </div>
   </div>
   <?php
} else {
?>
<?php
foreach($output['regions'] as $r) {
   createForm('forecast_' . $r['id'], 'forecast.php#top', array('region_id', $r['id']));
}
?>
<?php fail('Whoa, your screen is too small! Please visit this site on a non-mobile device, or try to expand your browser window. Sorry about that!', 'box_nocanvas', true); ?>
<div id="box_main_ui">
   <div id="box_status" class="box_status any_neutral right">
      <div class="box_status_line">
         <div class="box_region_label">
            <?= htmlspecialchars($region['name']) ?>
            <span style="font-size: 0.67em;">
               [<?= htmlspecialchars($region['states']) ?>]
            </span>
         </div>
         <div style="float: right;">
            <?php button('fa-upload', 'Save &amp; Continue', "submitForecast(true)", '', 'button_submit'); ?>
            <?php 
               if ($ifAllLocation) print "admin";
            ?>
         </div>
         <div class="box_status_info">
            <span id="status_message">Draw your forecast by clicking and dragging across the chart below.</span>
            <span id="status_icon"><i class="fa fa-info-circle"></i></span>
         </div>
         <div style="clear: both;"></div>
      </div>
   </div>
   <div id="box_side_bar">
      <div id="box_histories">
         <div class="box_decision_title centered" style="width: 100%;">History</div>
         <?php
         foreach($output['regions'] as $r) {<commit_msg>debug print<commit_after><?php
require_once('common/header.php');
require_once('common/navigation.php');
if($error) {
   return;
}
if(getYearForCurrentSeason($output) !== 1) {
   die('unable to get year for current season');
} else {
   $current_season = $output['season']['year'];
}
function getColor($regionID, $seasonID) {
   $r = intval((sin(($seasonID - 2004) * 0.4 + 0) + 1) / 2 * 15);
   $g = intval((sin(($seasonID - 2004) * 0.5 + 2) + 1) / 2 * 15);
   $b = intval((sin(($seasonID - 2004) * 0.6 + 4) + 1) / 2 * 15);
   return sprintf('#%x%x%x', $r, $g, $b);
}

//Epiweek info
if(getEpiweekInfo($output) !== 1) {
   fail('Error loading epiweek info');
}
//List of all regions
if(getRegionsExtended($output, $output['user_id']) !== 1) {
   fail('Error loading region details, history, or forecast');
}
if(isset($_REQUEST['skip_instructions'])) {
   $output['user_preferences']['skip_instructions'] = 1;
   if(saveUserPreferences($output, $output['user_id'], $output['user_preferences']) !== 1) {
      fail('Error updating preferences');
   }
}
if(isset($_REQUEST['region_id'])) {
   $regionID = intval(mysql_real_escape_string($_REQUEST['region_id']));
} else {
   //Default to USA National
   $regionID = 1;
}
//Specific region
if(!isset($output['regions'][$regionID])) {
   fail('Invalid region_id');
}
//Forecast from last round
if(loadForecast($output, $output['user_id'], $regionID, true) !== 1) {
   fail('Error loading last week forecast');
}
$lastForecast = $output['forecast'];
$region = $output['regions'][$regionID];
$num = count($output['regions']);
//History for this region
$output['history'] = &$output['regions'][$regionID]['history'];
//User's previous forecast for this region
$output['forecast'] = &$output['regions'][$regionID]['forecast'];
//Settings
$showPandemic = getPreference($output, 'advanced_pandemic', 'int');
//Calculate a few helpful stats
$firstWeekOfChart = 30;
$currentWeek = $output['epiweek']['round_epiweek'];
if(($currentWeek % 100) >= $firstWeekOfChart) {
   $yearStart = intval($currentWeek / 100);
} else {
   $yearStart = intval($currentWeek / 100) - 1;
}
$seasonStart = $yearStart * 100 + $firstWeekOfChart;
$seasonEnd = ($yearStart + 1) * 100 + ($firstWeekOfChart - 1);
$numPastWeeks = getDeltaWeeks($seasonStart, $currentWeek);
$numFutureWeeks = getDeltaWeeks($currentWeek, $seasonEnd);
$maxRegionalWILI = 0;
for($i = 0; $i < count($region['history']['wili']); $i++) {
   $epiweek = $region['history']['date'][$i];
   if($showPandemic || $epiweek < 200940 || $epiweek > 201020) {
      $maxRegionalWILI = max($maxRegionalWILI, $region['history']['wili'][$i]);
   }
}
max($region['history']['wili']);
$target = $seasonStart;
$seasonOffsets = array();
$seasonYears = array();
for($i = count($region['history']['date']) - 1; $i >= 0; $i--) {
   if($region['history']['date'][$i] <= $target) {
      array_push($seasonOffsets, $i);
      array_push($seasonYears, intval($target / 100));
      $target -= 100;
   }
}
if($seasonOffsets[count($seasonOffsets) - 1] != 0) {
   array_push($seasonOffsets, 0);
   array_push($seasonYears, intval($target / 100));
}
$seasonOffsets = array_reverse($seasonOffsets);
$seasonYears = array_reverse($seasonYears);
//Nowcast (may or may not be available)
getNowcast($output, addEpiweeks($currentWeek, 1), $regionID);
if(getPreference($output, 'skip_instructions', 'int') !== 1) {
   ?>
   <div class="box_section">
      <div class="box_section_title">
         How to Enter Your Forecast
         <div class="box_section_subtitle">Draw your forecast curve across the chart by clicking and dragging.</div>
      </div>
      <div class="centered">
         <p>
            <b></b><br />
            &nbsp;<i class="fa fa-angle-right"></i>&nbsp; You can draw <i>in one motion</i> the entire trajectory.<br />
            &nbsp;<i class="fa fa-angle-right"></i>&nbsp; You can edit any part of your forecast by redrawing just that part.<br />
            &nbsp;<i class="fa fa-angle-right"></i>&nbsp; You can adjust a single point by dragging it up or down.<br />
            The animation below demonstrates these actions.
            (If you don't see the animation, click <a target="_blank" href="images/tutorial.gif">here</a>.)
         </p>
         <video width="1112" height="480" controls autoplay loop>
            <source src="images/tutorial.mp4" type="video/mp4">
            Your browser does not support the video tag.
         </video>
         <p>
            <?php
            createForm('reload', 'forecast.php#top', array('region_id', $regionID, 'skip_instructions', '1'));
            button('fa-check', 'I Understand', "submit('reload')");
            ?>
         </p>
      </div>
   </div>
   <?php
} else {
?>
<?php
foreach($output['regions'] as $r) {
   createForm('forecast_' . $r['id'], 'forecast.php#top', array('region_id', $r['id']));
}
?>
<?php fail('Whoa, your screen is too small! Please visit this site on a non-mobile device, or try to expand your browser window. Sorry about that!', 'box_nocanvas', true); ?>
<div id="box_main_ui">
   <div id="box_status" class="box_status any_neutral right">
      <div class="box_status_line">
         <div class="box_region_label">
            <?= htmlspecialchars($region['name']) ?>
            <span style="font-size: 0.67em;">
               [<?= htmlspecialchars($region['states']) ?>]
            </span>
         </div>
         <div style="float: right;">
            <?php button('fa-upload', 'Save &amp; Continue', "submitForecast(true)", '', 'button_submit'); ?>
            <?php 
               $ifAllLocation = getPreference($output, 'allLocation', 'int');
               if ($ifAllLocation) print "admin";
            ?>
         </div>
         <div class="box_status_info">
            <span id="status_message">Draw your forecast by clicking and dragging across the chart below.</span>
            <span id="status_icon"><i class="fa fa-info-circle"></i></span>
         </div>
         <div style="clear: both;"></div>
      </div>
   </div>
   <div id="box_side_bar">
      <div id="box_histories">
         <div class="box_decision_title centered" style="width: 100%;">History</div>
         <?php
         foreach($output['regions'] as $r) {
{'fraction_non_alphanumeric': 0.1891891891891892, 'fraction_numerical': 0.01715487943032853, 'mean_word_length': 3.6637735849056603, 'pattern_counts': {'":': 0, '<': 141, '<?xml version=': 0, '>': 139, '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': '303676', 'n_tokens_mistral': 4200, 'n_tokens_neox': 3937, 'n_words': 935}