first commit
This commit is contained in:
Executable
+145
@@ -0,0 +1,145 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Quack Oracle 🦆</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: "Comic Sans MS", cursive, sans-serif;
|
||||
background: linear-gradient(135deg, #a8e6cf, #dcedc1);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
header {
|
||||
background: #ffcc70;
|
||||
padding: 20px;
|
||||
box-shadow: 0 4px 10px rgba(0,0,0,0.2);
|
||||
}
|
||||
|
||||
header h1 {
|
||||
margin: 0;
|
||||
font-size: 2.5em;
|
||||
}
|
||||
|
||||
.duck-banner {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.duck-banner img {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.container {
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
input {
|
||||
padding: 12px;
|
||||
width: 60%;
|
||||
max-width: 400px;
|
||||
font-size: 16px;
|
||||
border-radius: 10px;
|
||||
border: 2px solid #333;
|
||||
}
|
||||
|
||||
button {
|
||||
padding: 12px 20px;
|
||||
font-size: 16px;
|
||||
border-radius: 10px;
|
||||
border: none;
|
||||
background: #ff8b94;
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background: #ff6f7d;
|
||||
}
|
||||
|
||||
.response {
|
||||
margin-top: 30px;
|
||||
font-size: 1.5em;
|
||||
min-height: 50px;
|
||||
}
|
||||
|
||||
.big-duck {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.big-duck img {
|
||||
width: 180px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<header>
|
||||
<h1>🦆 The Quack Oracle 🦆</h1>
|
||||
<div class="duck-banner">
|
||||
<img src="https://upload.wikimedia.org/wikipedia/commons/5/5c/Mandarin.duck.arp.jpg">
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="container">
|
||||
<input type="text" id="userInput" placeholder="Ask the duck anything...">
|
||||
<button onclick="askDuck()">Ask 🦆</button>
|
||||
|
||||
<div class="response" id="response"></div>
|
||||
|
||||
<div class="big-duck">
|
||||
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2f/Duckling.jpg/320px-Duckling.jpg">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function hashString(str) {
|
||||
let hash = 0;
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
hash = str.charCodeAt(i) + ((hash << 5) - hash);
|
||||
}
|
||||
return Math.abs(hash);
|
||||
}
|
||||
|
||||
function generateQuackSentence(input) {
|
||||
const quacks = ["quack", "quaaack", "quackity", "quock", "quek", "quuuaack"];
|
||||
const structures = [
|
||||
["Quack", "means", "quack"],
|
||||
["The", "quack", "reveals", "quack"],
|
||||
["Quack", "quack", "therefore", "quack"],
|
||||
["In", "quack", "we", "trust"],
|
||||
["Only", "quack", "knows", "quack"]
|
||||
];
|
||||
|
||||
let hash = hashString(input.toLowerCase());
|
||||
|
||||
let structure = structures[hash % structures.length];
|
||||
|
||||
let sentence = structure.map((word, index) => {
|
||||
if (word.toLowerCase().includes("quack")) {
|
||||
let q = quacks[(hash + index) % quacks.length];
|
||||
return q;
|
||||
}
|
||||
return word;
|
||||
});
|
||||
|
||||
return sentence.join(" ") + ".";
|
||||
}
|
||||
|
||||
function askDuck() {
|
||||
const input = document.getElementById("userInput").value.trim();
|
||||
const responseDiv = document.getElementById("response");
|
||||
|
||||
if (!input) {
|
||||
responseDiv.innerText = "The duck waits for your wisdom... 🦆";
|
||||
return;
|
||||
}
|
||||
|
||||
const response = generateQuackSentence(input);
|
||||
responseDiv.innerText = "🦆 says: " + response;
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user