Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-substantive changes per recommendations #84

Open
wants to merge 80 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
74a1960
Update MMM-MyScoreboard.js
dathbe Mar 25, 2024
56dd8bc
Update README.md
dathbe Mar 25, 2024
2f461af
Update package.json
dathbe Mar 25, 2024
46dc422
Update package.json
dathbe Mar 25, 2024
073ba74
Update ESPN.js
dathbe Mar 25, 2024
a3806e7
Update SNET.js
dathbe Mar 25, 2024
c0defe5
Delete package-lock.json
dathbe Mar 25, 2024
0820acc
Revert "Delete package-lock.json"
dathbe Mar 25, 2024
7fef05c
Update ESPN.js
dathbe Mar 25, 2024
8b8b9ce
Update SNET.js
dathbe Mar 25, 2024
6945a6a
Update package.json
dathbe Mar 25, 2024
09febe9
Update ESPN.js
dathbe Mar 25, 2024
1bfefbe
Update SNET.js
dathbe Mar 25, 2024
6168091
Revert "Update SNET.js"
dathbe Mar 25, 2024
7e360e2
Revert "Update ESPN.js"
dathbe Mar 25, 2024
6d09c1c
Revert "Update package.json"
dathbe Mar 25, 2024
ab9dd1e
Revert "Update SNET.js"
dathbe Mar 25, 2024
a52e3ee
Revert "Update ESPN.js"
dathbe Mar 25, 2024
1605a90
Revert "Update SNET.js"
dathbe Mar 25, 2024
43a581f
Revert "Update ESPN.js"
dathbe Mar 25, 2024
d2bcbb6
Revert "Update package.json"
dathbe Mar 25, 2024
330d66b
Update package.json
dathbe Mar 25, 2024
6a70c3e
Update package.json
dathbe Mar 26, 2024
78e8cc9
Update README.md
dathbe Mar 26, 2024
74ce61a
Add files via upload
dathbe Mar 26, 2024
920e918
Update ESPN.js
dathbe May 15, 2024
93cf34b
Update SNET.js
dathbe May 15, 2024
d64b32e
Add files via upload
dathbe May 15, 2024
dcbb847
Update MMM-MyScoreboard.js
dathbe May 15, 2024
9415f04
Update node_helper.js
dathbe May 15, 2024
4b25a2b
Update package.json
dathbe May 15, 2024
5cc9e09
Update package.json
dathbe May 15, 2024
0cb990a
Update MMM-MyScoreboard.js
dathbe May 15, 2024
bb7eda3
Update node_helper.js
dathbe May 15, 2024
02cea44
Update node_helper.js
dathbe May 15, 2024
7eaac6f
Update MMM-MyScoreboard.js
dathbe May 15, 2024
0426429
Update MMM-MyScoreboard.js
dathbe May 15, 2024
10e2cc5
Update node_helper.js
dathbe May 15, 2024
a46614a
Update node_helper.js
dathbe May 15, 2024
971abfa
Update ESPN.js
dathbe May 15, 2024
b415a60
Update ESPN.js
dathbe May 15, 2024
22a582b
Update ESPN.js
dathbe May 15, 2024
848686c
Update ESPN.js
dathbe May 15, 2024
7495699
Update ESPN.js
dathbe May 15, 2024
f8848ab
Update SNET.js
dathbe May 15, 2024
f048f25
Update SNET_YD.js
dathbe May 15, 2024
7b10a75
Update README.md
dathbe May 15, 2024
b4efcb6
Update README.md
dathbe May 15, 2024
155f04e
Update README.md
dathbe May 15, 2024
81e277b
Update README.md
dathbe May 15, 2024
f2706f8
Update README.md
dathbe May 15, 2024
e9a0480
Update README.md
dathbe May 15, 2024
dc48598
Update node_helper.js
dathbe May 15, 2024
13ed5bc
Update node_helper.js
dathbe May 15, 2024
763542e
Update node_helper.js
dathbe May 15, 2024
2bd47d5
Update MMM-MyScoreboard.js
dathbe May 15, 2024
71c1a1a
Update node_helper.js
dathbe May 15, 2024
61393d5
Update MMM-MyScoreboard.js
dathbe May 15, 2024
b4cc3af
Update MMM-MyScoreboard.js
dathbe May 15, 2024
00968f8
Update node_helper.js
dathbe May 15, 2024
5827115
Update MMM-MyScoreboard.js
dathbe May 15, 2024
abe30e9
Update MMM-MyScoreboard.js
dathbe May 15, 2024
3becc35
Update MMM-MyScoreboard.js
dathbe May 15, 2024
78f10e6
Update README.md
dathbe May 15, 2024
583ccdf
Update MMM-MyScoreboard.js
dathbe May 15, 2024
b412661
Update MMM-MyScoreboard.js
dathbe May 15, 2024
7c79a4f
Update node_helper.js
dathbe May 15, 2024
a5291c3
Update MMM-MyScoreboard.js
dathbe May 15, 2024
9433782
Update node_helper.js
dathbe May 15, 2024
25ded1b
Update node_helper.js
dathbe May 16, 2024
70bf956
Update node_helper.js
dathbe May 16, 2024
1a27100
Update node_helper.js
dathbe May 16, 2024
5c9b6c7
Update SNET.js
zaccoffey Dec 15, 2024
b814354
Merge pull request #5 from dathbe/alwaysShowToday
dathbe Dec 17, 2024
ad0735c
Update ESPN.js
dathbe Dec 17, 2024
b43e28d
Merge pull request #1 from zaccoffey/patch-1
dathbe Dec 17, 2024
88c1537
Update SNET_YD.js
dathbe Dec 17, 2024
bae3d99
Update README.md
dathbe Dec 17, 2024
fe0655a
Update README.md
dathbe Dec 17, 2024
b8900aa
Merge pull request #9 from dathbe/filterBowl
dathbe Dec 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 36 additions & 11 deletions MMM-MyScoreboard.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*********************************

Magic Mirror Module:
MagicMirror² Module:
MMM-MyScoreboard
https://github.com/jclarke0000/MMM-MyScoreboard

Expand All @@ -16,6 +16,7 @@ Module.register("MMM-MyScoreboard",{
showLeagueSeparators: true,
colored: true,
rolloverHours: 3, //hours past midnight to show the pervious day's scores
alwaysShowToday: false, //show BOTH today and yesterday during rolloverHours
shadeRows: false,
highlightWinners: true,
viewStyle: "largeLogos",
Expand Down Expand Up @@ -520,7 +521,7 @@ Module.register("MMM-MyScoreboard",{
*/
if (!this.loaded) {
var loadingText = document.createElement("div");
loadingText.innerHTML = this.translate("LOADING");
loadingText.innerHTML = this.translate("LOADING MYSCOREBOARD");
loadingText.className = "dimmed light small";
wrapper.appendChild(loadingText);
return wrapper;
Expand Down Expand Up @@ -552,6 +553,24 @@ Module.register("MMM-MyScoreboard",{
wrapper.appendChild(boxScore);
});
}
if (self.sportsDataYd[index] != null && self.sportsDataYd[index].length > 0 && self.config.alwaysShowToday) {
anyGames = true;
if (self.config.showLeagueSeparators) {
var leagueSeparator = document.createElement("div");
leagueSeparator.classList.add("league-separator");
if (sport.label) {
leagueSeparator.innerHTML = "<span>" + sport.label + " - Yesterday</span>";
} else {
leagueSeparator.innerHTML = "<span>" + sport.league + " - Yesterday</span>";
}
wrapper.appendChild(leagueSeparator);
}
self.sportsDataYd[index].forEach(function(game, gidx) {
var boxScore = self.boxScoreFactory(sport.league, game);
boxScore.classList.add(gidx % 2 == 0 ? "odd" : "even") ;
wrapper.appendChild(boxScore);
});
}
});

/*
Expand All @@ -572,10 +591,15 @@ Module.register("MMM-MyScoreboard",{

socketNotificationReceived: function(notification, payload) {
if ( notification === "MMM-MYSCOREBOARD-SCORE-UPDATE" && payload.instanceId == this.identifier) {
console.log("[MMM-MyScoreboard] Updating Scores");
Log.info("[MMM-MyScoreboard] Updating Scores");
this.loaded = true;
this.sportsData[payload.index] = payload.scores;
this.updateDom();
} else if ( notification === "MMM-MYSCOREBOARD-SCORE-UPDATE-YD" && payload.instanceId == this.identifier && this.config.alwaysShowToday ) {
Log.info("[MMM-MyScoreboard] Updating Yesterday's Scores");
this.loaded = true;
this.sportsDataYd[payload.index] = payload.scores;
this.updateDom();
} else if (notification === "MMM-MYSCOREBOARD-LOCAL-LOGO-LIST" && payload.instanceId == this.identifier) {
this.localLogos = payload.logos;

Expand All @@ -599,7 +623,6 @@ Module.register("MMM-MyScoreboard",{
this.getScores();
}, 2 * 60 * 1000);


}
},

Expand All @@ -625,6 +648,7 @@ Module.register("MMM-MyScoreboard",{

this.loaded = false;
this.sportsData = new Array();
this.sportsDataYd = new Array();

if (this.viewStyles.indexOf(this.config.viewStyle) == -1) {
this.config.viewStyle = "largeLogos";
Expand Down Expand Up @@ -661,7 +685,6 @@ Module.register("MMM-MyScoreboard",{
}
}


if (teamList.length == 0) {
return null;
}
Expand All @@ -672,6 +695,7 @@ Module.register("MMM-MyScoreboard",{
getScores: function() {

var gameDate = moment(); //get today's date
var whichDay = 'one';

if (gameDate.hour() < this.config.rolloverHours) {
/*
Expand All @@ -680,6 +704,9 @@ Module.register("MMM-MyScoreboard",{
not today's
*/
gameDate.subtract(1, "day");
if (this.config.alwaysShowToday) {
whichDay = 'both';
}
}

//just used for debug, if you want to force a specific date
Expand All @@ -696,16 +723,14 @@ Module.register("MMM-MyScoreboard",{
league: sport.league,
teams: self.makeTeamList(self, sport.league, sport.teams, sport.groups),
provider: self.supportedLeagues[sport.league].provider,
gameDate: gameDate
gameDate: gameDate,
whichDay: whichDay
};

self.sendSocketNotification("MMM-MYSCOREBOARD-GET-SCORES", payload);



});



},

/*
Expand Down Expand Up @@ -924,4 +949,4 @@ Module.register("MMM-MyScoreboard",{

}

});
});
144 changes: 39 additions & 105 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# MMM-MyScoreboard

This a module for <strong>MagicMirror</strong><br>
This a module for **MagicMirror**<br>
https://magicmirror.builders/<br>
https://github.com/MichMich/MagicMirror
https://github.com/MagicMirrorOrg/MagicMirror

This module displays today's scores for your favourite teams across a number of different
leagues, including:
Expand All @@ -29,127 +29,58 @@ leagues, including:
* Spanish La Liga
* Mexican Liga BBVA Bancomer

## UPDATE RELEASE 3.0 9-OCT-2022

This update includes several addtions and fixes:
* Correction of SportsNet provider ticker URL
* Change of ESPN provider to HTTPS
* Replacement of deprecated library Request with Axios
* Addition of WNBA and NCAAW womens' basketball
* Update of logos for North American leagues
* Correction of Winsconsin Badgers NCAA team shortcode from WIS to WISC
* Improves how team logos are handled. Uses local logo files where available, otherwises uses URL from feed.

If you are upgrading from a previous version, this update introduces new libraries. Upgrade as follows:
In the MMM-MyScoreboard directory, type:

`git pull`
followed by
`npm install`


![Screenshot](/../screenshots/MMM-MyScoreboard-screenshot.png?raw=true "Screenshot")


## Installation

1. Navigate into your MagicMirror `modules` folder and execute<br>
`git clone https://github.com/jclarke0000/MMM-MyScoreboard`.
2. Enter the new `MMM-MyScoreboard` directory and execute `npm install`.


## Notice to anyone updating from previous versions
```sh
cd ~/MagicMirror/modules
git clone https://github.com/dathbe/MMM-MyScoreboard
cd MMM-MyScoreboard
npm install
```

1. Run `git pull` in the `MMM-MyScoreboard` directory to get the latest source code. If you are not seeing the latest update, then try deleting your `MMM-MyScoreboard` directory and reclone it as per the initial installation instructions above.
2. Still in the `MMM-MyScoreboard` directory, run `npm install`.
3. (Optional) Run `npm prune` to remove some packages that are no longer needed.
4. As the providers have changed for most sports, some of the team shortcodes are different. If you're not seeing your team show up even though you know a game is scheduled, check your config against the list of team shortcodes below.
## Update

```sh
cd ~/MagicMirror/modules/MMM-MyScoreboard
git pull
npm install
```

## Configuration

<table>
<thead>
<tr>
<th>Option</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>showLeagueSeparators</code></td>
<td>Whether to show separators between different leagues.<br><br><strong>Type</strong> <code>Boolean</code><br>Defaults to <code>true</code></td>
</tr>
<tr>
<td><code>colored</code></td>
<td>Whether to present module in colour or black-and-white.<br><br><strong>Type</strong> <code>Boolean</code><br>Defaults to <code>true</code></td>
</tr>
<tr>
<td><code>rolloverHours</code></td>
<td>How many hours past midnight to continue to show the previous day's games.<br><br><strong>Type</strong> <code>Number</code><br>Defaults to <code>3</code> (i.e.: continue to show yesterday's games until 3:00 AM)</td>
</tr>
<tr>
<td><code>viewStyle</code></td>
<td>One of the following: <code>largeLogos</code>, <code>mediumLogos</code>, <code>smallLogos</code>, <code>oneLine</code>, <code>oneLineWithLogos</code>, <code>stacked</code> or <code>stackedWithLogos</code>.<br><br><strong>Type</strong> <code>String</code><br>Defaults to <code>largeLogos</code><br />See below for examples of the view styles.</td>
</tr>
<tr>
<td><code>shadeRows</code></td>
<td>Whether to shade alternate rows.<br><br><strong>Type</strong> <code>Boolean</code><br>Defaults to <code>false</code></td>
</tr>
<tr>
<td><code>highlightWinners</code></td>
<td>For games that are final, the winning team / score is highlighted.<br><br><strong>Type</strong> <code>Boolean</code><br>Defaults to <code>true</code></td>
</tr>
<tr>
<td><code>showRankings</code></td>
<td>For the NCAAF and NCAAM, whether to show the rankings for the top 25 teams.<br><br><strong>Type</strong> <code>Boolean</code><br>Defaults to <code>true</code></td>
</tr>
<tr>
<td><code>sports</code></td>
<td><strong>REQUIRED</strong> An array of leagues and teams you wish to follow.<br><br><strong>Type</strong> <code>Array</code><br>See below for instructions to configure your <code>sports</code> list.</td>
</tr>
</tbody>
</table>

| Option | Description
|----------------------- |------------
| `showLeagueSeparators` | Whether to show separators between different leagues.<br><br>**Type** `Boolean`<br>**Default** `true`
| `colored` | Whether to present module in colour or black-and-white.<br><br>**Type** `Boolean`<br>**Default** `true`
| `rolloverHours` | How many hours past midnight to continue to show the previous day's games.<br><br>**Type** `Number`<br>**Default** `3` (i.e.: continue to show yesterday's games until 3:00 AM)
| `alwaysShowToday` | Whether to show today's games _along with_ the previous day's games during `rolloverHours` period.<br><br>**Type** `Boolean`<br>**Default** `false`
| `viewStyle` | One of the following: `largeLogos`, `mediumLogos`, `smallLogos`, `oneLine`, `oneLineWithLogos`, `stacked` or `stackedWithLogos`.<br>See below for examples of the view styles.<br><br>**Type** `String`<br>**Default** `largeLogos`
| `shadeRows` | Whether to shade alternate rows.<br><br>**Type** `Boolean`<br>**Default** `false`
| `highlightWinners` | For games that are final, the winning team / score is highlighted.<br><br>**Type** `Boolean`<br>**Default** `true`
| `showRankings` | For the NCAAF and NCAAM, whether to show the rankings for the top 25 teams.<br><br>**Type** `Boolean`<br>**Default** `true`
| `sports` | **REQUIRED** An array of leagues and teams you wish to follow.<br>See below for instructions to configure your `sports` list.<br><br>**Type** `Array`


## Configuring your sports list

Each entry in your `sports` array is an object with the following properties:

<table>
<thead>
<tr>
<th>Property</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>league</code></td>
<td><strong>REQUIRED</strong> e.g.: <code>"NHL"</code>. Use any of the bold, uppercase league labaels from the list bleow.<br><br><strong>Type</strong> <code>String</code></td>
</tr>
<tr>
<td><code>label</code></td>
<td>If <code>showLeagueSeparators</code> is set to <code>true</code>, you can optionally set a custom label for the separator. Useful in particular to show something other than <code>"NCAAM_MM"</code> for the March Madness tournament.<br><br><strong>Type</strong> <code>String</code><br />Defaults to the value for <code>league</code>.</td>
</tr>
<tr>
<td><code>teams</code></td>
<td>An array of teams for which you want to see scores. Specify teams using their shortcodes (e.g.: <code>"TOR"</code> for Toronto Maple Leafs.<br><br><strong>Type</strong> <code>Array</code><br>See below for a full listing of teams and their short codes<br><br><strong>UPDATE v2.0:</strong> This is no longer required.</td>
</tr>
<tr>
<td><code>groups</code></td>
<td>In addition to specifying individual teams, you may also specify groups. Generally these groups correspond to the league's respective conferences and divisions. See below for a full listing of groups available for each league. (e.g.: <code>["Atlantic", "Metropolitain"]</code> for teams in the Atlantic and Metropolitain divisions.<br><br><strong>Type</strong> <code>Array</code></td>
</tr>
</tbody>
</table>

It should be noted that if you specify arrays for both <code>teams</code> and <code>groups</code> they will be added together. So it's possible to make a team list out of a division and a few other specific teams. If you omit both parameters, then all games for the particular league will be shown.
| Property | Description
|----------- |------------
| `league` | **REQUIRED** e.g.: `"NHL"`. Use any of the bold, uppercase league labaels from the list bleow.<br><br>**Type** `String`
| `label` | If `showLeagueSeparators` is set to `true`, you can optionally set a custom label for the separator. Useful in particular to show something other than `"NCAAM_MM"` for the March Madness tournament.<br><br>**Type** `String`<br />**Default** the value for `league`.
| `teams` | An array of teams for which you want to see scores. Specify teams using their shortcodes (e.g.: `"TOR"` for Toronto Maple Leafs.<br>See below for a full listing of teams and their short codes<br><br>**Type** `Array`<br>**UPDATE v2.0:** This is no longer required.
| `groups` | In addition to specifying individual teams, you may also specify groups. Generally these groups correspond to the league's respective conferences and divisions. See below for a full listing of groups available for each league. (e.g.: `["Atlantic", "Metropolitain"]` for teams in the Atlantic and Metropolitain divisions.<br><br>**Type** `Array`

It should be noted that if you specify arrays for both `teams` and `groups` they will be added together. So it's possible to make a team list out of a division and a few other specific teams. If you omit both parameters, then all games for the particular league will be shown.


## Example configuration

```
```js
{
module: "MMM-MyScoreboard",
position: "top_right",
Expand Down Expand Up @@ -494,7 +425,7 @@ STL St. Louis Cardinals
TB Tampa Bay Rays
TEX Texas Rangers
TOR Toronto Blue Jays
WAS Washington Nationals
WSH Washington Nationals

Groups:
---------------
Expand Down Expand Up @@ -616,7 +547,7 @@ SEA Seattle Seahawks
SF San Francisco 49ers
TB Tampa Bay Buccaneers
TEN Tennessee Titans
WAS Washington
WSH Washington

Groups:
---------------
Expand Down Expand Up @@ -1646,3 +1577,6 @@ Sun Belt
West Coast
WAC
```

## Thank You
A special thanks goes to [@jclarke0000](https://github.com/jclarke0000/), who was the original author of this module and wrote most of the code.
Binary file added example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 21 additions & 7 deletions node_helper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const NodeHelper = require("node_helper");
const dirTree = require("directory-tree");

const moment = require("moment-timezone");

module.exports = NodeHelper.create({

Expand All @@ -10,6 +10,7 @@ module.exports = NodeHelper.create({
console.log("Starting node_helper for module [" + this.name + "]");

this.providers.SNET = require("./providers/SNET.js");
this.providers.SNET_YD = require("./providers/SNET_YD.js");
this.providers.ESPN = require("./providers/ESPN.js");
this.localLogos = {};

Expand Down Expand Up @@ -45,11 +46,24 @@ module.exports = NodeHelper.create({

var self = this;
var provider = this.providers[payload.provider];

provider.getScores(payload.league, payload.teams, payload.gameDate, function(scores) {
self.sendSocketNotification("MMM-MYSCOREBOARD-SCORE-UPDATE", {instanceId: payload.instanceId, index: payload.index, scores: scores});
});

var provider2 = this.providers[payload.provider];
if (payload.provider == "SNET") {
provider2 = this.providers["SNET_YD"];
}

if (payload.whichDay == 'both') {
provider.getScores(payload.league, payload.teams, moment(), function(scores) {
self.sendSocketNotification("MMM-MYSCOREBOARD-SCORE-UPDATE", {instanceId: payload.instanceId, index: payload.index, scores: scores});
});
provider2.getScores(payload.league, payload.teams, moment().subtract(1, "day"), function(scores) {
self.sendSocketNotification("MMM-MYSCOREBOARD-SCORE-UPDATE-YD", {instanceId: payload.instanceId, index: payload.index, scores: scores});
});
} else {
provider.getScores(payload.league, payload.teams, payload.gameDate, function(scores) {
self.sendSocketNotification("MMM-MYSCOREBOARD-SCORE-UPDATE", {instanceId: payload.instanceId, index: payload.index, scores: scores});
});
self.sendSocketNotification("MMM-MYSCOREBOARD-SCORE-UPDATE-YD", {instanceId: payload.instanceId, index: payload.index, scores: {}});
}

} else if (notification == "MMM-MYSCOREBOARD-GET-LOCAL-LOGOS") {

Expand All @@ -62,4 +76,4 @@ module.exports = NodeHelper.create({



});
});
Loading