Choose a file to view:
index.php word.php functions.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" >
<script type="text/javascript" src="periodic.js"></script>
<link rel="stylesheet" type="text/css" href="/style.css">
<title>Element Speller</title>
</head>
<body onload='init()'>
<h2>Periodic Table Speller</h2>
<p>Enter a word to see if it can be spelled using only element abbreviations from the Periodic Table.</p>
<?php
if($_GET['length'] == 2)
$r2 = "checked";
else
$r1 = "checked";
?>
<form action="index.php" method="get">
<p><input type="text" name="word" id="word">
<input type="submit" value="Submit"><br><table><tr>
<td><input id="chkImg" type="checkbox" name="pic" onchange="checkboxes()" value="checked" <?=$_GET['pic']?>><label for="chkImg">Generate image</label></td>
<td><input id="chkNum" type="checkbox" name="num" value="checked" <?=$_GET['num']?>><label for="chkNum">Show number</label></td></tr>
<tr><td><input id="chkName" type="checkbox" name="name" value="checked" <?=$_GET['name']?>><label for="chkName">Show name</label></td>
<td><input id="chkMass" type="checkbox" name="mass" value="checked" <?=$_GET['mass']?>><label for="chkMass">Show mass</label></td></tr></table>
Use more: <input id="btnOne" name="length" type="radio" value="1" <?=$r1?>><label for="btnOne">One-letter symbols</label> <input id="btnTwo" name="length" type="radio" value="2" <?=$r2?>><label for="btnTwo">Two-letter symbols</label>
</form>
<?PHP
require 'functions.php';
$e = elements();
$solvable = true;
if($_GET["word"] != null) {
echo "<h1>";
$words = explode(" ", $_GET["word"]);
$size = ($_GET['length'] == "2");
foreach( $words as $word ) {
$sub = periodic($word, $e, $size);
if( !$sub )
$solvable = false;
$solution = $solution." ".$sub;
}
if( $solvable ) {
save(strtolower($solution));
echo trim( $solution );
if($_GET['pic'] == "checked")
echo "<br><br><img src=\"word.php?word=".urlencode(trim($solution))."&showname=".$_GET['name']."&shownum=".$_GET['num']."&showmass=".$_GET['mass']."&size=$size\" alt=\"Successfully spelled with element symbols\">";
$spelled = countspelled(strtolower($solution));
echo "</h1>This phrase has been spelled $spelled time".($spelled == 1 ? "" : "s");
} else {
echo "Impossible!</h1>";
}
echo "</h1>";
}
echo "<span style='display: none;' id='post'>";
echo $_GET["word"];
echo "</span>";
?>
<p class="footer"><br><a href="/">Home</a> <a href="source.php">View source code</a></p>
</body>
</html>