Mahmoudmody777
commited on
Commit
•
318214d
1
Parent(s):
aae3e63
Update index.html
Browse files- index.html +35 -21
index.html
CHANGED
@@ -31,13 +31,13 @@
|
|
31 |
}
|
32 |
|
33 |
.header img {
|
34 |
-
max-height: 50px;
|
35 |
-
margin-right: 10px;
|
36 |
-
cursor: pointer;
|
37 |
}
|
38 |
|
39 |
.header img:hover + .tooltip {
|
40 |
-
display: block;
|
41 |
}
|
42 |
|
43 |
.tooltip {
|
@@ -48,8 +48,8 @@
|
|
48 |
padding: 5px;
|
49 |
border-radius: 5px;
|
50 |
font-size: 14px;
|
51 |
-
margin-left: -30px;
|
52 |
-
margin-top: -30px;
|
53 |
}
|
54 |
|
55 |
.container {
|
@@ -145,7 +145,7 @@
|
|
145 |
}
|
146 |
|
147 |
.slider-value {
|
148 |
-
width: 40px;
|
149 |
text-align: center;
|
150 |
font-size: 14px;
|
151 |
margin-left: 10px;
|
@@ -277,7 +277,7 @@
|
|
277 |
}
|
278 |
|
279 |
input[type="range"] {
|
280 |
-
width: 100%;
|
281 |
}
|
282 |
|
283 |
.toggle-button {
|
@@ -299,13 +299,13 @@
|
|
299 |
<body>
|
300 |
|
301 |
<div class="header">
|
302 |
-
<img src="palestine.png" alt="Logo" id="logo">
|
303 |
<span class="tooltip">Free Palestine</span>
|
304 |
Pray for Palestine
|
305 |
</div>
|
306 |
|
307 |
<div class="api-info">
|
308 |
-
<p>Get the API key and 50 free credits to generate images and purchase from here<a href="https://api.bfl.ml/auth/login#" target="_blank">BFL API Portal</a>.</p>
|
309 |
</div>
|
310 |
|
311 |
<div class="container">
|
@@ -337,6 +337,12 @@
|
|
337 |
<input type="range" id="steps" min="1" max="100" step="1" value="8">
|
338 |
<input class="slider-value" type="text" id="steps-value" value="8" readonly>
|
339 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
340 |
</div>
|
341 |
|
342 |
<button id="generate-btn">Generate Image</button>
|
@@ -364,9 +370,11 @@
|
|
364 |
const widthSlider = document.getElementById('width');
|
365 |
const heightSlider = document.getElementById('height');
|
366 |
const stepsSlider = document.getElementById('steps');
|
|
|
367 |
const widthValue = document.getElementById('width-value');
|
368 |
const heightValue = document.getElementById('height-value');
|
369 |
const stepsValue = document.getElementById('steps-value');
|
|
|
370 |
const statusElement = document.getElementById('status');
|
371 |
const outputContainer = document.getElementById('output-container');
|
372 |
const modal = document.getElementById('modal');
|
@@ -393,7 +401,7 @@
|
|
393 |
|
394 |
function loadImagesFromStorage() {
|
395 |
const savedImages = JSON.parse(localStorage.getItem('images')) || [];
|
396 |
-
savedImages.forEach(imgObj => addImageToOutput(imgObj.url, imgObj.prompt, imgObj.width, imgObj.height, imgObj.steps));
|
397 |
}
|
398 |
|
399 |
widthSlider.addEventListener('input', () => {
|
@@ -411,15 +419,20 @@
|
|
411 |
localStorage.setItem('lastSteps', stepsSlider.value);
|
412 |
});
|
413 |
|
|
|
|
|
|
|
|
|
|
|
414 |
generateBtn.addEventListener('click', async () => {
|
415 |
const prompt = promptInput.value;
|
416 |
const apiKey = apiKeyInput.value;
|
417 |
const width = widthSlider.value;
|
418 |
const height = heightSlider.value;
|
419 |
const steps = stepsSlider.value;
|
|
|
420 |
|
421 |
-
|
422 |
-
if (prompt.length >1000) {
|
423 |
alert('The prompt cannot exceed 1000 characters.');
|
424 |
return;
|
425 |
}
|
@@ -435,9 +448,9 @@
|
|
435 |
statusElement.textContent = 'Generating image...';
|
436 |
|
437 |
try {
|
438 |
-
const requestId = await sendImageGenerationRequest(prompt, width, height, steps, apiKey);
|
439 |
const imageUrl = await pollResult(requestId, apiKey);
|
440 |
-
addImageToOutput(imageUrl, prompt, width, height, steps);
|
441 |
statusElement.textContent = 'Image generated successfully!';
|
442 |
} catch (error) {
|
443 |
statusElement.textContent = `Error: ${error.message}`;
|
@@ -450,14 +463,14 @@
|
|
450 |
toggleApiKeyBtn.textContent = isApiKeyVisible ? 'Hide' : 'Show';
|
451 |
});
|
452 |
|
453 |
-
function addImageToOutput(imageUrl, prompt, width, height, steps) {
|
454 |
const container = document.createElement('div');
|
455 |
container.className = 'image-container';
|
456 |
|
457 |
const img = document.createElement('img');
|
458 |
img.src = imageUrl;
|
459 |
img.alt = "Generated Image";
|
460 |
-
img.onclick = () => openModal(imageUrl, prompt, width, height, steps);
|
461 |
|
462 |
const deleteButton = document.createElement('button');
|
463 |
deleteButton.className = 'delete-button';
|
@@ -474,7 +487,7 @@
|
|
474 |
|
475 |
let savedImages = JSON.parse(localStorage.getItem('images')) || [];
|
476 |
if (!savedImages.some(imgObj => imgObj.url === imageUrl)) {
|
477 |
-
savedImages.push({ url: imageUrl, prompt: prompt, width: width, height: height, steps: steps });
|
478 |
localStorage.setItem('images', JSON.stringify(savedImages));
|
479 |
}
|
480 |
}
|
@@ -485,11 +498,11 @@
|
|
485 |
localStorage.setItem('images', JSON.stringify(savedImages));
|
486 |
}
|
487 |
|
488 |
-
function openModal(imageUrl, prompt, width, height, steps) {
|
489 |
modal.style.display = 'flex';
|
490 |
modalImage.src = imageUrl;
|
491 |
promptInfo.innerText = `Prompt: ${prompt}`;
|
492 |
-
settingsInfo.innerText = `Width: ${width}, Height: ${height}, Steps: ${steps}`;
|
493 |
}
|
494 |
|
495 |
copyPromptBtn.onclick = () => {
|
@@ -503,7 +516,7 @@
|
|
503 |
}
|
504 |
};
|
505 |
|
506 |
-
async function sendImageGenerationRequest(prompt, width, height, steps, apiKey) {
|
507 |
const response = await fetch('https://api.bfl.ml/v1/image', {
|
508 |
method: 'POST',
|
509 |
headers: {
|
@@ -515,6 +528,7 @@
|
|
515 |
width: parseInt(width),
|
516 |
height: parseInt(height),
|
517 |
steps: parseInt(steps),
|
|
|
518 |
}),
|
519 |
});
|
520 |
|
|
|
31 |
}
|
32 |
|
33 |
.header img {
|
34 |
+
max-height: 50px;
|
35 |
+
margin-right: 10px;
|
36 |
+
cursor: pointer;
|
37 |
}
|
38 |
|
39 |
.header img:hover + .tooltip {
|
40 |
+
display: block;
|
41 |
}
|
42 |
|
43 |
.tooltip {
|
|
|
48 |
padding: 5px;
|
49 |
border-radius: 5px;
|
50 |
font-size: 14px;
|
51 |
+
margin-left: -30px;
|
52 |
+
margin-top: -30px;
|
53 |
}
|
54 |
|
55 |
.container {
|
|
|
145 |
}
|
146 |
|
147 |
.slider-value {
|
148 |
+
width: 40px;
|
149 |
text-align: center;
|
150 |
font-size: 14px;
|
151 |
margin-left: 10px;
|
|
|
277 |
}
|
278 |
|
279 |
input[type="range"] {
|
280 |
+
width: 100%;
|
281 |
}
|
282 |
|
283 |
.toggle-button {
|
|
|
299 |
<body>
|
300 |
|
301 |
<div class="header">
|
302 |
+
<img src="palestine.png" alt="Logo" id="logo">
|
303 |
<span class="tooltip">Free Palestine</span>
|
304 |
Pray for Palestine
|
305 |
</div>
|
306 |
|
307 |
<div class="api-info">
|
308 |
+
<p>Get the API key and 50 free credits to generate images and purchase from here<a href="https://api.bfl.ml/auth/login#" target="_blank">BFL API Portal</a>.</p>
|
309 |
</div>
|
310 |
|
311 |
<div class="container">
|
|
|
337 |
<input type="range" id="steps" min="1" max="100" step="1" value="8">
|
338 |
<input class="slider-value" type="text" id="steps-value" value="8" readonly>
|
339 |
</div>
|
340 |
+
|
341 |
+
<div class="slider-container">
|
342 |
+
<label for="prompt-power">Prompt Power:</label>
|
343 |
+
<input type="range" id="prompt-power" min="1" max="10" step="0.1" value="3.5">
|
344 |
+
<input class="slider-value" type="text" id="prompt-power-value" value="3.5" readonly>
|
345 |
+
</div>
|
346 |
</div>
|
347 |
|
348 |
<button id="generate-btn">Generate Image</button>
|
|
|
370 |
const widthSlider = document.getElementById('width');
|
371 |
const heightSlider = document.getElementById('height');
|
372 |
const stepsSlider = document.getElementById('steps');
|
373 |
+
const promptPowerSlider = document.getElementById('prompt-power'); // خانة التحكم الجديدة
|
374 |
const widthValue = document.getElementById('width-value');
|
375 |
const heightValue = document.getElementById('height-value');
|
376 |
const stepsValue = document.getElementById('steps-value');
|
377 |
+
const promptPowerValue = document.getElementById('prompt-power-value'); // خانة التحكم الجديدة
|
378 |
const statusElement = document.getElementById('status');
|
379 |
const outputContainer = document.getElementById('output-container');
|
380 |
const modal = document.getElementById('modal');
|
|
|
401 |
|
402 |
function loadImagesFromStorage() {
|
403 |
const savedImages = JSON.parse(localStorage.getItem('images')) || [];
|
404 |
+
savedImages.forEach(imgObj => addImageToOutput(imgObj.url, imgObj.prompt, imgObj.width, imgObj.height, imgObj.steps, imgObj.promptPower));
|
405 |
}
|
406 |
|
407 |
widthSlider.addEventListener('input', () => {
|
|
|
419 |
localStorage.setItem('lastSteps', stepsSlider.value);
|
420 |
});
|
421 |
|
422 |
+
promptPowerSlider.addEventListener('input', () => {
|
423 |
+
promptPowerValue.value = promptPowerSlider.value;
|
424 |
+
localStorage.setItem('lastPromptPower', promptPowerSlider.value);
|
425 |
+
});
|
426 |
+
|
427 |
generateBtn.addEventListener('click', async () => {
|
428 |
const prompt = promptInput.value;
|
429 |
const apiKey = apiKeyInput.value;
|
430 |
const width = widthSlider.value;
|
431 |
const height = heightSlider.value;
|
432 |
const steps = stepsSlider.value;
|
433 |
+
const promptPower = promptPowerSlider.value; // قيمة Prompt Power
|
434 |
|
435 |
+
if (prompt.length > 1000) {
|
|
|
436 |
alert('The prompt cannot exceed 1000 characters.');
|
437 |
return;
|
438 |
}
|
|
|
448 |
statusElement.textContent = 'Generating image...';
|
449 |
|
450 |
try {
|
451 |
+
const requestId = await sendImageGenerationRequest(prompt, width, height, steps, promptPower, apiKey); // تمرير Prompt Power
|
452 |
const imageUrl = await pollResult(requestId, apiKey);
|
453 |
+
addImageToOutput(imageUrl, prompt, width, height, steps, promptPower); // تمرير Prompt Power
|
454 |
statusElement.textContent = 'Image generated successfully!';
|
455 |
} catch (error) {
|
456 |
statusElement.textContent = `Error: ${error.message}`;
|
|
|
463 |
toggleApiKeyBtn.textContent = isApiKeyVisible ? 'Hide' : 'Show';
|
464 |
});
|
465 |
|
466 |
+
function addImageToOutput(imageUrl, prompt, width, height, steps, promptPower) { // إضافة خانة Prompt Power
|
467 |
const container = document.createElement('div');
|
468 |
container.className = 'image-container';
|
469 |
|
470 |
const img = document.createElement('img');
|
471 |
img.src = imageUrl;
|
472 |
img.alt = "Generated Image";
|
473 |
+
img.onclick = () => openModal(imageUrl, prompt, width, height, steps, promptPower); // تمرير Prompt Power
|
474 |
|
475 |
const deleteButton = document.createElement('button');
|
476 |
deleteButton.className = 'delete-button';
|
|
|
487 |
|
488 |
let savedImages = JSON.parse(localStorage.getItem('images')) || [];
|
489 |
if (!savedImages.some(imgObj => imgObj.url === imageUrl)) {
|
490 |
+
savedImages.push({ url: imageUrl, prompt: prompt, width: width, height: height, steps: steps, promptPower: promptPower }); // إضافة خانة Prompt Power
|
491 |
localStorage.setItem('images', JSON.stringify(savedImages));
|
492 |
}
|
493 |
}
|
|
|
498 |
localStorage.setItem('images', JSON.stringify(savedImages));
|
499 |
}
|
500 |
|
501 |
+
function openModal(imageUrl, prompt, width, height, steps, promptPower) { // تمرير Prompt Power
|
502 |
modal.style.display = 'flex';
|
503 |
modalImage.src = imageUrl;
|
504 |
promptInfo.innerText = `Prompt: ${prompt}`;
|
505 |
+
settingsInfo.innerText = `Width: ${width}, Height: ${height}, Steps: ${steps}, Prompt Power: ${promptPower}`; // عرض Prompt Power
|
506 |
}
|
507 |
|
508 |
copyPromptBtn.onclick = () => {
|
|
|
516 |
}
|
517 |
};
|
518 |
|
519 |
+
async function sendImageGenerationRequest(prompt, width, height, steps, promptPower, apiKey) { // إضافة خانة Prompt Power
|
520 |
const response = await fetch('https://api.bfl.ml/v1/image', {
|
521 |
method: 'POST',
|
522 |
headers: {
|
|
|
528 |
width: parseInt(width),
|
529 |
height: parseInt(height),
|
530 |
steps: parseInt(steps),
|
531 |
+
promptPower: parseFloat(promptPower), // تمرير Prompt Power
|
532 |
}),
|
533 |
});
|
534 |
|