Fixed pencil bug.
This commit is contained in:
+14
-28
@@ -29,25 +29,19 @@
|
|||||||
z-index: -1;
|
z-index: -1;
|
||||||
}
|
}
|
||||||
.cursor-pointer { cursor: pointer; }
|
.cursor-pointer { cursor: pointer; }
|
||||||
#edit-xp {
|
#edit-xp { display: inline-block; transform: scaleX(-1); }
|
||||||
display: inline-block;
|
|
||||||
transform: scaleX(-1);
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body class="bg-slate-50 flex items-center justify-center min-h-screen p-4">
|
<body class="bg-slate-50 flex items-center justify-center min-h-screen p-4">
|
||||||
|
|
||||||
<div class="w-full max-w-md bg-white rounded-2xl shadow-xl p-6 md:p-8 border border-slate-200 text-center">
|
<div class="w-full max-w-md bg-white rounded-2xl shadow-xl p-6 md:p-8 border border-slate-200 text-center">
|
||||||
|
|
||||||
<img src="pogo.png" alt="Pokémon GO" class="mx-auto mb-4 w-32 h-auto">
|
<img src="pogo.png" alt="Pokémon GO" class="mx-auto mb-4 w-32 h-auto">
|
||||||
|
|
||||||
<h1 class="text-2xl md:text-3xl font-bold text-slate-900 mb-4">Pokémon GO Level Calculator</h1>
|
<h1 class="text-2xl md:text-3xl font-bold text-slate-900 mb-4">Pokémon GO Level Calculator</h1>
|
||||||
<p class="text-slate-500 mb-6">Enter your total XP to see your level</p>
|
<p class="text-slate-500 mb-6">Enter your total XP to see your level</p>
|
||||||
|
|
||||||
<div class="flex gap-2 mb-4 justify-center">
|
<div class="flex gap-2 mb-4 justify-center">
|
||||||
<input type="text" id="xp-input" placeholder="e.g., 123,456,789"
|
<input type="text" id="xp-input" placeholder="e.g., 123,456,789"
|
||||||
class="flex-1 px-4 py-3 border border-slate-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-400 text-center text-lg">
|
class="flex-1 px-4 py-3 border border-slate-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-400 text-center text-lg">
|
||||||
|
|
||||||
<button id="calculate-btn"
|
<button id="calculate-btn"
|
||||||
class="w-12 h-12 bg-green-500 hover:bg-green-600 text-white font-bold rounded-lg transition-transform transform hover:scale-105">
|
class="w-12 h-12 bg-green-500 hover:bg-green-600 text-white font-bold rounded-lg transition-transform transform hover:scale-105">
|
||||||
GO!
|
GO!
|
||||||
@@ -95,26 +89,21 @@
|
|||||||
function calculateLevel(xp) {
|
function calculateLevel(xp) {
|
||||||
let level = 1;
|
let level = 1;
|
||||||
for (let i = 0; i < xpThresholds.length; i++) {
|
for (let i = 0; i < xpThresholds.length; i++) {
|
||||||
if (xp >= xpThresholds[i]) {
|
if (xp >= xpThresholds[i]) level = i + 1;
|
||||||
level = i + 1;
|
else break;
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatDays(days) {
|
function formatDays(days) {
|
||||||
if (days > 365) {
|
if (days > 365) return (days / 365).toFixed(1) + ' years';
|
||||||
return (days / 365).toFixed(1) + ' years';
|
|
||||||
}
|
|
||||||
return days.toLocaleString() + ' days';
|
return days.toLocaleString() + ' days';
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateExtraInfo() {
|
function updateExtraInfo() {
|
||||||
let nextLevelXp = (currentLevel < xpThresholds.length) ? xpThresholds[currentLevel] : currentXp;
|
let nextLevelXp = (currentLevel < xpThresholds.length) ? xpThresholds[currentLevel] : currentXp;
|
||||||
let xpToNext = Math.max(0, nextLevelXp - currentXp);
|
let xpToNext = Math.max(0, nextLevelXp - currentXp);
|
||||||
let xpTo40 = Math.max(0, xpThresholds[39] - currentXp); // Level 40
|
let xpTo40 = Math.max(0, xpThresholds[39] - currentXp);
|
||||||
let xpTo80 = Math.max(0, xpThresholds[79] - currentXp);
|
let xpTo80 = Math.max(0, xpThresholds[79] - currentXp);
|
||||||
|
|
||||||
let daysNext = Math.ceil(xpToNext / avgXpPerDay);
|
let daysNext = Math.ceil(xpToNext / avgXpPerDay);
|
||||||
@@ -126,14 +115,19 @@
|
|||||||
: `If you average ${avgXpPerDay.toLocaleString()} XP per day, you will reach the next level in ${formatDays(daysNext)} and level 80 in ${formatDays(days80)}.`;
|
: `If you average ${avgXpPerDay.toLocaleString()} XP per day, you will reach the next level in ${formatDays(daysNext)} and level 80 in ${formatDays(days80)}.`;
|
||||||
|
|
||||||
document.getElementById('extra-info').innerHTML = `<p>${nextText} <span id="edit-xp" class="ml-1 text-blue-500 cursor-pointer">✏️</span></p>`;
|
document.getElementById('extra-info').innerHTML = `<p>${nextText} <span id="edit-xp" class="ml-1 text-blue-500 cursor-pointer">✏️</span></p>`;
|
||||||
|
|
||||||
|
document.getElementById('edit-xp').addEventListener('click', () => {
|
||||||
|
let newVal = prompt("Enter your average XP per day:", avgXpPerDay);
|
||||||
|
if (newVal && !isNaN(newVal) && parseInt(newVal) > 0) {
|
||||||
|
avgXpPerDay = parseInt(newVal, 10);
|
||||||
|
updateExtraInfo();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById('calculate-btn').addEventListener('click', () => {
|
document.getElementById('calculate-btn').addEventListener('click', () => {
|
||||||
let xp = document.getElementById('xp-input').value.replace(/,/g,'').trim();
|
let xp = document.getElementById('xp-input').value.replace(/,/g,'').trim();
|
||||||
if (!xp || isNaN(xp)) {
|
if (!xp || isNaN(xp)) { alert('Please enter a valid number for XP.'); return; }
|
||||||
alert('Please enter a valid number for XP.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
currentXp = parseInt(xp, 10);
|
currentXp = parseInt(xp, 10);
|
||||||
|
|
||||||
currentLevel = calculateLevel(currentXp);
|
currentLevel = calculateLevel(currentXp);
|
||||||
@@ -154,14 +148,6 @@
|
|||||||
document.getElementById('xp-input').addEventListener('input', (e)=>{
|
document.getElementById('xp-input').addEventListener('input', (e)=>{
|
||||||
e.target.value = e.target.value.replace(/[^0-9,]/g,'');
|
e.target.value = e.target.value.replace(/[^0-9,]/g,'');
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('edit-xp').addEventListener('click', () => {
|
|
||||||
let newVal = prompt("Enter your average XP per day:", avgXpPerDay);
|
|
||||||
if (newVal && !isNaN(newVal) && parseInt(newVal) > 0) {
|
|
||||||
avgXpPerDay = parseInt(newVal, 10);
|
|
||||||
updateExtraInfo();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user