From d21af39fac32a5328c70adb2da83ef053078d914 Mon Sep 17 00:00:00 2001 From: Michael Schmidt Date: Sat, 15 Jan 2022 20:48:35 +0100 Subject: [PATCH 1/4] Device locale is used to format time --- package-lock.json | 128 +++++++++++++++++++------------------- providers/ESPN.js | 6 +- providers/SNET.js | 6 +- providers/localeMoment.js | 25 ++++++++ 4 files changed, 95 insertions(+), 70 deletions(-) create mode 100644 providers/localeMoment.js diff --git a/package-lock.json b/package-lock.json index 50c59c5..79fa86b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,10 +9,10 @@ "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", "requires": { - "co": "4.6.0", - "fast-deep-equal": "1.1.0", - "fast-json-stable-stringify": "2.0.0", - "json-schema-traverse": "0.3.1" + "co": "^4.6.0", + "fast-deep-equal": "^1.0.0", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.3.0" } }, "asn1": { @@ -46,7 +46,7 @@ "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", "optional": true, "requires": { - "tweetnacl": "0.14.5" + "tweetnacl": "^0.14.3" } }, "boom": { @@ -54,7 +54,7 @@ "resolved": "https://registry.npmjs.org/boom/-/boom-4.3.1.tgz", "integrity": "sha1-T4owBctKfjiJ90kDD9JbluAdLjE=", "requires": { - "hoek": "4.2.1" + "hoek": "4.x.x" } }, "caseless": { @@ -67,7 +67,7 @@ "resolved": "https://registry.npmjs.org/cb2promise/-/cb2promise-1.0.7.tgz", "integrity": "sha1-bggr8OGxakHRM853C+2VF7ldgH8=", "requires": { - "sliced": "1.0.1" + "sliced": "~1.0.1" } }, "co": { @@ -85,7 +85,7 @@ "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", "requires": { - "delayed-stream": "1.0.0" + "delayed-stream": "~1.0.0" } }, "core-util-is": { @@ -98,7 +98,7 @@ "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz", "integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=", "requires": { - "boom": "5.2.0" + "boom": "5.x.x" }, "dependencies": { "boom": { @@ -106,7 +106,7 @@ "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "requires": { - "hoek": "4.2.1" + "hoek": "4.x.x" } } } @@ -116,7 +116,7 @@ "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", "requires": { - "assert-plus": "1.0.0" + "assert-plus": "^1.0.0" } }, "delayed-stream": { @@ -130,7 +130,7 @@ "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", "optional": true, "requires": { - "jsbn": "0.1.1" + "jsbn": "~0.1.0" } }, "extend": { @@ -163,9 +163,9 @@ "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", "requires": { - "asynckit": "0.4.0", + "asynckit": "^0.4.0", "combined-stream": "1.0.6", - "mime-types": "2.1.18" + "mime-types": "^2.1.12" } }, "getpass": { @@ -173,7 +173,7 @@ "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", "requires": { - "assert-plus": "1.0.0" + "assert-plus": "^1.0.0" } }, "har-schema": { @@ -186,8 +186,8 @@ "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz", "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", "requires": { - "ajv": "5.5.2", - "har-schema": "2.0.0" + "ajv": "^5.1.0", + "har-schema": "^2.0.0" } }, "hawk": { @@ -195,10 +195,10 @@ "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "requires": { - "boom": "4.3.1", - "cryptiles": "3.1.2", - "hoek": "4.2.1", - "sntp": "2.1.0" + "boom": "4.x.x", + "cryptiles": "3.x.x", + "hoek": "4.x.x", + "sntp": "2.x.x" } }, "hoek": { @@ -211,9 +211,9 @@ "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", "requires": { - "assert-plus": "1.0.0", - "jsprim": "1.4.1", - "sshpk": "1.13.1" + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" } }, "is-typedarray": { @@ -237,8 +237,8 @@ "resolved": "https://registry.npmjs.org/json-parse-async/-/json-parse-async-1.0.3.tgz", "integrity": "sha1-0H76fXvvdVYsZVUguQWtlOwRs28=", "requires": { - "cb2promise": "1.0.7", - "whoops": "1.0.1" + "cb2promise": "~1.0.0", + "whoops": "~1.0.0" } }, "json-schema": { @@ -277,7 +277,7 @@ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "requires": { - "mime-db": "1.33.0" + "mime-db": "~1.33.0" } }, "moment": { @@ -290,7 +290,7 @@ "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.14.tgz", "integrity": "sha1-TrOP+VOLgBCLpGekWPPtQmjM/LE=", "requires": { - "moment": "2.21.0" + "moment": ">= 2.9.0" } }, "oauth-sign": { @@ -318,28 +318,28 @@ "resolved": "https://registry.npmjs.org/request/-/request-2.83.0.tgz", "integrity": "sha512-lR3gD69osqm6EYLk9wB/G1W/laGWjzH90t1vEa2xuxHD5KUrSzp9pUSfTm+YC5Nxt2T8nMPEvKlhbQayU7bgFw==", "requires": { - "aws-sign2": "0.7.0", - "aws4": "1.6.0", - "caseless": "0.12.0", - "combined-stream": "1.0.6", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "2.3.2", - "har-validator": "5.0.3", - "hawk": "6.0.2", - "http-signature": "1.2.0", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.18", - "oauth-sign": "0.8.2", - "performance-now": "2.1.0", - "qs": "6.5.1", - "safe-buffer": "5.1.1", - "stringstream": "0.0.5", - "tough-cookie": "2.3.4", - "tunnel-agent": "0.6.0", - "uuid": "3.2.1" + "aws-sign2": "~0.7.0", + "aws4": "^1.6.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.5", + "extend": "~3.0.1", + "forever-agent": "~0.6.1", + "form-data": "~2.3.1", + "har-validator": "~5.0.3", + "hawk": "~6.0.2", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.17", + "oauth-sign": "~0.8.2", + "performance-now": "^2.1.0", + "qs": "~6.5.1", + "safe-buffer": "^5.1.1", + "stringstream": "~0.0.5", + "tough-cookie": "~2.3.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.1.0" } }, "safe-buffer": { @@ -357,7 +357,7 @@ "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "requires": { - "hoek": "4.2.1" + "hoek": "4.x.x" } }, "sshpk": { @@ -365,14 +365,14 @@ "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz", "integrity": "sha1-US322mKHFEMW3EwY/hzx2UBzm+M=", "requires": { - "asn1": "0.2.3", - "assert-plus": "1.0.0", - "bcrypt-pbkdf": "1.0.1", - "dashdash": "1.14.1", - "ecc-jsbn": "0.1.1", - "getpass": "0.1.7", - "jsbn": "0.1.1", - "tweetnacl": "0.14.5" + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "tweetnacl": "~0.14.0" } }, "stringstream": { @@ -385,7 +385,7 @@ "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "requires": { - "punycode": "1.4.1" + "punycode": "^1.4.1" } }, "tunnel-agent": { @@ -393,7 +393,7 @@ "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", "requires": { - "safe-buffer": "5.1.1" + "safe-buffer": "^5.0.1" } }, "tweetnacl": { @@ -412,9 +412,9 @@ "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", "requires": { - "assert-plus": "1.0.0", + "assert-plus": "^1.0.0", "core-util-is": "1.0.2", - "extsprintf": "1.3.0" + "extsprintf": "^1.2.0" } }, "whoops": { @@ -422,7 +422,7 @@ "resolved": "https://registry.npmjs.org/whoops/-/whoops-1.0.1.tgz", "integrity": "sha1-Vr3Af8QnR7DBJw53EnpgRhTBP5Q=", "requires": { - "coffee-script": "1.12.7" + "coffee-script": "*" } } } diff --git a/providers/ESPN.js b/providers/ESPN.js index e9e982b..98859b0 100644 --- a/providers/ESPN.js +++ b/providers/ESPN.js @@ -34,7 +34,7 @@ */ const request = require("request"); -const moment = require("moment-timezone"); +const moment = require("./localeMoment"); const parseJSON = require("json-parse-async"); module.exports = { @@ -542,7 +542,7 @@ module.exports = { break; case "1": //scheduled gameState = 0; - status.push(moment(game.competitions[0].date).tz(localTZ).format("h:mm a")); + status.push(moment(game.competitions[0].date).tz(localTZ).format("LT")); break; case "2": //in-progress case "21": //beginning of period @@ -612,7 +612,7 @@ module.exports = { break; default: //Anything else, treat like a game that hasn't started yet gameState = 0; - status.push(moment(game.competitions[0].date).tz(localTZ).format("h:mm a")); + status.push(moment(game.competitions[0].date).tz(localTZ).format("LT")); break; } diff --git a/providers/SNET.js b/providers/SNET.js index ea6f5ee..6654cd4 100644 --- a/providers/SNET.js +++ b/providers/SNET.js @@ -44,7 +44,7 @@ */ const request = require("request"); -const moment = require("moment-timezone"); +const moment = require("./localeMoment"); const parseJSON = require("json-parse-async"); module.exports = { @@ -188,7 +188,7 @@ module.exports = { case "Pre-Game": gameState = 0; //not started //Feed provides all game times in Eastern Time - status.push(moment(game.timestamp * 1000).tz(localTZ).format("h:mm a")); + status.push(moment(game.timestamp * 1000).tz(localTZ).format("LT")); break; case "In-Progress": @@ -298,7 +298,7 @@ module.exports = { default: gameState = 0; - status.push(moment(game.timestamp * 1000).tz(localTZ).format("h:mm a")); + status.push(moment(game.timestamp * 1000).tz(localTZ).format("LT")); break; } diff --git a/providers/localeMoment.js b/providers/localeMoment.js new file mode 100644 index 0000000..8fc724e --- /dev/null +++ b/providers/localeMoment.js @@ -0,0 +1,25 @@ +const momentTz = require('moment-timezone'); +const moment = require("moment/min/moment-with-locales"); + +const chooseMomentLocale = (locale) => { + // make the locale lower case + // will fix crashes caused by "en-GB" (instead of "en-gb") not being found + locale = locale.toLowerCase(); + if (moment.locales().includes(locale)) { // check if the locale is included in the array returned by `locales()` which (in this case) tells us which locales moment will support + return locale; + } else if (moment.locales().includes(locale.substring(0, 2))) { + // check if the first two letters of the locale are included in the array returned by `locales()` which (in this case) tells us which locales moment will support + // will fixes crashes caused by "en-US" not being found, as we'll tell moment to load "en" instead + return locale.substring(0, 2); + } + // use "en-gb" (the default language and locale for my app) as a fallback if we can't find any other locale + return 'en-gb'; +}; + +const environment = process.env; +const userLocale = environment.LC_ALL || environment.LC_MESSAGES || environment.LANG || environment.LANGUAGE || environment.LC_NAME +const momentLocale = userLocale.split('.')[0].replace('_', '-').toLowerCase() +const localeToImport = chooseMomentLocale(momentLocale) +momentTz.locale(localeToImport) + +module.exports = momentTz \ No newline at end of file From 2e669de4bfe3372face9740511e2e0f2598faae5 Mon Sep 17 00:00:00 2001 From: Michael Schmidt Date: Sun, 16 Jan 2022 16:48:36 +0100 Subject: [PATCH 2/4] Added translations --- MMM-MyScoreboard.js | 3 +- localeHelper.js | 18 ++++++ providers/localeMoment.js => localeMoment.js | 5 +- node_helper.js | 2 +- providers/ESPN.js | 54 +++++++++--------- providers/SNET.js | 59 ++++++++++---------- translations/de.json | 25 +++++++++ translations/en.json | 25 +++++++++ 8 files changed, 133 insertions(+), 58 deletions(-) create mode 100644 localeHelper.js rename providers/localeMoment.js => localeMoment.js (82%) create mode 100644 translations/de.json create mode 100644 translations/en.json diff --git a/MMM-MyScoreboard.js b/MMM-MyScoreboard.js index bad34a1..4dc2580 100644 --- a/MMM-MyScoreboard.js +++ b/MMM-MyScoreboard.js @@ -660,7 +660,8 @@ 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, + language: config.language }; self.sendSocketNotification("MMM-MYSCOREBOARD-GET-SCORES", payload); diff --git a/localeHelper.js b/localeHelper.js new file mode 100644 index 0000000..60d988b --- /dev/null +++ b/localeHelper.js @@ -0,0 +1,18 @@ +const fs = require('fs') +const path = require('path') +const environment = process.env; +const userLocale = environment.LC_ALL || environment.LC_MESSAGES || environment.LANG || environment.LANGUAGE || environment.LC_NAME + +module.exports = { + getMomentLocale: function() { + return userLocale.split('.')[0].replace('_', '-').toLowerCase(); + }, + loadTranslations: function(language) { + const path = './modules/MMM-MyScoreboard/translations/' + language + '.json' + if (fs.existsSync(path)) { + return require('./translations/' + language + '.json'); + } else { + return require('./translations/en.json'); + } + } +} \ No newline at end of file diff --git a/providers/localeMoment.js b/localeMoment.js similarity index 82% rename from providers/localeMoment.js rename to localeMoment.js index 8fc724e..8122eb9 100644 --- a/providers/localeMoment.js +++ b/localeMoment.js @@ -1,5 +1,6 @@ const momentTz = require('moment-timezone'); const moment = require("moment/min/moment-with-locales"); +const localeHelper = require("./localeHelper"); const chooseMomentLocale = (locale) => { // make the locale lower case @@ -16,9 +17,7 @@ const chooseMomentLocale = (locale) => { return 'en-gb'; }; -const environment = process.env; -const userLocale = environment.LC_ALL || environment.LC_MESSAGES || environment.LANG || environment.LANGUAGE || environment.LC_NAME -const momentLocale = userLocale.split('.')[0].replace('_', '-').toLowerCase() +const momentLocale = localeHelper.getMomentLocale() const localeToImport = chooseMomentLocale(momentLocale) momentTz.locale(localeToImport) diff --git a/node_helper.js b/node_helper.js index 05abd9c..8780929 100644 --- a/node_helper.js +++ b/node_helper.js @@ -28,7 +28,7 @@ module.exports = NodeHelper.create({ var self = this; var provider = this.providers[payload.provider]; - provider.getScores(payload.league, payload.teams, payload.gameDate, function(scores) { + provider.getScores(payload.league, payload.teams, payload.gameDate, payload.language, function(scores) { self.sendSocketNotification("MMM-MYSCOREBOARD-SCORE-UPDATE", {instanceId: payload.instanceId, index: payload.index, scores: scores}); }); diff --git a/providers/ESPN.js b/providers/ESPN.js index 98859b0..1ff6e33 100644 --- a/providers/ESPN.js +++ b/providers/ESPN.js @@ -34,8 +34,10 @@ */ const request = require("request"); -const moment = require("./localeMoment"); +const moment = require("../localeMoment"); const parseJSON = require("json-parse-async"); +const localeHelper = require("../localeHelper"); + module.exports = { @@ -381,14 +383,16 @@ module.exports = { "ZIM_PREMIER_LEAGUE", ], + translations: {}, getLeaguePath: function(league) { return this.LEAGUE_PATHS[league]; }, - getScores: function(league, teams, gameDate, callback) { + getScores: function(league, teams, gameDate, language, callback) { var self = this; + self.translations = localeHelper.loadTranslations(language); var url = "http://site.api.espn.com/apis/site/v2/sports/" + this.getLeaguePath(league) + @@ -538,7 +542,7 @@ module.exports = { switch (game.status.type.id) { case "0" : //TBD gameState = 0; - status.push("TBD"); + status.push(this.translations.tbd); break; case "1": //scheduled gameState = 0; @@ -557,58 +561,58 @@ module.exports = { break; case "3": //final gameState = 2; - status.push("Final" + this.getFinalOT(league, game.status.period)); + status.push(this.translations.final.replace('##1##', this.getFinalOT(league, game.status.period)).trim()); break; case "4": //forfeit case "9": //forfeit of home team case "10": //forfeit of away team gameState = 0; - status.push("Forfeit"); + status.push(this.translations.forfeit); break; case "5": //cancelled gameState = 0; - status.push("Cancelled"); + status.push(this.translations.canceled); break; case "6": //postponed gameState = 0; - status.push("Postponed"); + status.push(this.translations.postponed); break; case "7": //delayed case "17": //rain delay gameState = 1; classes.push["delay"]; - status.push("Delay"); + status.push(this.translations.delay); break; case "8": //suspended gameState = 0; - status.push("Suspended"); + status.push(this.translations.suspended); break; case "22": //end period case "48": //SOCCER end extra time gameState = 1; - status.push("END"); + status.push(this.translations.end); status.push(this.getPeriod(league, game.status.period)); break; case "23": //halftime gameState = 1; - status.push("HALFTIME"); + status.push(this.translations.halfTime); break; case "49": //SOCCER extra time half time gameState = 1; - status.push("HALFTIME (ET)"); + status.push(this.translations.halfTimeEt); break; case "28": //SOCCER Full Time gameState = 2; - status.push("Full Time " + this.getFinalOT(league, game.status.period)); + status.push(this.translations.fullTime.replace('##1##', this.getFinalOT(league, game.status.period)).trim()); break; case "45": //SOCCER Final ET case "46": //SOCCER final score - after golden goal gameState = 2; - status.push("Full Time (ET)"); + status.push(this.translations.fullTime.replace('##1##', this.translations.finalEtSuffix)); break; case "47": //Soccer Final PK gameState = 2; - status.push("Full Time (PK) " + this.getFinalPK(hTeamData,vTeamData)); + status.push(this.translations.fullTime.Replace('##1##', this.translations.finalPkSuffix.replace('##1##', this.getFinalPK(hTeamData,vTeamData)))); break; default: //Anything else, treat like a game that hasn't started yet gameState = 0; @@ -688,16 +692,16 @@ module.exports = { var mod100 = p % 100; if (mod10 == 1 && mod100 != 11) { - return p + "ST"; + return p + this.translations.ordinalOne; } if (mod10 == 2 && mod100 != 12) { - return p + "ND"; + return p + this.translations.ordinalTwo; } if (mod10 == 3 && mod100 != 13) { - return p + "RD"; + return p + this.translations.ordinalThree; } - return p + "TH"; + return p + this.translations.ordinalOther; }, @@ -707,16 +711,16 @@ module.exports = { if (this.isSoccer(league)) { if (p > 2) { - return "ET"; + return this.translations.et; } else { return ""; //no need to indicate first or second half } } else { if (p == 5) { - return "OT"; + return this.translations.ot.replace('##1##', ''); } else if (p > 5) { - return (p - 4) + "OT"; + return this.translations.ot.replace('##1##', (p-4).toString()) } } @@ -727,12 +731,12 @@ module.exports = { getFinalOT: function(league, p) { if (this.isSoccer(league) && p > 2) { - return " (ET)"; + return this.translations.finalEtSuffix; } else if (!this.isSoccer(league)) { if (p == 5) { - return " (OT)"; + return this.translations.finalOtSuffix.replace('##1##', ''); } else if (p > 5) { - return " (" + (p - 4) + "OT)"; + return this.translations.finalOtSuffix.replace('##1##', (p-4).toString()); } } diff --git a/providers/SNET.js b/providers/SNET.js index 6654cd4..e0fc41f 100644 --- a/providers/SNET.js +++ b/providers/SNET.js @@ -44,8 +44,9 @@ */ const request = require("request"); -const moment = require("./localeMoment"); +const moment = require("../localeMoment"); const parseJSON = require("json-parse-async"); +const localeHelper = require("../localeHelper"); module.exports = { @@ -64,10 +65,12 @@ module.exports = { scoresObj: null, dataPollStarted: false, gameDate: null, + translations: {}, - getScores: function(league, teams, gameDate, callback) { + getScores: function(league, teams, gameDate, language, callback) { var self = this; + self.translations = localeHelper.loadTranslations(language); this.gameDate = moment(gameDate); if (this.scoresObj == null) { @@ -212,12 +215,12 @@ module.exports = { into the getPeriod() routine. */ if (game.shootout == true) { - status.push("SHOOTOUT"); + status.push(this.translations.shootout); } else if (game.overtime == true) { status.push(game.clock); - status.push("OT"); + status.push(this.translations.ot.replace('##1##', '')); } else if (game.clock == "0:00") { - status.push("END"); + status.push(this.translations.end); status.push(self.getPeriod(league, game.period)); } else { status.push(game.clock); @@ -238,7 +241,7 @@ module.exports = { case "MLS": if (game.clock == "Half") { - status.push("HALFTIME"); + status.push(this.translations.halfTime); } else { status.push(game.clock); } @@ -261,9 +264,9 @@ module.exports = { their own special cases. */ if (game.clock == "0:00" && game.period == 2) { - status.push("HALFTIME"); + status.push(this.translations.halfTime); } else if (game.clock == "0:00") { - status.push("END"); + status.push(this.translations.end); status.push(self.getPeriod(league, game.period)); } else { status.push(game.clock); @@ -277,23 +280,23 @@ module.exports = { case "Half-Over": gameState = 1; //in-progress - status.push("HALFTIME"); + status.push(this.translations.halfTime); break; case "Delayed": gameState = 1; //in-progress classes.push("delay"); - status.push("Delay"); + status.push(this.translations.delay); break; case "Postponed": gameState = 0; - status.push("Postponed"); + status.push(this.translations.postponed); break; case "Final": gameState = 2; //final - status.push("Final" + self.getFinalOT(league, game)); + status.push(this.translations.final.replace('##1##', self.getFinalOT(league, game)).trim()); break; default: @@ -333,30 +336,30 @@ module.exports = { switch (league) { case "NHL": if (game.shootout == true) { - return " (SO)"; + return this.translations.finalSoSuffix; } else if (game.overtime == true) { - return " (OT)"; + return this.translations.finalOtSuffix.replace('##1##', ''); } else if (game.period == 4) { - return " (OT)"; + return this.translations.finalOtSuffix.replace('##1##', ''); } else if (game.period > 4) { - return " (" + (game.period - 3) + "OT)"; + return this.translations.finalOtSuffix.replace('##1##', (game.period - 3).toString()); } break; case "MLB": if (game.period > 9) { - return " (" + game.period + ")"; + return this.translations.finalPeriodSuffix.replace('##1##', game.period.toString()); } break; case "NFL": case "CFL": case "NBA": if (game.period > 4) { - return " (OT)"; + return this.translations.finalOtSuffix.replace('##1##', ''); } break; case "MLS": if (game.period > 2) { - return " (ET)"; + return this.translations.finalEtSuffix; } break; } @@ -369,16 +372,16 @@ module.exports = { var mod100 = p % 100; if (mod10 == 1 && mod100 != 11) { - return p + "ST"; + return p + this.translations.ordinalOne; } if (mod10 == 2 && mod100 != 12) { - return p + "ND"; + return p + this.translations.ordinalTwo; } if (mod10 == 3 && mod100 != 13) { - return p + "RD"; + return p + this.translations.ordinalThree; } - return p + "TH"; + return p + this.translations.ordinalOther; }, @@ -390,21 +393,21 @@ module.exports = { case "NBA": case "CFL": if (p == 5) { - return ("OT"); + return (this.translations.ot.replace('##1##', '')); } else if (p > 5) { - return (p - 4) + "OT"; + return this.translations.ot.replace('##1##', (p-4).toString()); } break; case "NHL": if (p == 4) { - return ("OT"); + return (this.translations.ot.replace('##1##', '')); } else if (p > 4) { - return (p - 3) + "OT"; + return this.translations.ot.replace('##1##', (p-3).toString()); } break; case "MLS" : if (p > 2) { - return ("ET"); + return this.translations.et; } break; } diff --git a/translations/de.json b/translations/de.json new file mode 100644 index 0000000..84d6447 --- /dev/null +++ b/translations/de.json @@ -0,0 +1,25 @@ +{ + "tbd": "Noch offen", + "et": "VL", + "ot": "##1##VL", + "final": "Beendet ##1##", + "finalEtSuffix": "(n.V.)", + "finalOtSuffix": "(n.V. (##1##))", + "finalSoSuffix": "(SO)", + "finalPkSuffix": "(n.E.) ##1##", + "finalPeriodSuffix": "(##1##)", + "forfeit": "Aufgabe", + "canceled": "Abgesagt", + "postponed": "Verschoben", + "delay": "Verzögert", + "suspended": "Abgebrochen", + "end": "Beendet", + "halfTime": "Halbzeit", + "halfTimeEt": "Halbzeit (Nachspielzeit)", + "fullTime": "Beendet ##1##", + "ordinalOne": ".", + "ordinalTwo": ".", + "ordinalThree": ".", + "ordinalOther": ".", + "shootout": "Penalty" +} \ No newline at end of file diff --git a/translations/en.json b/translations/en.json new file mode 100644 index 0000000..0dbd946 --- /dev/null +++ b/translations/en.json @@ -0,0 +1,25 @@ +{ + "tbd": "TBD", + "et": "ET", + "ot": "##1##OT", + "final": "Final ##1##", + "finalEtSuffix": "(ET)", + "finalOtSuffix": "(##1##OT)", + "finalSoSuffix": "(SO)", + "finalPkSuffix": "(PK) ##1##", + "finalPeriodSuffix": "(##1##)", + "forfeit": "Forfeit", + "canceled": "Cancelled", + "postponed": "Postponed", + "delay": "Delay", + "suspended": "Suspended", + "end": "END", + "halfTime": "HALFTIME", + "halfTimeEt": "HALFTIME (ET)", + "fullTime": "Full Time ##1##", + "ordinalOne": "ST", + "ordinalTwo": "ND", + "ordinalThree": "RD", + "ordinalOther": "TH", + "shootout": "SHOOTOUT" +} \ No newline at end of file From 40bb25c07eb394507d7546ba713a906c9f903db1 Mon Sep 17 00:00:00 2001 From: Michael Schmidt Date: Sun, 16 Jan 2022 16:55:11 +0100 Subject: [PATCH 3/4] Fixed loading of translations with SNET --- providers/SNET.js | 52 +++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/providers/SNET.js b/providers/SNET.js index e0fc41f..163679f 100644 --- a/providers/SNET.js +++ b/providers/SNET.js @@ -215,12 +215,12 @@ module.exports = { into the getPeriod() routine. */ if (game.shootout == true) { - status.push(this.translations.shootout); + status.push(self.translations.shootout); } else if (game.overtime == true) { status.push(game.clock); - status.push(this.translations.ot.replace('##1##', '')); + status.push(self.translations.ot.replace('##1##', '')); } else if (game.clock == "0:00") { - status.push(this.translations.end); + status.push(self.translations.end); status.push(self.getPeriod(league, game.period)); } else { status.push(game.clock); @@ -241,7 +241,7 @@ module.exports = { case "MLS": if (game.clock == "Half") { - status.push(this.translations.halfTime); + status.push(self.translations.halfTime); } else { status.push(game.clock); } @@ -264,9 +264,9 @@ module.exports = { their own special cases. */ if (game.clock == "0:00" && game.period == 2) { - status.push(this.translations.halfTime); + status.push(self.translations.halfTime); } else if (game.clock == "0:00") { - status.push(this.translations.end); + status.push(self.translations.end); status.push(self.getPeriod(league, game.period)); } else { status.push(game.clock); @@ -280,23 +280,23 @@ module.exports = { case "Half-Over": gameState = 1; //in-progress - status.push(this.translations.halfTime); + status.push(self.translations.halfTime); break; case "Delayed": gameState = 1; //in-progress classes.push("delay"); - status.push(this.translations.delay); + status.push(self.translations.delay); break; case "Postponed": gameState = 0; - status.push(this.translations.postponed); + status.push(self.translations.postponed); break; case "Final": gameState = 2; //final - status.push(this.translations.final.replace('##1##', self.getFinalOT(league, game)).trim()); + status.push(self.translations.final.replace('##1##', self.getFinalOT(league, game)).trim()); break; default: @@ -336,30 +336,30 @@ module.exports = { switch (league) { case "NHL": if (game.shootout == true) { - return this.translations.finalSoSuffix; + return self.translations.finalSoSuffix; } else if (game.overtime == true) { - return this.translations.finalOtSuffix.replace('##1##', ''); + return self.translations.finalOtSuffix.replace('##1##', ''); } else if (game.period == 4) { - return this.translations.finalOtSuffix.replace('##1##', ''); + return self.translations.finalOtSuffix.replace('##1##', ''); } else if (game.period > 4) { - return this.translations.finalOtSuffix.replace('##1##', (game.period - 3).toString()); + return self.translations.finalOtSuffix.replace('##1##', (game.period - 3).toString()); } break; case "MLB": if (game.period > 9) { - return this.translations.finalPeriodSuffix.replace('##1##', game.period.toString()); + return self.translations.finalPeriodSuffix.replace('##1##', game.period.toString()); } break; case "NFL": case "CFL": case "NBA": if (game.period > 4) { - return this.translations.finalOtSuffix.replace('##1##', ''); + return self.translations.finalOtSuffix.replace('##1##', ''); } break; case "MLS": if (game.period > 2) { - return this.translations.finalEtSuffix; + return self.translations.finalEtSuffix; } break; } @@ -372,16 +372,16 @@ module.exports = { var mod100 = p % 100; if (mod10 == 1 && mod100 != 11) { - return p + this.translations.ordinalOne; + return p + self.translations.ordinalOne; } if (mod10 == 2 && mod100 != 12) { - return p + this.translations.ordinalTwo; + return p + self.translations.ordinalTwo; } if (mod10 == 3 && mod100 != 13) { - return p + this.translations.ordinalThree; + return p + self.translations.ordinalThree; } - return p + this.translations.ordinalOther; + return p + self.translations.ordinalOther; }, @@ -393,21 +393,21 @@ module.exports = { case "NBA": case "CFL": if (p == 5) { - return (this.translations.ot.replace('##1##', '')); + return (self.translations.ot.replace('##1##', '')); } else if (p > 5) { - return this.translations.ot.replace('##1##', (p-4).toString()); + return self.translations.ot.replace('##1##', (p-4).toString()); } break; case "NHL": if (p == 4) { - return (this.translations.ot.replace('##1##', '')); + return (self.translations.ot.replace('##1##', '')); } else if (p > 4) { - return this.translations.ot.replace('##1##', (p-3).toString()); + return self.translations.ot.replace('##1##', (p-3).toString()); } break; case "MLS" : if (p > 2) { - return this.translations.et; + return self.translations.et; } break; } From 7c99a08d063a7285ab8857473a20440c0cc64a20 Mon Sep 17 00:00:00 2001 From: Michael Schmidt Date: Wed, 2 Nov 2022 11:12:11 +0100 Subject: [PATCH 4/4] Module sends notification when visible or invisible --- MMM-MyScoreboard.js | 1709 ++++++++++++++++++++++++++++++++++--------- node_helper.js | 34 +- 2 files changed, 1389 insertions(+), 354 deletions(-) diff --git a/MMM-MyScoreboard.js b/MMM-MyScoreboard.js index 4dc2580..cdc9010 100644 --- a/MMM-MyScoreboard.js +++ b/MMM-MyScoreboard.js @@ -9,8 +9,7 @@ *********************************/ -Module.register("MMM-MyScoreboard",{ - +Module.register("MMM-MyScoreboard", { // Default module config. defaults: { showLeagueSeparators: true, @@ -42,178 +41,553 @@ Module.register("MMM-MyScoreboard",{ supportedLeagues: { //North American Leagues - "NBA": {provider: "ESPN", logoFormat: "svg"}, - "NHL": {provider: "SNET", logoFormat: "svg"}, - "NFL": {provider: "SNET", logoFormat: "svg"}, - "CFL": {provider: "SNET", logoFormat: "svg"}, - "MLB": {provider: "SNET", logoFormat: "svg"}, - "MLS": {provider: "SNET", logoFormat: "svg", homeTeamFirst: true}, - "NCAAF": {provider: "ESPN", logoFormat: "png"}, - "NCAAM": {provider: "ESPN", logoFormat: "png"}, - "NCAAM_MM": {provider: "ESPN",logoFormat: "png"}, + NBA: { provider: "ESPN", logoFormat: "svg" }, + NHL: { provider: "SNET", logoFormat: "svg" }, + NFL: { provider: "SNET", logoFormat: "svg" }, + CFL: { provider: "SNET", logoFormat: "svg" }, + MLB: { provider: "SNET", logoFormat: "svg" }, + MLS: { provider: "SNET", logoFormat: "svg", homeTeamFirst: true }, + NCAAF: { provider: "ESPN", logoFormat: "png" }, + NCAAM: { provider: "ESPN", logoFormat: "png" }, + NCAAM_MM: { provider: "ESPN", logoFormat: "png" }, //International Soccer - "AFC_ASIAN_CUP": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "AFC_ASIAN_CUP_Q": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "AFF_CUP": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "AFR_NATIONS_CUP": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "AFR_NATIONS_CUP_Q": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "AFR_NATIONS_Q": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "CONCACAF_GOLD_CUP": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "CONCACAF_NATIONS_Q": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "CONCACAF_WOMENS_CHAMPIONSHIP": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "CONMEBOL_COPA_AMERICA": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "FIFA_CLUB_WORLD_CUP": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "FIFA_CONFEDERATIONS_CUP": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "FIFA_MENS_FRIENDLIES": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "FIFA_MENS_OLYMPICS": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "FIFA_WOMENS_FRIENDLIES": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "FIFA_WOMENS_OLYMPICS": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "FIFA_WOMENS_WORLD_CUP": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "FIFA_WORLD_CUP": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "FIFA_WORLD_CUP_Q_AFC": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "FIFA_WORLD_CUP_Q_CAF": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "FIFA_WORLD_CUP_Q_CONCACAF": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "FIFA_WORLD_CUP_Q_CONMEBOL": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "FIFA_WORLD_CUP_Q_OFC": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "FIFA_WORLD_CUP_Q_UEFA": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "FIFA_WORLD_U17": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "FIFA_WORLD_U20": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "UEFA_CHAMPIONS": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "UEFA_EUROPEAN_CHAMPIONSHIP": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "UEFA_EUROPEAN_CHAMPIONSHIP_Q": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "UEFA_EUROPEAN_CHAMPIONSHIP_U19": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "UEFA_EUROPEAN_CHAMPIONSHIP_U21": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "UEFA_EUROPA": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "UEFA_NATIONS": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "SAFF_CHAMPIONSHIP": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "WOMENS_EUROPEAN_CHAMPIONSHIP": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, + AFC_ASIAN_CUP: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + AFC_ASIAN_CUP_Q: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + AFF_CUP: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + AFR_NATIONS_CUP: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + AFR_NATIONS_CUP_Q: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + AFR_NATIONS_Q: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + CONCACAF_GOLD_CUP: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + CONCACAF_NATIONS_Q: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + CONCACAF_WOMENS_CHAMPIONSHIP: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + CONMEBOL_COPA_AMERICA: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + FIFA_CLUB_WORLD_CUP: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + FIFA_CONFEDERATIONS_CUP: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + FIFA_MENS_FRIENDLIES: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + FIFA_MENS_OLYMPICS: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + FIFA_WOMENS_FRIENDLIES: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + FIFA_WOMENS_OLYMPICS: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + FIFA_WOMENS_WORLD_CUP: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + FIFA_WORLD_CUP: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + FIFA_WORLD_CUP_Q_AFC: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + FIFA_WORLD_CUP_Q_CAF: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + FIFA_WORLD_CUP_Q_CONCACAF: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + FIFA_WORLD_CUP_Q_CONMEBOL: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + FIFA_WORLD_CUP_Q_OFC: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + FIFA_WORLD_CUP_Q_UEFA: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + FIFA_WORLD_U17: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + FIFA_WORLD_U20: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + UEFA_CHAMPIONS: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + UEFA_EUROPEAN_CHAMPIONSHIP: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + UEFA_EUROPEAN_CHAMPIONSHIP_Q: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + UEFA_EUROPEAN_CHAMPIONSHIP_U19: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + UEFA_EUROPEAN_CHAMPIONSHIP_U21: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + UEFA_EUROPA: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + UEFA_NATIONS: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + SAFF_CHAMPIONSHIP: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + WOMENS_EUROPEAN_CHAMPIONSHIP: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, //UK / Ireland Soccer - "ENG_CARABAO_CUP": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "ENG_CHAMPIONSHIP": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "ENG_EFL": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "ENG_FA_CUP": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "ENG_LEAGUE_1": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "ENG_LEAGUE_2": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "ENG_NATIONAL": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "ENG_PREMIERE_LEAGUE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "IRL_PREM": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "NIR_PREM": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "SCO_CHALLENGE_CUP": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "SCO_CHAMPIONSHIP": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "SCO_CIS": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "SCO_CUP": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "SCO_LEAGUE_1": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "SCO_LEAGUE_2": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "SCO_PREM": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "WAL_PREM": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, + ENG_CARABAO_CUP: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + ENG_CHAMPIONSHIP: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + ENG_EFL: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + ENG_FA_CUP: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + ENG_LEAGUE_1: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + ENG_LEAGUE_2: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + ENG_NATIONAL: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + ENG_PREMIERE_LEAGUE: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + IRL_PREM: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + NIR_PREM: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + SCO_CHALLENGE_CUP: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + SCO_CHAMPIONSHIP: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + SCO_CIS: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + SCO_CUP: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + SCO_LEAGUE_1: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + SCO_LEAGUE_2: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + SCO_PREM: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + WAL_PREM: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, //European Soccer - "AUT_BUNDESLIGA": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "BEL_DIV_A": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "DEN_SAS_LIGAEN": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "ESP_COPA_DEL_REY": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "ESP_LALIGA": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "ESP_SEGUNDA_DIV": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "FRA_COUPE_DE_FRANCE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "FRA_COUPE_DE_LA_LIGUE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "FRA_LIGUE_1": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "FRA_LIGUE_2": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "GER_2_BUNDESLIGA": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "GER_BUNDESLIGA": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "GER_DFB_POKAL": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "GRE_SUPER_LEAGUE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "ISR_PREMIER_LEAGUE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "MLT_PREMIER_LEAGUE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "ITA_COPPA_ITALIA": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "ITA_SERIE_A": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "ITA_SERIE_B": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "NED_EERSTE_DIVISIE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "NED_EREDIVISIE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "NED_KNVB_BEKER": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "NOR_ELITESERIEN": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "POR_LIGA": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "ROU_FIRST_DIV": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "RUS_PREMIER_LEAGUE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "SUI_SUPER_LEAGUE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "SWE_ALLSVENSKANLIGA": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "TUR_SUPER_LIG": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, + AUT_BUNDESLIGA: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + BEL_DIV_A: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + DEN_SAS_LIGAEN: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + ESP_COPA_DEL_REY: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + ESP_LALIGA: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + ESP_SEGUNDA_DIV: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + FRA_COUPE_DE_FRANCE: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + FRA_COUPE_DE_LA_LIGUE: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + FRA_LIGUE_1: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + FRA_LIGUE_2: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + GER_2_BUNDESLIGA: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + GER_BUNDESLIGA: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + GER_DFB_POKAL: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + GRE_SUPER_LEAGUE: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + ISR_PREMIER_LEAGUE: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + MLT_PREMIER_LEAGUE: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + ITA_COPPA_ITALIA: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + ITA_SERIE_A: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + ITA_SERIE_B: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + NED_EERSTE_DIVISIE: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + NED_EREDIVISIE: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + NED_KNVB_BEKER: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + NOR_ELITESERIEN: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + POR_LIGA: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + ROU_FIRST_DIV: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + RUS_PREMIER_LEAGUE: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + SUI_SUPER_LEAGUE: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + SWE_ALLSVENSKANLIGA: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + TUR_SUPER_LIG: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, //South American Soccer - "ARG_COPA": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "ARG_NACIONAL_B": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "ARG_PRIMERA_DIV_B": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "ARG_PRIMERA_DIV_C": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "ARG_PRIMERA_DIV_D": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "ARG_SUPERLIGA": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "BOL_LIGA_PRO": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "BRA_COPA": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "BRA_CAMP_CARIOCA": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "BRA_CAMP_GAUCHO": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "BRA_CAMP_MINEIRO": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "BRA_CAMP_PAULISTA": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "BRA_SERIE_A": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "BRA_SERIE_B": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "BRA_SERIE_C": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "CHI_COPA": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "CHI_PRIMERA_DIV": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "COL_COPA": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "COL_PRIMERA_A": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "COL_PRIMERA_B": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "CONMEBOL_COPA_LIBERTADORES": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "CONMEBOL_COPA_SUDAMERICANA": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "ECU_PRIMERA_A": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "PAR_PRIMERA_DIV": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "PER_PRIMERA_PRO": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "URU_PRIMERA_DIV": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "VEN_PRIMERA_PRO": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, + ARG_COPA: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + ARG_NACIONAL_B: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + ARG_PRIMERA_DIV_B: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + ARG_PRIMERA_DIV_C: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + ARG_PRIMERA_DIV_D: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + ARG_SUPERLIGA: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + BOL_LIGA_PRO: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + BRA_COPA: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + BRA_CAMP_CARIOCA: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + BRA_CAMP_GAUCHO: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + BRA_CAMP_MINEIRO: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + BRA_CAMP_PAULISTA: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + BRA_SERIE_A: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + BRA_SERIE_B: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + BRA_SERIE_C: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + CHI_COPA: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + CHI_PRIMERA_DIV: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + COL_COPA: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + COL_PRIMERA_A: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + COL_PRIMERA_B: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + CONMEBOL_COPA_LIBERTADORES: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + CONMEBOL_COPA_SUDAMERICANA: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + ECU_PRIMERA_A: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + PAR_PRIMERA_DIV: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + PER_PRIMERA_PRO: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + URU_PRIMERA_DIV: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + VEN_PRIMERA_PRO: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, //North American Soccer - "CONCACAF_CHAMPIONS": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "CONCACAF_LEAGUE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "CRC_PRIMERA_DIV": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "GUA_LIGA_NACIONAL": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "HON_PRIMERA_DIV": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "JAM_PREMIER_LEAGUE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "MEX_ASCENSO_MX": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "MEX_COPA_MX": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "MEX_LIGA_BANCOMER": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "SLV_PRIMERA_DIV": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "USA_MLS": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "USA_NCAA_SL_M": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "USA_NCAA_SL_W": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "USA_NASL": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "USA_NWSL": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "USA_OPEN": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "USA_USL": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, + CONCACAF_CHAMPIONS: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + CONCACAF_LEAGUE: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + CRC_PRIMERA_DIV: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + GUA_LIGA_NACIONAL: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + HON_PRIMERA_DIV: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + JAM_PREMIER_LEAGUE: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + MEX_ASCENSO_MX: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + MEX_COPA_MX: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + MEX_LIGA_BANCOMER: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + SLV_PRIMERA_DIV: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + USA_MLS: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + USA_NCAA_SL_M: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + USA_NCAA_SL_W: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + USA_NASL: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + USA_NWSL: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + USA_OPEN: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + USA_USL: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, //Asian Soccer - "AFC_CHAMPIONS": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "AUS_A_LEAGUE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "CHN_SUPER_LEAGUE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "IDN_SUPER_LEAGUE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "IND_I_LEAGUE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "IND_SUPER_LEAGUE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "JPN_J_LEAGUE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "MYS_SUPER_LEAGUE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "SGP_PREMIER_LEAGUE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "THA_PREMIER_LEAGUE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, + AFC_CHAMPIONS: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + AUS_A_LEAGUE: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + CHN_SUPER_LEAGUE: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + IDN_SUPER_LEAGUE: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + IND_I_LEAGUE: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + IND_SUPER_LEAGUE: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + JPN_J_LEAGUE: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + MYS_SUPER_LEAGUE: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + SGP_PREMIER_LEAGUE: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + THA_PREMIER_LEAGUE: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, //African Soccer - "CAF_CHAMPIONS": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "CAF_CONFED_CUP": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "GHA_PREMIERE_LEAGUE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "KEN_PREMIERE_LEAGUE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "NGA_PRO_LEAGUE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "RSA_FIRST_DIV": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "RSA_NEDBANK_CUP": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "RSA_PREMIERSHIP": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "RSA_TELKOM_KNOCKOUT": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "UGA_SUPER_LEAGUE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "ZAM_SUPER_LEAGUE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - "ZIM_PREMIER_LEAGUE": {provider: "ESPN", logoFormat: "url", homeTeamFirst: true}, - + CAF_CHAMPIONS: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + CAF_CONFED_CUP: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + GHA_PREMIERE_LEAGUE: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + KEN_PREMIERE_LEAGUE: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + NGA_PRO_LEAGUE: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + RSA_FIRST_DIV: { provider: "ESPN", logoFormat: "url", homeTeamFirst: true }, + RSA_NEDBANK_CUP: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + RSA_PREMIERSHIP: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + RSA_TELKOM_KNOCKOUT: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + UGA_SUPER_LEAGUE: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + ZAM_SUPER_LEAGUE: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + }, + ZIM_PREMIER_LEAGUE: { + provider: "ESPN", + logoFormat: "url", + homeTeamFirst: true + } }, // Define required styles. @@ -222,7 +596,7 @@ Module.register("MMM-MyScoreboard",{ }, // Define required scripts. - getScripts: function() { + getScripts: function () { return ["moment.js"]; }, @@ -242,8 +616,8 @@ Module.register("MMM-MyScoreboard",{ "stackedWithLogos" ], - viewStyleHasLogos: function(v) { - switch(v) { + viewStyleHasLogos: function (v) { + switch (v) { case "largeLogos": case "mediumLogos": case "smallLogos": @@ -255,7 +629,7 @@ Module.register("MMM-MyScoreboard",{ } }, - viewStyleHasRankingOverlay: function(v) { + viewStyleHasRankingOverlay: function (v) { switch (v) { case "largeLogos": case "mediumLogos": @@ -266,8 +640,8 @@ Module.register("MMM-MyScoreboard",{ } }, - viewStyleHasShortcodes: function(v) { - switch(v) { + viewStyleHasShortcodes: function (v) { + switch (v) { case "oneLine": case "oneLineWithLogos": return true; @@ -276,8 +650,8 @@ Module.register("MMM-MyScoreboard",{ } }, - viewStyleHasLongNames: function(v) { - switch(v) { + viewStyleHasLongNames: function (v) { + switch (v) { case "stacked": case "stackedWithLogos": return true; @@ -286,7 +660,6 @@ Module.register("MMM-MyScoreboard",{ } }, - /****************************************************************** Function boxScoreFactory() @@ -310,8 +683,7 @@ Module.register("MMM-MyScoreboard",{ vScore ******************************************************************/ - boxScoreFactory: function(league, gameObj) { - + boxScoreFactory: function (league, gameObj) { var viewStyle = this.config.viewStyle; var boxScore = document.createElement("div"); @@ -321,7 +693,7 @@ Module.register("MMM-MyScoreboard",{ boxScore.classList.add("in-progress"); } if (gameObj.classes) { - gameObj.classes.forEach( function(c) { + gameObj.classes.forEach(function (c) { boxScore.classList.add(c); }); } @@ -338,7 +710,6 @@ Module.register("MMM-MyScoreboard",{ //add team logos if applicable if (this.viewStyleHasLogos(viewStyle)) { - var hTeamLogo = document.createElement("span"); hTeamLogo.classList.add("logo", "home"); @@ -347,7 +718,14 @@ Module.register("MMM-MyScoreboard",{ //use URL to external logo image hTeamLogoImg.src = gameObj.hTeamLogoUrl; } else { - hTeamLogoImg.src = this.file("logos/" + leagueForLogoPath + "/" + gameObj.hTeam + "." + this.supportedLeagues[league].logoFormat ); + hTeamLogoImg.src = this.file( + "logos/" + + leagueForLogoPath + + "/" + + gameObj.hTeam + + "." + + this.supportedLeagues[league].logoFormat + ); } //End of for Soccer @@ -355,7 +733,11 @@ Module.register("MMM-MyScoreboard",{ hTeamLogo.appendChild(hTeamLogoImg); - if (this.config.showRankings && this.viewStyleHasRankingOverlay(viewStyle) && gameObj.hTeamRanking) { + if ( + this.config.showRankings && + this.viewStyleHasRankingOverlay(viewStyle) && + gameObj.hTeamRanking + ) { var hTeamRakingOverlay = document.createElement("span"); hTeamRakingOverlay.classList.add("ranking"); hTeamRakingOverlay.innerHTML = gameObj.hTeamRanking; @@ -363,8 +745,6 @@ Module.register("MMM-MyScoreboard",{ } boxScore.appendChild(hTeamLogo); - - var vTeamLogo = document.createElement("span"); vTeamLogo.classList.add("logo", "visitor"); @@ -372,14 +752,25 @@ Module.register("MMM-MyScoreboard",{ if (this.supportedLeagues[league].logoFormat == "url") { vTeamLogoImg.src = gameObj.vTeamLogoUrl; } else { - vTeamLogoImg.src = this.file("logos/" + leagueForLogoPath + "/" + gameObj.vTeam + "." + this.supportedLeagues[league].logoFormat ); + vTeamLogoImg.src = this.file( + "logos/" + + leagueForLogoPath + + "/" + + gameObj.vTeam + + "." + + this.supportedLeagues[league].logoFormat + ); } vTeamLogoImg.setAttribute("data-abbr", gameObj.vTeam); vTeamLogo.appendChild(vTeamLogoImg); - if (this.config.showRankings && this.viewStyleHasRankingOverlay(viewStyle) && gameObj.vTeamRanking) { + if ( + this.config.showRankings && + this.viewStyleHasRankingOverlay(viewStyle) && + gameObj.vTeamRanking + ) { var vTeamRakingOverlay = document.createElement("span"); vTeamRakingOverlay.classList.add("ranking"); vTeamRakingOverlay.innerHTML = gameObj.vTeamRanking; @@ -392,12 +783,18 @@ Module.register("MMM-MyScoreboard",{ if (this.viewStyleHasShortcodes(viewStyle)) { var hTeamSC = document.createElement("span"); hTeamSC.classList.add("team-short-code", "home"); - hTeamSC.innerHTML = (this.config.showRankings && gameObj.hTeamRanking ? "" + gameObj.hTeamRanking + "" : "") + gameObj.hTeam; + hTeamSC.innerHTML = + (this.config.showRankings && gameObj.hTeamRanking + ? '' + gameObj.hTeamRanking + "" + : "") + gameObj.hTeam; boxScore.appendChild(hTeamSC); var vTeamSC = document.createElement("span"); vTeamSC.classList.add("team-short-code", "visitor"); - vTeamSC.innerHTML = (this.config.showRankings && gameObj.vTeamRanking ? "" + gameObj.vTeamRanking + "" : "") + gameObj.vTeam; + vTeamSC.innerHTML = + (this.config.showRankings && gameObj.vTeamRanking + ? '' + gameObj.vTeamRanking + "" + : "") + gameObj.vTeam; boxScore.appendChild(vTeamSC); } @@ -405,20 +802,27 @@ Module.register("MMM-MyScoreboard",{ if (this.viewStyleHasLongNames(viewStyle)) { var hTeamName = document.createElement("span"); hTeamName.classList.add("team-name", "home"); - hTeamName.innerHTML = (this.config.showRankings && gameObj.hTeamRanking ? "" + gameObj.hTeamRanking + "" : "") + gameObj.hTeamLong; + hTeamName.innerHTML = + (this.config.showRankings && gameObj.hTeamRanking + ? '' + gameObj.hTeamRanking + "" + : "") + gameObj.hTeamLong; boxScore.appendChild(hTeamName); var vTeamName = document.createElement("span"); vTeamName.classList.add("team-name", "visitor"); - vTeamName.innerHTML = (this.config.showRankings && gameObj.vTeamRanking ? "" + gameObj.vTeamRanking + "" : "") + gameObj.vTeamLong; + vTeamName.innerHTML = + (this.config.showRankings && gameObj.vTeamRanking + ? '' + gameObj.vTeamRanking + "" + : "") + gameObj.vTeamLong; boxScore.appendChild(vTeamName); } - //add "@" for games not yet started for the oneLine //and oneLineWithLogos view styles - if (gameObj.gameMode == this.gameModes.FUTURE && - (viewStyle == "oneLine" || viewStyle == "oneLineWithLogos")) { + if ( + gameObj.gameMode == this.gameModes.FUTURE && + (viewStyle == "oneLine" || viewStyle == "oneLineWithLogos") + ) { var vsSymbol = document.createElement("span"); vsSymbol.classList.add("vs-symbol"); //Soccer games we don't say AT (@) but VS thus the HOME team is first (Chelsea Vs Manchester - Chelsea's Home instead of Manchester @ Chelsea) @@ -433,7 +837,7 @@ Module.register("MMM-MyScoreboard",{ //add game status var status = document.createElement("div"); status.classList.add("status"); - gameObj.status.forEach(function(s) { + gameObj.status.forEach(function (s) { var statusPart = document.createElement("span"); statusPart.innerHTML = s; status.appendChild(statusPart); @@ -442,17 +846,15 @@ Module.register("MMM-MyScoreboard",{ //add scores if game in progress or finished if (gameObj.gameMode != this.gameModes.FUTURE) { - var hTeamScore = document.createElement("span"); hTeamScore.classList.add("score", "home"); - hTeamScore.innerHTML = (gameObj.hScore); + hTeamScore.innerHTML = gameObj.hScore; boxScore.appendChild(hTeamScore); var vTeamScore = document.createElement("span"); vTeamScore.classList.add("score", "visitor"); - vTeamScore.innerHTML = (gameObj.vScore); + vTeamScore.innerHTML = gameObj.vScore; boxScore.appendChild(vTeamScore); - } //add classes to final games @@ -471,8 +873,7 @@ Module.register("MMM-MyScoreboard",{ }, // Override dom generator. - getDom: function() { - + getDom: function () { var wrapper = document.createElement("div"); wrapper.classList.add("wrapper"); @@ -503,14 +904,13 @@ Module.register("MMM-MyScoreboard",{ return wrapper; } - /* Run through the leagues and generate box score displays for each game. */ var anyGames = false; var self = this; - this.config.sports.forEach(function(sport, index) { + this.config.sports.forEach(function (sport, index) { if (self.sportsData[index] != null && self.sportsData[index].length > 0) { anyGames = true; if (self.config.showLeagueSeparators) { @@ -523,9 +923,9 @@ Module.register("MMM-MyScoreboard",{ } wrapper.appendChild(leagueSeparator); } - self.sportsData[index].forEach(function(game, gidx) { + self.sportsData[index].forEach(function (game, gidx) { var boxScore = self.boxScoreFactory(sport.league, game); - boxScore.classList.add(gidx % 2 == 0 ? "odd" : "even") ; + boxScore.classList.add(gidx % 2 == 0 ? "odd" : "even"); wrapper.appendChild(boxScore); }); } @@ -539,16 +939,25 @@ Module.register("MMM-MyScoreboard",{ should be visible. */ if (!anyGames) { - this.hide(1000, {lockString: this.identifier}); + this.hide(1000, { lockString: this.identifier }); + self.sendNotification("MODULE_INVISIBLE", { + moduleName: "MMM-MyScoreboard" + }); } else { - this.show(1000, {lockString: this.identifier}); + this.show(1000, { lockString: this.identifier }); + self.sendNotification("MODULE_VISIBLE", { + moduleName: "MMM-MyScoreboard" + }); } return wrapper; }, - socketNotificationReceived: function(notification, payload) { - if ( notification === "MMM-MYSCOREBOARD-SCORE-UPDATE" && payload.instanceId == this.identifier) { + socketNotificationReceived: function (notification, payload) { + if ( + notification === "MMM-MYSCOREBOARD-SCORE-UPDATE" && + payload.instanceId == this.identifier + ) { console.log("[MMM-MyScoreboard] Updating Scores"); this.loaded = true; this.sportsData[payload.index] = payload.scores; @@ -556,7 +965,7 @@ Module.register("MMM-MyScoreboard",{ } }, - start: function() { + start: function () { Log.info("Starting module: " + this.name); /* @@ -565,7 +974,7 @@ Module.register("MMM-MyScoreboard",{ var scrubbedSports = []; var self = this; - this.config.sports.forEach(function(sport) { + this.config.sports.forEach(function (sport) { if (self.supportedLeagues[sport.league]) { scrubbedSports.push(sport); } @@ -599,14 +1008,12 @@ Module.register("MMM-MyScoreboard",{ respective feed owners to lock down the APIs. Updating every two minutes should be more than fine for our purposes. */ - setInterval(function() { + setInterval(function () { self.getScores(); }, 2 * 60 * 1000); - }, - makeTeamList: function(inst, league, teams, groups) { - + makeTeamList: function (inst, league, teams, groups) { var teamList = []; if (teams != null) { @@ -617,24 +1024,20 @@ Module.register("MMM-MyScoreboard",{ for (var i = 0; i < groups.length; i++) { var group = inst.groups[league][groups[i]]; if (group != null) { - group.forEach( function(team) { + group.forEach(function (team) { teamList.push(team); }); - } } } - if (teamList.length == 0) { return null; } return teamList; - }, - getScores: function() { - + getScores: function () { var gameDate = moment(); //get today's date if (gameDate.hour() < this.config.rolloverHours) { @@ -652,8 +1055,7 @@ Module.register("MMM-MyScoreboard",{ } var self = this; - this.config.sports.forEach( function(sport, index) { - + this.config.sports.forEach(function (sport, index) { var payload = { instanceId: self.identifier, index: index, @@ -665,12 +1067,7 @@ Module.register("MMM-MyScoreboard",{ }; self.sendSocketNotification("MMM-MYSCOREBOARD-GET-SCORES", payload); - - }); - - - }, /* @@ -681,24 +1078,55 @@ Module.register("MMM-MyScoreboard",{ NCAAF and NCAAM where there are hundreds of teams. */ groups: { - NHL : { - + NHL: { //divisions - "Atlantic": ["BOS", "BUF", "DET", "FLA", "MTL", "OTT", "TB", "TOR"], - "Metropolitain": ["CAR", "CLB", "NJ", "NYI", "NYR", "PIT", "PHI", "WSH"], - "Central": ["CHI", "COL", "DAL", "MIN", "NSH", "STL", "WPG"], - "Pacific": ["ANA", "ARI", "CGY", "EDM", "LA", "SJ", "VAN", "VGK"], + Atlantic: ["BOS", "BUF", "DET", "FLA", "MTL", "OTT", "TB", "TOR"], + Metropolitain: ["CAR", "CLB", "NJ", "NYI", "NYR", "PIT", "PHI", "WSH"], + Central: ["CHI", "COL", "DAL", "MIN", "NSH", "STL", "WPG"], + Pacific: ["ANA", "ARI", "CGY", "EDM", "LA", "SJ", "VAN", "VGK"], //conferences - "East": ["BOS", "BUF", "CAR", "CLB", "DET", "FLA", "MTL", "NJ", "NYI", "NYR", "PIT", "PHI", "OTT", "TB", "TOR", "WSH"], - "West": ["ANA", "ARI", "CGY", "CHI", "COL", "DAL", "EDM", "LA", "MIN", "NSH", "SJ", "STL", "VAN", "VGK", "WPG"], + East: [ + "BOS", + "BUF", + "CAR", + "CLB", + "DET", + "FLA", + "MTL", + "NJ", + "NYI", + "NYR", + "PIT", + "PHI", + "OTT", + "TB", + "TOR", + "WSH" + ], + West: [ + "ANA", + "ARI", + "CGY", + "CHI", + "COL", + "DAL", + "EDM", + "LA", + "MIN", + "NSH", + "SJ", + "STL", + "VAN", + "VGK", + "WPG" + ], //all Canadian teams - "Canadian": ["CGY", "EDM", "MTL", "OTT", "TOR", "VAN", "WPG"] + Canadian: ["CGY", "EDM", "MTL", "OTT", "TOR", "VAN", "WPG"] }, - MLB : { - + MLB: { //divisions "AL East": ["BAL", "BOS", "NYY", "TB", "TOR"], "AL Central": ["CLE", "CWS", "DET", "KC", "MIN"], @@ -708,135 +1136,742 @@ Module.register("MMM-MyScoreboard",{ "NL West": ["ARI", "COL", "LAD", "SD", "SF"], //leagues - "American League": ["BAL", "BOS", "CLE", "CWS", "DET", "HOU", "LAA", "KC", "MIN", "NYY", "OAK", "SEA", "TB", "TEX", "TOR"], - "National League": ["ARI", "ATL", "CHC", "CIN", "COL", "LAD", "MIA", "MIL", "NYM", "PHI", "PIT", "SD", "SF", "STL", "WAS"] - + "American League": [ + "BAL", + "BOS", + "CLE", + "CWS", + "DET", + "HOU", + "LAA", + "KC", + "MIN", + "NYY", + "OAK", + "SEA", + "TB", + "TEX", + "TOR" + ], + "National League": [ + "ARI", + "ATL", + "CHC", + "CIN", + "COL", + "LAD", + "MIA", + "MIL", + "NYM", + "PHI", + "PIT", + "SD", + "SF", + "STL", + "WAS" + ] }, - NBA : { - + NBA: { //divisions - "Atlantic": ["BKN", "BOS", "NY", "PHI", "TOR"], - "Central": ["CHI", "CLE", "DET", "IND", "MIL"], - "Southeast": ["ATL", "CHA", "MIA", "ORL", "WSH"], - "Northwest": ["DEN", "MIN", "OKC", "POR", "UTAH"], - "Pacific": ["GS", "LAC", "LAL", "PHX", "SAC"], - "Southwest": ["DAL", "HOU", "MEM", "NO", "SA"], + Atlantic: ["BKN", "BOS", "NY", "PHI", "TOR"], + Central: ["CHI", "CLE", "DET", "IND", "MIL"], + Southeast: ["ATL", "CHA", "MIA", "ORL", "WSH"], + Northwest: ["DEN", "MIN", "OKC", "POR", "UTAH"], + Pacific: ["GS", "LAC", "LAL", "PHX", "SAC"], + Southwest: ["DAL", "HOU", "MEM", "NO", "SA"], //conferences - "East": ["ATL", "BKN", "BOS", "CHA", "CHI", "CLE", "DET", "IND", "MIA", "MIL", "NY", "ORL", "PHI", "TOR", "WSH"], - "West": ["DAL", "DEN", "GS", "HOU", "LAC", "LAL", "MEM", "MIN", "NO", "OKC", "PHX", "POR", "SA", "SAC", "UTAH"] - + East: [ + "ATL", + "BKN", + "BOS", + "CHA", + "CHI", + "CLE", + "DET", + "IND", + "MIA", + "MIL", + "NY", + "ORL", + "PHI", + "TOR", + "WSH" + ], + West: [ + "DAL", + "DEN", + "GS", + "HOU", + "LAC", + "LAL", + "MEM", + "MIN", + "NO", + "OKC", + "PHX", + "POR", + "SA", + "SAC", + "UTAH" + ] }, - NFL : { - + NFL: { //divisions - "AFC East" : ["NE", "BUF", "MIA", "NYJ"], - "AFC North" : ["BAL", "CIN", "CLE", "PIT"], - "AFC South" : ["JAX", "HOU", "IND", "TEN"], - "AFC West" : ["DEN", "KC", "LAC", "OAK"], - "NFC East" : ["DAL", "NYG", "PHI", "WAS"], - "NFC North" : ["CHI", "DET", "GB", "MIN"], - "NFC South" : ["ATL", "CAR", "NO", "TB"], - "NFC West" : ["ARI", "LA", "SEA", "SF"], + "AFC East": ["NE", "BUF", "MIA", "NYJ"], + "AFC North": ["BAL", "CIN", "CLE", "PIT"], + "AFC South": ["JAX", "HOU", "IND", "TEN"], + "AFC West": ["DEN", "KC", "LAC", "OAK"], + "NFC East": ["DAL", "NYG", "PHI", "WAS"], + "NFC North": ["CHI", "DET", "GB", "MIN"], + "NFC South": ["ATL", "CAR", "NO", "TB"], + "NFC West": ["ARI", "LA", "SEA", "SF"], //conferences - "AFC" : ["BAL", "BUF", "CIN", "CLE", "DEN", "HOU", "IND", "JAX", "KC", "LAC", "MIA", "NE", "NYJ", "OAK", "PIT", "TEN"], - "NFC" : ["ARI", "ATL", "CAR", "CHI", "DAL", "DET", "GB", "LA", "MIN", "NO", "NYG", "PHI", "SEA", "SF", "TB", "WAS"] + AFC: [ + "BAL", + "BUF", + "CIN", + "CLE", + "DEN", + "HOU", + "IND", + "JAX", + "KC", + "LAC", + "MIA", + "NE", + "NYJ", + "OAK", + "PIT", + "TEN" + ], + NFC: [ + "ARI", + "ATL", + "CAR", + "CHI", + "DAL", + "DET", + "GB", + "LA", + "MIN", + "NO", + "NYG", + "PHI", + "SEA", + "SF", + "TB", + "WAS" + ] }, - MLS : { - + MLS: { //conferences - "East" : ["ATL", "CHI", "CLB", "DC", "MTL", "NY", "NYC", "NE", "ORL", "PHI", "TOR"], - "West" : ["COL", "DAL", "HOU", "KC", "LA", "MIN", "POR", "RSL", "SEA", "SJ", "VAN"] - + East: [ + "ATL", + "CHI", + "CLB", + "DC", + "MTL", + "NY", + "NYC", + "NE", + "ORL", + "PHI", + "TOR" + ], + West: [ + "COL", + "DAL", + "HOU", + "KC", + "LA", + "MIN", + "POR", + "RSL", + "SEA", + "SJ", + "VAN" + ] }, - CFL : { - + CFL: { //conferences - "East" : ["HAM", "MTL", "OTT", "TOR"], - "West" : ["BC", "CGY", "EDM", "SSK", "WPG"] - + East: ["HAM", "MTL", "OTT", "TOR"], + West: ["BC", "CGY", "EDM", "SSK", "WPG"] }, - NCAAF : { - + NCAAF: { //divisions - "American Athletic" : ["CIN", "CONN", "ECU", "HOU", "MEM", "NAVY", "SMU", "TEM", "TULN", "TLSA", "UCF", "USF"], - "ACC" : ["BC", "CLEM", "DUKE", "FSU", "GT", "LOU", "MIAMI", "NCST", "PITT", "SYR", "UNC", "UVA", "VT", "WAKE"], - "Big 12" : ["BAY", "ISU", "KU", "KSU", "OKLA", "OKST", "TCU", "TEX", "TTU", "WVU"], - "Big Ten" : ["ILL", "IND", "IOWA", "MD", "MICH", "MSU", "MINN", "NEB", "NW", "OSU", "PSU", "PUR", "RUTG", "WIS"], - "Conference USA" : ["CHAR", "FAU", "FIU", "LT", "MRSH", "MTSU", "UNT", "ODU", "RICE", "UAB", "USM", "UTEP", "UTSA", "WKU"], - "FBS Independents" : ["ARMY", "BYU", "ND", "UMASS"], - "Mid-American" : ["AKR", "BALL", "BGSU", "BUFF", "CMU", "EMU", "KENT", "M-OH", "NIU", "OHIO", "TOL", "WMU"], - "Mountain West" : ["AFA", "BSU", "CSU", "FRES", "HAW", "NEV", "SDSU", "SJSU", "UNLV", "UNM", "USU", "WYO"], - "Pac-12" : ["ARIZ", "ASU", "CAL", "COLO", "ORE", "ORST", "STAN", "UCLA", "USC", "UTAH", "WASH", "WSU"], - "SEC" : ["ALA", "ARK", "AUB", "FLA", "UGA", "UK", "LSU", "MISS", "MSST", "MIZ", "SC", "TENN", "TA&M", "VAN"], - "Sun Belt" : ["APP", "ARST", "CCU", "GASO", "GAST", "IDHO", "ULL", "ULM", "NMSU", "USA", "TXST", "TROY"], - "Top 25" : ["@T25"] //special indicator for Top 25 ranked teams - + "American Athletic": [ + "CIN", + "CONN", + "ECU", + "HOU", + "MEM", + "NAVY", + "SMU", + "TEM", + "TULN", + "TLSA", + "UCF", + "USF" + ], + ACC: [ + "BC", + "CLEM", + "DUKE", + "FSU", + "GT", + "LOU", + "MIAMI", + "NCST", + "PITT", + "SYR", + "UNC", + "UVA", + "VT", + "WAKE" + ], + "Big 12": [ + "BAY", + "ISU", + "KU", + "KSU", + "OKLA", + "OKST", + "TCU", + "TEX", + "TTU", + "WVU" + ], + "Big Ten": [ + "ILL", + "IND", + "IOWA", + "MD", + "MICH", + "MSU", + "MINN", + "NEB", + "NW", + "OSU", + "PSU", + "PUR", + "RUTG", + "WIS" + ], + "Conference USA": [ + "CHAR", + "FAU", + "FIU", + "LT", + "MRSH", + "MTSU", + "UNT", + "ODU", + "RICE", + "UAB", + "USM", + "UTEP", + "UTSA", + "WKU" + ], + "FBS Independents": ["ARMY", "BYU", "ND", "UMASS"], + "Mid-American": [ + "AKR", + "BALL", + "BGSU", + "BUFF", + "CMU", + "EMU", + "KENT", + "M-OH", + "NIU", + "OHIO", + "TOL", + "WMU" + ], + "Mountain West": [ + "AFA", + "BSU", + "CSU", + "FRES", + "HAW", + "NEV", + "SDSU", + "SJSU", + "UNLV", + "UNM", + "USU", + "WYO" + ], + "Pac-12": [ + "ARIZ", + "ASU", + "CAL", + "COLO", + "ORE", + "ORST", + "STAN", + "UCLA", + "USC", + "UTAH", + "WASH", + "WSU" + ], + SEC: [ + "ALA", + "ARK", + "AUB", + "FLA", + "UGA", + "UK", + "LSU", + "MISS", + "MSST", + "MIZ", + "SC", + "TENN", + "TA&M", + "VAN" + ], + "Sun Belt": [ + "APP", + "ARST", + "CCU", + "GASO", + "GAST", + "IDHO", + "ULL", + "ULM", + "NMSU", + "USA", + "TXST", + "TROY" + ], + "Top 25": ["@T25"] //special indicator for Top 25 ranked teams }, - NCAAM : { - + NCAAM: { //divisions - "America East" : ["ALBY", "BING", "HART", "MAINE", "STON", "UML", "UMBC", "UNH", "UVM"], - "American" : ["CIN", "CONN", "ECU", "HOU", "MEM", "SMU", "USF", "TEM", "TULN", "UCF", "WICH"], - "Atlantic 10" : ["DAV", "DAY", "DUQ", "FOR", "GMU", "GW", "LAS", "RICH", "JOES", "SLU", "SBON", "UMASS", "URI", "VCU"], - "ACC" : ["BC", "CLEM", "DUKE", "FSU", "GT", "LOU", "MIA", "NCST", "UNC", "ND", "PITT", "SYR", "UVA", "VT", "WAKE"], - "Atlantic Sun" : ["FGCU", "JAC", "KENN", "LIP", "NJIT", "UNF", "UPST", "STET"], - "Big 12" : ["BAY", "ISU", "KU", "KSU", "OKLA", "OKST", "TCU", "TEX", "TTU", "WVU"], - "Big East" : ["BUT", "CREI", "DEP", "GTWN", "MARQ", "PROV", "HALL", "SJU", "VILL", "XAV"], - "Big Sky" : ["EWU", "IDHO", "IDST", "MONT", "MTST", "NAU", "PRST", "SAC", "SUU", "UNCO", "UND", "WEB"], - "Big South" : ["CAM", "CHSO", "WEBB", "HP", "LIB", "LONG", "PRE", "RAD", "UNCA", "WIN"], - "Big Ten" : ["ILL", "IND", "IOWA", "MD", "MICH", "MSU", "MINN", "NEB", "NW", "OSU", "PSU", "PUR", "RUTG", "WIS"], - "Big West" : ["CP", "CSF", "CSUN", "HAW", "LBSU", "UCD", "UCI", "UCRV", "UCSB"], - "Colonial" : ["COFC", "DEL", "DREX", "ELON", "HOF", "JMU", "NE", "TOWS", "UNCW", "WM"], - "Conference USA" : ["CHAR", "FAU", "FIU", "LT", "MRSH", "MTU", "ODU", "RICE", "UAB", "UNT", "USM", "UTSA", "UTEP", "WKU"], - "Horizon" : ["CLEV", "DET", "GB", "IUPU", "MILW", "NKU", "OAK", "UIC", "WRST", "YSU"], - "Ivy" : ["BRWN", "CLMB", "COR", "DART", "HARV", "PENN", "PRIN", "YALE"], - "MAAC" : ["CAN", "FAIR", "IONA", "MAN", "MRST", "MONM", "NIAG", "QUIN", "RID", "SPU", "SIE"], - "Mid-American" : ["AKR", "BALL", "BGSU", "BUFF", "CMU", "EMU", "KENT", "M-OH", "NIU", "OHIO", "TOL", "WMU"], - "MEAC" : ["BCU", "COPP", "DSU", "FAMU", "HAMP", "HOW", "MORG", "NSU", "NCAT", "NCCU", "SAV", "SCST", "UMES"], - "Missouri Valley" : ["BRAD", "DRKE", "EVAN", "ILST", "INST", "L-IL", "MOST", "UNI", "SIU", "VALP"], - "Mountain West" : ["AFA", "BSU", "CSU", "FRES", "NEV", "UNM", "SDSU", "SJSU", "UNLV", "USU", "WYO"], - "Northeast" : ["BRY", "CCSU", "FDU", "LIU", "MSM", "RMU", "SHU", "SFNY", "SFU", "WAG"], - "Ohio Valley" : ["BEL", "EIU", "EKY", "JVST", "MORE", "MURR", "PEAY", "SEMO", "SIUE", "TNST", "TNTC", "UTM"], - "Pac-12" : ["ARIZ", "ASU", "CAL", "COLO", "ORE", "ORST", "STAN", "UCLA", "USC", "UTAH", "WASH", "WSU"], - "Patriot League" : ["AMER", "ARMY", "BU", "BUCK", "COLG", "HC", "LAF", "LEH", "L-MD", "NAVY"], - "SEC" : ["ALA", "ARK", "AUB", "FLA", "LSU", "MSST", "MIZ", "MISS", "SC", "TENN", "TAMU", "UGA", "UK", "VAN"], - "Southern" : ["CHAT", "ETSU", "FUR", "MER", "SAM", "CIT", "UNCG", "VMI", "WCU", "WOF"], - "Southland" : ["ACU", "AMCC", "HBU", "IW", "LAM", "MCNS", "NICH", "NWST", "SHSU", "SELA", "SFA", "UCA", "UNO"], - "SWAC" : ["AAMU", "ALST", "ALCN", "GRAM", "JKST", "MVSU", "PV", "SOU", "TXSO", "UAPB"], - "Summit League" : ["DEN", "IPFW", "NDSU", "OMA", "ORU", "SDAK", "SDST", "WIU"], - "Sun Belt" : ["APP", "ARST", "CCAR", "GASO", "GAST", "TXST", "TROY", "UALR", "ULL", "ULM", "USA", "UTA"], - "West Coast" : ["BYU", "GONZ", "LMU", "PAC", "PEPP", "PORT", "SMC", "USD", "SF", "SCU"], - "WAC" : ["CHS", "CSB", "GCU", "NMSU", "SEA", "TRGV", "UMKC", "UVU"], - "Top 25" : ["@T25"] //special indicator for Top 25 ranked teams - - }, - - NCAAM_MM : {}, //no groups for March Madness + "America East": [ + "ALBY", + "BING", + "HART", + "MAINE", + "STON", + "UML", + "UMBC", + "UNH", + "UVM" + ], + American: [ + "CIN", + "CONN", + "ECU", + "HOU", + "MEM", + "SMU", + "USF", + "TEM", + "TULN", + "UCF", + "WICH" + ], + "Atlantic 10": [ + "DAV", + "DAY", + "DUQ", + "FOR", + "GMU", + "GW", + "LAS", + "RICH", + "JOES", + "SLU", + "SBON", + "UMASS", + "URI", + "VCU" + ], + ACC: [ + "BC", + "CLEM", + "DUKE", + "FSU", + "GT", + "LOU", + "MIA", + "NCST", + "UNC", + "ND", + "PITT", + "SYR", + "UVA", + "VT", + "WAKE" + ], + "Atlantic Sun": [ + "FGCU", + "JAC", + "KENN", + "LIP", + "NJIT", + "UNF", + "UPST", + "STET" + ], + "Big 12": [ + "BAY", + "ISU", + "KU", + "KSU", + "OKLA", + "OKST", + "TCU", + "TEX", + "TTU", + "WVU" + ], + "Big East": [ + "BUT", + "CREI", + "DEP", + "GTWN", + "MARQ", + "PROV", + "HALL", + "SJU", + "VILL", + "XAV" + ], + "Big Sky": [ + "EWU", + "IDHO", + "IDST", + "MONT", + "MTST", + "NAU", + "PRST", + "SAC", + "SUU", + "UNCO", + "UND", + "WEB" + ], + "Big South": [ + "CAM", + "CHSO", + "WEBB", + "HP", + "LIB", + "LONG", + "PRE", + "RAD", + "UNCA", + "WIN" + ], + "Big Ten": [ + "ILL", + "IND", + "IOWA", + "MD", + "MICH", + "MSU", + "MINN", + "NEB", + "NW", + "OSU", + "PSU", + "PUR", + "RUTG", + "WIS" + ], + "Big West": [ + "CP", + "CSF", + "CSUN", + "HAW", + "LBSU", + "UCD", + "UCI", + "UCRV", + "UCSB" + ], + Colonial: [ + "COFC", + "DEL", + "DREX", + "ELON", + "HOF", + "JMU", + "NE", + "TOWS", + "UNCW", + "WM" + ], + "Conference USA": [ + "CHAR", + "FAU", + "FIU", + "LT", + "MRSH", + "MTU", + "ODU", + "RICE", + "UAB", + "UNT", + "USM", + "UTSA", + "UTEP", + "WKU" + ], + Horizon: [ + "CLEV", + "DET", + "GB", + "IUPU", + "MILW", + "NKU", + "OAK", + "UIC", + "WRST", + "YSU" + ], + Ivy: ["BRWN", "CLMB", "COR", "DART", "HARV", "PENN", "PRIN", "YALE"], + MAAC: [ + "CAN", + "FAIR", + "IONA", + "MAN", + "MRST", + "MONM", + "NIAG", + "QUIN", + "RID", + "SPU", + "SIE" + ], + "Mid-American": [ + "AKR", + "BALL", + "BGSU", + "BUFF", + "CMU", + "EMU", + "KENT", + "M-OH", + "NIU", + "OHIO", + "TOL", + "WMU" + ], + MEAC: [ + "BCU", + "COPP", + "DSU", + "FAMU", + "HAMP", + "HOW", + "MORG", + "NSU", + "NCAT", + "NCCU", + "SAV", + "SCST", + "UMES" + ], + "Missouri Valley": [ + "BRAD", + "DRKE", + "EVAN", + "ILST", + "INST", + "L-IL", + "MOST", + "UNI", + "SIU", + "VALP" + ], + "Mountain West": [ + "AFA", + "BSU", + "CSU", + "FRES", + "NEV", + "UNM", + "SDSU", + "SJSU", + "UNLV", + "USU", + "WYO" + ], + Northeast: [ + "BRY", + "CCSU", + "FDU", + "LIU", + "MSM", + "RMU", + "SHU", + "SFNY", + "SFU", + "WAG" + ], + "Ohio Valley": [ + "BEL", + "EIU", + "EKY", + "JVST", + "MORE", + "MURR", + "PEAY", + "SEMO", + "SIUE", + "TNST", + "TNTC", + "UTM" + ], + "Pac-12": [ + "ARIZ", + "ASU", + "CAL", + "COLO", + "ORE", + "ORST", + "STAN", + "UCLA", + "USC", + "UTAH", + "WASH", + "WSU" + ], + "Patriot League": [ + "AMER", + "ARMY", + "BU", + "BUCK", + "COLG", + "HC", + "LAF", + "LEH", + "L-MD", + "NAVY" + ], + SEC: [ + "ALA", + "ARK", + "AUB", + "FLA", + "LSU", + "MSST", + "MIZ", + "MISS", + "SC", + "TENN", + "TAMU", + "UGA", + "UK", + "VAN" + ], + Southern: [ + "CHAT", + "ETSU", + "FUR", + "MER", + "SAM", + "CIT", + "UNCG", + "VMI", + "WCU", + "WOF" + ], + Southland: [ + "ACU", + "AMCC", + "HBU", + "IW", + "LAM", + "MCNS", + "NICH", + "NWST", + "SHSU", + "SELA", + "SFA", + "UCA", + "UNO" + ], + SWAC: [ + "AAMU", + "ALST", + "ALCN", + "GRAM", + "JKST", + "MVSU", + "PV", + "SOU", + "TXSO", + "UAPB" + ], + "Summit League": [ + "DEN", + "IPFW", + "NDSU", + "OMA", + "ORU", + "SDAK", + "SDST", + "WIU" + ], + "Sun Belt": [ + "APP", + "ARST", + "CCAR", + "GASO", + "GAST", + "TXST", + "TROY", + "UALR", + "ULL", + "ULM", + "USA", + "UTA" + ], + "West Coast": [ + "BYU", + "GONZ", + "LMU", + "PAC", + "PEPP", + "PORT", + "SMC", + "USD", + "SF", + "SCU" + ], + WAC: ["CHS", "CSB", "GCU", "NMSU", "SEA", "TRGV", "UMKC", "UVU"], + "Top 25": ["@T25"] //special indicator for Top 25 ranked teams + }, + + NCAAM_MM: {}, //no groups for March Madness //Generally no divisions / conferences for soccer - EPL : {}, - ENGCHMP : {}, - UEFACHMP : {}, - UEFAEUROPA : {}, - UEFANATIONS : {}, - FIFAWC : {}, - BRASILEIRAO : {}, - BUNDESLIGA : {}, + EPL: {}, + ENGCHMP: {}, + UEFACHMP: {}, + UEFAEUROPA: {}, + UEFANATIONS: {}, + FIFAWC: {}, + BRASILEIRAO: {}, + BUNDESLIGA: {}, FRL1: {}, - LALIGA : {}, - LIBERTADORES : {}, - MEX : {}, - SERIEA : {} - - + LALIGA: {}, + LIBERTADORES: {}, + MEX: {}, + SERIEA: {} } - -}); \ No newline at end of file +}); diff --git a/node_helper.js b/node_helper.js index 8780929..9874f57 100644 --- a/node_helper.js +++ b/node_helper.js @@ -1,20 +1,17 @@ const NodeHelper = require("node_helper"); module.exports = NodeHelper.create({ - providers: {}, - start: function() { + start: function () { console.log("Starting node_helper for module [" + this.name + "]"); this.providers.SNET = require("./providers/SNET.js"); this.providers.ESPN = require("./providers/ESPN.js"); }, - socketNotificationReceived: function(notification, payload) { - + socketNotificationReceived: function (notification, payload) { if (notification == "MMM-MYSCOREBOARD-GET-SCORES") { - /* payload contains: provider to get data from @@ -28,16 +25,19 @@ module.exports = NodeHelper.create({ var self = this; var provider = this.providers[payload.provider]; - provider.getScores(payload.league, payload.teams, payload.gameDate, payload.language, function(scores) { - self.sendSocketNotification("MMM-MYSCOREBOARD-SCORE-UPDATE", {instanceId: payload.instanceId, index: payload.index, scores: scores}); - }); - - + provider.getScores( + payload.league, + payload.teams, + payload.gameDate, + payload.language, + function (scores) { + self.sendSocketNotification("MMM-MYSCOREBOARD-SCORE-UPDATE", { + instanceId: payload.instanceId, + index: payload.index, + scores: scores + }); + } + ); } - - }, - - - - -}); \ No newline at end of file + } +});