Add 3 files
Browse files- index.html +1 -19
- main.js +89 -0
- style.css +57 -18
index.html
CHANGED
@@ -1,19 +1 @@
|
|
1 |
-
|
2 |
-
<html>
|
3 |
-
<head>
|
4 |
-
<meta charset="utf-8" />
|
5 |
-
<meta name="viewport" content="width=device-width" />
|
6 |
-
<title>My static Space</title>
|
7 |
-
<link rel="stylesheet" href="style.css" />
|
8 |
-
</head>
|
9 |
-
<body>
|
10 |
-
<div class="card">
|
11 |
-
<h1>Welcome to your static Space!</h1>
|
12 |
-
<p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
|
13 |
-
<p>
|
14 |
-
Also don't forget to check the
|
15 |
-
<a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
|
16 |
-
</p>
|
17 |
-
</div>
|
18 |
-
</body>
|
19 |
-
</html>
|
|
|
1 |
+
<html><head><link href="https://cdn.jsdelivr.net/npm/daisyui@3.1.6/dist/full.css" rel="stylesheet" type="text/css" /><script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script><script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio"></script><script defer src="https://cdnjs.cloudflare.com/ajax/libs/three.js/0.156.1/three.min.js"></script><script type="module" src="main.js"></script><title>MiniStoryGenerator</title></head><body><div class="mini-story-generator"> <div class="card"> <div class="card-header"> Mini Story Generator <button id="generate-button"> Generate! </button> </div> <div class="card-body"> <div class="story-type"><button id="sci-fi-button"> Sci-Fi </button> <button id="punk-button"> Punk </button> <button id="fantasy-button"> Fantasy </button></div> </div> <div class="story-container"></div> </div></body></html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main.js
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const SCI_FI = {
|
2 |
+
name1: "Aelita",
|
3 |
+
name2: "Korben",
|
4 |
+
adjective1: "daring",
|
5 |
+
adjective2: "ruthless",
|
6 |
+
noun1: "starship",
|
7 |
+
noun2: "droid",
|
8 |
+
action1: "blast off",
|
9 |
+
action2: "take control",
|
10 |
+
};
|
11 |
+
|
12 |
+
const PUNK = {
|
13 |
+
name1: "Kamala",
|
14 |
+
name2: "Zephyr",
|
15 |
+
adjective1: " icons , rebels",
|
16 |
+
adjective2: " wydry , detektive ",
|
17 |
+
noun1: " jakarta, wy�zen ",
|
18 |
+
noun2: " luftgaèse , kLngel ",
|
19 |
+
action1: " Comple cbdet buildings ",
|
20 |
+
action2: "Pretty release ",
|
21 |
+
};
|
22 |
+
|
23 |
+
const FANTASY = {
|
24 |
+
name1: "Aievilia",
|
25 |
+
name2: "Emily",
|
26 |
+
adjective1: " scenarios : Gelacataja arkennia ",
|
27 |
+
adjective2: "Caiaporangle , zemцький oINCTV ",
|
28 |
+
noun1: " domiens : Att mor slact or xdfniushonygriach Kr reason agnesnegea ",
|
29 |
+
noun2: " nomstore reason , Full remarkablepurgnom dobственной . ol mundo",
|
30 |
+
action1: "Kaja envitar film内 лю poco Ungdom - Osätze све lan Margitt Dominique cultural scattering Arteyi physical l ",
|
31 |
+
action2: " а ",
|
32 |
+
};
|
33 |
+
|
34 |
+
class MiniStoryGen {
|
35 |
+
constructor() {
|
36 |
+
this.type = "sci-fi";
|
37 |
+
this.story = {
|
38 |
+
name1: "",
|
39 |
+
name2: "",
|
40 |
+
adjective1: "",
|
41 |
+
adjective2: "",
|
42 |
+
noun1: "",
|
43 |
+
noun2: "",
|
44 |
+
action1: "",
|
45 |
+
action2: "",
|
46 |
+
};
|
47 |
+
this.init();
|
48 |
+
}
|
49 |
+
|
50 |
+
init() {
|
51 |
+
this.generateStory();
|
52 |
+
}
|
53 |
+
|
54 |
+
generateStory() {
|
55 |
+
let story = "";
|
56 |
+
if (this.type === "sci-fi") {
|
57 |
+
story = `${this.getStory()}, ${SCI_FI.name1} and ${SCI_FI.name2} were ${SCI_FI.adjective1} and ${SCI_FI.adjective2} space travelers who came across a ${SCI_FI.noun1} and a ${SCI_FI.noun2} in their journey. They decided to ${SCI_FI.action1} and ${SCI_FI.action2} to explore the wonders of the universe.`;
|
58 |
+
} else if (this.type === "punk") {
|
59 |
+
story = `${this.getStory()}, ${PUNK.name1} and ${PUNK.name2} were ${PUNK.adjective1} and ${PUNK.adjective2} rebels who lived a fast life in the city of ${PUNK.noun1} and ${PUNK.noun2}. They were always seeking to ${PUNK.action1} and ${PUNK.action2} the corrupt systems."`;
|
60 |
+
} else if (this.type === "fantasy") {
|
61 |
+
story = `${this.getStory()}, ${FANTASY.name1} and ${FANTASY.name2} were ${FANTASY.adjective1} and ${FANTASY.adjective2} heroes who lived in the ${FANTASY.noun1} and ${FANTASY.noun2}. They were destined to ${FANTASY.action1} and ${FANTASY.action2} the evil forces that threatened their world."`;
|
62 |
+
}
|
63 |
+
document.querySelector(".story-container").innerHTML = `<p>${story}</p>`;
|
64 |
+
}
|
65 |
+
|
66 |
+
getStory() {
|
67 |
+
return Math.floor(Math.random() * 100) + 1;
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
document.addEventListener("DOMContentLoaded", () => {
|
72 |
+
const miniStoryGen = new MiniStoryGen();
|
73 |
+
|
74 |
+
document.getElementById("generate-button").addEventListener("click", () => {
|
75 |
+
miniStoryGen.generateStory();
|
76 |
+
});
|
77 |
+
|
78 |
+
document.getElementById("sci-fi-button").addEventListener("click", () => {
|
79 |
+
miniStoryGen.type = "sci-fi";
|
80 |
+
});
|
81 |
+
|
82 |
+
document.getElementById("punk-button").addEventListener("click", () => {
|
83 |
+
miniStoryGen.type = "punk";
|
84 |
+
});
|
85 |
+
|
86 |
+
document.getElementById("fantasy-button").addEventListener("click", () => {
|
87 |
+
miniStoryGen.type = "fantasy";
|
88 |
+
});
|
89 |
+
});
|
style.css
CHANGED
@@ -1,28 +1,67 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
|
|
4 |
}
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
}
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
16 |
}
|
17 |
|
18 |
.card {
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
border-radius:
|
|
|
|
|
|
|
24 |
}
|
25 |
|
26 |
-
.card
|
27 |
-
|
|
|
|
|
|
|
28 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
* {
|
2 |
+
box-sizing: border-box;
|
3 |
+
margin: 0;
|
4 |
+
padding: 0;
|
5 |
}
|
6 |
|
7 |
+
body {
|
8 |
+
background-color: #222;
|
9 |
+
color: #fff;
|
10 |
}
|
11 |
|
12 |
+
.mini-story-generator {
|
13 |
+
width: 100%;
|
14 |
+
margin: 0 auto;
|
15 |
+
display: flex;
|
16 |
+
align-items: center;
|
17 |
+
justify-content: center;
|
18 |
}
|
19 |
|
20 |
.card {
|
21 |
+
display: flex;
|
22 |
+
flex-direction: column;
|
23 |
+
background-color: #333;
|
24 |
+
padding: 20px;
|
25 |
+
border-radius: 10px;
|
26 |
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
27 |
+
margin: 20px;
|
28 |
+
max-width: 600px;
|
29 |
}
|
30 |
|
31 |
+
.card-header {
|
32 |
+
display: flex;
|
33 |
+
align-items: center;
|
34 |
+
justify-content: space-between;
|
35 |
+
border-bottom: 1px solid #aaa;
|
36 |
}
|
37 |
+
|
38 |
+
.story-type button {
|
39 |
+
background-color: #444;
|
40 |
+
color: #fff;
|
41 |
+
padding: 10px 20px;
|
42 |
+
border: none;
|
43 |
+
border-radius: 10px;
|
44 |
+
cursor: pointer;
|
45 |
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
46 |
+
margin-right: 10px;
|
47 |
+
}
|
48 |
+
|
49 |
+
.story-type button:hover {
|
50 |
+
background-color: #555;
|
51 |
+
}
|
52 |
+
|
53 |
+
.story-type button:active {
|
54 |
+
background-color: #666;
|
55 |
+
}
|
56 |
+
|
57 |
+
.story-container {
|
58 |
+
margin-top: 20px;
|
59 |
+
padding: 20px;
|
60 |
+
border-radius: 10px;
|
61 |
+
background-color: #444;
|
62 |
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
63 |
+
}
|
64 |
+
|
65 |
+
.story-container p {
|
66 |
+
color: #ccc;
|
67 |
+
}
|