Skip to content

Commit

Permalink
Merge pull request #46 from leedrum/dev
Browse files Browse the repository at this point in the history
Fix level progress, ban history in profile
  • Loading branch information
leedrum authored Jan 7, 2024
2 parents 77057c2 + 9d6ad53 commit 0307dde
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 21 deletions.
18 changes: 9 additions & 9 deletions src/helpers/elo.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ export function predictRatingChange(winProbability, K = 50) {
}

export const LEVELS = {
1: [1, 800],
2: [801, 950],
3: [951, 1100],
4: [1101, 1250],
5: [1251, 1400],
6: [1401, 1550],
7: [1551, 1700],
8: [1701, 1850],
9: [1851, 2000],
1: [1, 500],
2: [501, 750],
3: [751, 900],
4: [901, 1050],
5: [1051, 1200],
6: [1201, 1350],
7: [1351, 1530],
8: [1531, 1750],
9: [1751, 2000],
10: [2001, null]
}

Expand Down
5 changes: 3 additions & 2 deletions src/pages/Content/modules/header-level-progress/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@ import { LEVELS } from '../../../../helpers/elo'
import SkillLevelComponent from "../../../../containers/skill-level";

const FEATURE_ATTRIBUTE = 'level-progress'
const REFRESH_TIME = 300
const REFRESH_TIME = 120 // seconds

export const FeatureHeaderLevelProgress = async () => {

if (!isLoggedIn()) {
return
}

let mainHeaderActionsElement = null
try {
mainHeaderActionsElement = document.querySelector("div[ui-view='header']").querySelector('#main-header-height-wrapper').querySelector("#main-header-height-wrapper").querySelector('div')
mainHeaderActionsElement = document.querySelector("div[ui-view='header']").querySelector('#main-header-height-wrapper').querySelector('div')
} catch (error) {
return
}
Expand Down
31 changes: 21 additions & 10 deletions src/pages/Content/modules/player-profile-ban/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,46 +14,57 @@ import { getPlayer, getPlayerBans } from '../../../../helpers/faceit-api'
const FEATURE_ATTRIBUTE = 'profile-bans'

export const PlayerProfileBan = async parentElement => {
const banElement = select('profile-overview-bans', parentElement)
// const banElement = select('profile-overview-bans', parentElement)
let aboutElement = parentElement.querySelector('#parasite-container').querySelector('#content-grid-element-5')

if (banElement === null || banElement === undefined) {
if (aboutElement === null || aboutElement === undefined) {
return
}

if (hasFeatureAttribute(FEATURE_ATTRIBUTE, banElement)) {
if (hasFeatureAttribute(FEATURE_ATTRIBUTE, aboutElement)) {
return
}

setFeatureAttribute(FEATURE_ATTRIBUTE, banElement)
const divClass = aboutElement.className
const headingClass = aboutElement.querySelector('h5').className
const spanClass = aboutElement.lastElementChild.className
setFeatureAttribute(FEATURE_ATTRIBUTE, aboutElement)
aboutElement = aboutElement.parentElement

const headerElement = (
<h3 className="heading-border">
<span translate="BANS">Bans</span>
</h3>
)

const noBanElement = <div>No match bans yet</div>
const noBanElement = (
<div className={divClass}>
<h5 className={headingClass}>
<span translate="BANS">Bans</span>
</h5>
<span translate="No match bans yet" className={spanClass}>No match bans yet</span>
</div>
)

const nickname = getPlayerProfileNickname()
const { id } = await getPlayer(nickname)

const playerBans = await getPlayerBans(id)

if (playerBans.length === 0) {
banElement.append(noBanElement)
aboutElement.append(noBanElement)
}

playerBans.forEach(ban => {
const playerBansElement = createPlayerBansElement(ban)

const banWrapper = <div className="mb-sm">{playerBansElement}</div>
const banWrapper = <div className={divClass}>{playerBansElement}</div>

banElement.append(banWrapper)
aboutElement.append(banWrapper)
})

const headerElementMissing = select('h3.heading-border', parentElement)
if (headerElementMissing === undefined) {
banElement.insertBefore(headerElement, banElement.firstChild)
aboutElement.insertBefore(headerElement, aboutElement.firstChild)
}
}

Expand Down

0 comments on commit 0307dde

Please sign in to comment.