back up to previous version
- User
back up to previous version
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
back up to previous version
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Here's the complete solution for the previous version:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Item Catalog</title>
<style>
body { font-family: Arial, sans-serif; padding: 20px; }
.item { border: 1px solid #ccc; padding: 10px; margin-bottom: 10px; display: flex; gap: 20px; align-items: center; }
.item img { max-width: 150px; height: auto; }
.item-description { flex-grow: 1; }
input[type="email"] { width: 300px; padding: 5px; margin-bottom: 20px; }
button { padding: 10px 20px; font-size: 16px; }
</style>
</head>
<body>
<h1>Item Selection</h1>
<label for="email">Enter your email:</label><br>
<input type="email" id="email" placeholder="example@example.com" required><br><br>
<div id="items"></div>
<button onclick="downloadSelected()">Send</button>
<script>
async function loadItems() {
try {
const response = await fetch('items.txt');
const text = await response.text();
const lines = text.trim().split('\n');
const itemsContainer = document.getElementById('items');
lines.forEach((line, index) => {
const [filename, description] = line.split('|');
const itemDiv = document.createElement('div');
itemDiv.classList.add('item');
itemDiv.innerHTML = `
<img src="images/${filename}" alt="Item image">
<div class="item-description">
<p>${description}</p>
<label>
<input type="checkbox" class="item-checkbox" data-description="${description}">
Interested
</label>
</div>
`;
itemsContainer.appendChild(itemDiv);
});
} catch (err) {
console.error('Error loading items:', err);
}
}
function downloadSelected() {
const email = document.getElementById('email').value;
const checkboxes = document.querySelectorAll('.item-checkbox:checked');
if (!email) {
alert('Please enter your email address.');
return;
}
if (checkboxes.length === 0) {
alert('Please select at least one item.');
return;
}
// Create content for the file
let message = `Thank you for your interest, ${email}!\n\nYou have selected the following items:\n\n`;
checkboxes.forEach(cb => {
message += `- ${cb.getAttribute('data-description')}\n`;
});
// Create downloadable text file
const blob = new Blob([message], { type: 'text/plain' });
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = 'selected_items.txt';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
// Load items on page load
window.onload = loadItems;
</script>
</body>
</html>
This HTML file should be saved as index.html in the same directory as your items.txt and images/ folder. When opened in a web browser, it will allow users to enter their email, view and select items, and download a text file with their selections.
Add a feature that when a user clicks on an image it will pop up a full size image view so they can see more detail in the photo.
Here's the complete solution with the added feature to view full-size images:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Item Catalog</title>
<style>
body { font-family: Arial, sans-serif; padding: 20px; }
.item { border: 1px solid #ccc; padding: 10px; margin-bottom: 10px; display: flex; gap: 20px; align-items: center; }
.item img { max-width: 150px; height: auto; cursor: pointer; }
.item-description { flex-grow: 1; }
input[type="email"] { width: 300px; padding: 5px; margin-bottom: 20px; }
button { padding: 10px 20px; font-size: 16px; }
/* Modal styles */
.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.7);
}
.modal-content {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #fefefe;
padding: 20px;
border: 1px solid #888;
width: 80%;
max-width: 800px;
text-align: center;
}
.modal-content img {
max-width: 100%;
max-height: 80vh;
}
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
cursor: pointer;
}
.close:hover {
color: black;
}
</style>
</head>
<body>
<h1>Item Selection</h1>
<label for="email">Enter your email:</label><br>
<input type="email" id="email" placeholder="example@example.com" required><br><br>
<div id="items"></div>
<button onclick="downloadSelected()">Send</button>
<!-- Modal for full-size image -->
<div id="imageModal" class="modal">
<div class="modal-content">
<span class="close">×</span>
<img id="modalImage" src="" alt="Full-size image">
</div>
</div>
<script>
async function loadItems() {
try {
const response = await fetch('items.txt');
const text = await response.text();
const lines = text.trim().split('\n');
const itemsContainer = document.getElementById('items');
lines.forEach((line, index) => {
const [filename, description] = line.split('|');
const itemDiv = document.createElement('div');
itemDiv.classList.add('item');
itemDiv.innerHTML = `
<img src="images/${filename}" alt="Item image" onclick="showFullSizeImage('images/${filename}')">
<div class="item-description">
<p>${description}</p>
<label>
<input type="checkbox" class="item-checkbox" data-description="${description}">
Interested
</label>
</div>
`;
itemsContainer.appendChild(itemDiv);
});
} catch (err) {
console.error('Error loading items:', err);
}
}
function showFullSizeImage(imageSrc) {
const modal = document.getElementById('imageModal');
const modalImg = document.getElementById('modalImage');
modal.style.display = 'block';
modalImg.src = imageSrc;
}
function closeModal() {
const modal = document.getElementById('imageModal');
modal.style.display = 'none';
}
// Close the modal when clicking on the close button
document.querySelector('.close').addEventListener('click', closeModal);
// Close the modal when clicking outside the image
document.getElementById('imageModal').addEventListener('click', function(event) {
if (event.target === this) {
closeModal();
}
});
function downloadSelected() {
const email = document.getElementById('email').value;
const checkboxes = document.querySelectorAll('.item-checkbox:checked');
if (!email) {
alert('Please enter your email address.');
return;
}
if (checkboxes.length === 0) {
alert('Please select at least one item.');
return;
}
// Create content for the file
let message = `Thank you for your interest, ${email}!\n\nYou have selected the following items:\n\n`;
checkboxes.forEach(cb => {
message += `- ${cb.getAttribute('data-description')}\n`;
});
// Create downloadable text file
const blob = new Blob([message], { type: 'text/plain' });
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = 'selected_items.txt';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
// Load items on page load
window.onload = loadItems;
</script>
</body>
</html>
This solution adds a modal that appears when an image is clicked, displaying the full-size image. The modal can be closed by clicking the close button or clicking outside the image. The rest of the functionality remains the same, allowing users to select items and download a text file with their selections.