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

Added World Baseball Classic (WBC) as new league / event #74

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
30 changes: 19 additions & 11 deletions MMM-MyScoreboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

*********************************/

Module.register("MMM-MyScoreboard",{
Module.register("MMM-MyScoreboard",{

// Default module config.
defaults: {
Expand Down Expand Up @@ -60,6 +60,7 @@ Module.register("MMM-MyScoreboard",{
"NFL": {provider: "SNET", logoFormat: "svg"},
"CFL": {provider: "SNET", logoFormat: "svg"},
"MLB": {provider: "SNET", logoFormat: "svg"},
"WBC": {provider: "SNET", logoFormat: "svg"},
"MLS": {provider: "SNET", logoFormat: "url", homeTeamFirst: true},
"NCAAF": {provider: "ESPN", logoFormat: "url"},
"NCAAM": {provider: "ESPN", logoFormat: "url"},
Expand Down Expand Up @@ -329,7 +330,7 @@ Module.register("MMM-MyScoreboard",{
</div>
******************************************************************/
boxScoreFactory: function(league, gameObj) {

this.sendToLog('league: ' + league + ', gameObj:' + gameObj);
var viewStyle = this.config.viewStyle;

var boxScore = document.createElement("div");
Expand Down Expand Up @@ -495,7 +496,7 @@ Module.register("MMM-MyScoreboard",{

// Override dom generator.
getDom: function() {

this.sendToLog('getDom');
var wrapper = document.createElement("div");
wrapper.classList.add("wrapper");

Expand Down Expand Up @@ -561,28 +562,31 @@ Module.register("MMM-MyScoreboard",{
the module will only be visible when both agree that it
should be visible.
*/
/* disabled to test MMM-Scenes2
if (!anyGames) {
this.hide(1000, {lockString: this.identifier});
} else {
this.show(1000, {lockString: this.identifier});
}
*/

return wrapper;
},

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

/*
get scores and set up polling
*/

this.getScores();

/*
Expand All @@ -595,17 +599,18 @@ Module.register("MMM-MyScoreboard",{
respective feed owners to lock down the APIs. Updating
every two minutes should be more than fine for our purposes.
*/
this.sendToLog('setInterval');
var self = this;
setInterval(() => {
this.getScores();
self.getScores();
}, 2 * 60 * 1000);


}
},

start: function() {
Log.info("Starting module: " + this.name);

this.sendToLog('Starting module');
/*
scrub the config to ensure only supported leagues are included
*/
Expand Down Expand Up @@ -670,7 +675,7 @@ Module.register("MMM-MyScoreboard",{
},

getScores: function() {

this.sendToLog('getScores()');
var gameDate = moment(); //get today's date

if (gameDate.hour() < this.config.rolloverHours) {
Expand Down Expand Up @@ -701,7 +706,6 @@ Module.register("MMM-MyScoreboard",{

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


});


Expand Down Expand Up @@ -922,6 +926,10 @@ Module.register("MMM-MyScoreboard",{
SERIEA : {}


}
},

sendToLog: function(message) {
Log.log('['+ this.name + '] ' + this.identifier + ' - ' + message);
}

});
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ Currently this module supports the following leagues. Use the bold uppercase sh
* **NCAAM** - NCAA College Basketball (Division I)
* **NCAAM_MM** - NCAA College Basketball (March Madness Tournament)
* **NCAAW** - NCAA Women's College Basketball

* **WBC** - World Baseball Classic

### Soccer Leagues & Competitions

Expand Down Expand Up @@ -508,6 +508,34 @@ American League
National League
```

### WBC

```
Teams:
---------------

AUS Australia
CAN Canada
CHN China
COL Colombia
CUB Cuba
CZE Czech Republic
DOM Dominican Republic
GBR Great Britain
ISR Israel
ITA Italy
JPN Japan
KOR Korea
MEX Mexico
NCA Nicaragua
NED Netherlands
PAN Panama
PUR Puerto Rico
TPE Chinese Taipei
USA United States
VEN Venezuela
```

### NBA

```
Expand Down
29 changes: 29 additions & 0 deletions logos/WBC/AUS.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions logos/WBC/CAN.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions logos/WBC/CHN.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions logos/WBC/COL.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading