I'll help you set up a website for your 3D print files. Let's create a basic structure with sections for free and paid downloads, without adding the actual files yet.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LUFFY101 - 3D Print Files</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f5f5f5;
}
header {
background-color: #333;
color: white;
padding: 20px;
text-align: center;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
.section {
background-color: white;
border-radius: 5px;
padding: 20px;
margin-bottom: 20px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
h2 {
color: #333;
border-bottom: 2px solid #eee;
padding-bottom: 10px;
}
.file-item {
display: flex;
justify-content: space-between;
padding: 10px 0;
border-bottom: 1px solid #eee;
}
.price {
font-weight: bold;
color: #4CAF50;
}
.free {
color: #2196F3;
}
footer {
background-color: #333;
color: white;
text-align: center;
padding: 10px;
position: fixed;
bottom: 0;
width: 100%;
}
</style>
</head>
<body>
<header>
<h1>LUFFY101 3D Print Files</h1>
</header>
<div class="container">
<div class="section">
<h2>Free Downloads</h2>
<div class="file-item">
<span>Sample Free File 1</span>
<span class="free">FREE</span>
</div>
<div class="file-item">
<span>Sample Free File 2</span>
<span class="free">FREE</span>
</div>
<!-- Add more free files here -->
</div>
<div class="section">
<h2>Premium Downloads</h2>
<div class="file-item">
<span>Premium Model 1</span>
<span class="price">$4.99</span>
</div>
<div class="file-item">
<span>Premium Model 2</span>
<span class="price">$7.99</span>
</div>
<!-- Add more premium files here -->
</div>
</div>
<footer>
© 2023 LUFFY101 - All rights reserved
</footer>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LUFFY101 - 3D Print Files</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f5f5f5;
}
header {
background-color: #333;
color: white;
padding: 20px;
text-align: center;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
.section {
background-color: white;
border-radius: 5px;
padding: 20px;
margin-bottom: 20px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
h2 {
color: #333;
border-bottom: 2px solid #eee;
padding-bottom: 10px;
}
.file-item {
display: flex;
justify-content: space-between;
padding: 10px 0;
border-bottom: 1px solid #eee;
}
.price {
font-weight: bold;
color: #4CAF50;
}
.free {
color: #2196F3;
}
footer {
background-color: #333;
color: white;
text-align: center;
padding: 10px;
position: fixed;
bottom: 0;
width: 100%;
}
</style>
</head>
<body>
<header>
<h1>LUFFY101 3D Print Files</h1>
</header>
<div class="container">
<div class="section">
<h2>Free Downloads</h2>
<div class="file-item">
<span>Sample Free File 1</span>
<span class="free">FREE</span>
</div>
<div class="file-item">
<span>Sample Free File 2</span>
<span class="free">FREE</span>
</div>
<!-- Add more free files here -->
</div>
<div class="section">
<h2>Premium Downloads</h2>
<div class="file-item">
<span>Premium Model 1</span>
<span class="price">$4.99</span>
</div>
<div class="file-item">
<span>Premium Model 2</span>
<span class="price">$7.99</span>
</div>
<!-- Add more premium files here -->
</div>
</div>
<footer>
© 2023 LUFFY101 - All rights reserved
</footer>
</body>
</html>
This is a basic HTML template for your 3D print files website. It includes:
To implement this:
index.htmlWould you like me to add any specific features to this basic template?
I'll help you modify the website to use C Points instead of money for purchasing files. Here's the updated HTML code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LUFFY101 - 3D Print Files</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f5f5f5;
}
header {
background-color: #333;
color: white;
padding: 20px;
text-align: center;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
.section {
background-color: white;
border-radius: 5px;
padding: 20px;
margin-bottom: 20px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
h2 {
color: #333;
border-bottom: 2px solid #eee;
padding-bottom: 10px;
}
.file-item {
display: flex;
justify-content: space-between;
padding: 10px 0;
border-bottom: 1px solid #eee;
}
.price {
font-weight: bold;
color: #4CAF50;
}
.free {
color: #2196F3;
}
.c-points {
display: flex;
align-items: center;
}
.c-points img {
width: 20px;
height: 20px;
margin-right: 5px;
}
footer {
background-color: #333;
color: white;
text-align: center;
padding: 10px;
position: fixed;
bottom: 0;
width: 100%;
}
</style>
</head>
<body>
<header>
<h1>LUFFY101 3D Print Files</h1>
</header>
<div class="container">
<div class="section">
<h2>Free Download</h2>
<div class="file-item">
<span>Sample Free File 1</span>
<span class="free">FREE</span>
</div>
<div class="file-item">
<span>Sample Free File 2</span>
<span class="free">FREE</span>
</div>
</div>
<div class="section">
<h2>Premium Download</h2>
<div class="file-item">
<span>Premium Model 1</span>
<div class="c-points">
<img src="https://pic2-cdn.creality.com/content/cover/2e095e2e32b5d6ca46c1c5d7a22faf7e" alt="C Points">
<span class="price">50 C Points</span>
</div>
</div>
<div class="file-item">
<span>Premium Model 2</span>
<div class="c-points">
<img src="https://pic2-cdn.creality.com/content/cover/2e095e2e32b5d6ca46c1c5d7a22faf7e" alt="C Points">
<span class="price">75 C Points</span>
</div>
</div>
</div>
</div>
<footer>
© 2023 LUFFY101 - All rights reserved
</footer>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LUFFY101 - 3D Print Files</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f5f5f5;
}
header {
background-color: #333;
color: white;
padding: 20px;
text-align: center;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
.section {
background-color: white;
border-radius: 5px;
padding: 20px;
margin-bottom: 20px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
h2 {
color: #333;
border-bottom: 2px solid #eee;
padding-bottom: 10px;
}
.file-item {
display: flex;
justify-content: space-between;
padding: 10px 0;
border-bottom: 1px solid #eee;
}
.price {
font-weight: bold;
color: #4CAF50;
}
.free {
color: #2196F3;
}
.c-points {
display: flex;
align-items: center;
}
.c-points img {
width: 20px;
height: 20px;
margin-right: 5px;
}
footer {
background-color: #333;
color: white;
text-align: center;
padding: 10px;
position: fixed;
bottom: 0;
width: 100%;
}
</style>
</head>
<body>
<header>
<h1>LUFFY101 3D Print Files</h1>
</header>
<div class="container">
<div class="section">
<h2>Free Download</h2>
<div class="file-item">
<span>Sample Free File 1</span>
<span class="free">FREE</span>
</div>
<div class="file-item">
<span>Sample Free File 2</span>
<span class="free">FREE</span>
</div>
</div>
<div class="section">
<h2>Premium Download</h2>
<div class="file-item">
<span>Premium Model 1</span>
<div class="c-points">
<img src="https://pic2-cdn.creality.com/content/cover/2e095e2e32b5d6ca46c1c5d7a22faf7e" alt="C Points">
<span class="price">50 C Points</span>
</div>
</div>
<div class="file-item">
<span>Premium Model 2</span>
<div class="c-points">
<img src="https://pic2-cdn.creality.com/content/cover/2e095e2e32b5d6ca46c1c5d7a22faf7e" alt="C Points">
<span class="price">75 C Points</span>
</div>
</div>
</div>
</div>
<footer>
© 2023 LUFFY101 - All rights reserved
</footer>
</body>
</html>
Key changes made:
The C Points image will be loaded from the URL you provided. The premium items now show their cost in C Points with the icon displayed next to the amount. The free items remain unchanged.
Here's the updated website with download functionality for free files and C Points verification for premium files:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LUFFY101 - 3D Print Files</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f5f5f5;
}
header {
background-color: #333;
color: white;
padding: 20px;
text-align: center;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
padding-bottom: 80px;
}
.section {
background-color: white;
border-radius: 5px;
padding: 20px;
margin-bottom: 20px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
h2 {
color: #333;
border-bottom: 2px solid #eee;
padding-bottom: 10px;
}
.file-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 0;
border-bottom: 1px solid #eee;
}
.price {
font-weight: bold;
color: #4CAF50;
}
.free {
color: #2196F3;
}
.c-points {
display: flex;
align-items: center;
}
.c-points img {
width: 20px;
height: 20px;
margin-right: 5px;
}
footer {
background-color: #333;
color: white;
text-align: center;
padding: 10px;
position: fixed;
bottom: 0;
width: 100%;
}
.download-btn {
background-color: #4CAF50;
color: white;
border: none;
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
margin-left: 10px;
}
.download-btn:hover {
background-color: #45a049;
}
.progress-container {
width: 100%;
background-color: #ddd;
border-radius: 4px;
margin-top: 10px;
display: none;
}
.progress-bar {
width: 0%;
height: 20px;
background-color: #4CAF50;
border-radius: 4px;
text-align: center;
line-height: 20px;
color: white;
}
.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.4);
}
.modal-content {
background-color: #fefefe;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
max-width: 400px;
border-radius: 5px;
}
.modal-buttons {
display: flex;
justify-content: space-between;
margin-top: 20px;
}
.modal-btn {
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
}
.confirm-btn {
background-color: #4CAF50;
color: white;
border: none;
}
.cancel-btn {
background-color: #f44336;
color: white;
border: none;
}
.user-cpoints {
position: absolute;
top: 20px;
right: 20px;
background-color: #333;
color: white;
padding: 5px 10px;
border-radius: 4px;
display: flex;
align-items: center;
}
</style>
</head>
<body>
<header>
<h1>LUFFY101 3D Print Files</h1>
<div class="user-cpoints">
<img src="https://pic2-cdn.creality.com/content/cover/2e095e2e32b5d6ca46c1c5d7a22faf7e" alt="C Points" style="width: 20px; height: 20px; margin-right: 5px;">
<span id="userPoints">100</span> C Points
</div>
</header>
<div class="container">
<div class="section">
<h2>Free Download</h2>
<div class="file-item">
<span>Sample Free File 1</span>
<div>
<span class="free">FREE</span>
<button class="download-btn" onclick="downloadFreeFile('Sample Free File 1')">Download</button>
</div>
<div class="progress-container" id="progress1">
<div class="progress-bar" id="progressBar1">0%</div>
</div>
</div>
<div class="file-item">
<span>Sample Free File 2</span>
<div>
<span class="free">FREE</span>
<button class="download-btn" onclick="downloadFreeFile('Sample Free File 2')">Download</button>
</div>
<div class="progress-container" id="progress2">
<div class="progress-bar" id="progressBar2">0%</div>
</div>
</div>
</div>
<div class="section">
<h2>Premium Download</h2>
<div class="file-item">
<span>Premium Model 1</span>
<div>
<div class="c-points">
<img src="https://pic2-cdn.creality.com/content/cover/2e095e2e32b5d6ca46c1c5d7a22faf7e" alt="C Points">
<span class="price">50 C Points</span>
</div>
<button class="download-btn" onclick="showPurchaseModal('Premium Model 1', 50)">Download</button>
</div>
</div>
<div class="file-item">
<span>Premium Model 2</span>
<div>
<div class="c-points">
<img src="https://pic2-cdn.creality.com/content/cover/2e095e2e32b5d6ca46c1c5d7a22faf7e" alt="C Points">
<span class="price">75 C Points</span>
</div>
<button class="download-btn" onclick="showPurchaseModal('Premium Model 2', 75)">Download</button>
</div>
</div>
</div>
</div>
<div id="purchaseModal" class="modal">
<div class="modal-content">
<h3 id="modalTitle">Confirm Purchase</h3>
<p id="modalText">Are you sure you want to spend <span id="modalPoints">0</span> C Points to download this file?</p>
<div class="modal-buttons">
<button class="modal-btn cancel-btn" onclick="closeModal()">Cancel</button>
<button class="modal-btn confirm-btn" onclick="confirmPurchase()">Confirm</button>
</div>
</div>
</div>
<footer>
© 2023 LUFFY101 - All rights reserved
</footer>
<script>
let currentFile = null;
let currentCost = 0;
function downloadFreeFile(filename) {
const progressId = filename.includes('1') ? '1' : '2';
const progressContainer = document.getElementById(`progress${progressId}`);
const progressBar = document.getElementById(`progressBar${progressId}`);
progressContainer.style.display = 'block';
progressBar.style.width = '0%';
progressBar.textContent = '0%';
let progress = 0;
const interval = setInterval(() => {
progress += 1;
progressBar.style.width = `${progress}%`;
progressBar.textContent = `${progress}%`;
if (progress >= 100) {
clearInterval(interval);
setTimeout(() => {
progressContainer.style.display = 'none';
alert(`Download complete: ${filename}`);
}, 100);
}
}, 100);
}
function showPurchaseModal(filename, cost) {
currentFile = filename;
currentCost = cost;
const userPoints = parseInt(document.getElementById('userPoints').textContent);
if (userPoints < cost) {
alert('Not enough C Points to purchase this model');
return;
}
document.getElementById('modalTitle').textContent = `Purchase ${filename}`;
document.getElementById('modalPoints').textContent = cost;
document.getElementById('modalText').textContent = `Are you sure you want to spend ${cost} C Points to download this file?`;
document.getElementById('purchaseModal').style.display = 'block';
}
function closeModal() {
document.getElementById('purchaseModal').style.display = 'none';
}
function confirmPurchase() {
const userPointsElement = document.getElementById('userPoints');
let userPoints = parseInt(userPointsElement.textContent);
if (userPoints >= currentCost) {
userPoints -= currentCost;
userPointsElement.textContent = userPoints;
closeModal();
alert(`Download started: ${currentFile}\nRemaining C Points: ${userPoints}`);
} else {
alert('Not enough C Points');
closeModal();
}
}
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LUFFY101 - 3D Print Files</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f5f5f5;
}
header {
background-color: #333;
color: white;
padding: 20px;
text-align: center;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
padding-bottom: 80px;
}
.section {
background-color: white;
border-radius: 5px;
padding: 20px;
margin-bottom: 20px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
h2 {
color: #333;
border-bottom: 2px solid #eee;
padding-bottom: 10px;
}
.file-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 0;
border-bottom: 1px solid #eee;
}
.price {
font-weight: bold;
color: #4CAF50;
}
.free {
color: #2196F3;
}
.c-points {
display: flex;
align-items: center;
}
.c-points img {
width: 20px;
height: 20px;
margin-right: 5px;
}
footer {
background-color: #333;
color: white;
text-align: center;
padding: 10px;
position: fixed;
bottom: 0;
width: 100%;
}
.download-btn {
background-color: #4CAF50;
color: white;
border: none;
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
margin-left: 10px;
}
.download-btn:hover {
background-color: #45a049;
}
.progress-container {
width: 100%;
background-color: #ddd;
border-radius: 4px;
margin-top: 10px;
display: none;
}
.progress-bar {
width: 0%;
height: 20px;
background-color: #4CAF50;
border-radius: 4px;
text-align: center;
line-height: 20px;
color: white;
}
.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.4);
}
.modal-content {
background-color: #fefefe;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
max-width: 400px;
border-radius: 5px;
}
.modal-buttons {
display: flex;
justify-content: space-between;
margin-top: 20px;
}
.modal-btn {
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
}
.confirm-btn {
background-color: #4CAF50;
color: white;
border: none;
}
.cancel-btn {
background-color: #f44336;
color: white;
border: none;
}
.user-cpoints {
position: absolute;
top: 20px;
right: 20px;
background-color: #333;
color: white;
padding: 5px 10px;
border-radius: 4px;
display: flex;
align-items: center;
}
</style>
</head>
<body>
<header>
<h1>LUFFY101 3D Print Files</h1>
<div class="user-cpoints">
<img src="https://pic2-cdn.creality.com/content/cover/2e095e2e32b5d6ca46c1c5d7a22faf7e" alt="C Points" style="width: 20px; height: 20px; margin-right: 5px;">
<span id="userPoints">100</span> C Points
</div>
</header>
<div class="container">
<div class="section">
<h2>Free Download</h2>
<div class="file-item">
<span>Sample Free File 1</span>
<div>
<span class="free">FREE</span>
<button class="download-btn" onclick="downloadFreeFile('Sample Free File 1')">Download</button>
</div>
<div class="progress-container" id="progress1">
<div class="progress-bar" id="progressBar1">0%</div>
</div>
</div>
<div class="file-item">
<span>Sample Free File 2</span>
<div>
<span class="free">FREE</span>
<button class="download-btn" onclick="downloadFreeFile('Sample Free File 2')">Download</button>
</div>
<div class="progress-container" id="progress2">
<div class="progress-bar" id="progressBar2">0%</div>
</div>
</div>
</div>
<div class="section">
<h2>Premium Download</h2>
<div class="file-item">
<span>Premium Model 1</span>
<div>
<div class="c-points">
<img src="https://pic2-cdn.creality.com/content/cover/2e095e2e32b5d6ca46c1c5d7a22faf7e" alt="C Points">
<span class="price">50 C Points</span>
</div>
<button class="download-btn" onclick="showPurchaseModal('Premium Model 1', 50)">Download</button>
</div>
</div>
<div class="file-item">
<span>Premium Model 2</span>
<div>
<div class="c-points">
<img src="https://pic2-cdn.creality.com/content/cover/2e095e2e32b5d6ca46c1c5d7a22faf7e" alt="C Points">
<span class="price">75 C Points</span>
</div>
<button class="download-btn" onclick="showPurchaseModal('Premium Model 2', 75)">Download</button>
</div>
</div>
</div>
</div>
<div id="purchaseModal" class="modal">
<div class="modal-content">
<h3 id="modalTitle">Confirm Purchase</h3>
<p id="modalText">Are you sure you want to spend <span id="modalPoints">0</span> C Points to download this file?</p>
<div class="modal-buttons">
<button class="modal-btn cancel-btn" onclick="closeModal()">Cancel</button>
<button class="modal-btn confirm-btn" onclick="confirmPurchase()">Confirm</button>
</div>
</div>
</div>
<footer>
© 2023 LUFFY101 - All rights reserved
</footer>
<script>
let currentFile = null;
let currentCost = 0;
function downloadFreeFile(filename) {
const progressId = filename.includes('1') ? '1' : '2';
const progressContainer = document.getElementById(`progress${progressId}`);
const progressBar = document.getElementById(`progressBar${progressId}`);
progressContainer.style.display = 'block';
progressBar.style.width = '0%';
progressBar.textContent = '0%';
let progress = 0;
const interval = setInterval(() => {
progress += 1;
progressBar.style.width = `${progress}%`;
progressBar.textContent = `${progress}%`;
if (progress >= 100) {
clearInterval(interval);
setTimeout(() => {
progressContainer.style.display = 'none';
alert(`Download complete: ${filename}`);
}, 100);
}
}, 100);
}
function showPurchaseModal(filename, cost) {
currentFile = filename;
currentCost = cost;
const userPoints = parseInt(document.getElementById('userPoints').textContent);
if (userPoints < cost) {
alert('Not enough C Points to purchase this model');
return;
}
document.getElementById('modalTitle').textContent = `Purchase ${filename}`;
document.getElementById('modalPoints').textContent = cost;
document.getElementById('modalText').textContent = `Are you sure you want to spend ${cost} C Points to download this file?`;
document.getElementById('purchaseModal').style.display = 'block';
}
function closeModal() {
document.getElementById('purchaseModal').style.display = 'none';
}
function confirmPurchase() {
const userPointsElement = document.getElementById('userPoints');
let userPoints = parseInt(userPointsElement.textContent);
if (userPoints >= currentCost) {
userPoints -= currentCost;
userPointsElement.textContent = userPoints;
closeModal();
alert(`Download started: ${currentFile}\nRemaining C Points: ${userPoints}`);
} else {
alert('Not enough C Points');
closeModal();
}
}
</script>
</body>
</html>
Key features added:
The user starts with 100 C Points. When they try to download a premium file:
Here's the updated version without browser popups and with download progress bars for both free and premium files:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LUFFY101 - 3D Print Files</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f5f5f5;
}
header {
background-color: #333;
color: white;
padding: 20px;
text-align: center;
position: relative;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
padding-bottom: 80px;
}
.section {
background-color: white;
border-radius: 5px;
padding: 20px;
margin-bottom: 20px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
h2 {
color: #333;
border-bottom: 2px solid #eee;
padding-bottom: 10px;
}
.file-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 0;
border-bottom: 1px solid #eee;
}
.price {
font-weight: bold;
color: #4CAF50;
}
.free {
color: #2196F3;
}
.c-points {
display: flex;
align-items: center;
}
.c-points img {
width: 20px;
height: 20px;
margin-right: 5px;
}
footer {
background-color: #333;
color: white;
text-align: center;
padding: 10px;
position: fixed;
bottom: 0;
width: 100%;
}
.download-btn {
background-color: #4CAF50;
color: white;
border: none;
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
margin-left: 10px;
}
.download-btn:hover {
background-color: #45a049;
}
.progress-container {
width: 100%;
background-color: #ddd;
border-radius: 4px;
margin-top: 10px;
display: none;
}
.progress-bar {
width: 0%;
height: 20px;
background-color: #4CAF50;
border-radius: 4px;
text-align: center;
line-height: 20px;
color: white;
}
.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.4);
}
.modal-content {
background-color: #fefefe;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
max-width: 400px;
border-radius: 5px;
}
.modal-buttons {
display: flex;
justify-content: space-between;
margin-top: 20px;
}
.modal-btn {
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
}
.confirm-btn {
background-color: #4CAF50;
color: white;
border: none;
}
.cancel-btn {
background-color: #f44336;
color: white;
border: none;
}
.user-cpoints {
position: absolute;
top: 20px;
right: 20px;
background-color: #333;
color: white;
padding: 5px 10px;
border-radius: 4px;
display: flex;
align-items: center;
}
.status-message {
position: fixed;
top: 20px;
left: 50%;
transform: translateX(-50%);
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border-radius: 4px;
display: none;
z-index: 1000;
}
.error-message {
background-color: #f44336;
}
</style>
</head>
<body>
<header>
<h1>LUFFY101 3D Print Files</h1>
<div class="user-cpoints">
<img src="https://pic2-cdn.creality.com/content/cover/2e095e2e32b5d6ca46c1c5d7a22faf7e" alt="C Points" style="width: 20px; height: 20px; margin-right: 5px;">
<span id="userPoints">100</span> C Points
</div>
</header>
<div class="status-message" id="statusMessage"></div>
<div class="status-message error-message" id="errorMessage"></div>
<div class="container">
<div class="section">
<h2>Free Download</h2>
<div class="file-item">
<span>Sample Free File 1</span>
<div>
<span class="free">FREE</span>
<button class="download-btn" onclick="downloadFile('Sample Free File 1', 0, 'progress1')">Download</button>
</div>
<div class="progress-container" id="progress1">
<div class="progress-bar" id="progressBar1">0%</div>
</div>
</div>
<div class="file-item">
<span>Sample Free File 2</span>
<div>
<span class="free">FREE</span>
<button class="download-btn" onclick="downloadFile('Sample Free File 2', 0, 'progress2')">Download</button>
</div>
<div class="progress-container" id="progress2">
<div class="progress-bar" id="progressBar2">0%</div>
</div>
</div>
</div>
<div class="section">
<h2>Premium Download</h2>
<div class="file-item">
<span>Premium Model 1</span>
<div>
<div class="c-points">
<img src="https://pic2-cdn.creality.com/content/cover/2e095e2e32b5d6ca46c1c5d7a22faf7e" alt="C Points">
<span class="price">50 C Points</span>
</div>
<button class="download-btn" onclick="showPurchaseModal('Premium Model 1', 50, 'progress3')">Download</button>
</div>
<div class="progress-container" id="progress3">
<div class="progress-bar" id="progressBar3">0%</div>
</div>
</div>
<div class="file-item">
<span>Premium Model 2</span>
<div>
<div class="c-points">
<img src="https://pic2-cdn.creality.com/content/cover/2e095e2e32b5d6ca46c1c5d7a22faf7e" alt="C Points">
<span class="price">75 C Points</span>
</div>
<button class="download-btn" onclick="showPurchaseModal('Premium Model 2', 75, 'progress4')">Download</button>
</div>
<div class="progress-container" id="progress4">
<div class="progress-bar" id="progressBar4">0%</div>
</div>
</div>
</div>
</div>
<div id="purchaseModal" class="modal">
<div class="modal-content">
<h3 id="modalTitle">Confirm Purchase</h3>
<p id="modalText">Are you sure you want to spend <span id="modalPoints">0</span> C Points to download this file?</p>
<div class="modal-buttons">
<button class="modal-btn cancel-btn" onclick="closeModal()">Cancel</button>
<button class="modal-btn confirm-btn" onclick="confirmPurchase()">Confirm</button>
</div>
</div>
</div>
<footer>
© 2023 LUFFY101 - All rights reserved
</footer>
<script>
let currentFile = null;
let currentCost = 0;
let currentProgressId = null;
function showStatusMessage(message, isError = false) {
const element = isError ? document.getElementById('errorMessage') : document.getElementById('statusMessage');
element.textContent = message;
element.style.display = 'block';
setTimeout(() => {
element.style.display = 'none';
}, 3000);
}
function downloadFile(filename, cost, progressId) {
const progressContainer = document.getElementById(progressId);
const progressBar = document.getElementById(`progressBar${progressId.slice(-1)}`);
progressContainer.style.display = 'block';
progressBar.style.width = '0%';
progressBar.textContent = '0%';
let progress = 0;
const interval = setInterval(() => {
progress += 1;
progressBar.style.width = `${progress}%`;
progressBar.textContent = `${progress}%`;
if (progress >= 100) {
clearInterval(interval);
setTimeout(() => {
progressContainer.style.display = 'none';
showStatusMessage(`Download complete: ${filename}`);
}, 100);
}
}, 100);
}
function showPurchaseModal(filename, cost, progressId) {
currentFile = filename;
currentCost = cost;
currentProgressId = progressId;
const userPoints = parseInt(document.getElementById('userPoints').textContent);
if (userPoints < cost) {
showStatusMessage('Not enough C Points to purchase this model', true);
return;
}
document.getElementById('modalTitle').textContent = `Purchase ${filename}`;
document.getElementById('modalPoints').textContent = cost;
document.getElementById('modalText').textContent = `Are you sure you want to spend ${cost} C Points to download this file?`;
document.getElementById('purchaseModal').style.display = 'block';
}
function closeModal() {
document.getElementById('purchaseModal').style.display = 'none';
}
function confirmPurchase() {
const userPointsElement = document.getElementById('userPoints');
let userPoints = parseInt(userPointsElement.textContent);
if (userPoints >= currentCost) {
userPoints -= currentCost;
userPointsElement.textContent = userPoints;
closeModal();
showStatusMessage(`Purchased ${currentFile} for ${currentCost} C Points. Remaining: ${userPoints}`);
downloadFile(currentFile, currentCost, currentProgressId);
} else {
showStatusMessage('Not enough C Points', true);
closeModal();
}
}
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LUFFY101 - 3D Print Files</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f5f5f5;
}
header {
background-color: #333;
color: white;
padding: 20px;
text-align: center;
position: relative;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
padding-bottom: 80px;
}
.section {
background-color: white;
border-radius: 5px;
padding: 20px;
margin-bottom: 20px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
h2 {
color: #333;
border-bottom: 2px solid #eee;
padding-bottom: 10px;
}
.file-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 0;
border-bottom: 1px solid #eee;
}
.price {
font-weight: bold;
color: #4CAF50;
}
.free {
color: #2196F3;
}
.c-points {
display: flex;
align-items: center;
}
.c-points img {
width: 20px;
height: 20px;
margin-right: 5px;
}
footer {
background-color: #333;
color: white;
text-align: center;
padding: 10px;
position: fixed;
bottom: 0;
width: 100%;
}
.download-btn {
background-color: #4CAF50;
color: white;
border: none;
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
margin-left: 10px;
}
.download-btn:hover {
background-color: #45a049;
}
.progress-container {
width: 100%;
background-color: #ddd;
border-radius: 4px;
margin-top: 10px;
display: none;
}
.progress-bar {
width: 0%;
height: 20px;
background-color: #4CAF50;
border-radius: 4px;
text-align: center;
line-height: 20px;
color: white;
}
.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.4);
}
.modal-content {
background-color: #fefefe;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
max-width: 400px;
border-radius: 5px;
}
.modal-buttons {
display: flex;
justify-content: space-between;
margin-top: 20px;
}
.modal-btn {
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
}
.confirm-btn {
background-color: #4CAF50;
color: white;
border: none;
}
.cancel-btn {
background-color: #f44336;
color: white;
border: none;
}
.user-cpoints {
position: absolute;
top: 20px;
right: 20px;
background-color: #333;
color: white;
padding: 5px 10px;
border-radius: 4px;
display: flex;
align-items: center;
}
.status-message {
position: fixed;
top: 20px;
left: 50%;
transform: translateX(-50%);
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border-radius: 4px;
display: none;
z-index: 1000;
}
.error-message {
background-color: #f44336;
}
</style>
</head>
<body>
<header>
<h1>LUFFY101 3D Print Files</h1>
<div class="user-cpoints">
<img src="https://pic2-cdn.creality.com/content/cover/2e095e2e32b5d6ca46c1c5d7a22faf7e" alt="C Points" style="width: 20px; height: 20px; margin-right: 5px;">
<span id="userPoints">100</span> C Points
</div>
</header>
<div class="status-message" id="statusMessage"></div>
<div class="status-message error-message" id="errorMessage"></div>
<div class="container">
<div class="section">
<h2>Free Download</h2>
<div class="file-item">
<span>Sample Free File 1</span>
<div>
<span class="free">FREE</span>
<button class="download-btn" onclick="downloadFile('Sample Free File 1', 0, 'progress1')">Download</button>
</div>
<div class="progress-container" id="progress1">
<div class="progress-bar" id="progressBar1">0%</div>
</div>
</div>
<div class="file-item">
<span>Sample Free File 2</span>
<div>
<span class="free">FREE</span>
<button class="download-btn" onclick="downloadFile('Sample Free File 2', 0, 'progress2')">Download</button>
</div>
<div class="progress-container" id="progress2">
<div class="progress-bar" id="progressBar2">0%</div>
</div>
</div>
</div>
<div class="section">
<h2>Premium Download</h2>
<div class="file-item">
<span>Premium Model 1</span>
<div>
<div class="c-points">
<img src="https://pic2-cdn.creality.com/content/cover/2e095e2e32b5d6ca46c1c5d7a22faf7e" alt="C Points">
<span class="price">50 C Points</span>
</div>
<button class="download-btn" onclick="showPurchaseModal('Premium Model 1', 50, 'progress3')">Download</button>
</div>
<div class="progress-container" id="progress3">
<div class="progress-bar" id="progressBar3">0%</div>
</div>
</div>
<div class="file-item">
<span>Premium Model 2</span>
<div>
<div class="c-points">
<img src="https://pic2-cdn.creality.com/content/cover/2e095e2e32b5d6ca46c1c5d7a22faf7e" alt="C Points">
<span class="price">75 C Points</span>
</div>
<button class="download-btn" onclick="showPurchaseModal('Premium Model 2', 75, 'progress4')">Download</button>
</div>
<div class="progress-container" id="progress4">
<div class="progress-bar" id="progressBar4">0%</div>
</div>
</div>
</div>
</div>
<div id="purchaseModal" class="modal">
<div class="modal-content">
<h3 id="modalTitle">Confirm Purchase</h3>
<p id="modalText">Are you sure you want to spend <span id="modalPoints">0</span> C Points to download this file?</p>
<div class="modal-buttons">
<button class="modal-btn cancel-btn" onclick="closeModal()">Cancel</button>
<button class="modal-btn confirm-btn" onclick="confirmPurchase()">Confirm</button>
</div>
</div>
</div>
<footer>
© 2023 LUFFY101 - All rights reserved
</footer>
<script>
let currentFile = null;
let currentCost = 0;
let currentProgressId = null;
function showStatusMessage(message, isError = false) {
const element = isError ? document.getElementById('errorMessage') : document.getElementById('statusMessage');
element.textContent = message;
element.style.display = 'block';
setTimeout(() => {
element.style.display = 'none';
}, 3000);
}
function downloadFile(filename, cost, progressId) {
const progressContainer = document.getElementById(progressId);
const progressBar = document.getElementById(`progressBar${progressId.slice(-1)}`);
progressContainer.style.display = 'block';
progressBar.style.width = '0%';
progressBar.textContent = '0%';
let progress = 0;
const interval = setInterval(() => {
progress += 1;
progressBar.style.width = `${progress}%`;
progressBar.textContent = `${progress}%`;
if (progress >= 100) {
clearInterval(interval);
setTimeout(() => {
progressContainer.style.display = 'none';
showStatusMessage(`Download complete: ${filename}`);
}, 100);
}
}, 100);
}
function showPurchaseModal(filename, cost, progressId) {
currentFile = filename;
currentCost = cost;
currentProgressId = progressId;
const userPoints = parseInt(document.getElementById('userPoints').textContent);
if (userPoints < cost) {
showStatusMessage('Not enough C Points to purchase this model', true);
return;
}
document.getElementById('modalTitle').textContent = `Purchase ${filename}`;
document.getElementById('modalPoints').textContent = cost;
document.getElementById('modalText').textContent = `Are you sure you want to spend ${cost} C Points to download this file?`;
document.getElementById('purchaseModal').style.display = 'block';
}
function closeModal() {
document.getElementById('purchaseModal').style.display = 'none';
}
function confirmPurchase() {
const userPointsElement = document.getElementById('userPoints');
let userPoints = parseInt(userPointsElement.textContent);
if (userPoints >= currentCost) {
userPoints -= currentCost;
userPointsElement.textContent = userPoints;
closeModal();
showStatusMessage(`Purchased ${currentFile} for ${currentCost} C Points. Remaining: ${userPoints}`);
downloadFile(currentFile, currentCost, currentProgressId);
} else {
showStatusMessage('Not enough C Points', true);
closeModal();
}
}
</script>
</body>
</html>
Key improvements:
The functionality remains the same but with a much cleaner user experience without disruptive browser popups.
Here's the updated version that hides the download button during download and shows it again after completion:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LUFFY101 - 3D Print Files</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f5f5f5;
}
header {
background-color: #333;
color: white;
padding: 20px;
text-align: center;
position: relative;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
padding-bottom: 80px;
}
.section {
background-color: white;
border-radius: 5px;
padding: 20px;
margin-bottom: 20px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
h2 {
color: #333;
border-bottom: 2px solid #eee;
padding-bottom: 10px;
}
.file-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 0;
border-bottom: 1px solid #eee;
}
.price {
font-weight: bold;
color: #4CAF50;
}
.free {
color: #2196F3;
}
.c-points {
display: flex;
align-items: center;
}
.c-points img {
width: 20px;
height: 20px;
margin-right: 5px;
}
footer {
background-color: #333;
color: white;
text-align: center;
padding: 10px;
position: fixed;
bottom: 0;
width: 100%;
}
.download-btn {
background-color: #4CAF50;
color: white;
border: none;
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
margin-left: 10px;
}
.download-btn:hover {
background-color: #45a049;
}
.download-btn:disabled {
background-color: #cccccc;
cursor: not-allowed;
}
.progress-container {
width: 100%;
background-color: #ddd;
border-radius: 4px;
margin-top: 10px;
display: none;
}
.progress-bar {
width: 0%;
height: 20px;
background-color: #4CAF50;
border-radius: 4px;
text-align: center;
line-height: 20px;
color: white;
}
.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.4);
}
.modal-content {
background-color: #fefefe;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
max-width: 400px;
border-radius: 5px;
}
.modal-buttons {
display: flex;
justify-content: space-between;
margin-top: 20px;
}
.modal-btn {
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
}
.confirm-btn {
background-color: #4CAF50;
color: white;
border: none;
}
.cancel-btn {
background-color: #f44336;
color: white;
border: none;
}
.user-cpoints {
position: absolute;
top: 20px;
right: 20px;
background-color: #333;
color: white;
padding: 5px 10px;
border-radius: 4px;
display: flex;
align-items: center;
}
.status-message {
position: fixed;
top: 20px;
left: 50%;
transform: translateX(-50%);
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border-radius: 4px;
display: none;
z-index: 1000;
}
.error-message {
background-color: #f44336;
}
</style>
</head>
<body>
<header>
<h1>LUFFY101 3D Print Files</h1>
<div class="user-cpoints">
<img src="https://pic2-cdn.creality.com/content/cover/2e095e2e32b5d6ca46c1c5d7a22faf7e" alt="C Points" style="width: 20px; height: 20px; margin-right: 5px;">
<span id="userPoints">100</span> C Points
</div>
</header>
<div class="status-message" id="statusMessage"></div>
<div class="status-message error-message" id="errorMessage"></div>
<div class="container">
<div class="section">
<h2>Free Download</h2>
<div class="file-item">
<span>Sample Free File 1</span>
<div>
<span class="free">FREE</span>
<button class="download-btn" id="btn1" onclick="downloadFile('Sample Free File 1', 0, 'progress1', 'btn1')">Download</button>
</div>
<div class="progress-container" id="progress1">
<div class="progress-bar" id="progressBar1">0%</div>
</div>
</div>
<div class="file-item">
<span>Sample Free File 2</span>
<div>
<span class="free">FREE</span>
<button class="download-btn" id="btn2" onclick="downloadFile('Sample Free File 2', 0, 'progress2', 'btn2')">Download</button>
</div>
<div class="progress-container" id="progress2">
<div class="progress-bar" id="progressBar2">0%</div>
</div>
</div>
</div>
<div class="section">
<h2>Premium Download</h2>
<div class="file-item">
<span>Premium Model 1</span>
<div>
<div class="c-points">
<img src="https://pic2-cdn.creality.com/content/cover/2e095e2e32b5d6ca46c1c5d7a22faf7e" alt="C Points">
<span class="price">50 C Points</span>
</div>
<button class="download-btn" id="btn3" onclick="showPurchaseModal('Premium Model 1', 50, 'progress3', 'btn3')">Download</button>
</div>
<div class="progress-container" id="progress3">
<div class="progress-bar" id="progressBar3">0%</div>
</div>
</div>
<div class="file-item">
<span>Premium Model 2</span>
<div>
<div class="c-points">
<img src="https://pic2-cdn.creality.com/content/cover/2e095e2e32b5d6ca46c1c5d7a22faf7e" alt="C Points">
<span class="price">75 C Points</span>
</div>
<button class="download-btn" id="btn4" onclick="showPurchaseModal('Premium Model 2', 75, 'progress4', 'btn4')">Download</button>
</div>
<div class="progress-container" id="progress4">
<div class="progress-bar" id="progressBar4">0%</div>
</div>
</div>
</div>
</div>
<div id="purchaseModal" class="modal">
<div class="modal-content">
<h3 id="modalTitle">Confirm Purchase</h3>
<p id="modalText">Are you sure you want to spend <span id="modalPoints">0</span> C Points to download this file?</p>
<div class="modal-buttons">
<button class="modal-btn cancel-btn" onclick="closeModal()">Cancel</button>
<button class="modal-btn confirm-btn" onclick="confirmPurchase()">Confirm</button>
</div>
</div>
</div>
<footer>
© 2023 LUFFY101 - All rights reserved
</footer>
<script>
let currentFile = null;
let currentCost = 0;
let currentProgressId = null;
let currentButtonId = null;
function showStatusMessage(message, isError = false) {
const element = isError ? document.getElementById('errorMessage') : document.getElementById('statusMessage');
element.textContent = message;
element.style.display = 'block';
setTimeout(() => {
element.style.display = 'none';
}, 3000);
}
function downloadFile(filename, cost, progressId, buttonId) {
const progressContainer = document.getElementById(progressId);
const progressBar = document.getElementById(`progressBar${progressId.slice(-1)}`);
const downloadBtn = document.getElementById(buttonId);
// Disable the download button
downloadBtn.disabled = true;
progressContainer.style.display = 'block';
progressBar.style.width = '0%';
progressBar.textContent = '0%';
let progress = 0;
const interval = setInterval(() => {
progress += 1;
progressBar.style.width = `${progress}%`;
progressBar.textContent = `${progress}%`;
if (progress >= 100) {
clearInterval(interval);
setTimeout(() => {
progressContainer.style.display = 'none';
// Re-enable the download button
downloadBtn.disabled = false;
showStatusMessage(`Download complete: ${filename}`);
}, 100);
}
}, 100);
}
function showPurchaseModal(filename, cost, progressId, buttonId) {
currentFile = filename;
currentCost = cost;
currentProgressId = progressId;
currentButtonId = buttonId;
const userPoints = parseInt(document.getElementById('userPoints').textContent);
if (userPoints < cost) {
showStatusMessage('Not enough C Points to purchase this model', true);
return;
}
document.getElementById('modalTitle').textContent = `Purchase ${filename}`;
document.getElementById('modalPoints').textContent = cost;
document.getElementById('modalText').textContent = `Are you sure you want to spend ${cost} C Points to download this file?`;
document.getElementById('purchaseModal').style.display = 'block';
}
function closeModal() {
document.getElementById('purchaseModal').style.display = 'none';
}
function confirmPurchase() {
const userPointsElement = document.getElementById('userPoints');
let userPoints = parseInt(userPointsElement.textContent);
if (userPoints >= currentCost) {
userPoints -= currentCost;
userPointsElement.textContent = userPoints;
closeModal();
showStatusMessage(`Purchased ${currentFile} for ${currentCost} C Points. Remaining: ${userPoints}`);
downloadFile(currentFile, currentCost, currentProgressId, currentButtonId);
} else {
showStatusMessage('Not enough C Points', true);
closeModal();
}
}
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LUFFY101 - 3D Print Files</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f5f5f5;
}
header {
background-color: #333;
color: white;
padding: 20px;
text-align: center;
position: relative;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
padding-bottom: 80px;
}
.section {
background-color: white;
border-radius: 5px;
padding: 20px;
margin-bottom: 20px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
h2 {
color: #333;
border-bottom: 2px solid #eee;
padding-bottom: 10px;
}
.file-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 0;
border-bottom: 1px solid #eee;
}
.price {
font-weight: bold;
color: #4CAF50;
}
.free {
color: #2196F3;
}
.c-points {
display: flex;
align-items: center;
}
.c-points img {
width: 20px;
height: 20px;
margin-right: 5px;
}
footer {
background-color: #333;
color: white;
text-align: center;
padding: 10px;
position: fixed;
bottom: 0;
width: 100%;
}
.download-btn {
background-color: #4CAF50;
color: white;
border: none;
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
margin-left: 10px;
}
.download-btn:hover {
background-color: #45a049;
}
.download-btn:disabled {
background-color: #cccccc;
cursor: not-allowed;
}
.progress-container {
width: 100%;
background-color: #ddd;
border-radius: 4px;
margin-top: 10px;
display: none;
}
.progress-bar {
width: 0%;
height: 20px;
background-color: #4CAF50;
border-radius: 4px;
text-align: center;
line-height: 20px;
color: white;
}
.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.4);
}
.modal-content {
background-color: #fefefe;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
max-width: 400px;
border-radius: 5px;
}
.modal-buttons {
display: flex;
justify-content: space-between;
margin-top: 20px;
}
.modal-btn {
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
}
.confirm-btn {
background-color: #4CAF50;
color: white;
border: none;
}
.cancel-btn {
background-color: #f44336;
color: white;
border: none;
}
.user-cpoints {
position: absolute;
top: 20px;
right: 20px;
background-color: #333;
color: white;
padding: 5px 10px;
border-radius: 4px;
display: flex;
align-items: center;
}
.status-message {
position: fixed;
top: 20px;
left: 50%;
transform: translateX(-50%);
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border-radius: 4px;
display: none;
z-index: 1000;
}
.error-message {
background-color: #f44336;
}
</style>
</head>
<body>
<header>
<h1>LUFFY101 3D Print Files</h1>
<div class="user-cpoints">
<img src="https://pic2-cdn.creality.com/content/cover/2e095e2e32b5d6ca46c1c5d7a22faf7e" alt="C Points" style="width: 20px; height: 20px; margin-right: 5px;">
<span id="userPoints">100</span> C Points
</div>
</header>
<div class="status-message" id="statusMessage"></div>
<div class="status-message error-message" id="errorMessage"></div>
<div class="container">
<div class="section">
<h2>Free Download</h2>
<div class="file-item">
<span>Sample Free File 1</span>
<div>
<span class="free">FREE</span>
<button class="download-btn" id="btn1" onclick="downloadFile('Sample Free File 1', 0, 'progress1', 'btn1')">Download</button>
</div>
<div class="progress-container" id="progress1">
<div class="progress-bar" id="progressBar1">0%</div>
</div>
</div>
<div class="file-item">
<span>Sample Free File 2</span>
<div>
<span class="free">FREE</span>
<button class="download-btn" id="btn2" onclick="downloadFile('Sample Free File 2', 0, 'progress2', 'btn2')">Download</button>
</div>
<div class="progress-container" id="progress2">
<div class="progress-bar" id="progressBar2">0%</div>
</div>
</div>
</div>
<div class="section">
<h2>Premium Download</h2>
<div class="file-item">
<span>Premium Model 1</span>
<div>
<div class="c-points">
<img src="https://pic2-cdn.creality.com/content/cover/2e095e2e32b5d6ca46c1c5d7a22faf7e" alt="C Points">
<span class="price">50 C Points</span>
</div>
<button class="download-btn" id="btn3" onclick="showPurchaseModal('Premium Model 1', 50, 'progress3', 'btn3')">Download</button>
</div>
<div class="progress-container" id="progress3">
<div class="progress-bar" id="progressBar3">0%</div>
</div>
</div>
<div class="file-item">
<span>Premium Model 2</span>
<div>
<div class="c-points">
<img src="https://pic2-cdn.creality.com/content/cover/2e095e2e32b5d6ca46c1c5d7a22faf7e" alt="C Points">
<span class="price">75 C Points</span>
</div>
<button class="download-btn" id="btn4" onclick="showPurchaseModal('Premium Model 2', 75, 'progress4', 'btn4')">Download</button>
</div>
<div class="progress-container" id="progress4">
<div class="progress-bar" id="progressBar4">0%</div>
</div>
</div>
</div>
</div>
<div id="purchaseModal" class="modal">
<div class="modal-content">
<h3 id="modalTitle">Confirm Purchase</h3>
<p id="modalText">Are you sure you want to spend <span id="modalPoints">0</span> C Points to download this file?</p>
<div class="modal-buttons">
<button class="modal-btn cancel-btn" onclick="closeModal()">Cancel</button>
<button class="modal-btn confirm-btn" onclick="confirmPurchase()">Confirm</button>
</div>
</div>
</div>
<footer>
© 2023 LUFFY101 - All rights reserved
</footer>
<script>
let currentFile = null;
let currentCost = 0;
let currentProgressId = null;
let currentButtonId = null;
function showStatusMessage(message, isError = false) {
const element = isError ? document.getElementById('errorMessage') : document.getElementById('statusMessage');
element.textContent = message;
element.style.display = 'block';
setTimeout(() => {
element.style.display = 'none';
}, 3000);
}
function downloadFile(filename, cost, progressId, buttonId) {
const progressContainer = document.getElementById(progressId);
const progressBar = document.getElementById(`progressBar${progressId.slice(-1)}`);
const downloadBtn = document.getElementById(buttonId);
// Disable the download button
downloadBtn.disabled = true;
progressContainer.style.display = 'block';
progressBar.style.width = '0%';
progressBar.textContent = '0%';
let progress = 0;
const interval = setInterval(() => {
progress += 1;
progressBar.style.width = `${progress}%`;
progressBar.textContent = `${progress}%`;
if (progress >= 100) {
clearInterval(interval);
setTimeout(() => {
progressContainer.style.display = 'none';
// Re-enable the download button
downloadBtn.disabled = false;
showStatusMessage(`Download complete: ${filename}`);
}, 100);
}
}, 100);
}
function showPurchaseModal(filename, cost, progressId, buttonId) {
currentFile = filename;
currentCost = cost;
currentProgressId = progressId;
currentButtonId = buttonId;
const userPoints = parseInt(document.getElementById('userPoints').textContent);
if (userPoints < cost) {
showStatusMessage('Not enough C Points to purchase this model', true);
return;
}
document.getElementById('modalTitle').textContent = `Purchase ${filename}`;
document.getElementById('modalPoints').textContent = cost;
document.getElementById('modalText').textContent = `Are you sure you want to spend ${cost} C Points to download this file?`;
document.getElementById('purchaseModal').style.display = 'block';
}
function closeModal() {
document.getElementById('purchaseModal').style.display = 'none';
}
function confirmPurchase() {
const userPointsElement = document.getElementById('userPoints');
let userPoints = parseInt(userPointsElement.textContent);
if (userPoints >= currentCost) {
userPoints -= currentCost;
userPointsElement.textContent = userPoints;
closeModal();
showStatusMessage(`Purchased ${currentFile} for ${currentCost} C Points. Remaining: ${userPoints}`);
downloadFile(currentFile, currentCost, currentProgressId, currentButtonId);
} else {
showStatusMessage('Not enough C Points', true);
closeModal();
}
}
</script>
</body>
</html>
Key changes made:
downloadFile() function to accept a button ID parameterNow when a user clicks a download button:
Here's a futuristic redesign with a login/signup page that leads to the main download site:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LUFFY101 - 3D Print Portal</title>
<style>
:root {
--primary: #00f7ff;
--secondary: #0066ff;
--dark: #0a0a1a;
--light: #e0f8ff;
--accent: #ff00aa;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
body {
background-color: var(--dark);
color: var(--light);
background-image:
radial-gradient(circle at 20% 30%, rgba(0, 247, 255, 0.1) 0%, transparent 20%),
radial-gradient(circle at 80% 70%, rgba(255, 0, 170, 0.1) 0%, transparent 20%);
min-height: 100vh;
overflow-x: hidden;
}
.neon-text {
text-shadow: 0 0 5px var(--primary), 0 0 10px var(--primary);
}
.glow-box {
box-shadow: 0 0 15px rgba(0, 247, 255, 0.3);
border: 1px solid rgba(0, 247, 255, 0.2);
}
/* Login Page Styles */
#login-page {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
padding: 20px;
background-color: rgba(10, 10, 26, 0.9);
position: relative;
overflow: hidden;
}
#login-page::before {
content: '';
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background:
linear-gradient(45deg, transparent 65%, var(--primary) 65%, var(--primary) 70%, transparent 70%),
linear-gradient(-45deg, transparent 65%, var(--accent) 65%, var(--accent) 70%, transparent 70%);
background-size: 40px 40px;
opacity: 0.1;
animation: moveGrid 20s linear infinite;
z-index: -1;
}
@keyframes moveGrid {
0% { transform: translate(0, 0); }
100% { transform: translate(-20px, -20px); }
}
.login-container {
background-color: rgba(20, 20, 40, 0.8);
padding: 40px;
border-radius: 10px;
width: 100%;
max-width: 400px;
backdrop-filter: blur(10px);
transform-style: preserve-3d;
transform: perspective(1000px) rotateX(5deg);
transition: all 0.5s ease;
}
.login-container:hover {
transform: perspective(1000px) rotateX(0deg);
}
.logo {
text-align: center;
margin-bottom: 30px;
}
.logo h1 {
font-size: 2.5rem;
margin-bottom: 10px;
background: linear-gradient(90deg, var(--primary), var(--secondary));
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}
.logo p {
color: var(--primary);
font-size: 0.9rem;
}
.tabs {
display: flex;
margin-bottom: 20px;
border-bottom: 1px solid rgba(0, 247, 255, 0.3);
}
.tab {
padding: 10px 20px;
cursor: pointer;
position: relative;
color: var(--light);
opacity: 0.7;
transition: all 0.3s ease;
}
.tab.active {
opacity: 1;
color: var(--primary);
}
.tab.active::after {
content: '';
position: absolute;
bottom: -1px;
left: 0;
width: 100%;
height: 2px;
background: linear-gradient(90deg, var(--primary), var(--accent));
}
.tab-content {
display: none;
}
.tab-content.active {
display: block;
}
.form-group {
margin-bottom: 20px;
position: relative;
}
.form-group label {
display: block;
margin-bottom: 8px;
color: var(--primary);
font-size: 0.9rem;
}
.form-control {
width: 100%;
padding: 12px 15px;
background-color: rgba(0, 0, 0, 0.3);
border: 1px solid rgba(0, 247, 255, 0.3);
border-radius: 5px;
color: var(--light);
font-size: 1rem;
transition: all 0.3s ease;
}
.form-control:focus {
outline: none;
border-color: var(--primary);
box-shadow: 0 0 10px rgba(0, 247, 255, 0.3);
}
.btn {
background: linear-gradient(90deg, var(--primary), var(--secondary));
color: var(--dark);
border: none;
padding: 12px 20px;
border-radius: 5px;
cursor: pointer;
font-weight: bold;
width: 100%;
font-size: 1rem;
transition: all 0.3s ease;
text-transform: uppercase;
letter-spacing: 1px;
}
.btn:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(0, 247, 255, 0.4);
}
.divider {
text-align: center;
margin: 20px 0;
position: relative;
color: var(--primary);
}
.divider::before, .divider::after {
content: '';
position: absolute;
top: 50%;
width: 40%;
height: 1px;
background: linear-gradient(90deg, transparent, var(--primary));
}
.divider::before {
left: 0;
}
.divider::after {
right: 0;
background: linear-gradient(90deg, var(--primary), transparent);
}
.social-login {
display: flex;
justify-content: center;
gap: 15px;
}
.social-btn {
width: 40px;
height: 40px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
background-color: rgba(0, 247, 255, 0.1);
border: 1px solid rgba(0, 247, 255, 0.3);
cursor: pointer;
transition: all 0.3s ease;
}
.social-btn:hover {
background-color: rgba(0, 247, 255, 0.2);
transform: translateY(-3px);
}
/* Main App Styles (hidden initially) */
#app {
display: none;
/* Your existing app styles would go here */
}
</style>
</head>
<body>
<!-- Login/Signup Page -->
<div id="login-page">
<div class="login-container glow-box">
<div class="logo">
<h1 class="neon-text">LUFFY101</h1>
<p>3D PRINT FILE PORTAL</p>
</div>
<div class="tabs">
<div class="tab active" onclick="switchTab('login')">Login</div>
<div class="tab" onclick="switchTab('signup')">Sign Up</div>
</div>
<div id="login-tab" class="tab-content active">
<form id="login-form">
<div class="form-group">
<label for="login-email">Email</label>
<input type="email" id="login-email" class="form-control" placeholder="Enter your email" required>
</div>
<div class="form-group">
<label for="login-password">Password</label>
<input type="password" id="login-password" class="form-control" placeholder="Enter your password" required>
</div>
<button type="submit" class="btn">Login</button>
</form>
<div class="divider">OR</div>
<div class="social-login">
<div class="social-btn">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z"></path>
</svg>
</div>
<div class="social-btn">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"></path>
</svg>
</div>
<div class="social-btn">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="2" y="4" width="20" height="16" rx="2"></rect>
<path d="M2 10h20"></path>
</svg>
</div>
</div>
</div>
<div id="signup-tab" class="tab-content">
<form id="signup-form">
<div class="form-group">
<label for="signup-username">Username</label>
<input type="text" id="signup-username" class="form-control" placeholder="Choose a username" required>
</div>
<div class="form-group">
<label for="signup-email">Email</label>
<input type="email" id="signup-email" class="form-control" placeholder="Enter your email" required>
</div>
<div class="form-group">
<label for="signup-password">Password</label>
<input type="password" id="signup-password" class="form-control" placeholder="Create a password" required>
</div>
<div class="form-group">
<label for="signup-confirm">Confirm Password</label>
<input type="password" id="signup-confirm" class="form-control" placeholder="Confirm your password" required>
</div>
<button type="submit" class="btn">Create Account</button>
</form>
</div>
</div>
</div>
<!-- Main App (hidden initially) -->
<div id="app">
<!-- Your existing app content would go here -->
</div>
<script>
// Tab switching
function switchTab(tabName) {
// Hide all tab contents
document.querySelectorAll('.tab-content').forEach(tab => {
tab.classList.remove('active');
});
// Deactivate all tabs
document.querySelectorAll('.tab').forEach(tab => {
tab.classList.remove('active');
});
// Activate selected tab
document.getElementById(`${tabName}-tab`).classList.add('active');
document.querySelector(`.tab[onclick="switchTab('${tabName}')"]`).classList.add('active');
}
// Form submission
document.getElementById('login-form').addEventListener('submit', function(e) {
e.preventDefault();
// Here you would normally validate and send to server
// For demo, we'll just show the app
document.getElementById('login-page').style.display = 'none';
document.getElementById('app').style.display = 'block';
});
document.getElementById('signup-form').addEventListener('submit', function(e) {
e.preventDefault();
// Here you would normally validate and send to server
// For demo, we'll just show the app
document.getElementById('login-page').style.display = 'none';
document.getElementById('app').style.display = 'block';
});
// You would need to include your existing app JavaScript here
// and make sure it only runs when the app is shown
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LUFFY101 - 3D Print Portal</title>
<style>
:root {
--primary: #00f7ff;
--secondary: #0066ff;
--dark: #0a0a1a;
--light: #e0f8ff;
--accent: #ff00aa;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
body {
background-color: var(--dark);
color: var(--light);
background-image:
radial-gradient(circle at 20% 30%, rgba(0, 247, 255, 0.1) 0%, transparent 20%),
radial-gradient(circle at 80% 70%, rgba(255, 0, 170, 0.1) 0%, transparent 20%);
min-height: 100vh;
overflow-x: hidden;
}
.neon-text {
text-shadow: 0 0 5px var(--primary), 0 0 10px var(--primary);
}
.glow-box {
box-shadow: 0 0 15px rgba(0, 247, 255, 0.3);
border: 1px solid rgba(0, 247, 255, 0.2);
}
/* Login Page Styles */
#login-page {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
padding: 20px;
background-color: rgba(10, 10, 26, 0.9);
position: relative;
overflow: hidden;
}
#login-page::before {
content: '';
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background:
linear-gradient(45deg, transparent 65%, var(--primary) 65%, var(--primary) 70%, transparent 70%),
linear-gradient(-45deg, transparent 65%, var(--accent) 65%, var(--accent) 70%, transparent 70%);
background-size: 40px 40px;
opacity: 0.1;
animation: moveGrid 20s linear infinite;
z-index: -1;
}
@keyframes moveGrid {
0% { transform: translate(0, 0); }
100% { transform: translate(-20px, -20px); }
}
.login-container {
background-color: rgba(20, 20, 40, 0.8);
padding: 40px;
border-radius: 10px;
width: 100%;
max-width: 400px;
backdrop-filter: blur(10px);
transform-style: preserve-3d;
transform: perspective(1000px) rotateX(5deg);
transition: all 0.5s ease;
}
.login-container:hover {
transform: perspective(1000px) rotateX(0deg);
}
.logo {
text-align: center;
margin-bottom: 30px;
}
.logo h1 {
font-size: 2.5rem;
margin-bottom: 10px;
background: linear-gradient(90deg, var(--primary), var(--secondary));
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}
.logo p {
color: var(--primary);
font-size: 0.9rem;
}
.tabs {
display: flex;
margin-bottom: 20px;
border-bottom: 1px solid rgba(0, 247, 255, 0.3);
}
.tab {
padding: 10px 20px;
cursor: pointer;
position: relative;
color: var(--light);
opacity: 0.7;
transition: all 0.3s ease;
}
.tab.active {
opacity: 1;
color: var(--primary);
}
.tab.active::after {
content: '';
position: absolute;
bottom: -1px;
left: 0;
width: 100%;
height: 2px;
background: linear-gradient(90deg, var(--primary), var(--accent));
}
.tab-content {
display: none;
}
.tab-content.active {
display: block;
}
.form-group {
margin-bottom: 20px;
position: relative;
}
.form-group label {
display: block;
margin-bottom: 8px;
color: var(--primary);
font-size: 0.9rem;
}
.form-control {
width: 100%;
padding: 12px 15px;
background-color: rgba(0, 0, 0, 0.3);
border: 1px solid rgba(0, 247, 255, 0.3);
border-radius: 5px;
color: var(--light);
font-size: 1rem;
transition: all 0.3s ease;
}
.form-control:focus {
outline: none;
border-color: var(--primary);
box-shadow: 0 0 10px rgba(0, 247, 255, 0.3);
}
.btn {
background: linear-gradient(90deg, var(--primary), var(--secondary));
color: var(--dark);
border: none;
padding: 12px 20px;
border-radius: 5px;
cursor: pointer;
font-weight: bold;
width: 100%;
font-size: 1rem;
transition: all 0.3s ease;
text-transform: uppercase;
letter-spacing: 1px;
}
.btn:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(0, 247, 255, 0.4);
}
.divider {
text-align: center;
margin: 20px 0;
position: relative;
color: var(--primary);
}
.divider::before, .divider::after {
content: '';
position: absolute;
top: 50%;
width: 40%;
height: 1px;
background: linear-gradient(90deg, transparent, var(--primary));
}
.divider::before {
left: 0;
}
.divider::after {
right: 0;
background: linear-gradient(90deg, var(--primary), transparent);
}
.social-login {
display: flex;
justify-content: center;
gap: 15px;
}
.social-btn {
width: 40px;
height: 40px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
background-color: rgba(0, 247, 255, 0.1);
border: 1px solid rgba(0, 247, 255, 0.3);
cursor: pointer;
transition: all 0.3s ease;
}
.social-btn:hover {
background-color: rgba(0, 247, 255, 0.2);
transform: translateY(-3px);
}
/* Main App Styles (hidden initially) */
#app {
display: none;
/* Your existing app styles would go here */
}
</style>
</head>
<body>
<!-- Login/Signup Page -->
<div id="login-page">
<div class="login-container glow-box">
<div class="logo">
<h1 class="neon-text">LUFFY101</h1>
<p>3D PRINT FILE PORTAL</p>
</div>
<div class="tabs">
<div class="tab active" onclick="switchTab('login')">Login</div>
<div class="tab" onclick="switchTab('signup')">Sign Up</div>
</div>
<div id="login-tab" class="tab-content active">
<form id="login-form">
<div class="form-group">
<label for="login-email">Email</label>
<input type="email" id="login-email" class="form-control" placeholder="Enter your email" required>
</div>
<div class="form-group">
<label for="login-password">Password</label>
<input type="password" id="login-password" class="form-control" placeholder="Enter your password" required>
</div>
<button type="submit" class="btn">Login</button>
</form>
<div class="divider">OR</div>
<div class="social-login">
<div class="social-btn">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z"></path>
</svg>
</div>
<div class="social-btn">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"></path>
</svg>
</div>
<div class="social-btn">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="2" y="4" width="20" height="16" rx="2"></rect>
<path d="M2 10h20"></path>
</svg>
</div>
</div>
</div>
<div id="signup-tab" class="tab-content">
<form id="signup-form">
<div class="form-group">
<label for="signup-username">Username</label>
<input type="text" id="signup-username" class="form-control" placeholder="Choose a username" required>
</div>
<div class="form-group">
<label for="signup-email">Email</label>
<input type="email" id="signup-email" class="form-control" placeholder="Enter your email" required>
</div>
<div class="form-group">
<label for="signup-password">Password</label>
<input type="password" id="signup-password" class="form-control" placeholder="Create a password" required>
</div>
<div class="form-group">
<label for="signup-confirm">Confirm Password</label>
<input type="password" id="signup-confirm" class="form-control" placeholder="Confirm your password" required>
</div>
<button type="submit" class="btn">Create Account</button>
</form>
</div>
</div>
</div>
<!-- Main App (hidden initially) -->
<div id="app">
<!-- Your existing app content would go here -->
</div>
<script>
// Tab switching
function switchTab(tabName) {
// Hide all tab contents
document.querySelectorAll('.tab-content').forEach(tab => {
tab.classList.remove('active');
});
// Deactivate all tabs
document.querySelectorAll('.tab').forEach(tab => {
tab.classList.remove('active');
});
// Activate selected tab
document.getElementById(`${tabName}-tab`).classList.add('active');
document.querySelector(`.tab[onclick="switchTab('${tabName}')"]`).classList.add('active');
}
// Form submission
document.getElementById('login-form').addEventListener('submit', function(e) {
e.preventDefault();
// Here you would normally validate and send to server
// For demo, we'll just show the app
document.getElementById('login-page').style.display = 'none';
document.getElementById('app').style.display = 'block';
});
document.getElementById('signup-form').addEventListener('submit', function(e) {
e.preventDefault();
// Here you would normally validate and send to server
// For demo, we'll just show the app
document.getElementById('login-page').style.display = 'none';
document.getElementById('app').style.display = 'block';
});
// You would need to include your existing app JavaScript here
// and make sure it only runs when the app is shown
</script>
</body>
</html>
This design features:
Futuristic Login/Signup Page:
Modern UI Elements:
Transition to Main App:
To complete this, you would need to:
The design is fully responsive and has a cohesive futuristic aesthetic that matches the high-tech nature of 3D printing.*
Here's the updated code that automatically switches to the signup tab when login fails due to non-existent account:
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Previous head content remains the same -->
<style>
/* Previous styles remain the same */
.error-message {
color: #ff4d4d;
font-size: 0.8rem;
margin-top: 5px;
display: none;
}
.shake {
animation: shake 0.5s;
}
@keyframes shake {
0%, 100% { transform: translateX(0); }
20%, 60% { transform: translateX(-5px); }
40%, 80% { transform: translateX(5px); }
}
</style>
</head>
<body>
<!-- Previous HTML remains the same until the script section -->
<script>
// Tab switching
function switchTab(tabName) {
// Hide all tab contents
document.querySelectorAll('.tab-content').forEach(tab => {
tab.classList.remove('active');
});
// Deactivate all tabs
document.querySelectorAll('.tab').forEach(tab => {
tab.classList.remove('active');
});
// Activate selected tab
document.getElementById(`${tabName}-tab`).classList.add('active');
document.querySelector(`.tab[onclick="switchTab('${tabName}')"]`).classList.add('active');
}
// Mock database of users
const users = [
{ email: "user@example.com", password: "password123", username: "exampleuser" }
];
// Form submission
document.getElementById('login-form').addEventListener('submit', function(e) {
e.preventDefault();
const email = document.getElementById('login-email').value;
const password = document.getElementById('login-password').value;
const errorElement = document.getElementById('login-error');
// Find user in mock database
const user = users.find(u => u.email === email);
if (!user) {
// No account found - switch to signup
document.getElementById('signup-email').value = email;
switchTab('signup');
document.getElementById('signup-form').classList.add('shake');
setTimeout(() => {
document.getElementById('signup-form').classList.remove('shake');
}, 500);
return;
}
if (user.password !== password) {
// Wrong password
showError('login-error', 'Incorrect password');
document.getElementById('login-form').classList.add('shake');
setTimeout(() => {
document.getElementById('login-form').classList.remove('shake');
}, 500);
return;
}
// Successful login
document.getElementById('login-page').style.display = 'none';
document.getElementById('app').style.display = 'block';
});
document.getElementById('signup-form').addEventListener('submit', function(e) {
e.preventDefault();
const username = document.getElementById('signup-username').value;
const email = document.getElementById('signup-email').value;
const password = document.getElementById('signup-password').value;
const confirm = document.getElementById('signup-confirm').value;
// Validate passwords match
if (password !== confirm) {
showError('signup-error', 'Passwords do not match');
document.getElementById('signup-form').classList.add('shake');
setTimeout(() => {
document.getElementById('signup-form').classList.remove('shake');
}, 500);
return;
}
// Check if email already exists
if (users.some(u => u.email === email)) {
showError('signup-error', 'Email already registered');
document.getElementById('signup-form').classList.add('shake');
setTimeout(() => {
document.getElementById('signup-form').classList.remove('shake');
}, 500);
return;
}
// Add new user (in a real app, this would be a server call)
users.push({ email, password, username });
// Successful signup
document.getElementById('login-page').style.display = 'none';
document.getElementById('app').style.display = 'block';
});
function showError(elementId, message) {
const errorElement = document.getElementById(elementId);
if (!errorElement) {
const form = document.activeElement.closest('form');
errorElement = document.createElement('div');
errorElement.id = elementId;
errorElement.className = 'error-message';
form.appendChild(errorElement);
}
errorElement.textContent = message;
errorElement.style.display = 'block';
setTimeout(() => {
errorElement.style.display = 'none';
}, 3000);
}
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Previous head content remains the same -->
<style>
/* Previous styles remain the same */
.error-message {
color: #ff4d4d;
font-size: 0.8rem;
margin-top: 5px;
display: none;
}
.shake {
animation: shake 0.5s;
}
@keyframes shake {
0%, 100% { transform: translateX(0); }
20%, 60% { transform: translateX(-5px); }
40%, 80% { transform: translateX(5px); }
}
</style>
</head>
<body>
<!-- Previous HTML remains the same until the script section -->
<script>
// Tab switching
function switchTab(tabName) {
// Hide all tab contents
document.querySelectorAll('.tab-content').forEach(tab => {
tab.classList.remove('active');
});
// Deactivate all tabs
document.querySelectorAll('.tab').forEach(tab => {
tab.classList.remove('active');
});
// Activate selected tab
document.getElementById(`${tabName}-tab`).classList.add('active');
document.querySelector(`.tab[onclick="switchTab('${tabName}')"]`).classList.add('active');
}
// Mock database of users
const users = [
{ email: "user@example.com", password: "password123", username: "exampleuser" }
];
// Form submission
document.getElementById('login-form').addEventListener('submit', function(e) {
e.preventDefault();
const email = document.getElementById('login-email').value;
const password = document.getElementById('login-password').value;
const errorElement = document.getElementById('login-error');
// Find user in mock database
const user = users.find(u => u.email === email);
if (!user) {
// No account found - switch to signup
document.getElementById('signup-email').value = email;
switchTab('signup');
document.getElementById('signup-form').classList.add('shake');
setTimeout(() => {
document.getElementById('signup-form').classList.remove('shake');
}, 500);
return;
}
if (user.password !== password) {
// Wrong password
showError('login-error', 'Incorrect password');
document.getElementById('login-form').classList.add('shake');
setTimeout(() => {
document.getElementById('login-form').classList.remove('shake');
}, 500);
return;
}
// Successful login
document.getElementById('login-page').style.display = 'none';
document.getElementById('app').style.display = 'block';
});
document.getElementById('signup-form').addEventListener('submit', function(e) {
e.preventDefault();
const username = document.getElementById('signup-username').value;
const email = document.getElementById('signup-email').value;
const password = document.getElementById('signup-password').value;
const confirm = document.getElementById('signup-confirm').value;
// Validate passwords match
if (password !== confirm) {
showError('signup-error', 'Passwords do not match');
document.getElementById('signup-form').classList.add('shake');
setTimeout(() => {
document.getElementById('signup-form').classList.remove('shake');
}, 500);
return;
}
// Check if email already exists
if (users.some(u => u.email === email)) {
showError('signup-error', 'Email already registered');
document.getElementById('signup-form').classList.add('shake');
setTimeout(() => {
document.getElementById('signup-form').classList.remove('shake');
}, 500);
return;
}
// Add new user (in a real app, this would be a server call)
users.push({ email, password, username });
// Successful signup
document.getElementById('login-page').style.display = 'none';
document.getElementById('app').style.display = 'block';
});
function showError(elementId, message) {
const errorElement = document.getElementById(elementId);
if (!errorElement) {
const form = document.activeElement.closest('form');
errorElement = document.createElement('div');
errorElement.id = elementId;
errorElement.className = 'error-message';
form.appendChild(errorElement);
}
errorElement.textContent = message;
errorElement.style.display = 'block';
setTimeout(() => {
errorElement.style.display = 'none';
}, 3000);
}
</script>
</body>
</html>
Key improvements:
Automatic Tab Switching:
Visual Feedback:
Basic Validation:
Mock User Database:
Smooth Transitions:
To implement this in your real application, you would need to:
The current implementation provides a complete client-side demo that demonstrates the switching behavior you requested.