mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-17 09:09:30 -07:00
class static code cleanup
This commit is contained in:
@@ -133,7 +133,7 @@ class Almanac extends WeatherDisplay {
|
||||
|
||||
fill.date = date;
|
||||
fill.type = MoonPhase.phase;
|
||||
fill.icon = { type: 'img', src: Almanac.imageName(MoonPhase.Phase) };
|
||||
fill.icon = { type: 'img', src: imageName(MoonPhase.Phase) };
|
||||
|
||||
return this.fillTemplate('day', fill);
|
||||
});
|
||||
@@ -145,20 +145,6 @@ class Almanac extends WeatherDisplay {
|
||||
this.finishDraw();
|
||||
}
|
||||
|
||||
static imageName(type) {
|
||||
switch (type) {
|
||||
case 'Full':
|
||||
return 'images/2/Full-Moon.gif';
|
||||
case 'Last':
|
||||
return 'images/2/Last-Quarter.gif';
|
||||
case 'New':
|
||||
return 'images/2/New-Moon.gif';
|
||||
case 'First':
|
||||
default:
|
||||
return 'images/2/First-Quarter.gif';
|
||||
}
|
||||
}
|
||||
|
||||
// make sun and moon data available outside this class
|
||||
// promise allows for data to be requested before it is available
|
||||
async getSun() {
|
||||
@@ -170,6 +156,20 @@ class Almanac extends WeatherDisplay {
|
||||
}
|
||||
}
|
||||
|
||||
const imageName = (type) => {
|
||||
switch (type) {
|
||||
case 'Full':
|
||||
return 'images/2/Full-Moon.gif';
|
||||
case 'Last':
|
||||
return 'images/2/Last-Quarter.gif';
|
||||
case 'New':
|
||||
return 'images/2/New-Moon.gif';
|
||||
case 'First':
|
||||
default:
|
||||
return 'images/2/First-Quarter.gif';
|
||||
}
|
||||
};
|
||||
|
||||
// register display
|
||||
const display = new Almanac(8, 'almanac');
|
||||
registerDisplay(display);
|
||||
|
||||
Reference in New Issue
Block a user