[ { "id": "4e89cc08.dc99f4", "type": "http in", "z": "27c9fb93.5d22f4", "name": "", "url": "/scoreboard", "method": "get", "upload": false, "swaggerDoc": "", "x": 100, "y": 80, "wires": [ [ "898a8a6b.39ed18" ] ] }, { "id": "f4db0c8c.4b32f", "type": "template", "z": "27c9fb93.5d22f4", "name": "HTML", "field": "payload", "fieldType": "msg", "format": "handlebars", "syntax": "mustache", "template": "
\n
\n \n \n \n \n
\n
\n\n\n \n {{#payload}}\n \n \n \n \n \n \n \n {{/payload}}\n \n
{{visitorPts}}\n {{status}}\n\n {{homePts}}
\n", "output": "str", "x": 1110, "y": 80, "wires": [ [ "a167e41e.187f58" ] ] }, { "id": "317e30d5.229b2", "type": "http in", "z": "27c9fb93.5d22f4", "name": "", "url": "/scoreboard", "method": "post", "upload": false, "swaggerDoc": "", "x": 110, "y": 200, "wires": [ [ "95e1654b.659098" ] ] }, { "id": "46819eef.6ddb9", "type": "http response", "z": "27c9fb93.5d22f4", "name": "", "statusCode": "", "headers": {}, "x": 1110, "y": 200, "wires": [] }, { "id": "898a8a6b.39ed18", "type": "function", "z": "27c9fb93.5d22f4", "name": "get today's date", "func": "var tzoffset = (new Date()).getTimezoneOffset() * 60000; \nmsg.date = (new Date(Date.now() - tzoffset)).toISOString().slice(0, 10);\nreturn msg;", "outputs": 1, "noerr": 0, "x": 300, "y": 80, "wires": [ [ "ebdefffe.54929" ] ] }, { "id": "a167e41e.187f58", "type": "link out", "z": "27c9fb93.5d22f4", "name": "Scoreboard", "links": [ "3867cf53.b064e", "13cbe348.6a8f1d", "220161cc.3a9fde" ], "x": 1215, "y": 80, "wires": [] }, { "id": "198dbb79.129655", "type": "http in", "z": "27c9fb93.5d22f4", "name": "", "url": "/public/scoreboard.js", "method": "get", "upload": false, "swaggerDoc": "", "x": 130, "y": 320, "wires": [ [ "282522b0.6c039e" ] ] }, { "id": "6662b25e.42e2cc", "type": "http response", "z": "27c9fb93.5d22f4", "name": "", "statusCode": "", "headers": {}, "x": 600, "y": 320, "wires": [] }, { "id": "282522b0.6c039e", "type": "template", "z": "27c9fb93.5d22f4", "name": "javascript", "field": "payload", "fieldType": "msg", "format": "javascript", "syntax": "mustache", "template": "async function updateDate(event) {\n event.preventDefault(); \n var date = document.getElementById(\"date\").value;\n var body = {\"date\": date};\n var response = await fetch(\"/scoreboard\", {\n \"method\": \"POST\", \n \"body\": JSON.stringify(body),\n \"headers\": {\"Content-Type\": \"application/json\"}\n })\n var data = await response.json()\n emptyTable(); \n addDataToTable(data);\n}\n\nfunction createIconImg(src) {\n var img = document.createElement(\"img\");\n img.src = src; \n img.className = \"icon\";\n return img; \n}\n\nfunction addDataToTable(data){\n var tbody = document.getElementById(\"tbody\");\n data.forEach((element, index, array) => {\n var row = tbody.insertRow(); \n var cell = row.insertCell(); \n var img = createIconImg(element.visitorIcon);\n cell.appendChild(img);\n \n cell = row.insertCell(); \n cell.innerText = element.visitorPts;\n \n cell = row.insertCell(); \n var a = document.createElement(\"a\");\n a.href = \"/boxscore/\" + element.gameId;\n a.innerText = element.status;\n cell.appendChild(a);\n \n cell = row.insertCell(); \n cell.innerText = element.homePts;\n \n cell = row.insertCell(); \n img = createIconImg(element.homeIcon)\n cell.appendChild(img);\n });\n}\n\nfunction removeChildren(elem) {\n while (elem.firstChild) {\n elem.removeChild(elem.firstChild);\n }\n}\n\nfunction emptyTable() {\n var tbody = document.getElementById(\"tbody\");\n removeChildren(tbody);\n}\n", "output": "str", "x": 400, "y": 320, "wires": [ [ "6662b25e.42e2cc" ] ] }, { "id": "3deb6d39.13f172", "type": "template", "z": "27c9fb93.5d22f4", "name": "CSS", "field": "payload", "fieldType": "msg", "format": "css", "syntax": "mustache", "template": ".icon {\n height: 7.5vh;\n width: auto;\n}\n\n#scoreboard {\n width:50%;\n margin: auto;\n}\n\n#date-form {\n width:50%;\n margin: auto auto 1rem auto;\n}", "output": "str", "x": 390, "y": 380, "wires": [ [ "740950e7.14122" ] ] }, { "id": "3aa633ca.4e414c", "type": "http in", "z": "27c9fb93.5d22f4", "name": "", "url": "/public/scoreboard.css", "method": "get", "upload": false, "swaggerDoc": "", "x": 130, "y": 380, "wires": [ [ "3deb6d39.13f172" ] ] }, { "id": "740950e7.14122", "type": "http response", "z": "27c9fb93.5d22f4", "name": "", "statusCode": "", "headers": { "Content-Type": "text/css" }, "x": 610, "y": 380, "wires": [] }, { "id": "ebdefffe.54929", "type": "league", "z": "27c9fb93.5d22f4", "name": "scoreboard", "league_type": "scoreboard", "season": "2018-19", "season_type": "Regular Season", "game_date": "{{date}}", "per_mode": "PerGame", "stat_category": "PTS", "sorter": "PTS", "player_or_team": "Player", "measure_type": "Base", "ahead_behind": "Ahead or Behind", "point_diff": "", "clutch_time": "Last 5 Minutes", "group_quantity": "5", "pt_measure_type": "CatchShoot", "close_def_dist_range": "", "dribble_range": "", "touch_time_range": "", "shot_clock_range": "", "general_range": "", "x": 490, "y": 80, "wires": [ [ "7ad4c3f9.6ae63c" ] ] }, { "id": "95e1654b.659098", "type": "league", "z": "27c9fb93.5d22f4", "name": "scoreboard", "league_type": "scoreboard", "season": "2018-19", "season_type": "Regular Season", "game_date": "{{req.body.date}}", "per_mode": "PerGame", "stat_category": "PTS", "sorter": "PTS", "player_or_team": "Player", "measure_type": "Base", "ahead_behind": "Ahead or Behind", "point_diff": "", "clutch_time": "Last 5 Minutes", "group_quantity": "5", "pt_measure_type": "CatchShoot", "close_def_dist_range": "", "dribble_range": "", "touch_time_range": "", "shot_clock_range": "", "general_range": "", "x": 390, "y": 200, "wires": [ [ "7ad4c3f9.6ae63c" ] ] }, { "id": "7ad4c3f9.6ae63c", "type": "function", "z": "27c9fb93.5d22f4", "name": "format response", "func": "var header = msg.payload.sports_content.games.game; \n\nvar response = [];\n\nheader.forEach((game) => {\n var home = game.home; \n var visitor = game.visitor; \n var obj = {\n \"visitorIcon\": \"https://raw.githubusercontent.com/Arieg419/NBA_Scorecard/master/src/client/src/img/\" + visitor.team_key + \".png\",\n \"visitorTeam\": visitor.team_key,\n \"visitorPts\": visitor.score,\n \"homeTeam\": home.team_key, \n \"homePts\": home.score,\n \"homeIcon\": \"https://raw.githubusercontent.com/Arieg419/NBA_Scorecard/master/src/client/src/img/\" + home.team_key + \".png\",\n \"status\": game.period_time.period_status,\n \"gameId\": game.id\n }\n response.push(obj);\n});\n\nmsg.script = \"scoreboard.js\";\nmsg.css = \"scoreboard.css\";\nmsg.payload = response; \n\nreturn msg;", "outputs": 1, "noerr": 0, "x": 720, "y": 140, "wires": [ [ "14a10be5.18795c" ] ] }, { "id": "14a10be5.18795c", "type": "switch", "z": "27c9fb93.5d22f4", "name": "req.method", "property": "req.method", "propertyType": "msg", "rules": [ { "t": "eq", "v": "GET", "vt": "str" }, { "t": "eq", "v": "POST", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 930, "y": 140, "wires": [ [ "f4db0c8c.4b32f" ], [ "46819eef.6ddb9" ] ] }, { "id": "220161cc.3a9fde", "type": "link in", "z": "27c9fb93.5d22f4", "name": "Render", "links": [ "6f04b46b.aebf4c", "ce87bc5c.6da2", "1149517.f7753af", "3e961365.f7699c", "b5ec5b43.b16828", "609d03f1.35666c", "8caa9b06.428e28", "96990762.9b1898", "a167e41e.187f58", "3280a0a0.92805", "dc05fa7c.6de4d8", "dbfa7c7.675528", "8277d77b.0f2798", "2fa36897.334258", "cf043fe5.aa0cf", "9bb29777.a44a08", "73e4455.40aeebc" ], "x": 35, "y": 480, "wires": [ [ "bec08f9.0b2b5f" ] ] }, { "id": "bec08f9.0b2b5f", "type": "template", "z": "27c9fb93.5d22f4", "name": "main template", "field": "payload", "fieldType": "msg", "format": "handlebars", "syntax": "mustache", "template": "\n\n \n \n \n \n \n \n {{!----}}\n\n NBA\n\n \n \n \n \n \n \n \n\n \n\n \n\n
\n {{{payload}}}\n
\n\n \n\n \n \n \n \n \n \n \n \n\n", "output": "str", "x": 175, "y": 480, "wires": [ [ "d79b475.090b7b8" ] ] }, { "id": "d79b475.090b7b8", "type": "http response", "z": "27c9fb93.5d22f4", "name": "", "statusCode": "", "headers": {}, "x": 395, "y": 480, "wires": [] } ]