Skip to content

Commit

Permalink
style: change constant name
Browse files Browse the repository at this point in the history
  • Loading branch information
sheverniskiy committed Jun 1, 2022
1 parent 79dfdf3 commit 9025596
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
28 changes: 14 additions & 14 deletions src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,18 @@ export enum Wildcard {
NOW_SUNRISE = 'div.now div.now-astro div.now-astro-sunrise div.time',
NOW_SUNSET = 'div.now div.now-astro div.now-astro-sunset div.time',
NOW_IMAGE = 'div.now',
TOMORROW_TIME = 'div[data-stat-value*="weather"] div.widget-row-time div.row-item',
TOMORROW_TEMP = 'div[data-stat-value*="weather"] div.widget-row-chart-temperature div.value span.UNIT_TEMP',
TOMORROW_PRECIPITATION = 'div[data-stat-value*="weather"] div.widget-row-precipitation-bars div.row-item div.item-unit',
TOMORROW_SUMMARY = 'div[data-stat-value*="weather"] div.widget-row-icon div.row-item div.tooltip',
TOMORROW_WINDSPEED = 'div[data-stat-value*="wind"] div.widget-row-wind-speed div.row-item span.UNIT_WIND',
TOMORROW_WINDGUST = 'div[data-stat-value*="wind"] div.widget-row-wind-gust div.row-item span.UNIT_WIND',
TOMORROW_WINDDIR = 'div[data-stat-value*="wind"] div.widget-row-wind-direction div.row-item div.direction',
TOMORROW_POLLEN_BIRCH = 'div[data-stat-value*="pollen"] div.widget-row-pollen-birch-point div.row-item div.item',
TOMORROW_POLLEN_GRASS = 'div[data-stat-value*="pollen"] div.widget-row-pollen-grass-point div.row-item div.item',
TOMORROW_POLLEN_RAGWEED = 'div[data-stat-value*="pollen"] div.widget-row-pollen-ragweed div.row-item div.item',
TOMORROW_ROADS = 'div[data-stat-value*="roadcondition"] div.row-item div.item-description',
TOMORROW_PRESSURE = 'div[data-stat-value*="pressure"] div.widget-row-chart-pressure div.value span.UNIT_PRESSURE',
TOMORROW_HUMIDITY = 'div[data-stat-value*="humidity"] div.widget-items div.row-item',
TOMORROW_GEOMAGNETIC = 'div[data-stat-value*="geomagnetic"] div.row-item div.item',
ONEDAY_TIME = 'div[data-stat-value*="weather"] div.widget-row-time div.row-item',
ONEDAY_TEMP = 'div[data-stat-value*="weather"] div.widget-row-chart-temperature div.value span.UNIT_TEMP',
ONEDAY_PRECIPITATION = 'div[data-stat-value*="weather"] div.widget-row-precipitation-bars div.row-item div.item-unit',
ONEDAY_SUMMARY = 'div[data-stat-value*="weather"] div.widget-row-icon div.row-item div.tooltip',
ONEDAY_WINDSPEED = 'div[data-stat-value*="wind"] div.widget-row-wind-speed div.row-item span.UNIT_WIND',
ONEDAY_WINDGUST = 'div[data-stat-value*="wind"] div.widget-row-wind-gust div.row-item span.UNIT_WIND',
ONEDAY_WINDDIR = 'div[data-stat-value*="wind"] div.widget-row-wind-direction div.row-item div.direction',
ONEDAY_POLLEN_BIRCH = 'div[data-stat-value*="pollen"] div.widget-row-pollen-birch-point div.row-item div.item',
ONEDAY_POLLEN_GRASS = 'div[data-stat-value*="pollen"] div.widget-row-pollen-grass-point div.row-item div.item',
ONEDAY_POLLEN_RAGWEED = 'div[data-stat-value*="pollen"] div.widget-row-pollen-ragweed div.row-item div.item',
ONEDAY_ROADS = 'div[data-stat-value*="roadcondition"] div.row-item div.item-description',
ONEDAY_PRESSURE = 'div[data-stat-value*="pressure"] div.widget-row-chart-pressure div.value span.UNIT_PRESSURE',
ONEDAY_HUMIDITY = 'div[data-stat-value*="humidity"] div.widget-items div.row-item',
ONEDAY_GEOMAGNETIC = 'div[data-stat-value*="geomagnetic"] div.row-item div.item',
}
38 changes: 19 additions & 19 deletions src/gismeteo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,35 +166,35 @@ export class Gismeteo {
const $ = load(this.prepareHtml(data))
let out: Partial<GismeteoTomorrow>[] = []

const dates = this.parseAttr<string>($, Wildcard.TOMORROW_TIME, 'title')
const dates = this.parseAttr<string>($, Wildcard.ONEDAY_TIME, 'title')
out = this.parseDtFromStringArray<Partial<GismeteoTomorrow>>(dates)
out = this.mergeArray(out, 'temp', this.parseValue<number>($, Wildcard.TOMORROW_TEMP))
out = this.mergeArray(out, 'pressure', this.parseValue<number>($, Wildcard.TOMORROW_PRESSURE))
out = this.mergeArray(out, 'wind_speed', this.parseValue<number>($, Wildcard.TOMORROW_WINDSPEED))
out = this.mergeArray(out, 'wind_gust', this.parseValue<number>($, Wildcard.TOMORROW_WINDGUST))
out = this.mergeArray(out, 'wind_dir', this.parseValue<string>($, Wildcard.TOMORROW_WINDDIR))
out = this.mergeArray(out, 'precipitation', this.parseValue<number>($, Wildcard.TOMORROW_PRECIPITATION))
out = this.mergeArray(out, 'humidity', this.parseValue<number>($, Wildcard.TOMORROW_HUMIDITY))
out = this.mergeArray(out, 'summary', this.parseAttr<string>($, Wildcard.TOMORROW_SUMMARY, 'data-text'))
out = this.mergeArray(out, 'geomagnetic', this.parseValue<number>($, Wildcard.TOMORROW_GEOMAGNETIC))

if ($(Wildcard.TOMORROW_ROADS).length > 0) {
out = this.mergeArray(out, 'road_condition', this.parseValue<string>($, Wildcard.TOMORROW_ROADS))
out = this.mergeArray(out, 'temp', this.parseValue<number>($, Wildcard.ONEDAY_TEMP))
out = this.mergeArray(out, 'pressure', this.parseValue<number>($, Wildcard.ONEDAY_PRESSURE))
out = this.mergeArray(out, 'wind_speed', this.parseValue<number>($, Wildcard.ONEDAY_WINDSPEED))
out = this.mergeArray(out, 'wind_gust', this.parseValue<number>($, Wildcard.ONEDAY_WINDGUST))
out = this.mergeArray(out, 'wind_dir', this.parseValue<string>($, Wildcard.ONEDAY_WINDDIR))
out = this.mergeArray(out, 'precipitation', this.parseValue<number>($, Wildcard.ONEDAY_PRECIPITATION))
out = this.mergeArray(out, 'humidity', this.parseValue<number>($, Wildcard.ONEDAY_HUMIDITY))
out = this.mergeArray(out, 'summary', this.parseAttr<string>($, Wildcard.ONEDAY_SUMMARY, 'data-text'))
out = this.mergeArray(out, 'geomagnetic', this.parseValue<number>($, Wildcard.ONEDAY_GEOMAGNETIC))

if ($(Wildcard.ONEDAY_ROADS).length > 0) {
out = this.mergeArray(out, 'road_condition', this.parseValue<string>($, Wildcard.ONEDAY_ROADS))
} else {
out = this.mergeArray(out, 'road_condition', new Array(out.length).fill('unknown'))
}
if ($(Wildcard.TOMORROW_POLLEN_BIRCH).length > 0) {
out = this.mergeArray(out, 'pollen_birch', this.parseValue<number>($, Wildcard.TOMORROW_POLLEN_BIRCH))
if ($(Wildcard.ONEDAY_POLLEN_BIRCH).length > 0) {
out = this.mergeArray(out, 'pollen_birch', this.parseValue<number>($, Wildcard.ONEDAY_POLLEN_BIRCH))
} else {
out = this.mergeArray(out, 'pollen_birch', new Array(out.length).fill(0))
}
if ($(Wildcard.TOMORROW_POLLEN_GRASS).length > 0) {
out = this.mergeArray(out, 'pollen_grass', this.parseValue<number>($, Wildcard.TOMORROW_POLLEN_GRASS))
if ($(Wildcard.ONEDAY_POLLEN_GRASS).length > 0) {
out = this.mergeArray(out, 'pollen_grass', this.parseValue<number>($, Wildcard.ONEDAY_POLLEN_GRASS))
} else {
out = this.mergeArray(out, 'pollen_grass', new Array(out.length).fill(0))
}
if ($(Wildcard.TOMORROW_POLLEN_RAGWEED).length > 0) {
out = this.mergeArray(out, 'pollen_ragweed', this.parseValue<number>($, Wildcard.TOMORROW_POLLEN_RAGWEED))
if ($(Wildcard.ONEDAY_POLLEN_RAGWEED).length > 0) {
out = this.mergeArray(out, 'pollen_ragweed', this.parseValue<number>($, Wildcard.ONEDAY_POLLEN_RAGWEED))
} else {
out = this.mergeArray(out, 'pollen_ragweed', new Array(out.length).fill(0))
}
Expand Down

0 comments on commit 9025596

Please sign in to comment.