-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
780 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
$(document).ready(function() { | ||
|
||
Vue.component('game-info', { | ||
data: function () { | ||
return { | ||
message: 'Hey there!', | ||
} | ||
}, | ||
template: '<div class="game-info">{{ message }}</div>' | ||
}); | ||
|
||
Vue.component('game-box', { | ||
props: ['datetime', 'sport', 'team1', 'team2'], | ||
template: | ||
`<div class="game" v-on:click="viewGame"> | ||
<div class="time-container col-sm-3"> | ||
<p class="time alt-text" v-text="datetime"></p> | ||
</div> | ||
<div class="info-container col-sm-9"> | ||
<p class="sport alt-text" v-text="sport"></p> | ||
<div class="team1 col-sm-3" v-text="team1"></div> | ||
<div class="vs col-sm-3">VS</div> | ||
<div class="team2 col-sm-3" v-text="team2"></div> | ||
</div> | ||
</div>`, | ||
methods: { | ||
viewGame: function(event) { | ||
var target = event.currentTarget; | ||
$(target).addClass('game-click'); | ||
$('.game-info').show(); | ||
setTimeout(function() { | ||
$(target).removeClass('game-click'); | ||
}, 400); | ||
} | ||
}, | ||
}); | ||
|
||
Vue.component('games', { | ||
props: ['games_list'], | ||
template: | ||
`<div id="games"> | ||
<game-box | ||
v-for="game in games_list" | ||
:datetime="game.datetime" | ||
:sport="game.sport.name" | ||
:team1="game.team1.name" | ||
:team2="game.team2.name"> | ||
</game-box> | ||
</div>` | ||
}); | ||
|
||
new Vue({ | ||
el: '#home', | ||
data: { | ||
games_list: [], | ||
}, | ||
created: function() { | ||
this.scroll(); | ||
this.getGames(); | ||
}, | ||
methods: { | ||
scroll: function() { | ||
var that = this; | ||
window.addEventListener('scroll', function () { | ||
if($(window).scrollTop() + $(window).height() == $(document).height()) { | ||
that.getGames(); | ||
} | ||
}) | ||
}, | ||
getGames: function() { | ||
var that = this; | ||
var lastDateTimeString = getLastDateTime(this.games_list) | ||
var lock = true; | ||
|
||
$.ajax({ | ||
url: `/games.json?game_datetime=${lastDateTimeString}`, | ||
success: function(res) { | ||
res.games.forEach(function(game) { | ||
that.games_list.push(game); | ||
}); | ||
lock = false; | ||
} | ||
}); | ||
} | ||
} | ||
}); | ||
|
||
function getDateTime() { | ||
var today = new Date(); | ||
var yr = today.getFullYear(); | ||
var month = today.getMonth() + 1; | ||
var day = today.getDate(); | ||
return yr + '-' + month + '-' + day + ' 00:00:00'; | ||
} | ||
|
||
function getLastDateTime(games_array) { | ||
if (games_array.length === 0) { | ||
return getDateTime(); | ||
} else { | ||
return games_array[games_array.length - 1].datetime; | ||
} | ||
} | ||
|
||
|
||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.