changeset 10:8780755f38a1

Refactor per-material alloy result table code.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 04 Jan 2016 10:45:20 +0200
parents 3c3fadcf13f2
children 2808bc76a2fa
files info.php
diffstat 1 files changed, 3 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/info.php	Mon Jan 04 10:43:48 2016 +0200
+++ b/info.php	Mon Jan 04 10:45:20 2016 +0200
@@ -310,18 +310,6 @@
     echo "<h3>Alloy combinations</h3>\n";
     if (isset($alloyRevTable[$setShowMat]))
     {
-      echo
-        "<table class=\"alloyTable\">".
-        " <tr>\n".
-        "  <th>+</th>\n";
-
-      foreach ($alloyRevTable[$setShowMat] as $key => $value)
-      {
-        echo "<th>".stGetMatLink($key)."</th>\n";
-      }
-      echo
-        " </tr>\n";
-
       $ptable1 = [];
       $ptable2 = [];
       foreach ($matDataTable as $name1 => $data1)
@@ -331,30 +319,10 @@
         $ptable1[$name1] = 1;
         $ptable2[$name2] = 1;
       }
-      
-      foreach ($ptable2 as $name2 => $pz2)
-      {
-        echo "<tr><th>".stGetMatLink($name2)."</th>";
-        foreach ($ptable1 as $name1 => $pz1)
-        {
-          $hit = isset($alloyRevTable[$setShowMat][$name1][$name2]);
 
-          if ($hit)
-          {
-            $str = [];
-            foreach ($alloyTable[$name1][$name2] as $mnam => $mdat)
-              $str[] = $mnam;
-          }
-
-          echo "<td title=\"".$name2." + ".$name1."\" class=\"".
-            ($hit ? stGetReliabilityClass($alloyRevTable[$setShowMat][$name1][$name2]) : "nohits")."\">".
-            ($hit ? implode(", ", $str) : "")."</td>";
-        }
-        echo "</tr>\n";
-      }
-
-      echo
-        "</table>\n";
+      ksort($ptable1);
+      ksort($ptable2);
+      stPrintAlloyTable("alloyTable", array_keys($ptable1), array_keys($ptable2), FALSE, $setShowMat);
     }
     else
     {