Update prettier and reformat code

This commit is contained in:
2020-10-10 10:21:30 +03:00
parent ecaa98b69c
commit 60078e94b2
39 changed files with 149 additions and 146 deletions

View File

@@ -26,7 +26,7 @@ export function createBuildButton(
const resElement = $el.find('.resourceWrapper .resource');
const resources = grabResourcesFromList(resElement);
$el.append(`<div style="padding: 8px"><a id="${btnId}" href="#">Построить</a></div>`);
jQuery(`#${btnId}`).on('click', evt => {
jQuery(`#${btnId}`).on('click', (evt) => {
evt.preventDefault();
onClickHandler(buildTypeId, resources);
});
@@ -50,17 +50,14 @@ export function createUpgradeButton(onClickHandler: (resources: Resources) => vo
const btn = `<div style="padding: 8px"><a id="${id}" href="#">В очередь</a></div>`;
upgradeContainer.append(btn);
const resources = grabContractResources();
jQuery(`#${id}`).on('click', evt => {
jQuery(`#${id}`).on('click', (evt) => {
evt.preventDefault();
onClickHandler(resources);
});
}
export function grabResourcesFromList($els: JQuery) {
const getText = (n: number) =>
jQuery($els.get(n))
.find('.value')
.text();
const getText = (n: number) => jQuery($els.get(n)).find('.value').text();
const grab = (n: number) => getNumber(getText(n));
return new Resources(grab(0), grab(1), grab(2), grab(3));
}

View File

@@ -22,7 +22,7 @@ function createResearchButton($researchBlockEl: JQuery, onClickHandler: Research
<a id="${id}" href="#">Исследовать</a>
</div>`);
jQuery(`#${id}`).on('click', evt => {
jQuery(`#${id}`).on('click', (evt) => {
evt.preventDefault();
onClickHandler(resources, unitId);
});

View File

@@ -45,7 +45,7 @@ function createCelebrationButton(
<a id="${id}" href="#">Праздновать</a>
</div>`);
jQuery(`#${id}`).on('click', evt => {
jQuery(`#${id}`).on('click', (evt) => {
evt.preventDefault();
onClickHandler(resources, idx);
});

View File

@@ -23,7 +23,7 @@ export function createTrainTroopButtons(
);
const resElement = $el.find('.resourceWrapper .resource');
const resources = grabResourcesFromList(resElement);
jQuery(`#${id}`).on('click', evt => {
jQuery(`#${id}`).on('click', (evt) => {
evt.preventDefault();
const input = $el.find(`input[name="t${troopId}"]`);
const count = getNumber(input.val());

View File

@@ -46,7 +46,7 @@ export class BuildingPageController {
this.logger.info('BUILD PAGE DETECTED', 'ID', this.attributes.buildId, this.attributes);
if (buildTypeId) {
createUpgradeButton(res => this.onScheduleUpgradeBuilding(res));
createUpgradeButton((res) => this.onScheduleUpgradeBuilding(res));
} else {
createBuildButton((buildTypeId, res) => this.onScheduleBuildBuilding(buildTypeId, res));
}
@@ -126,7 +126,7 @@ export class BuildingPageController {
private onSendResources(coordinates: Coordinates) {
const villageId = grabActiveVillageId();
const targetVillage = grabVillageList().find(v => v.crd.eq(coordinates));
const targetVillage = grabVillageList().find((v) => v.crd.eq(coordinates));
this.scheduler.scheduleTask(SendResourcesTask.name, {
villageId: villageId,
targetVillageId: targetVillage?.id,

View File

@@ -18,8 +18,8 @@ function slotElements(prefix: string): Array<SlotElement> {
function showSlotIds(prefix: string, buildingIds: Array<number>): void {
const slots = slotElements(prefix);
slots.forEach(slot => {
const upCount = buildingIds.filter(id => id === slot.buildId).length;
slots.forEach((slot) => {
const upCount = buildingIds.filter((id) => id === slot.buildId).length;
const $slotEl = jQuery(slot.el);
const $labelEl = $slotEl.find('.labelLayer');
const oldLabel = $labelEl.data('oldLabel') || $labelEl.text();
@@ -53,10 +53,10 @@ export function showBuildingSlotIds(buildingIds: number[]): void {
function onSlotCtrlClick(prefix: string, onClickHandler: (buildId: number) => void): void {
const slots = slotElements(prefix);
slots.forEach(slot => {
slots.forEach((slot) => {
jQuery(slot.el)
.find('.labelLayer')
.on('click', evt => {
.on('click', (evt) => {
if (evt.ctrlKey) {
evt.preventDefault();
evt.stopPropagation();