Skip to content

Commit

Permalink
Merge pull request #57 from Gwenillia/staging
Browse files Browse the repository at this point in the history
v2.1.0
  • Loading branch information
Gwenillia authored Jan 15, 2023
2 parents 1a1f395 + 5333ccb commit b49a85f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 21 deletions.
20 changes: 6 additions & 14 deletions foodSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,16 @@ class FoodSelect {
}

if (window.location.href.indexOf("elevage/chevaux/cheval?") > -1) {
const foodSelect = new FoodSelect()
if (foodSelect.feedingBtn !== null)
foodSelect.feedingBtn.addEventListener("click", () => {
foodSelect.run()
})

/**
* @description generate a new FoodSelect() because after #loading style change,
* it seems like the different this.elements from foodSelect are erased ..
* @todo fix it...
*/
const startObserver = () => {
observer.start().then(() => {
let newFoodSelect = new FoodSelect()
newFoodSelect.run()
const foodSelect = new FoodSelect()
if (foodSelect.feedingBtn !== null)
foodSelect.feedingBtn.addEventListener("click", () => {
foodSelect.run()
})

startObserver()
})
}

startObserver()
}
21 changes: 19 additions & 2 deletions horseStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class HorseStats {
this.jumpingBase = this.calcStatBase('sautValeur')
this.jumpingBonuses = this.calcStatBonus(new RegExp(`(${translation.get(this.lang, 'stat', 'jumping')}).+?[1-9]\d*`, "g"))
this.jumpingTotal = this.calcStatTotal(this.jumpingBase, this.jumpingBonuses)

this.previousHorseButton = document.getElementById('nav-previous')
this.nextHorseButton = document.getElementById('nav-next')
}

convert(value) {
Expand Down Expand Up @@ -68,7 +71,7 @@ class HorseStats {
}

calcStatBase(stat) {
return parseFloat(document.getElementById(stat).innerText)
return parseFloat(document.getElementById(stat)?.innerText)
}

calcStatBonus(stat) {
Expand All @@ -90,7 +93,7 @@ class HorseStats {
competitionsDiffDisplay() {
this.competitionTitle.style.display = 'flex'
this.competitionTitle.style.flexFlow = 'column nowrap'
const hintHTML = `<span style='font-size: .8em;'> ${this.isFrenchApp ? 'Plus le coeff est élevé plus il y a de chances de gagner' : 'The higher the coefficient, the greater the chance of winning'}</span> `
const hintHTML = `<span style='font-size: .8em;'> ${translation.get(this.lang, 'competition', 'disclaimer')}</span> `
const parsedHintHtml = this.parser.parseFromString(hintHTML, `text/html`)
const hintTags = parsedHintHtml.getElementsByTagName(`span`)

Expand Down Expand Up @@ -152,7 +155,21 @@ class HorseStats {
})
}

handleArrowKeySwitch(event) {
switch (event.keyCode) {
case 37:
const previousHorseButton = document.getElementById('nav-previous')
previousHorseButton.click()
break
case 39:
const nextHorseButton = document.getElementById('nav-next')
nextHorseButton.click()
break
}
}

run() {
document.addEventListener('keyup', this.handleArrowKeySwitch)
this.competitionsDiffDisplay()
}
}
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "__MSG_appName__",
"description": "__MSG_appDesc__",
"default_locale": "fr",
"version": "2.0.0",
"version": "2.1.0",
"manifest_version": 3,
"author": "TC-Dev",
"icons": {
Expand Down
5 changes: 4 additions & 1 deletion moreInfos.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ class MoreInfos {
}

run() {
const infoDivExist = document.getElementsByClassName('infodiv')
if (infoDivExist.length > 1) return

const isDetailedView = document.getElementById("detail-chevaux")
const names = document.getElementsByClassName("horsename")
const namesArr = Array.from(names)
Expand Down Expand Up @@ -160,4 +163,4 @@ if (moreInfos.locationAllowed) {
})
}
startObserver()
}
}
9 changes: 6 additions & 3 deletions translation.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class Translation {
cutting: 'Cutting',
trailClass: 'Trail class',
reining: 'Reining',
westernPleasure: 'Western pleasure'
westernPleasure: 'Western pleasure',
disclaimer: 'Plus le coeff est élevé plus il y a de chances de gagner'
},
other: {
pet: 'Compagnon: ',
Expand All @@ -47,7 +48,8 @@ class Translation {
cutting: 'Cutting',
trailClass: 'Trail class',
reining: 'Reining',
westernPleasure: 'Western pleasure'
westernPleasure: 'Western pleasure',
disclaimer: 'The higher the coefficient, the greater the chance of winning'
},
other: {
pet: 'Pet: ',
Expand All @@ -74,7 +76,8 @@ class Translation {
cutting: 'Cutting',
trailClass: 'Trail class',
reining: 'Reining',
westernPleasure: 'Western pleasure'
westernPleasure: 'Western pleasure',
disclaimer: 'Jo høyere koeffisient, jo større er sjansen for å vinne'
},
other: {
pet: 'Følgesvenner: ',
Expand Down

0 comments on commit b49a85f

Please sign in to comment.