re-arranged user flow to display assignment first, with the optional button to access information from spotify.

This commit is contained in:
Joshua Ashton
2025-02-04 12:34:29 -07:00
parent 1888f11fe5
commit ea1def7409
111 changed files with 12269 additions and 128 deletions
+84
View File
@@ -0,0 +1,84 @@
@import url('https://fonts.googleapis.com/css2?family=Ranchers&display=swap');
* {margin: 0; padding: 0; box-sizing: border-box; font-family: 'Ranchers', cursive; letter-spacing: 5px;}
nav > a:hover
{
opacity: .5;
}
nav > a
{
font-size: 75px;
text-decoration: none;
text-align: center;
margin: 20px;
display: block;
transition: opacity 500ms;
}
span.warning, span.message
{
text-align: center;
padding: 3px 5px 3px 10px;
display: inline-block;
border-radius: 3px;
}
span.warning {background-color: rgba(200,0,0,.5);}
span.message {background-color: rgba(0,200,0,.5);}
span.contrast {color: white;}
body{background-image: url('../img/watercolor.png');}
main
{
display: flex;
flex-wrap: wrap;
justify-content: space-around;
}
section
{
flex-basis: 30%;
padding: 20px;
margin: 5px;
border: 1px solid #777;
background-color: mediumpurple;
color: black;
border-radius: 5px;
box-shadow: 0 8px 6px -6px black;
}
h3
{
margin-bottom: 15px;
}
li
{
letter-spacing: 2px;
margin: 5px;
margin-left: 25px;
}
input, select
{
padding: 8px;
margin: 5px auto;
height: 50px;
font-size: 25px;
display: inline-block;
}
select
{
padding: 0
}
form h2
{
text-align: center;
margin: 10px auto;
font-size: 30px;
margin-bottom: 50px;
}
form
{
display: block;
min-height: 400px;
margin: 20px auto;
background-color: lavender;
padding: 20px;
border-radius: 8px;
}
p.warning {text-align: center; margin: 20px auto; padding: 10px; background-color: rgba(150,0,0,.5); width: 75%; border-radius: 8px; color: white; font-size: 25px;}
Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

+29
View File
@@ -0,0 +1,29 @@
<?php
$numOfPals = 20;
?>
<!doctype html>
<html lang="en">
<head>
<title>Palindrome Stuff</title>
<link rel="stylesheet" href="css/style.css" type="text/css">
</head>
<body>
<main>
<form action="palindrome.php" method="post">
<select name="pal-count">
<option value="" disabled selected hidden>How Many Palindromes?</option>
<?php
for ($x = 1; $x <=$numOfPals; $x++)
echo '<option value="'.$x.'">'.$x.' Palindrome'.($x==1 ? "" : "s").'</option>';
?>
</select>
<input type="text" name="search-word" placeholder="Enter a word">
<input type="submit">
<?php
if (isset($_GET['error']) && $_GET['error'] == "true")
echo'<p class="warning">Enter Something!</p>';
?>
</form>
</main>
</body>
</html>
+89
View File
@@ -0,0 +1,89 @@
<?php
$wordCounter = 0;
$displayPageContent = "";
function wordCountOutput($sw)
{
global $wordCounter;
echo "<section><p>There are $wordCounter instances of $sw on this site</p></section>";
}
function output($inputArray, $sw)
{
global $wordCounter;
$return = "";
foreach($inputArray as $input)
{
if(strpos(strtolower($input), $sw) !== false) $wordCounter++;
$return .= "<section><h3>Facts About \"$input\"</h3>";
$return .= "<ul>";
$return .= "<li> Palindrome: ".(isPalindrome($input) ? "<span class='message'>TRUE</span>" : "<span class='warning'>FALSE</span>")."</li>";
$return .= "<li> Number of Characters: <span class='contrast'>".strlen($input)."</span></li>";
$return .= "<li> Number of Words: <span class='contrast'>".str_word_count($input)."</span></li>";
$return .= "</ul></section>";
}
return $return;
}
function isPalindrome($phrase)
{
//removes spaces from phrase
$phrase = str_replace(" ", "", $phrase);
$phrase = str_replace("'", "", $phrase);
$phrase = str_replace("?", "", $phrase);
$phrase = str_replace("/", "", $phrase);
$phrase = str_replace("\\", "", $phrase);
$phrase = str_replace(".", "", $phrase);
$phrase = str_replace(",", "", $phrase);
//lower case the phrase
$phrase = strtolower($phrase);
//reverse phrase and assign to variable
$revPhrase = strrev($phrase);
//compare and return
if($revPhrase == $phrase) return true;
else return false;
}
if(!empty($_POST['search-word']) && !empty($_POST['pal-count']))
{
$searchWord = $_POST['search-word'];
$palCount = $_POST['pal-count'];
}
else header('location: .?error=true');
if (!isset($_POST['palindromes']))
{
$displayPageContent .= '<form method="post">';
$displayPageContent .= '<input type="hidden" name="search-word" value="'.$searchWord.'">';
$displayPageContent .= '<input type="hidden" name="pal-count" value="'.$palCount.'">';
for ($x=0;$x<$_POST['pal-count'];$x++)
$displayPageContent .= '<input name="palindromes[]"><br>';
$displayPageContent .= '<input type="submit">';
$displayPageContent .= '</form>';
}
else
{
$inputs = $_POST['palindromes'];
$displayPageContent .= output($inputs, $searchWord);
$displayPageContent .= wordCountOutput($searchWord);
}
?>
<!doctype html>
<html lang="en">
<head>
<title>Palindrome Stuff</title>
<link rel="stylesheet" href="css/style.css" type="text/css">
</head>
<body>
<nav><a href=".">Back Home</a></nav>
<main>
<?php echo $displayPageContent; ?>
</main>
</body>
</html>