Browse Source

Update interactive energy point plots

Implemented selector for the season (now RHO2018 and NNBAR2021 are available)
compton 2 years ago
parent
commit
d37deeb29e
1 changed files with 16 additions and 5 deletions
  1. 16 5
      page/init.php

+ 16 - 5
page/init.php

@@ -2,10 +2,10 @@
 <!-- https://towardsdatascience.com/4-ways-to-improve-your-plotly-graphs-517c75947f7e -->
 
 <?php
-$selected_csv = 
-
 $branch = 'dev';
-$season = 'NNBAR2021';
+$availableSeasons = array("RHO2018", "NNBAR2021");
+
+$season = isset($_GET["season"])&&in_array($_GET["season"], $availableSeasons) ? $_GET["season"] : reset($availableSeasons);
 $url = "https://cmd.inp.nsk.su/~compton/gitlist/compton_tables/raw/".$branch."/tables/".$season."/";
 $url_total_info = "https://cmd.inp.nsk.su/~compton/gitlist/compton_tables/raw/".$branch."/tables/".$season.".csv";
 $text = file_get_contents($url);
@@ -22,7 +22,7 @@ function isSelected($a, $b){
     return "";
 }
 
-$selected_csv = isset($_GET["csv_file"]) ? $_GET["csv_file"] : reset($cleanArrs);
+$selected_csv = isset($_GET["csv_file"])&&in_array($_GET["csv_file"], $cleanArrs) ? $_GET["csv_file"] : reset($cleanArrs);
 
 ?>
 
@@ -40,7 +40,17 @@ $selected_csv = isset($_GET["csv_file"]) ? $_GET["csv_file"] : reset($cleanArrs)
             
     <form name="form" action="" method="get">
         <p style="text-align: center;">Select energy point:</p>
-        <select name="csv_file" class="select-css" onchange="this.form.submit()">
+	<div style="margin: 0 auto; display: flex; justify-content: center;">
+	<select name="season" class="select-css" style="margin: 0;" onchange="this.form.submit()">
+	<?
+	    foreach($availableSeasons as $s){
+	    ?><option value="<?echo $s?>" <?echo isSelected($s, $season)?>><?echo $s?></option>
+	    <?
+	    }
+	?>
+
+	</select>
+        <select name="csv_file" class="select-css" style="margin: 0;" onchange="this.form.submit()">
             <?
             foreach($cleanArrs as $file){
                 ?><option value="<?echo $file?>" <?echo isSelected($file, $selected_csv)?>><?echo $file?></option>
@@ -48,6 +58,7 @@ $selected_csv = isset($_GET["csv_file"]) ? $_GET["csv_file"] : reset($cleanArrs)
             }
             ?>
         </select>
+	</div>
     </form>