Select JPG images
or drag and drop JPG files here
.jpg-to-pdf-converter {
font-family: ‘Segoe UI’, Tahoma, Geneva, Verdana, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
text-align: center;
color: #333;
}
.converter-header h1 {
font-size: 32px;
margin-bottom: 10px;
color: #2c3e50;
}
.converter-header p {
font-size: 16px;
color: #7f8c8d;
margin-bottom: 30px;
}
.converter-container {
background-color: #f8f9fa;
border-radius: 10px;
padding: 30px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}
.upload-area {
border: 2px dashed #4a6cf7;
border-radius: 8px;
padding: 40px 20px;
margin-bottom: 20px;
transition: all 0.3s ease;
background-color: rgba(74, 108, 247, 0.05);
}
.upload-area:hover {
background-color: rgba(74, 108, 247, 0.1);
}
.upload-area.drag-over {
background-color: rgba(74, 108, 247, 0.2);
border-color: #3a5bd9;
}
.upload-icon {
margin-bottom: 15px;
}
.upload-area h3 {
font-size: 18px;
margin-bottom: 5px;
color: #2c3e50;
}
.upload-area p {
font-size: 14px;
color: #7f8c8d;
margin-bottom: 20px;
}
.select-files-btn {
background-color: #4a6cf7;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
font-size: 14px;
cursor: pointer;
transition: background-color 0.3s;
}
.select-files-btn:hover {
background-color: #3a5bd9;
}
.cloud-options {
display: flex;
justify-content: center;
gap: 20px;
}
.cloud-option {
display: flex;
align-items: center;
padding: 10px 15px;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}
.cloud-option:hover {
background-color: rgba(74, 108, 247, 0.1);
}
.cloud-icon {
margin-right: 8px;
}
.converter-footer p {
font-size: 14px;
color: #7f8c8d;
margin-top: 30px;
}
/* Modal styles */
.modal {
display: none;
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
}
.modal-content {
background-color: white;
margin: 10% auto;
padding: 20px;
border-radius: 8px;
width: 80%;
max-width: 500px;
}
.close-btn {
float: right;
font-size: 24px;
cursor: pointer;
}
.url-input {
width: 100%;
padding: 10px;
margin: 15px 0;
border: 1px solid #ddd;
border-radius: 4px;
}
.submit-btn {
background-color: #4a6cf7;
color: white;
border: none;
padding: 10px 20px;
border-radius: 4px;
cursor: pointer;
}
document.addEventListener(‘DOMContentLoaded’, function() {
const uploadArea = document.getElementById(‘uploadArea’);
const fileInput = document.getElementById(‘fileInput’);
const selectFilesBtn = document.getElementById(‘selectFilesBtn’);
const dropboxOption = document.getElementById(‘dropboxOption’);
const driveOption = document.getElementById(‘driveOption’);
// Handle file selection via button
selectFilesBtn.addEventListener(‘click’, function() {
fileInput.click();
});
// Handle file selection via input
fileInput.addEventListener(‘change’, function(e) {
if (e.target.files.length > 0) {
handleFiles(e.target.files);
}
});
// Drag and drop functionality
[‘dragenter’, ‘dragover’, ‘dragleave’, ‘drop’].forEach(eventName => {
uploadArea.addEventListener(eventName, preventDefaults, false);
});
function preventDefaults(e) {
e.preventDefault();
e.stopPropagation();
}
[‘dragenter’, ‘dragover’].forEach(eventName => {
uploadArea.addEventListener(eventName, highlight, false);
});
[‘dragleave’, ‘drop’].forEach(eventName => {
uploadArea.addEventListener(eventName, unhighlight, false);
});
function highlight() {
uploadArea.classList.add(‘drag-over’);
}
function unhighlight() {
uploadArea.classList.remove(‘drag-over’);
}
uploadArea.addEventListener(‘drop’, function(e) {
const dt = e.dataTransfer;
const files = dt.files;
if (files.length > 0) {
handleFiles(files);
}
});
// Cloud options
dropboxOption.addEventListener(‘click’, function() {
showModal(‘Dropbox’);
});
driveOption.addEventListener(‘click’, function() {
showModal(‘Google Drive’);
});
// Handle the selected files (simulated conversion)
function handleFiles(files) {
// Check if files are JPG images
const validFiles = Array.from(files).filter(file =>
file.type === ‘image/jpeg’ || file.name.toLowerCase().endsWith(‘.jpg’) || file.name.toLowerCase().endsWith(‘.jpeg’)
);
if (validFiles.length === 0) {
alert(‘Please select valid JPG files.’);
return;
}
// Simulate conversion process
alert(`Selected ${validFiles.length} JPG file(s). Conversion to PDF would happen here.`);
// In a real implementation, you would upload the files to a server for conversion
// and then provide a download link for the resulting PDF
}
// Modal for cloud services
function showModal(service) {
const modal = document.createElement(‘div’);
modal.className = ‘modal’;
modal.innerHTML = `
×
Import from ${service}
Paste the ${service} URL of your JPG file below:
`;
document.body.appendChild(modal);
modal.style.display = ‘block’;
const closeBtn = modal.querySelector(‘.close-btn’);
closeBtn.addEventListener(‘click’, function() {
modal.style.display = ‘none’;
document.body.removeChild(modal);
});
const submitBtn = modal.querySelector(‘.submit-btn’);
submitBtn.addEventListener(‘click’, function() {
const urlInput = modal.querySelector(‘.url-input’);
if (urlInput.value.trim() === ”) {
alert(‘Please enter a valid URL’);
return;
}
// Simulate conversion
alert(`Converting JPG from ${service} URL: ${urlInput.value}`);
modal.style.display = ‘none’;
document.body.removeChild(modal);
});
// Close modal when clicking outside
window.addEventListener(‘click’, function(e) {
if (e.target === modal) {
modal.style.display = ‘none’;
document.body.removeChild(modal);
}
});
}
});