<commit_before><div id="container"><div id="menu">

<div id="menu_row">
  <div id="menu_cell">
  &nbsp;
  <form name="opts" method="get" action="index.php">
    &nbsp;Environment:&nbsp;
    <div id="select"><select name="env" onchange="document.opts.c.value = ''; document.opts.h.value = ''; document.opts.submit()">
      <option value="">Select environment</option>
<?php
$environment_search = json_decode(file_get_contents($conf['graphite_search_url'] . $conf['graphite_prefix'] . "*"), TRUE);
foreach ($environment_search['results'] as $environment) {
    $environment_name = str_replace($conf['graphite_prefix'], "", $environment);
    if ($environment_name == $env) { $selected = "selected=\"selected\""; }
    else { $selected = ""; }
    print "<option value=\"$environment_name\" $selected>$environment_name</option>\n";
}
?>
    </select></div>
    &nbsp;Cluster:&nbsp;
    <div id="select"><select name="c" onchange="document.opts.h.value = ''; document.opts.submit()">
<?php
$cluster_search = json_decode(file_get_contents($conf['graphite_search_url'] . $conf['graphite_prefix'] . "$env.*"), TRUE);
if (sizeof($cluster_search['results']) < 1) { $default = "None"; }
else { $default = "All"; }
print "<option value=\"\">$default</option>";
foreach ($cluster_search['results'] as $cluster) {
    $cluster_name = str_replace($conf['graphite_prefix'] . "$env.", "", $cluster);
    if ($cluster_name == $c) { $selected = "selected=\"selected\""; }
    else { $selected = ""; }
    print "<option value=\"$cluster_name\" $selected>$cluster_name</option>\n";
}
?>
    </select></div>
    &nbsp;Host:&nbsp;
    <div id="select"><select name="h" onchange="document.opts.submit()">
<?php
$host_search = json_decode(file_get_contents($conf['graphite_search_url'] . $conf['graphite_prefix'] . "$env.$c.*"), TRUE);
if (sizeof($host_search['results']) < 1) { $default = "None"; }
else { $default = "All"; }
print "<option value=\"\">$default</option>";
foreach ($host_search['results'] as $host) {
    $host_name = str_replace($conf['graphite_prefix'] . "$env.$c.", "", $host);
    if ($host_name == $h) { $selected = "selected=\"selected\""; }
    else { $selected = ""; }
    print "<option value=\"$host_name\" $selected>$host_name</option>\n";
}
?>
    </select></div>
<?php
if (isset($m)) {
    $onchange = "document.opts.m.value = ''; document.opts.submit();";
} else {
    $onchange = "document.opts.submit();";<commit_msg>Pretty sorting of dropdowns<commit_after><div id="container"><div id="menu">

<div id="menu_row">
  <div id="menu_cell">
  &nbsp;
  <form name="opts" method="get" action="index.php">
    &nbsp;Environment:&nbsp;
    <div id="select"><select name="env" onchange="document.opts.c.value = ''; document.opts.h.value = ''; document.opts.submit()">
      <option value="">Select environment</option>
<?php
$environment_search = json_decode(file_get_contents($conf['graphite_search_url'] . $conf['graphite_prefix'] . "*"), TRUE);
$environments = $environment_search['results'];
natsort($environments);

$cluster_search = json_decode(file_get_contents($conf['graphite_search_url'] . $conf['graphite_prefix'] . "$env.*"), TRUE);
$clusters = $cluster_search['results'];
natsort($clusters);

$host_search = json_decode(file_get_contents($conf['graphite_search_url'] . $conf['graphite_prefix'] . "$env.$c.*"), TRUE);
$hosts = $host_search['results'];
natsort($hosts);

foreach ($environments as $environment) {
    $environment_name = str_replace($conf['graphite_prefix'], "", $environment);
    if ($environment_name == $env) { $selected = "selected=\"selected\""; }
    else { $selected = ""; }
    print "<option value=\"$environment_name\" $selected>$environment_name</option>\n";
}
?>
    </select></div>
    &nbsp;Cluster:&nbsp;
    <div id="select"><select name="c" onchange="document.opts.h.value = ''; document.opts.submit()">
<?php

if (sizeof($clusters) < 1) { $default = "None"; }
else { $default = "All"; }
print "<option value=\"\">$default</option>";
foreach ($clusters as $cluster) {
    $cluster_name = str_replace($conf['graphite_prefix'] . "$env.", "", $cluster);
    if ($cluster_name == $c) { $selected = "selected=\"selected\""; }
    else { $selected = ""; }
    print "<option value=\"$cluster_name\" $selected>$cluster_name</option>\n";
}
?>
    </select></div>
    &nbsp;Host:&nbsp;
    <div id="select"><select name="h" onchange="document.opts.submit()">
<?php

if (sizeof($hosts) < 1) { $default = "None"; }
else { $default = "All"; }
print "<option value=\"\">$default</option>";
foreach ($hosts as $host) {
    $host_name = str_replace($conf['graphite_prefix'] . "$env.$c.", "", $host);
    if ($host_name == $h) { $selected = "selected=\"selected\""; }
    else { $selected = ""; }
    print "<option value=\"$host_name\" $selected>$host_name</option>\n";
}
?>
    </select></div>
<?php
if (isset($m)) {
    $onchange = "document.opts.m.value = ''; document.opts.submit();";
} else {
    $onchange = "document.opts.submit();";
{'fraction_non_alphanumeric': 0.22964005630404183, 'fraction_numerical': 0.0008043434546551378, 'mean_word_length': 5.209737827715355, 'pattern_counts': {'":': 0, '<': 73, '<?xml version=': 0, '>': 67, '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': '386899', 'n_tokens_mistral': 1633, 'n_tokens_neox': 1605, 'n_words': 291}