Update static/index.html
Browse files- static/index.html +434 -22
static/index.html
CHANGED
|
@@ -3,12 +3,343 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
</head>
|
| 8 |
<body>
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
<label for="language">Choose a language:</label>
|
| 13 |
<select name="language" id="language">
|
| 14 |
<option value="english">English</option>
|
|
@@ -122,32 +453,113 @@
|
|
| 122 |
|
| 123 |
<!-- Add more language options as needed -->
|
| 124 |
</select>
|
| 125 |
-
|
|
|
|
| 126 |
</form>
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
<script>
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
var languageSelect = document.getElementById('language');
|
| 134 |
formData.append('image_file', fileInput.files[0]);
|
| 135 |
formData.append('language', languageSelect.value);
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
</script>
|
| 150 |
</body>
|
| 151 |
</html>
|
| 152 |
|
| 153 |
-
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.13.11/katex.min.css">
|
| 7 |
+
<link href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@100&display=swap" rel="stylesheet">
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
| 9 |
+
<style>
|
| 10 |
+
body {
|
| 11 |
+
background-color: #121212;
|
| 12 |
+
color: #FFFFFF;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
/* Dark mode for upload buttons */
|
| 16 |
+
#upload-form button[type="button"] {
|
| 17 |
+
background-color: #1E7E34;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
/* Dark mode for file input labels */
|
| 21 |
+
#image-label {
|
| 22 |
+
background-color: #BF2C25;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
/* Dark mode for face number inputs */
|
| 26 |
+
#best_max_flavors {
|
| 27 |
+
background-color: #333333;
|
| 28 |
+
color: #FFFFFF;
|
| 29 |
+
border: 1px solid #555555;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
/* Dark mode for swap button */
|
| 33 |
+
button[type="button"] {
|
| 34 |
+
background-color: #1E7E34;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
/* Dark mode hover effect for swap button */
|
| 38 |
+
button[type="button"]:hover {
|
| 39 |
+
background-color: #2E9E44;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
/* Style for upload buttons */
|
| 43 |
+
input[type="file"] {
|
| 44 |
+
display: none; /* Hide the default file input */
|
| 45 |
+
}
|
| 46 |
+
#upload-form label[for="image"] {
|
| 47 |
+
padding: 10px 20px;
|
| 48 |
+
background-color: #f44336;
|
| 49 |
+
color: white;
|
| 50 |
+
border-radius: 5px;
|
| 51 |
+
cursor: pointer;
|
| 52 |
+
display: inline-block;
|
| 53 |
+
margin: 0 auto;
|
| 54 |
+
}
|
| 55 |
+
#image-label {
|
| 56 |
+
padding: 10px 20px;
|
| 57 |
+
background-color: #f44336;
|
| 58 |
+
color: white;
|
| 59 |
+
border-radius: 5px;
|
| 60 |
+
cursor: pointer;
|
| 61 |
+
display: inline-block;
|
| 62 |
+
margin: 0 auto;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
.uploadButton {
|
| 66 |
+
background-color: #4CAF50;
|
| 67 |
+
border: none;
|
| 68 |
+
color: white;
|
| 69 |
+
padding: 10px 20px;
|
| 70 |
+
text-align: center;
|
| 71 |
+
text-decoration: none;
|
| 72 |
+
display: inline-block;
|
| 73 |
+
font-size: 16px;
|
| 74 |
+
margin-top: 10px;
|
| 75 |
+
cursor: pointer;
|
| 76 |
+
border-radius: 5px;
|
| 77 |
+
margin: auto;
|
| 78 |
+
margin: 0 auto;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
/* Style for file input labels */
|
| 82 |
+
#upload-form {
|
| 83 |
+
display: flex;
|
| 84 |
+
flex-direction: column;
|
| 85 |
+
align-items: center;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
#image-label {
|
| 89 |
+
padding: 10px 20px;
|
| 90 |
+
background-color: #f44336;
|
| 91 |
+
color: white;
|
| 92 |
+
border-radius: 5px;
|
| 93 |
+
cursor: pointer;
|
| 94 |
+
display: block;
|
| 95 |
+
margin: 0 auto;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
#image-label input[type="file"] {
|
| 99 |
+
display: none;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
/* Style for face number inputs */
|
| 103 |
+
#mode, #best_max_flavors {
|
| 104 |
+
padding: 8px;
|
| 105 |
+
border: 1px solid #ccc;
|
| 106 |
+
border-radius: 4px;
|
| 107 |
+
box-sizing: border-box;
|
| 108 |
+
margin-top: 5px;
|
| 109 |
+
font-size: 16px;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
/* Style for labels */
|
| 113 |
+
label {
|
| 114 |
+
font-weight: bold;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
/* Optional: Increase space between elements */
|
| 118 |
+
form > * {
|
| 119 |
+
margin-bottom: 10px;
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
/* Style for the swap button */
|
| 123 |
+
button {
|
| 124 |
+
background-image: linear-gradient(
|
| 125 |
+
45deg,
|
| 126 |
+
hsl(240deg 75% 29%) 0%,
|
| 127 |
+
hsl(254deg 78% 28%) 6%,
|
| 128 |
+
hsl(264deg 82% 27%) 13%,
|
| 129 |
+
hsl(272deg 87% 26%) 19%,
|
| 130 |
+
hsl(278deg 93% 25%) 25%,
|
| 131 |
+
hsl(284deg 98% 24%) 31%,
|
| 132 |
+
hsl(289deg 100% 23%) 37%,
|
| 133 |
+
hsl(294deg 100% 23%) 44%,
|
| 134 |
+
hsl(299deg 100% 22%) 50%,
|
| 135 |
+
hsl(303deg 100% 23%) 56%,
|
| 136 |
+
hsl(307deg 100% 24%) 63%,
|
| 137 |
+
hsl(311deg 100% 25%) 69%,
|
| 138 |
+
hsl(313deg 100% 26%) 75%,
|
| 139 |
+
hsl(316deg 95% 28%) 81%,
|
| 140 |
+
hsl(320deg 88% 30%) 87%,
|
| 141 |
+
hsl(323deg 81% 32%) 94%,
|
| 142 |
+
hsl(326deg 75% 33%) 100%
|
| 143 |
+
);
|
| 144 |
+
border: none;
|
| 145 |
+
color: white;
|
| 146 |
+
padding: 10px 20px;
|
| 147 |
+
text-align: center;
|
| 148 |
+
text-decoration: none;
|
| 149 |
+
display: inline-block;
|
| 150 |
+
font-size: 16px;
|
| 151 |
+
margin-top: 10px;
|
| 152 |
+
cursor: pointer;
|
| 153 |
+
border-radius: 5px;
|
| 154 |
+
display: block;
|
| 155 |
+
margin: 0 auto;
|
| 156 |
+
width: 200px;
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
/* Hover effect for the button */
|
| 160 |
+
button:hover {
|
| 161 |
+
background-color: #45a049;
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
/* Style for file input */
|
| 165 |
+
#image {
|
| 166 |
+
display: none; /* Hide the default file input */
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
#image-label {
|
| 170 |
+
padding: 10px 20px;
|
| 171 |
+
background-color: #f44336;
|
| 172 |
+
color: white;
|
| 173 |
+
border-radius: 5px;
|
| 174 |
+
cursor: pointer;
|
| 175 |
+
display: inline-block;
|
| 176 |
+
margin: 0 auto;
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
#image-label input[type="file"] {
|
| 180 |
+
display: none;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
h1 {
|
| 184 |
+
text-align: center;
|
| 185 |
+
margin-bottom: 20px;
|
| 186 |
+
font-family: 'Barlow Condensed';
|
| 187 |
+
color: pink;
|
| 188 |
+
font-size: 40px; /* Adjust the font size as needed */
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
h2 {
|
| 192 |
+
font-size: 24px; /* Adjust size as needed */
|
| 193 |
+
font-family: 'Barlow Condensed';
|
| 194 |
+
color: #FFFFFF; /* Text color */
|
| 195 |
+
margin-top: 20px; /* Top margin */
|
| 196 |
+
margin-bottom: 10px; /* Bottom margin */
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
select {
|
| 200 |
+
width: 150px; /* Adjust width as needed */
|
| 201 |
+
padding: 8px;
|
| 202 |
+
border: 1px solid #ccc;
|
| 203 |
+
border-radius: 4px;
|
| 204 |
+
background-color: #333333; /* Background color */
|
| 205 |
+
color: white; /* Text color */
|
| 206 |
+
font-size: 16px;
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
#best_max_flavors {
|
| 210 |
+
width: 60px;
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
/* Style for the scale number input */
|
| 214 |
+
input[type="number"]#best_max_flavors {
|
| 215 |
+
padding: 8px;
|
| 216 |
+
width: 50px;
|
| 217 |
+
border: 1px solid #ccc;
|
| 218 |
+
border-radius: 4px;
|
| 219 |
+
box-sizing: border-box;
|
| 220 |
+
margin-top: 5px;
|
| 221 |
+
font-size: 16px;
|
| 222 |
+
color: white; /* Set text color to white */
|
| 223 |
+
background-color: #333333; /* Set background color */
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
/* Optional: Adjust focus styling for the scale number input */
|
| 227 |
+
input[type="number"]#best_max_flavors:focus {
|
| 228 |
+
outline: none; /* Remove default outline */
|
| 229 |
+
border-color: #1E7E34; /* Change border color on focus */
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
#estimatedTime {
|
| 233 |
+
display: none;
|
| 234 |
+
text-align: center; /* Center align the text */
|
| 235 |
+
margin-top: 10px; /* Add margin to separate it from the spinner */
|
| 236 |
+
color: white; /* Set text color */
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
#results {
|
| 240 |
+
border: 2px solid blue;
|
| 241 |
+
width: 265px;
|
| 242 |
+
height: 300px;
|
| 243 |
+
display: flex;
|
| 244 |
+
flex-direction: column;
|
| 245 |
+
overflow-y: scroll;
|
| 246 |
+
margin: auto;
|
| 247 |
+
margin-top: 30px;
|
| 248 |
+
padding-bottom: 7px;
|
| 249 |
+
gap: 14px;
|
| 250 |
+
background: linear-gradient(black , black) padding-box,
|
| 251 |
+
linear-gradient(to right, red, blue) border-box;
|
| 252 |
+
border-radius: 20px;
|
| 253 |
+
border: 2.5px solid transparent;
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
#image-preview {
|
| 257 |
+
border: 2px solid blue;
|
| 258 |
+
width: 200px;
|
| 259 |
+
height: 200px;
|
| 260 |
+
display: flex;
|
| 261 |
+
flex-direction: column;
|
| 262 |
+
overflow-y: scroll;
|
| 263 |
+
margin: auto;
|
| 264 |
+
margin-top: 30px;
|
| 265 |
+
padding-bottom: 7px;
|
| 266 |
+
gap: 100px;
|
| 267 |
+
background: linear-gradient(black , black) padding-box,
|
| 268 |
+
linear-gradient(to right, red, blue) border-box;
|
| 269 |
+
border-radius: 20px;
|
| 270 |
+
border: 2.5px solid transparent;
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
#sourceImage {
|
| 274 |
+
max-width: 100%;
|
| 275 |
+
height: auto;
|
| 276 |
+
display: block;
|
| 277 |
+
margin: auto;
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
#loadingSpinner {
|
| 281 |
+
border: 3px solid rgba(255, 255, 255, 0.3);
|
| 282 |
+
border-radius: 50%;
|
| 283 |
+
border-top: 3px solid #ffffff;
|
| 284 |
+
width: 20px;
|
| 285 |
+
height: 20px;
|
| 286 |
+
animation: spin 2s linear infinite;
|
| 287 |
+
position: relative;
|
| 288 |
+
top: 50%;
|
| 289 |
+
left: 50%;
|
| 290 |
+
transform: translate(-50%, -50%);
|
| 291 |
+
display: none; /* Initially hide the loading spinner */
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
@keyframes spin {
|
| 295 |
+
0% { transform: rotate(0deg); }
|
| 296 |
+
100% { transform: rotate(360deg); }
|
| 297 |
+
}
|
| 298 |
+
#results {
|
| 299 |
+
position: relative; /* Set position to relative */
|
| 300 |
+
/* Your existing styles */
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
#copyIcon {
|
| 304 |
+
font-size: 24px; /* Adjust the font size as needed */
|
| 305 |
+
position: absolute;
|
| 306 |
+
bottom: 10px; /* Adjust the distance from the bottom */
|
| 307 |
+
left: 10px; /* Adjust the distance from the left */
|
| 308 |
+
cursor: pointer;
|
| 309 |
+
z-index: 1;
|
| 310 |
+
color: rgba(255, 255, 255, 0.7); /* Adjust the opacity value */
|
| 311 |
+
}
|
| 312 |
+
#resultContainer {
|
| 313 |
+
/* Include padding and border in the total height */
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
#resultContainer p {
|
| 317 |
+
font-size: 14px; /* Adjust the font size as needed */
|
| 318 |
+
text-align: center; /* Center text horizontally */
|
| 319 |
+
margin: 5px 0; /* Add margin for spacing between paragraphs */
|
| 320 |
+
line-height: 1.5; /* Adjust line height for better readability */
|
| 321 |
+
}
|
| 322 |
+
</style>
|
| 323 |
</head>
|
| 324 |
<body>
|
| 325 |
+
<h1>Aiconvert.online</h1>
|
| 326 |
+
<form id="upload-form" enctype="multipart/form-data">
|
| 327 |
+
<label for="image">Select image:</label>
|
| 328 |
+
<input type="file" id="image" accept="image/*" required onchange="previewImage(event)">
|
| 329 |
+
<div id="image-preview">
|
| 330 |
+
|
| 331 |
+
<img id="sourceImage">
|
| 332 |
+
</div><br>
|
| 333 |
+
|
| 334 |
+
|
| 335 |
+
|
| 336 |
+
|
| 337 |
+
|
| 338 |
+
|
| 339 |
+
|
| 340 |
+
|
| 341 |
+
|
| 342 |
+
|
| 343 |
<label for="language">Choose a language:</label>
|
| 344 |
<select name="language" id="language">
|
| 345 |
<option value="english">English</option>
|
|
|
|
| 453 |
|
| 454 |
<!-- Add more language options as needed -->
|
| 455 |
</select>
|
| 456 |
+
|
| 457 |
+
<button type="button" onclick="generateStory()">Generate Description</button>
|
| 458 |
</form>
|
| 459 |
+
<div id="results">
|
| 460 |
+
<div id="estimatedTime" style="display: none;">Estimated time: 90s</div>
|
| 461 |
+
<div id="loadingSpinner" style="display: none;"></div>
|
| 462 |
+
<i class="far fa-copy" id="copyIcon" onclick="copyTextToClipboard()"></i>
|
| 463 |
+
<div id="resultContainer">
|
| 464 |
+
</div>
|
| 465 |
+
</div>
|
| 466 |
|
| 467 |
<script>
|
| 468 |
+
function previewImage(event) {
|
| 469 |
+
const file = event.target.files[0];
|
| 470 |
+
const sourceImageContainer = document.getElementById('image-preview');
|
| 471 |
+
const uploadButton = document.querySelector('button');
|
| 472 |
+
|
| 473 |
+
// Check if file size is larger than 500 KB
|
| 474 |
+
if (file.size > 1000 * 1024) {
|
| 475 |
+
sourceImageContainer.innerHTML = `<p style="color: white;">Please upload an image smaller than 1000 KB.</p>`;
|
| 476 |
+
uploadButton.disabled = true; // Disable the button
|
| 477 |
+
return;
|
| 478 |
+
}
|
| 479 |
+
|
| 480 |
+
// If file size is within limit, display image preview
|
| 481 |
+
const reader = new FileReader();
|
| 482 |
+
reader.onload = function(event) {
|
| 483 |
+
sourceImageContainer.innerHTML = `<img src="${event.target.result}" alt="Uploaded Image" style="max-width: 300px; max-height: 300px;">`;
|
| 484 |
+
};
|
| 485 |
+
reader.readAsDataURL(file);
|
| 486 |
+
uploadButton.disabled = false; // Enable the button
|
| 487 |
+
}
|
| 488 |
+
|
| 489 |
+
async function generateStory() {
|
| 490 |
+
var formData = new FormData();
|
| 491 |
+
var fileInput = document.querySelector('input[type="file"]');
|
| 492 |
var languageSelect = document.getElementById('language');
|
| 493 |
formData.append('image_file', fileInput.files[0]);
|
| 494 |
formData.append('language', languageSelect.value);
|
| 495 |
+
// Check if the file input is empty
|
| 496 |
+
if (!fileInput.files[0]) {
|
| 497 |
+
document.getElementById('resultContainer').innerHTML = `<p style="color: white ;">Please upload an image.</p>`;
|
| 498 |
+
return;
|
| 499 |
+
}
|
| 500 |
+
|
| 501 |
+
// Clear the result container
|
| 502 |
+
document.getElementById('resultContainer').innerHTML = "";
|
| 503 |
+
// Display loading spinner
|
| 504 |
+
const loadingSpinner = document.getElementById('loadingSpinner');
|
| 505 |
+
loadingSpinner.style.display = 'block';
|
| 506 |
+
const estimatedTime = document.getElementById('estimatedTime');
|
| 507 |
+
estimatedTime.style.display = 'block';
|
| 508 |
+
|
| 509 |
+
try {
|
| 510 |
+
const response = await fetch('/generate-story/', {
|
| 511 |
+
method: 'POST',
|
| 512 |
+
body: formData
|
| 513 |
});
|
| 514 |
+
// Hide loading spinner
|
| 515 |
+
loadingSpinner.style.display = 'none';
|
| 516 |
+
estimatedTime.style.display = 'none';
|
| 517 |
+
|
| 518 |
+
if (response.ok) {
|
| 519 |
+
const resultContainer = document.getElementById('resultContainer');
|
| 520 |
+
const data = await response.text(); // Get response as text
|
| 521 |
+
resultContainer.innerHTML = '<h2></h2>';
|
| 522 |
+
resultContainer.innerText = data.story; // Set response text to innerText
|
| 523 |
+
|
| 524 |
+
} else {
|
| 525 |
+
document.getElementById('resultContainer').innerHTML = `<p style="color: white;">Oops! Something went wrong. Please try again later.</p>`;
|
| 526 |
+
}
|
| 527 |
+
} catch (error) {
|
| 528 |
+
console.error('Error:', error);
|
| 529 |
+
document.getElementById('resultContainer').innerHTML = `<p style="color: white ;">Oops! Something went wrong. Please try again later.</p>`;
|
| 530 |
+
}
|
| 531 |
+
}
|
| 532 |
+
function copyTextToClipboard() {
|
| 533 |
+
const resultContainer = document.getElementById('resultContainer');
|
| 534 |
+
const textToCopy = resultContainer.innerText;
|
| 535 |
+
|
| 536 |
+
// Create a temporary textarea element to copy the text
|
| 537 |
+
const textarea = document.createElement('textarea');
|
| 538 |
+
textarea.value = textToCopy;
|
| 539 |
+
document.body.appendChild(textarea);
|
| 540 |
+
|
| 541 |
+
// Select the text inside the textarea
|
| 542 |
+
textarea.select();
|
| 543 |
+
textarea.setSelectionRange(0, 99999); // For mobile devices
|
| 544 |
+
|
| 545 |
+
// Copy the selected text
|
| 546 |
+
document.execCommand('copy');
|
| 547 |
+
|
| 548 |
+
// Remove the temporary textarea
|
| 549 |
+
document.body.removeChild(textarea);
|
| 550 |
+
|
| 551 |
+
// Change the copy icon text to "Copied"
|
| 552 |
+
const copyIcon = document.getElementById('copyIcon');
|
| 553 |
+
copyIcon.textContent = ' # Copied' ;
|
| 554 |
+
copyIcon.style.fontSize = '14px';
|
| 555 |
+
// Revert the copy icon back to "Copy" after 1.5 seconds
|
| 556 |
+
setTimeout(() => {
|
| 557 |
+
copyIcon.textContent = '';
|
| 558 |
+
}, 1500);
|
| 559 |
+
}
|
| 560 |
+
|
| 561 |
+
|
| 562 |
</script>
|
| 563 |
</body>
|
| 564 |
</html>
|
| 565 |
|
|
|