changeset 119:959ba6d00c05 misc

Updated.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 19 Dec 2010 21:15:21 +0000
parents 08373f9769d3
children b1f88a66e3e9
files materials/alloy.php materials/index.php materials/mkalloyinfo.sh materials/submit.php
diffstat 4 files changed, 36 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/materials/alloy.php	Sun Dec 19 21:13:06 2010 +0000
+++ b/materials/alloy.php	Sun Dec 19 21:15:21 2010 +0000
@@ -22,11 +22,11 @@
  <tr>
   <th width="25%">Show type</th>
   <td rowspan="3" class="infobox">
-   Only 2-material alloys are supported by this browser. It is known, that there are
-   at least SOME 3-material alloys, and naturally the "all but one" of given
-   material class combination. There may be bugs and lots of combinations are not researched yet.
-   <br />
-   <b>You can now help! We have a <a href="submit.php">submission form</a>.</b>
+   <ul>
+    <li>Only 2-material alloys are supported by this browser.</li>
+    <li>There may be bugs and lots of combinations are not researched yet.</li>
+    <li><b>You can now help! We have a <a href="submit.php">submission form</a>!</b></li>
+   </ul>
   </td>
  </tr>
  <tr>
--- a/materials/index.php	Sun Dec 19 21:13:06 2010 +0000
+++ b/materials/index.php	Sun Dec 19 21:15:21 2010 +0000
@@ -1,5 +1,5 @@
 <?
-$pageTitle = "BatMUD Material Browser";
+$pageTitle = "Ggr's BatMUD Material Browser";
 $pageIndex = "index.php";
 require "materials.inc.php";
 
@@ -28,9 +28,9 @@
   $filterTable = array();
 
 
-if (isset($_GET["o"])) {
+if (isset($_GET["o"]))
   $showOnly = intval($_GET["o"]);
-} else
+else
   $showOnly = -1;
 
 
@@ -79,14 +79,16 @@
   <th>Hide columns</th>
   <th>Show only type</th>
   <td rowspan="3" class="infobox">
-   There may be bugs. If you notice any inaccuracies, contact <b>Ggr</b>@Bat.
    <ul>
+    <li>This informations free to use in any way you wish. It would be nice to be credited, however.</li>
+    <li>There may be bugs. If you notice any inaccuracies, contact <b>Ggr</b> @ Bat.</li>
+    <li><b>Raw material data is also available in <a href="materials.csv">CSV format</a>, <a href="materials_short.txt">short tabular format</a> and <a href="materials_long.txt">long format</a></b>.</li>
     <li>You can sort by any column by clicking on the column name. Clicking again will change
     sorting direction (ascending/descending).</li>
     <li>Filtering to show only certain type of materials is possible.</li>
     <li>Columns can be disabled from the filtering list (shift or ctrl with mouse click to select several)</li>
    </ul>
-   There's also a very preliminary alpha version of <a href="alloy.php">alloy browser</a> available.
+   <b>There's also a very preliminary alpha version of <a href="alloy.php">alloy browser</a> available.</b>
   </td>
  </tr>
  <tr>
@@ -96,10 +98,9 @@
 reset($transNameTable);
 next($transNameTable);
 while (list($key, $value) = each($transNameTable)) {
-  echo "<option";
-  if (isset($filterTable[$key]))
-    echo " selected=\"selected\"";
-  echo " value=\"$key\">".htmlentities($value)."</option>\n";
+  echo "<option".
+  (isset($filterTable[$key]) ? " selected=\"selected\"" : "").
+  " value=\"$key\">".htmlentities($value)."</option>\n";
 }
 ?>
    </select>
@@ -109,10 +110,9 @@
 <?
 $typeTable = $transTable[14];
 $typeTable[-1] = "EVERYTHING";
+$showOnlySet = FALSE;
 ksort($typeTable);
-reset($typeTable);
-$showOnlySet = FALSE;
-while (list($key, $value) = each($typeTable)) {
+foreach ($typeTable as $key => $value) {
   echo "    <option value=\"$key\"";
   if ($showOnly == $key) {
     echo " selected=\"selected\"";
@@ -137,29 +137,26 @@
 <table class="matTable">
  <tr>
 <?
-reset($transNameTable);
-while (list($key, $value) = each($transNameTable)) {
+foreach ($transNameTable as $key => $value) {
   if (!isset($filterTable[$key])) {
-  echo "  ";
-  printTC("th", $key);
-  echo "<a href=\"?s=".$key."&amp;d=";
-  if ($key == $sortColumn)
-    echo $sortDirs[!$sortDirection];
-  else
-    echo $sortDirs[$sortDirection];
-  if ($showOnlySet)
-    echo "&amp;o=".$showOnly;
+    echo "  ";
+    printTC("th", $key);
+    echo "<a href=\"?s=".$key."&amp;d=".
+      $sortDirs[($key == $sortColumn) ? !$sortDirection : $sortDirection];
+
+    if ($showOnlySet)
+      echo "&amp;o=".$showOnly;
   
-  reset($filterTable);
-  while (list($fkey, $fvalue) = each($filterTable)) {
-    echo "&amp;h%5B%5D=".$fkey;
-  }
-  echo "\">".htmlentities($value)."</a></th>\n";
+    foreach ($filterTable as $filKey => $filValue)
+      echo "&amp;h%5B%5D=".$filKey;
+
+    echo "\">".htmlentities($value)."</a></th>\n";
   }
 }
 echo " </tr>\n";
 
 foreach ($matTable as $key => $value) {
+
   $doShow = $showOnlySet ? ($value[14] == $showOnly) : TRUE;
   
   if ($doShow) {
@@ -172,12 +169,16 @@
       if (!isset($filterTable[$kkey + 1])) {
         printTC("td", $col);
         if (is_array($kvalue)) {
+          // Arrays need special handling, and is bit messy
           reset($kvalue);
+
           if (list($nam, $lode) = each($kvalue))
             echo htmlentities($transTable[$kkey][$lode]);
+
           while (list($nam, $lode) = each($kvalue))
             echo ", ".htmlentities($transTable[$kkey][$lode]);
         } else {
+          // A simple entry, just print it out
           echo htmlentities($transTable[$kkey][$kvalue]);
         }
         echo "</td>";
--- a/materials/mkalloyinfo.sh	Sun Dec 19 21:13:06 2010 +0000
+++ b/materials/mkalloyinfo.sh	Sun Dec 19 21:15:21 2010 +0000
@@ -4,7 +4,7 @@
 ALLOYTXT="$DESTDIR/alloys.txt"
 
 echo "Fetching alloy submissions ..."
-scp "ccr@tnsp.org:public_html/bat/mat/data-*.log" .
+scp "ccr@tnsp.org:public_html/bat/mat/*.{log,php}" .
 
 echo "Generating alloy data ..."
 cat ggr_alloys.txt data-*.log > tmp
--- a/materials/submit.php	Sun Dec 19 21:13:06 2010 +0000
+++ b/materials/submit.php	Sun Dec 19 21:15:21 2010 +0000
@@ -184,7 +184,7 @@
 to submit data, this form offers a simple submission "API". You can use an URL
 in following format to submit data automatically:
 <pre>
-http://low.fi/~ccr/bat/mat/submit.php?guid=<b>your_guid</b>&amp;mat1=<b>material1</b>&amp;mat2=<b>material2</b>&amp;res=<b>result</b>
+http://tnsp.org/~ccr/bat/mat/submit.php?guid=<b>your_guid</b>&amp;mat1=<b>material1</b>&amp;mat2=<b>material2</b>&amp;res=<b>result</b>
 </pre>
 The parameters should be self-explanatory. The URL and arguments need to be properly encoded,
 of course (at least spaces replaced with "+", if nothing else).