From a8cf983e26f2c025ad581f65aaef8887e0627e81 Mon Sep 17 00:00:00 2001
From: Index
Date: Wed, 27 Mar 2024 12:31:51 -0500
Subject: [PATCH] Add "Place Achievements Progress Bar" Feature
---
README.md | 2 +-
js/account/profile.js | 2 +-
js/places/place-view.js | 36 ++++++++++++++++++++++++++++++++----
settings.html | 2 +-
4 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index c4c7a8f..b1f66b9 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
> [!IMPORTANT]
> This extension is currently in BETA. If you find any bugs, please report them in this repository's issues section as it'd be a great help towards development of the extension.
-> [!ROADMAP]
+> [!TIP]
> Want to learn what's in store for Poly+? Check out the roadmap [here](https://github.com/users/indexxing/projects/2)!
# Poly+
diff --git a/js/account/profile.js b/js/account/profile.js
index e0cac54..e93f746 100755
--- a/js/account/profile.js
+++ b/js/account/profile.js
@@ -230,7 +230,7 @@ async function OutfitCost() {
const ResultText = document.createElement('small')
ResultText.classList = 'fw-normal text-success'
ResultText.style.letterSpacing = '0px'
- ResultText.innerHTML = `( ${ (AvatarCost.Limiteds > 0 || AvatarCost.Exclusives > 0) ? '~' : '' } ${ AvatarCost.Total.toLocaleString() }${ (AvatarCost.Limiteds > 0) ? `, ${AvatarCost.Limiteds} limiteds` : '' }${ (AvatarCost.Exclusives > 0) ? `, ${AvatarCost.Exclusives} exclusives` : '' })`
+ ResultText.innerHTML = `( ${ (AvatarCost.Limiteds > 0 || AvatarCost.Exclusives > 0) ? '~' : '' }${ AvatarCost.Total.toLocaleString() }${ (AvatarCost.Limiteds > 0) ? `, ${AvatarCost.Limiteds} limited` : '' }${ (AvatarCost.Exclusives > 0) ? `, ${AvatarCost.Exclusives} exclusive` : '' })`
CalculateButton.remove()
AvatarHeading.appendChild(ResultText)
diff --git a/js/places/place-view.js b/js/places/place-view.js
index 088d0de..6ea5122 100644
--- a/js/places/place-view.js
+++ b/js/places/place-view.js
@@ -92,6 +92,8 @@ let CalculateRevenueButton;
}
})
}
+
+ AchievementProgressBar()
});
})()
@@ -439,7 +441,6 @@ async function OwnedTags() {
}
async function PlaceRevenue() {
- console.log('place revenue ran')
const Visits = parseInt(document.querySelector('li:has(i.fad.fa-users.text-muted[style])').innerText)
const BricksPerView = 5
let Revenue = (round5(Visits) / 5)
@@ -457,8 +458,6 @@ async function PlaceRevenue() {
break
}
- console.log('CREATOR TAX: ' + CreatorTax)
-
fetch(`https://api.polytoria.com/v1/places/${PlaceID}/gamepasses`)
.then(response => {
if (!response.ok) {
@@ -485,4 +484,33 @@ async function PlaceRevenue() {
})
}
-function round5(number) { const remainder = number % 5; if (remainder < 2.5) { return number - remainder; } else { return number + (5 - remainder); } }
\ No newline at end of file
+function round5(number) { const remainder = number % 5; if (remainder < 2.5) { return number - remainder; } else { return number + (5 - remainder); } }
+
+function AchievementProgressBar() {
+ const Achievements = document.getElementById('achievements-tabpane')
+
+ const AchievementCount = Achievements.children.length
+ let AchievementsEarned = 0
+
+ for (let achievement of Array.from(Achievements.children)) {
+ const Achieved = (achievement.getElementsByClassName('fad fa-calendar')[0] !== undefined)
+
+ if (Achieved === true) {
+ AchievementsEarned++
+ }
+ }
+
+ const PercentageEarned = ((AchievementsEarned*100)/AchievementCount).toFixed(0)
+
+ const ProgressBar = document.createElement('div')
+ ProgressBar.role = 'progressbar'
+ ProgressBar.classList = 'progress'
+ ProgressBar.style.background = '#000'
+ ProgressBar.ariaValueNow = PercentageEarned
+ ProgressBar.ariaValueMin = "0"
+ ProgressBar.ariaValueMax = "100"
+ ProgressBar.innerHTML = `${PercentageEarned}%
`
+
+ Achievements.prepend(document.createElement('hr'))
+ Achievements.prepend(ProgressBar)
+}
\ No newline at end of file
diff --git a/settings.html b/settings.html
index cc492e4..b56fb82 100755
--- a/settings.html
+++ b/settings.html
@@ -510,7 +510,7 @@
Quickly see how many bricks a user has gained from one of their places!
- * Gamepass revenue is calculated assuming the price hasn't changed and all users that bought the gamepass, bought it at the same price.
+ * Gamepass revenue is calculated assuming the price hasn't changed and all users that bought the gamepass, bought it at the same price that it is at the time of calculating.