Skip to content

Commit 08cc9dd

Browse files
author
veeck
committed
Typos and whiteline cleanups
1 parent dc4fad4 commit 08cc9dd

File tree

1 file changed

+15
-40
lines changed

1 file changed

+15
-40
lines changed

modules/default/weather/providers/envcanada.js

Lines changed: 15 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,13 @@ WeatherProvider.register("envcanada", {
6666

6767
/*
6868
* Override the fetchCurrentWeather method to query EC and construct a Current weather object
69-
*
7069
*/
7170
fetchCurrentWeather () {
72-
7371
this.fetchCommon("Current");
74-
7572
},
7673

7774
/*
7875
* Override the fetchWeatherForecast method to query EC and construct Forecast/Daily weather objects
79-
*
8076
*/
8177
fetchWeatherForecast () {
8278

@@ -86,12 +82,9 @@ WeatherProvider.register("envcanada", {
8682

8783
/*
8884
* Override the fetchWeatherHourly method to query EC and construct Hourly weather objects
89-
*
9085
*/
9186
fetchWeatherHourly () {
92-
9387
this.fetchCommon("Hourly");
94-
9588
},
9689

9790
/*
@@ -108,7 +101,6 @@ WeatherProvider.register("envcanada", {
108101
* city specified in the Weather module Config information
109102
*/
110103
fetchCommon (target) {
111-
112104
const forecastURL = this.getUrl(); // Get the approriate URL for the MSC Datamart Index page
113105

114106
Log.debug(`[weather.envcanada] ${target} Index url: ${forecastURL}`);
@@ -122,13 +114,13 @@ WeatherProvider.register("envcanada", {
122114
return;
123115
}
124116

125-
/*
126-
* With the Index page read, we must locate the filename/link for the specified city (aka Sitecode).
127-
* This is done by building the city filename and searching for it on the Index page. Once found,
128-
* extract the full filename (a unique name that includes dat/time, filename, etc.) and then add it
129-
* to the Index page URL to create the proper URL pointing to the city's weather data. Finally, read the
130-
* URL to pull in the city's XML document so that weather data can be parsed and displayed.
131-
*/
117+
/**
118+
* With the Index page read, we must locate the filename/link for the specified city (aka Sitecode).
119+
* This is done by building the city filename and searching for it on the Index page. Once found,
120+
* extract the full filename (a unique name that includes dat/time, filename, etc.) and then add it
121+
* to the Index page URL to create the proper URL pointing to the city's weather data. Finally, read the
122+
* URL to pull in the city's XML document so that weather data can be parsed and displayed.
123+
*/
132124

133125
let forecastFile = "";
134126
let forecastFileURL = "";
@@ -160,14 +152,12 @@ WeatherProvider.register("envcanada", {
160152
return;
161153
}
162154

163-
164155
if (target === "Hourly" && this.lastCityPageHourly === forecastFileURL) {
165156
Log.debug(`[weather.envcanada] ${target} - Newest Citypage has already been seen - skipping!`);
166157
this.updateAvailable(); // Update anyways to reset refresh timer
167158
return;
168159
}
169160

170-
171161
this.fetchData(forecastFileURL, "xml") // Read city's URL to get weather data
172162
.then((cityData) => {
173163
if (!cityData) {
@@ -183,32 +173,22 @@ WeatherProvider.register("envcanada", {
183173
Log.debug(`[weather.envcanada] ${target} - Citypage has been read and will be processed for updates`);
184174

185175
if (target === "Current") {
186-
187176
const currentWeather = this.generateWeatherObjectFromCurrentWeather(cityData);
188-
189177
this.setCurrentWeather(currentWeather);
190-
191178
this.lastCityPageCurrent = forecastFileURL;
192179
}
193180

194181
if (target === "Forecast") {
195-
196182
const forecastWeather = this.generateWeatherObjectsFromForecast(cityData);
197-
198183
this.setWeatherForecast(forecastWeather);
199-
200184
this.lastCityPageForecast = forecastFileURL;
201185
}
202186

203187
if (target === "Hourly") {
204-
205188
const hourlyWeather = this.generateWeatherObjectsFromHourly(cityData);
206-
207189
this.setWeatherHourly(hourlyWeather);
208-
209190
this.lastCityPageHourly = forecastFileURL;
210191
}
211-
212192
})
213193
.catch(function (cityRequest) {
214194
Log.info(`weather.envcanada ${target} - could not load citypage data from: ${forecastFileURL}`);
@@ -219,8 +199,6 @@ WeatherProvider.register("envcanada", {
219199
Log.error(`weather.envcanada ${target} - could not load index data ... `, indexRequest);
220200
this.updateAvailable(); // If there were issues, update anyways to reset timer
221201
});
222-
223-
224202
},
225203

226204
/*
@@ -230,11 +208,9 @@ WeatherProvider.register("envcanada", {
230208
* Fixed value + Prov code specified in Weather module Config.js + current hour as GMT
231209
*/
232210
getUrl () {
233-
234211
let forecastURL = `https://dd.weather.gc.ca/citypage_weather/${this.config.provCode}`;
235212
const hour = this.getCurrentHourGMT();
236213
forecastURL += `/${hour}/`;
237-
238214
return forecastURL;
239215
},
240216

@@ -269,7 +245,6 @@ WeatherProvider.register("envcanada", {
269245
}
270246

271247
currentWeather.windSpeed = WeatherUtils.convertWindToMs(ECdoc.querySelector("siteData currentConditions wind speed").textContent);
272-
273248
currentWeather.windFromDirection = ECdoc.querySelector("siteData currentConditions wind bearing").textContent;
274249

275250
currentWeather.humidity = ECdoc.querySelector("siteData currentConditions relativeHumidity").textContent;
@@ -332,7 +307,7 @@ WeatherProvider.register("envcanada", {
332307
/*
333308
* The EC forecast is held in a 12-element array - Elements 0 to 11 - with each day encompassing
334309
* 2 elements. the first element for a day details the Today (daytime) forecast while the second
335-
* element details the Tonight (nightime) forecast. Element 0 is always for the current day.
310+
* element details the Tonight (nighttime) forecast. Element 0 is always for the current day.
336311
*
337312
* However... the forecast is somewhat 'rolling'.
338313
*
@@ -343,7 +318,7 @@ WeatherProvider.register("envcanada", {
343318
*
344319
* But, if the EC forecast is queried in late afternoon, the Current Today forecast will be rolled
345320
* off and Element 0 will contain Current Tonight. From there, the next 5 days will be contained in
346-
* Elements 1/2, 3/4, 5/6, 7/8, and 9/10. As well, Elelement 11 will contain a forecast for a 6th day,
321+
* Elements 1/2, 3/4, 5/6, 7/8, and 9/10. As well, Element 11 will contain a forecast for a 6th day,
347322
* but only for the Today portion (not Tonight). This module will create a 6-day forecast using
348323
* Elements 0 to 11, and will ignore the additional Todat forecast in Element 11.
349324
*
@@ -554,17 +529,17 @@ WeatherProvider.register("envcanada", {
554529
* then it will be displayed ONLY if no POP is present.
555530
*
556531
* POP Logic: By default, we want to show the POP for 'daytime' since we are presuming that is what
557-
* people are more interested in seeing. While EC provides a separate POP for daytime and nightime portions
532+
* people are more interested in seeing. While EC provides a separate POP for daytime and nighttime portions
558533
* of each day, the weather module does not really allow for that view of a daily forecast. There we will
559-
* ignore any nightime portion. There is an exception however! For the Current day, the EC data will only show
560-
* the nightime forecast after a certain point in the afternoon. As such, we will be showing the nightime POP
534+
* ignore any nighttime portion. There is an exception however! For the Current day, the EC data will only show
535+
* the nighttime forecast after a certain point in the afternoon. As such, we will be showing the nighttime POP
561536
* (if one exists) in that specific scenario.
562537
*
563538
* Accumulation Logic: Similar to POP, we want to show accumulation for 'daytime' since we presume that is what
564-
* people are interested in seeing. While EC provides a separate accumulation for daytime and nightime portions
539+
* people are interested in seeing. While EC provides a separate accumulation for daytime and nighttime portions
565540
* of each day, the weather module does not really allow for that view of a daily forecast. There we will
566-
* ignore any nightime portion. There is an exception however! For the Current day, the EC data will only show
567-
* the nightime forecast after a certain point in that specific scenario.
541+
* ignore any nighttime portion. There is an exception however! For the Current day, the EC data will only show
542+
* the nighttime forecast after a certain point in that specific scenario.
568543
*/
569544
setPrecipitation (weather, foreGroup, today) {
570545
if (foreGroup[today].querySelector("precipitation accumulation")) {

0 commit comments

Comments
 (0)