Fixed pencil bug.
This commit is contained in:
1 parent
362b1b4b3a
commit
255d0d3a29
1 file changed
+14
-28
+14
-28
@@ -29,25 +29,19 @@
|
||||
z-index: -1;
|
||||
}
|
||||
.cursor-pointer { cursor: pointer; }
|
||||
#edit-xp {
|
||||
display: inline-block;
|
||||
transform: scaleX(-1);
|
||||
}
|
||||
#edit-xp { display: inline-block; transform: scaleX(-1); }
|
||||
</style>
|
||||
</head>
|
||||
<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">
|
||||
|
||||
<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>
|
||||
<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">
|
||||
<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">
|
||||
|
||||
<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">
|
||||
GO!
|
||||
@@ -95,26 +89,21 @@
|
||||
function calculateLevel(xp) {
|
||||
let level = 1;
|
||||
for (let i = 0; i < xpThresholds.length; i++) {
|
||||
if (xp >= xpThresholds[i]) {
|
||||
level = i + 1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
if (xp >= xpThresholds[i]) level = i + 1;
|
||||
else break;
|
||||
}
|
||||
return level;
|
||||
}
|
||||
|
||||
function formatDays(days) {
|
||||
if (days > 365) {
|
||||
return (days / 365).toFixed(1) + ' years';
|
||||
}
|
||||
if (days > 365) return (days / 365).toFixed(1) + ' years';
|
||||
return days.toLocaleString() + ' days';
|
||||
}
|
||||
|
||||
function updateExtraInfo() {
|
||||
let nextLevelXp = (currentLevel < xpThresholds.length) ? xpThresholds[currentLevel] : 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 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)}.`;
|
||||
|
||||
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', () => {
|
||||
let xp = document.getElementById('xp-input').value.replace(/,/g,'').trim();
|
||||
if (!xp || isNaN(xp)) {
|
||||
alert('Please enter a valid number for XP.');
|
||||
return;
|
||||
}
|
||||
if (!xp || isNaN(xp)) { alert('Please enter a valid number for XP.'); return; }
|
||||
currentXp = parseInt(xp, 10);
|
||||
|
||||
currentLevel = calculateLevel(currentXp);
|
||||
@@ -154,14 +148,6 @@
|
||||
document.getElementById('xp-input').addEventListener('input', (e)=>{
|
||||
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>
|
||||
|
||||
</body>
|
||||
|
||||
Reference in new issue
Block a user