Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Bubble Solution Calculator</title>
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <style>
- body {
- font-family: system-ui, sans-serif;
- background: #f0f7fb;
- display: flex;
- justify-content: center;
- padding: 40px 16px;
- margin: 0;
- }
- .card {
- position: relative;
- background: white;
- padding: 24px;
- border-radius: 16px;
- box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
- max-width: 600px;
- width: 100%;
- box-sizing: border-box;
- }
- .lang-toggle {
- position: absolute;
- top: 16px;
- right: 16px;
- }
- .lang-toggle button {
- padding: 6px 12px;
- font-size: 14px;
- border: 1px solid #007BFF;
- background: #fff;
- color: #007BFF;
- border-radius: 6px;
- cursor: pointer;
- }
- h2 {
- text-align: center;
- margin-bottom: 24px;
- font-size: 1.5rem;
- display: flex;
- align-items: center;
- justify-content: center;
- gap: 0.5rem;
- }
- label {
- font-weight: 600;
- display: block;
- margin-top: 15px;
- }
- input[type="number"] {
- width: 100%;
- padding: 10px;
- margin-top: 5px;
- font-size: 16px;
- border-radius: 6px;
- border: 1px solid #ccc;
- box-sizing: border-box;
- }
- .unit-button-container {
- display: flex;
- align-items: flex-end;
- justify-content: space-between;
- margin-top: 10px;
- flex-wrap: wrap;
- gap: 10px;
- }
- .unit-selection {
- display: flex;
- gap: 20px;
- flex-wrap: wrap;
- }
- .unit-selection label {
- font-weight: normal;
- }
- button {
- padding: 12px 20px;
- font-size: 16px;
- background-color: #007BFF;
- color: white;
- border: none;
- border-radius: 6px;
- cursor: pointer;
- white-space: nowrap;
- }
- .divider {
- height: 1px;
- background: #ccc;
- margin: 30px 0 20px;
- }
- .result {
- background: #EAF4FE;
- padding: 20px;
- border-radius: 10px;
- }
- .result h3 {
- margin-top: 0;
- display: flex;
- align-items: center;
- gap: 0.5rem;
- }
- .result ul {
- list-style: none;
- padding-left: 0;
- }
- .result ul li {
- position: relative;
- padding-left: 2em;
- margin-bottom: 6px;
- }
- .result ul li::before {
- content: '';
- position: absolute;
- left: 0.6em;
- top: 0.5em;
- width: 8px;
- height: 8px;
- border-radius: 50%;
- }
- .result ul li:nth-child(1)::before { background-color: #6c4f2c; }
- .result ul li:nth-child(2)::before { background-color: #0056b3; }
- .result ul li:nth-child(3)::before { background-color: #00796b; }
- .result ul li:nth-child(4)::before { background-color: #6a1b9a; }
- .instructions {
- background: #FFF7E1;
- padding: 20px;
- border-left: 5px solid #F7C132;
- margin-top: 25px;
- border-radius: 10px;
- }
- .instructions h3 {
- margin-top: 0;
- display: flex;
- align-items: center;
- gap: 0.5rem;
- }
- ol {
- padding-left: 20px;
- }
- #instruction-steps {
- list-style: none;
- padding-left: 0;
- }
- #instruction-steps li {
- position: relative;
- left: 0.1em;
- padding-left: 1.2em;
- }
- .list-num {
- position: absolute;
- left: 0;
- font-weight: normal;
- }
- @media (max-width: 480px) {
- .unit-button-container {
- flex-direction: column;
- align-items: stretch;
- }
- .unit-selection {
- justify-content: space-around;
- }
- button {
- width: 100%;
- }
- }
- </style>
- </head>
- <body>
- <div class="card" id="capture-area">
- <div class="lang-toggle">
- <button onclick="toggleLanguage()" id="lang-btn"></button>
- </div>
- <h2 id="title"></h2>
- <label for="amount" id="label-amount"></label>
- <input type="number" id="amount" value="1" min="0.1" step="0.1">
- <div class="unit-button-container">
- <div class="unit-selection">
- <label><input type="radio" name="unit" value="l" checked> <span id="label-liter"></span></label>
- <label><input type="radio" name="unit" value="ml"> <span id="label-ml"></span></label>
- </div>
- <button onclick="calculateSolution()" id="calc-btn"></button>
- </div>
- <div class="divider"></div>
- <div class="result" id="result"></div>
- <div class="instructions">
- <h3 id="instructions-title"></h3>
- <ol id="instruction-steps"></ol>
- </div>
- </div>
- <script>
- const translations = {
- en: {
- title: 'đ̧ Bubble Solution Calculator',
- amountLabel: 'Enter Total Solution Amount',
- liter: 'Liter (L)',
- ml: 'Milliliter (ml)',
- button: 'Calculate Ingredients',
- ingredientsTitle: 'đ§´ Required Ingredients',
- restLine: 'Let the mixture rest for at least 1 hour for best bubbles!',
- items: [
- 'Warm Water',
- 'Dish Soap',
- 'Glycerin (or Sugar/Corn Syrup)',
- 'Baking Powder (optional)'
- ],
- instructionsTitle: 'đ§Ē Instructions',
- instructions: [
- 'Pour the calculated amount of warm water into a large container.',
- 'Add the measured dish soap and stir gently to avoid bubbles.',
- 'Mix in the glycerin (or sugar/corn syrup).',
- 'Stir in the baking powder (optional).',
- 'Let the mixture rest for at least 1 hour or overnight for best results.',
- 'Enjoy making big and strong bubbles!'
- ]
- },
- bn: {
- title: 'đ̧ āĻŦāĻžāĻŦāϞ āϏāϞā§āϝā§āĻļāύ āĻā§āϝāĻžāϞāĻā§āϞā§āĻāϰ',
- amountLabel: 'āĻŽā§āĻ āĻŦāĻžāĻŦāϞ āϏāϞā§āϝā§āĻļāύā§āϰ āĻĒāϰāĻŋāĻŽāĻžāĻŖ āϞāĻŋāĻā§āύ',
- liter: 'āϞāĻŋāĻāĻžāϰ (L)',
- ml: 'āĻŽāĻŋāϞāĻŋāϞāĻŋāĻāĻžāϰ (ml)',
- button: 'āĻāĻĒāĻžāĻĻāĻžāύ āĻšāĻŋāϏāĻžāĻŦ āĻāϰā§āύ',
- ingredientsTitle: 'đ§´ āĻĒā§āϰāϝāĻŧā§āĻāύā§āϝāĻŧ āĻāĻĒāĻžāĻĻāĻžāύ',
- restLine: 'āϏāϰā§āĻŦā§āϤā§āϤāĻŽ āĻŦāĻžāĻŦāϞ āĻĒāĻžāϰāĻĢāϰāĻŽā§āϝāĻžāύā§āϏā§āϰ āĻāύā§āϝ āĻāĻŽāĻĒāĻā§āώ⧠⧧ āĻāĻŖā§āĻāĻž āĻŦāĻŋāĻļā§āϰāĻžāĻŽ āĻĻāĻŋāύāĨ¤',
- items: [
- 'āĻāώā§āĻŖ āĻĒāĻžāύāĻŋ',
- 'āĻĄāĻŋāĻļ āϏā§āĻĄāĻž',
- 'āĻā§āϞāĻŋāϏāĻžāϰāĻŋāύ (āĻ āĻĨāĻŦāĻž āĻāĻŋāύāĻŋ/āĻā§āĻā§āĻāĻžāϰ āϏāĻŋāϰāĻžāĻĒ)',
- 'āĻŦā§āĻāĻŋāĻ āĻĒāĻžāĻāĻĄāĻžāϰ (āĻāĻā§āĻāĻŋāĻ)'
- ],
- instructionsTitle: 'đ§Ē āύāĻŋāϰā§āĻĻā§āĻļāĻžāĻŦāϞā§',
- instructions: [
- 'āĻāώā§āĻŖ āĻĒāĻžāύāĻŋ āĻāĻāĻāĻŋ āĻŦāĻĄāĻŧ āĻĒāĻžāϤā§āϰ⧠āύāĻŋāύāĨ¤',
- 'āĻĄāĻŋāĻļ āϏā§āĻĄāĻž āĻŽāĻŋāĻļāĻŋā§ā§ āĻāϏā§āϤ⧠āύāĻžāĻĄāĻŧā§āύ āϝāĻžāϤ⧠āĻĢā§āύāĻž āύāĻž āĻāĻ ā§āĨ¤',
- 'āĻā§āϞāĻŋāϏāĻžāϰāĻŋāύ (āĻ āĻĨāĻŦāĻž āĻāĻŋāύāĻŋ/āĻā§āĻā§āĻāĻžāϰ āϏāĻŋāϰāĻžāĻĒ) āĻŽā§āĻļāĻžāύāĨ¤',
- 'āĻŦā§āĻāĻŋāĻ āĻĒāĻžāĻāĻĄāĻžāϰ (āĻāĻā§āĻāĻŋāĻ) āĻĻāĻŋā§ā§ āĻŽāĻŋāĻļāĻŋā§ā§ āύāĻŋāύāĨ¤',
- 'āĻāĻŽāĻĒāĻā§āώ⧠⧧ āĻāĻŖā§āĻāĻž āĻŦāĻž āϰāĻžāϤāĻāϰ āϰā§āĻā§ āĻĻāĻŋāύāĨ¤',
- 'āϤāĻžāϰāĻĒāϰ āĻŽāĻāĻžāϰ āĻŦāĻžāĻŦāϞ āϤā§āϰāĻŋ āĻāĻĒāĻā§āĻ āĻāϰā§āύ!'
- ]
- }
- };
- let currentLang = 'en';
- function toggleLanguage() {
- currentLang = currentLang === 'en' ? 'bn' : 'en';
- setLanguage();
- calculateSolution();
- }
- function setLanguage() {
- const t = translations[currentLang];
- document.getElementById('title').innerText = t.title;
- document.getElementById('label-amount').innerText = t.amountLabel;
- document.getElementById('label-liter').innerText = t.liter;
- document.getElementById('label-ml').innerText = t.ml;
- document.getElementById('calc-btn').innerText = t.button;
- document.getElementById('instructions-title').innerText = t.instructionsTitle;
- document.getElementById('lang-btn').innerText = currentLang === 'en' ? 'āĻŦāĻžāĻāϞāĻž' : 'English';
- document.getElementById('instruction-steps').innerHTML = t.instructions.map((text, index) => {
- const num = currentLang === 'bn' ? convertToBanglaNumber(index + 1) : index + 1;
- return `<li><span class="list-num">${num}.</span> ${text}</li>`;
- }).join('');
- }
- function convertToBanglaNumber(str) {
- const bnDigits = ['ā§Ļ', 'ā§§', '⧍', 'ā§Š', 'ā§Ē', 'ā§Ģ', 'ā§Ŧ', 'ā§', 'ā§Ž', '⧝'];
- return str.toString().replace(/[0-9]/g, d => bnDigits[d]);
- }
- function formatVolume(value) {
- const formatted = value >= 1000 ? `${(value / 1000).toFixed(1)} L` : `${value.toFixed(0)} mL`;
- return currentLang === 'bn' ? convertToBanglaNumber(formatted) : formatted;
- }
- function formatNumber(value) {
- return currentLang === 'bn' ? convertToBanglaNumber(value.toString()) : value.toString();
- }
- function calculateSolution() {
- const amount = parseFloat(document.getElementById('amount').value);
- const unit = document.querySelector('input[name="unit"]:checked').value;
- const t = translations[currentLang];
- if (isNaN(amount) || amount <= 0) {
- alert("Please enter a valid amount.");
- return;
- }
- const totalMl = unit === "l" ? amount * 1000 : amount;
- const baseVolume = 1900;
- const multiplier = totalMl / baseVolume;
- const water = 1900 * multiplier;
- const dishSoap = 250 * multiplier;
- const glycerinMl = 60 * multiplier;
- const glycerinTbsp = glycerinMl / 15;
- const bakingPowderGm = 10 * multiplier;
- const bakingPowderTsp = bakingPowderGm / 5;
- const result = `
- <h3>${t.ingredientsTitle}</h3>
- <ul>
- <li><strong>${t.items[0]}:</strong> ${formatVolume(water)}</li>
- <li><strong>${t.items[1]}:</strong> ${formatVolume(dishSoap)}</li>
- <li><strong>${t.items[2]}:</strong> ${formatVolume(glycerinMl)} (${formatNumber(glycerinTbsp.toFixed(1))} tbsp)</li>
- <li><strong>${t.items[3]}:</strong> ${formatNumber(bakingPowderGm.toFixed(0))} g (${formatNumber(bakingPowderTsp.toFixed(1))} tsp)</li>
- </ul>
- <p style="margin-top: 10px;">${t.restLine}</p>
- `;
- document.getElementById('result').innerHTML = result;
- }
- window.onload = () => {
- setLanguage();
- calculateSolution();
- };
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement