-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
138 lines (125 loc) · 3.22 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<!DOCTYPE html>
<html>
<head>
<title>Sport Alarm</title>
<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">
</head>
<body>
<div id="app">
<div v-if="isFenwayGame(getGames())" class="redsox game-alert">
<h1 class='alert-icon'><i class="fa fa-baseball-ball"></i></h1>
<h1>Red Sox Home Game</h1>
<h2>@ {{ fenwayGame.home_time }} {{ fenwayGame.ampm }}</h2>
</div>
<div v-if="!isFenwayGame(getGames())" class="game-alert nogame">
<h1>No Games Today!</h1>
<h2>Everything is good.</h2>
</div>
</div>
<script>
var app = new Vue({
el: '#app',
data: {
games: {},
homeGames: {},
fenwayGame: {},
},
methods: {
getGames: function() {
gameData = this
.$data
.games
.data
.data
.games
.game
return gameData
},
buildQuery: function (date) {
let thisMonth = date.getMonth() + 101;
thisMonth = thisMonth.toString().slice(-2);
let queryString = "https://gd2.mlb.com/components/game/mlb/year_" + date.getFullYear() + "/month_" + thisMonth + "/day_" + (date.getDate()) + '/miniscoreboard.json'
return queryString;
},
isFenwayGame: function (games) {
for (game in games) {
if (games[game].home_team_city.indexOf("Boston") !== -1 ){
document.title="🚨 SPORT ALARM 🚨"
this.fenwayGame = games[game];
return true;
}
else {
document.title="Sport Alarm"
}
}
return false;
}
},
mounted () {
axios
.get(this.buildQuery(new Date()))
.then(response => (this.games = response));
}
})
</script>
<style type="text/css">
html{
height: 100%;
}
body{
padding: 0;
margin: 0;
height: 100%;
}
#app {
display: flex;
flex-flow: column nowrap;
justify-content: stretch;
align-items: stretch;
padding: 0;
height: 100%;
}
.game-alert {
display: flex;
flex-flow: column nowrap;
align-items: center;
justify-content: center;
height: 100%;
padding: 50px;
text-align: center;
font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif
}
.game-alert h1 {
text-align: center;
font-size: 6rem;
margin: 1rem;
}
.game-alert .alert-icon {
font-size: 8rem;
}
.game-alert h2 {
text-align: center;
font-size: 4rem;
opacity: 0.6;
}
.nogame{
background: lightgray;
color: gray;
}
.redsox {
background: red;
color: white;
animation-name: redsox;
animation-duration: 4s;
animation-direction: alternate;
animation-iteration-count: infinite;
}
@keyframes redsox {
from {background: #da1e1e;}
to {background: #a90000}
}
</style>
</body>
</html>