annotate materials/info.php @ 327:fd471bd4e013 misc

Improve page HTML output cosmetics.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 31 Dec 2015 03:02:17 +0200
parents 03963c456ed8
children 98c798a843ed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 <?
325
b65e0d6efe9d Add copyright blurb.
Matti Hamalainen <ccr@tnsp.org>
parents: 322
diff changeset
2 //
b65e0d6efe9d Add copyright blurb.
Matti Hamalainen <ccr@tnsp.org>
parents: 322
diff changeset
3 // BatMUD material alloy combo and material info viewer
b65e0d6efe9d Add copyright blurb.
Matti Hamalainen <ccr@tnsp.org>
parents: 322
diff changeset
4 // (C) Copyright 2009 - 2015 Matti 'ccr' Hämäläinen <ccr@tnsp.org>
b65e0d6efe9d Add copyright blurb.
Matti Hamalainen <ccr@tnsp.org>
parents: 322
diff changeset
5 //
316
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
6 require "mgeneric.inc.php";
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
7 require "materials.inc.php";
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
8 require "alloys.inc.php";
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
9
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 $pageTitle = "Pupunen BatMUD Alloy Browser";
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 $pageIndex = "info.php";
316
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
12
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
13
326
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
14 // Static list of alloy data contributors
316
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
15 $contributors =
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
16 [
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
17 "Hair", "Malacoda", "Kiomet", "Aegenor", "Gileon", "Corto",
313
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
18 ];
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
19
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20
326
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
21 // Material type table for the type selector.
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
22 // Because some types are combinations, we need to have
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
23 // mappings for those (the last two columns)
316
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
24 $matTypeTable =
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
25 [
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
26 0 => ["Organic + cloth (sewing)" , 0, 1],
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
27 1 => ["Wood + bone (carpentry)" , 5, 3],
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
28 2 => ["Metal + alloy (blacksmithing)" , 4, 7],
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
29 3 => ["Stone (masonry)" , 6, -1],
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
30 4 => ["Gem (gemcutting)" , 10, -1],
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
31 5 => ["Inorganic (sculpture)" , 8, -1],
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
32 6 => ["Glass (glassblowing)" , 9, -1],
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
33
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
34 7 => ["Organic" , 0, -1],
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
35 8 => ["Wood" , 5, -1],
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
36 9 => ["Metal" , 4, -1],
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
37
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
38 10 => ["Cloth" , -1, 1],
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
39 11 => ["Bone" , -1, 3],
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
40 12 => ["Alloy" , -1, 7],
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
41 ];
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
42
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
43
326
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
44 // Define ranges for alloy tests' "reliability" based
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
45 // on how many tests have been performed. Define the
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
46 // lower and upper bound (inclusive), informative text
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
47 // and CSS style for those items.
316
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
48 $matReliability =
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
49 [
322
1f3fd2d0831b Adjust threshold values for alloy tests.
Matti Hamalainen <ccr@tnsp.org>
parents: 316
diff changeset
50 [ 1, 2, "1-2 tests", "background: #a00; color: white;" ],
1f3fd2d0831b Adjust threshold values for alloy tests.
Matti Hamalainen <ccr@tnsp.org>
parents: 316
diff changeset
51 [ 3, 5, "3-5 tests", "background: #750; color: white;" ],
1f3fd2d0831b Adjust threshold values for alloy tests.
Matti Hamalainen <ccr@tnsp.org>
parents: 316
diff changeset
52 [ 6, 9, "6-9 tests", "background: #c90; color: black;", "color: black;" ],
1f3fd2d0831b Adjust threshold values for alloy tests.
Matti Hamalainen <ccr@tnsp.org>
parents: 316
diff changeset
53 [ 10, 9999, "10 or more", "background: #080; color: white;" ],
316
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
54 ];
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
57 function stGetMatLink($mat, $title = "", $extra = "")
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 {
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 $tmp = ($title != "") ? " title=\"".chentities($title)."\"" : "";
253
1eca10751695 Improve alloy browser output.
Matti Hamalainen <ccr@tnsp.org>
parents: 250
diff changeset
60 return "<a href=\"/mat/".urlencode($mat)."\"".$tmp.">".chentities($mat)."</a>".$extra;
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61 }
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63
316
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
64 function stGetReliabilityStyle($n)
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 {
316
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
66 global $matReliability;
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
67 foreach ($matReliability as $chk)
313
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
68 {
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
69 if ($n >= $chk[0] && $n <= $chk[1])
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
70 return " class=\"hits".$chk[0]."to".$chk[1]."\"";
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
71 }
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
72 return "";
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 }
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
76 //
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
77 // Actual main code begins
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
78 //
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
79 $setShowOnly = intval(stGetRequestItem("o", 0, TRUE));
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
80
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
81 if (isset($_GET["m"]))
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
82 {
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
83 $setShowMat = strtolower($_GET["m"]);
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
84 $setShowMatName = strtoupper(substr($setShowMat,0,1)).substr($setShowMat, 1);
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
85 }
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
86
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
87 $setSwapRows = (isset($_GET["swap"]) && is_array($_GET["swap"])) ? $_GET["swap"] : array();
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
88
326
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
89
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
90 // Generate CSS and information snippets into temporary arrays
313
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
91 $extraCSS = [];
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
92 $extraInfo = [];
316
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
93 foreach ($matReliability as $chk)
313
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
94 {
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
95 $tmps = "hits".$chk[0]."to".$chk[1];
327
fd471bd4e013 Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 326
diff changeset
96 $extraCSS[] = " td.".$tmps.", .".$tmps." { ".$chk[3]." }";
313
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
97 if (isset($chk[4]))
327
fd471bd4e013 Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 326
diff changeset
98 $extraCSS[] = " td.".$tmps." a { ".$chk[4]." }";
313
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
99
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
100 $extraInfo[] = "<span class=\"hits".$chk[0]."to".$chk[1]."\"><b>".$chk[2]."</b></span>";
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
101 }
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
102
326
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
103
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
104 //
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
105 // Let's start pooping out the page
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
106 //
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107 cmPrintPageHeader($pageTitle, "
327
fd471bd4e013 Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 326
diff changeset
108 <meta name=\"robots\" content=\"nofollow\" />
fd471bd4e013 Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 326
diff changeset
109 <style type=\"text/css\">
fd471bd4e013 Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 326
diff changeset
110 span.alternate { color: red; font-weight: bold; }
313
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
111 ".implode("\n", $extraCSS)."
327
fd471bd4e013 Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 326
diff changeset
112 td.nohits, .nohits { background: black; }
fd471bd4e013 Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 326
diff changeset
113 td.impossible { background: black; color: #f00; text-align: center; }
fd471bd4e013 Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 326
diff changeset
114 </style>
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115 ");
310
b82fc05fbd4a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
116
313
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
117 echo
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
118 "<h1>".$pageTitle."</h1>\n".
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
119 "<form action=\"".$pageIndex."\" method=\"get\">\n".
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
120 "<table class=\"optionsTable\" width=\"100%\">\n".
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
121 " <tr>\n".
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
122 " <th width=\"25%\">Show type</th>\n".
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
123 " <td rowspan=\"3\" class=\"infobox\">\n".
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
124 " [<a href=\"".$pageIndex."\">Reset/Clear</a>] [<a href=\"index.php\">Material browser</a>]\n".
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
125 " <br />\n".
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
126 " <ul>\n".
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
127 " <li><b>Also available in <a href=\"alloys.txt\">ASCII plaintext format</a>.</b></li>\n".
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
128 " <li><b><a href=\"instructions.php\">Read this</a> for instructions on how you can collect and submit your own alloy research data.</b></li>\n".
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
129 " <li>Only 2-material alloys are supported by this browser.</li>\n".
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
130 " <li>There may be errors, and lots of combinations are not researched yet.</li>\n".
314
7615bf7f980f Cosmetics + HTML syntax.
Matti Hamalainen <ccr@tnsp.org>
parents: 313
diff changeset
131 " <li>The cell colour reflects how \"reliable\" the information is: ".implode(", ", $extraInfo).".</li>\n";
313
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
132
316
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
133 if (isset($contributors) && count($contributors) > 0)
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
134 {
313
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
135 $tmp = [];
316
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
136 foreach ($contributors as $key)
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
137 $tmp[] = "<b>".$key."</b>";
313
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
138 echo " <li>Thanks to the following people for providing alloying data: ".join(", ", $tmp).".</li>\n";
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
139 }
310
b82fc05fbd4a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
140
b82fc05fbd4a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
141 echo
314
7615bf7f980f Cosmetics + HTML syntax.
Matti Hamalainen <ccr@tnsp.org>
parents: 313
diff changeset
142 " </ul>\n".
310
b82fc05fbd4a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
143 " </td>\n".
b82fc05fbd4a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
144 " </tr>\n".
b82fc05fbd4a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
145 " <tr>\n".
b82fc05fbd4a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
146 " <td class=\"icenter\">\n".
b82fc05fbd4a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
147 " <select name=\"o\">\n";
b82fc05fbd4a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
148
326
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
149 // Output the type selectors
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
150 foreach ($matTypeTable as $key => $value)
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151 {
255
af08f54f0bc6 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
152 $n = 0;
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
153 foreach ($matDataTable as $name => $data)
255
af08f54f0bc6 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
154 {
af08f54f0bc6 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
155 if ($data[14] == $value[1] || $data[14] == $value[2])
af08f54f0bc6 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
156 $n++;
af08f54f0bc6 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
157 }
af08f54f0bc6 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
158
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
159 $matTypeTable[$key][] = $n;
255
af08f54f0bc6 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
160
af08f54f0bc6 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
161 printf(
af08f54f0bc6 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
162 " <option value=\"%s\"%s>%-30s [%d]</option>\n",
af08f54f0bc6 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
163 $key,
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
164 ($setShowOnly == $key ? " selected=\"selected\"" : ""),
255
af08f54f0bc6 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
165 chentities($value[0]), $n);
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
166 }
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
167
310
b82fc05fbd4a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
168 echo
b82fc05fbd4a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
169 " </select>\n".
b82fc05fbd4a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
170 " </td>\n".
b82fc05fbd4a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
171 " </tr>\n".
b82fc05fbd4a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
172 " <tr>\n".
b82fc05fbd4a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
173 " <td class=\"icenter\"><input type=\"submit\" value=\" Filter \" class=\"isubmit\" /></td>\n".
b82fc05fbd4a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
174 " </tr>\n".
b82fc05fbd4a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
175 "</table>\n".
b82fc05fbd4a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
176 "</form>\n";
b82fc05fbd4a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
177
326
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
178 //
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
179 // Now, act accordingly ..
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
180 //
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
181 if (isset($setShowMat))
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
182 {
326
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
183 //
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
184 // We are showing information about one specific material
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
185 //
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
186 if (!isset($matDataTable[$setShowMat]))
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
187 {
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
188 echo
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
189 "<h2>Error! No such material '".$setShowMatName."'</h2>\n".
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
190 "<p>Material is not known. Check spelling.</p>\n";
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
191 }
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
192 else
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
193 {
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
194 echo "<h2>".$setShowMatName."</h2>\n".
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195 "<table width=\"95%\">\n".
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
196 "<tr>";
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
198 $n = 0;
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
199 foreach ($matDataTable[$setShowMat] as $key => $val)
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
200 {
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
201 echo "<th>".chentities($matTransNames[$key + 1])."</th><td>";
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202 if (is_array($val))
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203 {
313
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
204 $tmp = [];
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
205 foreach ($val as $lode)
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
206 $tmp[] = chentities($matTransTable[$key][$lode]);
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
207 echo join(", ", $tmp);
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
208 }
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
209 else
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210 {
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
211 echo chentities($matTransTable[$key][$val]);
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
212 }
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
213 echo "</td>";
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
214 if ($n++ >= 2) { echo "</tr>\n<tr>"; $n = 0; }
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
215 }
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
216 echo "</tr>\n</table>\n";
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
217
326
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
218 //
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
219 // Show alloy combinations table for this material
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
220 //
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
221 echo "<h3>Alloy combinations</h3>\n";
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
222 if (isset($alloyRevTable[$setShowMat]))
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
223 {
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
224 echo "<ul>\n";
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
225 foreach ($alloyRevTable[$setShowMat] as $mat => $value)
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
226 {
313
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
227 $tmp = [];
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
228 foreach ($value as $qkey => $qval)
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
229 $tmp[] = stGetMatLink($qkey);
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
230
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
231 echo
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
232 " <li>".stGetMatLink($mat)." <b>+</b> ".join(" <b>|</b> ", $tmp).
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
233 "<b> = ".chentities($setShowMat)."</b></li>\n";
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
234 }
291
8720936884bb Add help.
Matti Hamalainen <ccr@tnsp.org>
parents: 255
diff changeset
235 echo
8720936884bb Add help.
Matti Hamalainen <ccr@tnsp.org>
parents: 255
diff changeset
236 "</ul>\n".
8720936884bb Add help.
Matti Hamalainen <ccr@tnsp.org>
parents: 255
diff changeset
237 "<pre>\n".
8720936884bb Add help.
Matti Hamalainen <ccr@tnsp.org>
parents: 255
diff changeset
238 "Syntax: <b>+</b> is AND, <b>|</b> is OR, e.g.:\n".
8720936884bb Add help.
Matti Hamalainen <ccr@tnsp.org>
parents: 255
diff changeset
239 "<b>A + B = C</b> means A alloyed with B produces C.\n".
8720936884bb Add help.
Matti Hamalainen <ccr@tnsp.org>
parents: 255
diff changeset
240 "<b>A + B | C = D</b> means A alloyed with B <b>or</b> C produces D.\n".
8720936884bb Add help.
Matti Hamalainen <ccr@tnsp.org>
parents: 255
diff changeset
241 "</pre>\n";
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
242 }
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
243 else
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
244 {
326
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
245 //
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
246 // No alloy combos known, show "generic" formula
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
247 //
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248 echo "<p>No known alloy combinations.</p>\n";
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
249 }
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
251 /*
313
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
252 $typeMats = [];
309
c5e63ca351eb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
253 foreach ($matDataTable as $name => $data)
c5e63ca351eb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
254 {
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
255 if ($data[14] == $matDataTable[$setShowMat][14] && $name != $setShowMat)
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
256 $typeMats[] = $name;
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
257 }
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
258
309
c5e63ca351eb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
259 echo "<p>Full mix: ";
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
260 if (list($a, $b) = each($typeMats))
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
261 echo stGetMatLink($b);
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
262
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
263 while (list($a, $b) = each($typeMats))
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
264 echo " <b>+</b> ".stGetMatLink($b);
309
c5e63ca351eb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
265 echo "</p>\n";
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
266 */
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
267
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
268 echo "<h3>Mixtable</h3>\n";
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
269 if (count($alloyTable[$setShowMat]) > 0)
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
270 {
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
271 echo
309
c5e63ca351eb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
272 "<table class=\"matTable\">".
c5e63ca351eb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
273 " <tr>\n".
c5e63ca351eb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
274 " <th>+</th>\n";
c5e63ca351eb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
275
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
276 foreach ($alloyTable[$setShowMat] as $key => $value)
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
277 {
327
fd471bd4e013 Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 326
diff changeset
278 echo " <th>".stGetMatLink($key)."</th>\n";
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
279 }
309
c5e63ca351eb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
280
c5e63ca351eb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
281 echo
c5e63ca351eb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
282 " </tr>\n".
327
fd471bd4e013 Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 326
diff changeset
283 " <tr>\n".
fd471bd4e013 Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 326
diff changeset
284 " <th>".chentities($setShowMat)."</th>\n";
309
c5e63ca351eb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
285
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
286 foreach ($alloyTable[$setShowMat] as $key => $value)
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
287 {
309
c5e63ca351eb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
288 if (list($a, $b) = each($value))
c5e63ca351eb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
289 {
327
fd471bd4e013 Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 326
diff changeset
290 echo " <td".stGetReliabilityStyle($b).">".stGetMatLink($a)."</td>\n";
309
c5e63ca351eb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
291 }
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
292 }
327
fd471bd4e013 Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 326
diff changeset
293 echo
fd471bd4e013 Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 326
diff changeset
294 " </tr>\n".
fd471bd4e013 Improve page HTML output cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 326
diff changeset
295 "</table>\n";
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
296 }
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
297 else
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
298 {
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
299 echo "<p>No mixtable entries.</p>\n";
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
300 }
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
301 }
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
302 }
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
303 else
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
304 {
326
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
305 //
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
306 // Print alloy table for given material type
03963c456ed8 Sprinkle in some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 325
diff changeset
307 //
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
308 // Filter table from maintable matching desired material type(s)
313
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
309 $currTable = [];
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
310 foreach ($matDataTable as $name => $data)
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
311 {
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
312 if ($data[14] == $matTypeTable[$setShowOnly][1] ||
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
313 $data[14] == $matTypeTable[$setShowOnly][2])
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
314 $currTable[] = $name;
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
315 }
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
316
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
317 // Swap desired rows
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
318 if (count($setSwapRows) > 0)
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
319 {
313
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
320 $str = [];
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
321 $nkeys = count($currTable);
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
322 foreach ($setSwapRows as $from => $to)
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
323 if ($from >= 0 && $from < $nkeys && $to >= 0 && $to < $nkeys && $to != $from)
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
324 {
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
325 $str[] = $from." &lt;=&gt; ".$to;
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
326
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
327 $tmp = $currTable[$from];
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
328 $currTable[$from] = $currTable[$to];
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
329 $currTable[$to] = $tmp;
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
330 }
309
c5e63ca351eb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
331
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
332 if (count($str) > 0)
307
d6b1b38cbb30 Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
333 {
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
334 echo "<p>Swapped rows: ".implode(", ", $str)."</p>\n";
307
d6b1b38cbb30 Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
335 }
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
336 }
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
337
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
338 // Print out the table
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
339 echo
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
340 "<table class=\"alloyTable\">".
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
341 " <tr>\n".
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
342 " <th>-</th>\n";
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
343
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
344 foreach ($currTable as $name)
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
345 {
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
346 echo " <th>".stGetMatLink($name)."</th>\n";
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
347 }
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
348 echo " </tr>\n";
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
349
255
af08f54f0bc6 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
350 $researched = 0;
af08f54f0bc6 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
351 $researchValue = 0;
307
d6b1b38cbb30 Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
352 $total = 0;
255
af08f54f0bc6 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
353
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
354 foreach ($currTable as $mat1)
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
355 {
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
356 echo " <tr><th>".stGetMatLink($mat1)."</th>";
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
357 foreach ($currTable as $mat2)
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
358 {
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
359 // Is the combo possible?
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
360 if ($mat1 != $mat2)
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
361 {
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
362 // Check for combination result
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
363 if (isset($alloyTable[$mat1][$mat2]))
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
364 $tmp = $alloyTable[$mat1][$mat2];
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
365 else
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
366 if (isset($alloyTable[$mat2][$mat1]))
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
367 $tmp = $alloyTable[$mat2][$mat1];
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
368 else
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
369 unset($tmp);
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
370
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
371 if (isset($tmp))
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
372 {
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
373 arsort($tmp);
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
374 $value = 0;
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
375 foreach ($tmp as $a => $b)
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
376 $value += $b;
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
377
255
af08f54f0bc6 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
378 $researched++;
af08f54f0bc6 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
379 $researchValue += $value;
af08f54f0bc6 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
380
313
c31c428afaf5 Many code cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 311
diff changeset
381 $slist = [];
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
382 foreach ($tmp as $a => $b)
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
383 {
296
8724b9de70bf Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 292
diff changeset
384 $slist[] = stGetMatLink($a,
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
385 $b." successful alloys (".$mat1." + ".$mat2." = ".$a.")".
255
af08f54f0bc6 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
386 (count($tmp) > 1 ? " [UNSTABLE]" : "")
af08f54f0bc6 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
387 );
af08f54f0bc6 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
388 // , " <sup>".$b."</sup>");
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
389 }
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
390 echo
316
fedf17494a35 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
391 "<td".stGetReliabilityStyle($value, count($tmp) > 1 ? " mitalic" : "").">".
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
392 join(" <span class=\"alternate\">/</span> ", $slist)."</td>";
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
393 }
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
394 else
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
395 echo "<td class=\"nohits\" title=\"Not researched\">?</td>";
309
c5e63ca351eb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
396
307
d6b1b38cbb30 Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
397 $total++;
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
398 }
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
399 else
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
400 {
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
401 echo "<td class=\"impossible\" title=\"Impossible combination\">-</td>";
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
402 }
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
403 }
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
404 echo "</tr>\n";
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
405 }
255
af08f54f0bc6 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
406
307
d6b1b38cbb30 Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
407 //
d6b1b38cbb30 Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
408 // Calculate some statistics
d6b1b38cbb30 Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
409 //
309
c5e63ca351eb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
410 $researchValue /= $researched * 15.0;
c5e63ca351eb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
411 if ($researchValue > 1.0)
c5e63ca351eb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
412 $researchValue = 1.0;
c5e63ca351eb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
413
307
d6b1b38cbb30 Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
414 $total /= 2;
d6b1b38cbb30 Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
415 $researched /= 2;
255
af08f54f0bc6 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
416
307
d6b1b38cbb30 Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
417 printf(
d6b1b38cbb30 Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
418 "</table>\n".
255
af08f54f0bc6 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
419 "<div><b>%1.2f%%</b> (%d / %d) of combinations researched. ".
af08f54f0bc6 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
420 "Estimating <b>%1.2f%%</b> overall accuracy.</div>\n",
af08f54f0bc6 Upstream sync.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
421 ($researched * 100.0) / $total, $researched, $total,
307
d6b1b38cbb30 Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
422 $researchValue * 100.0);
250
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
423 }
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
424
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
425 cmPrintPageFooter();
233141af4dcf Import "new" file.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
426 ?>