Spaces:
Running
Running
Ron Au
commited on
Commit
·
2458d58
1
Parent(s):
5c239ba
fix(ui): Maintain duration time after loss of focus
Browse files- app.py +0 -1
- static/index.js +8 -2
- templates/index.html +1 -1
app.py
CHANGED
@@ -5,7 +5,6 @@ from modules.details import load_lists, rand_details
|
|
5 |
from modules.inference import generate_image
|
6 |
|
7 |
app = Flask(__name__)
|
8 |
-
app.config['TEMPLATES_AUTO_RELOAD'] = True
|
9 |
|
10 |
|
11 |
@app.route('/')
|
|
|
5 |
from modules.inference import generate_image
|
6 |
|
7 |
app = Flask(__name__)
|
|
|
8 |
|
9 |
|
10 |
@app.route('/')
|
static/index.js
CHANGED
@@ -206,7 +206,6 @@ const cardRotationInitiator = (renderSection) => {
|
|
206 |
|
207 |
generateButton.addEventListener('click', async () => {
|
208 |
const details = await generateDetails();
|
209 |
-
console.log({ details });
|
210 |
|
211 |
const renderSection = document.querySelector('section.render');
|
212 |
const durationSeconds = document.querySelector('.duration > .seconds');
|
@@ -218,11 +217,18 @@ generateButton.addEventListener('click', async () => {
|
|
218 |
|
219 |
queueTask(task.task_id);
|
220 |
|
|
|
|
|
221 |
const incrementSeconds = setInterval(() => {
|
|
|
222 |
duration += 0.1;
|
223 |
-
durationSeconds.textContent = duration.toFixed(1)
|
224 |
}, 100);
|
225 |
|
|
|
|
|
|
|
|
|
226 |
const completedTask = await longPollTask(task);
|
227 |
|
228 |
clearInterval(incrementSeconds);
|
|
|
206 |
|
207 |
generateButton.addEventListener('click', async () => {
|
208 |
const details = await generateDetails();
|
|
|
209 |
|
210 |
const renderSection = document.querySelector('section.render');
|
211 |
const durationSeconds = document.querySelector('.duration > .seconds');
|
|
|
217 |
|
218 |
queueTask(task.task_id);
|
219 |
|
220 |
+
const startTime = performance.now();
|
221 |
+
|
222 |
const incrementSeconds = setInterval(() => {
|
223 |
+
console.log(typeof duration);
|
224 |
duration += 0.1;
|
225 |
+
durationSeconds.textContent = duration.toFixed(1);
|
226 |
}, 100);
|
227 |
|
228 |
+
window.addEventListener('focus', () => {
|
229 |
+
duration = Number(((performance.now() - startTime) / 1000).toFixed(1));
|
230 |
+
});
|
231 |
+
|
232 |
const completedTask = await longPollTask(task);
|
233 |
|
234 |
clearInterval(incrementSeconds);
|
templates/index.html
CHANGED
@@ -15,7 +15,7 @@
|
|
15 |
</head>
|
16 |
<body>
|
17 |
<h1>This Pokémon Does Not Exist</h1>
|
18 |
-
<div class="duration"><span class="seconds">0.0</span
|
19 |
<button class="generate">Generate Pokémon Card with AI</button>
|
20 |
<section class="render"></section>
|
21 |
</body>
|
|
|
15 |
</head>
|
16 |
<body>
|
17 |
<h1>This Pokémon Does Not Exist</h1>
|
18 |
+
<div class="duration"><span class="seconds">0.0</span>s (ETA: 350s)</div>
|
19 |
<button class="generate">Generate Pokémon Card with AI</button>
|
20 |
<section class="render"></section>
|
21 |
</body>
|