From 8d1b6cc13f9d8b7a091616cc94b387a21c14b090 Mon Sep 17 00:00:00 2001 From: Anton Vakhrushev Date: Tue, 21 Apr 2020 09:30:31 +0300 Subject: [PATCH] Fix upgrade handler --- src/Page/BuildingPage.ts | 9 ++++++--- src/Page/BuildingPageController.ts | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Page/BuildingPage.ts b/src/Page/BuildingPage.ts index f130574..e2a1c5e 100644 --- a/src/Page/BuildingPage.ts +++ b/src/Page/BuildingPage.ts @@ -46,10 +46,13 @@ export function clickUpgradeButton() { } export function createUpgradeButton(onClickHandler: (resources: Resources) => void) { + const upgradeContainer = jQuery('.upgradeButtonsContainer .section1'); + if (upgradeContainer.length !== 1) { + return; + } const id = uniqId(); - jQuery('.upgradeButtonsContainer .section1').append( - `
В очередь
` - ); + const btn = `
В очередь
`; + upgradeContainer.append(btn); const resources = grabContractResources(); jQuery(`#${id}`).on('click', evt => { evt.preventDefault(); diff --git a/src/Page/BuildingPageController.ts b/src/Page/BuildingPageController.ts index 178dd4b..28f2de6 100644 --- a/src/Page/BuildingPageController.ts +++ b/src/Page/BuildingPageController.ts @@ -31,7 +31,7 @@ export class BuildingPageController { } run() { - const buildTypeId = this.attributes.buildTypeId; + const { buildTypeId } = this.attributes; this.logger.log('BUILD PAGE DETECTED', 'ID', this.attributes.buildId, 'TYPE', buildTypeId); if (buildTypeId) {