Skip to content

Commit

Permalink
support item automatic expire
Browse files Browse the repository at this point in the history
  • Loading branch information
changkun committed May 13, 2018
1 parent 69e80e5 commit ea95710
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 18 deletions.
13 changes: 12 additions & 1 deletion schedule.js → database.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
const schedule = [
const messages = [
{
"info": "Announcement: No reading group on 21.05.2018",
"termination": "21.05.2018",
},
{
"info": "This is an outdated message on 1.05.2018",
"termination": "1.05.2018",
},
]

const schedules = [
{
"person": "Georgia Olympia Brikis",
"email": null,
Expand Down
48 changes: 31 additions & 17 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,26 @@ <h3>A paper reading group for students of Ludwig Maximilians University of Munic

<h4>Location: Mondays 9am, L U117 (Data Science Lab), Oettingenstrasse 67, Munich, Germany</h4>
<h4>Topics: Machine Learning, Deep Learning, Computer Vision, Natural Language Processing</h4>

<ul class="announcement">
<li v-for="message in messages"
v-if="!isAnnouncementOutDated(message)">
<h4>
{{ message.info }}
</h4>
</li>
</ul>

<h4 class="announcement">Announcement: no reading group on 21.05.2018</h4>
</div>
<div class="schedule" v-for="event in events">
<div class="schedule" v-for="event in events" v-if="event.schedules.length > 0">
<h2>{{event.header}}</h2>
<div class="meeting" v-for="item in event.schedule">
<div class="person label"><i class="fas fa-user-circle"></i> {{ item.person }}</div>
<div class="date label"><i class="far fa-calendar-alt"></i> {{ item.date }}</div>
<div class="meeting" v-for="schedule in event.schedules">
<div class="person label"><i class="fas fa-user-circle"></i> {{ schedule.person }}</div>
<div class="date label"><i class="far fa-calendar-alt"></i> {{ schedule.date }}</div>
<div class="paper">
{{ item.paper }}
<a :href="item.link" target="_blank" v-if="haslink(item)"><i class="fas fa-external-link-alt"></i></a>
<div class="material" v-for="material in item.materials">
{{ schedule.paper }}
<a :href="schedule.link" target="_blank" v-if="haslink(schedule)"><i class="fas fa-external-link-alt"></i></a>
<div class="material" v-for="material in schedule.materials">
<a :href="material"><i class="fas fa-paperclip"></i></a>
</div>
</div>
Expand All @@ -160,44 +168,50 @@ <h2 class="title">Organizers</h2>
</ul>
</div>
</div>
<script src="schedule.js"></script>
<script src="database.js"></script>
<script>
const date_parser = (d) => {
let date = d.split('.')
return new Date(parseInt(date[2]), parseInt(date[1])-1, parseInt(date[0]))
}
const app = new Vue({
el: '#app',
data: {
schedule: schedule
schedules: schedules,
messages: messages
},
methods: {
haslink: (meeting) => {
return meeting.link === null ? false : true
},
isAnnouncementOutDated: (announcement) => {
const today = new Date()
return date_parser(announcement.termination) <= today ? true : false
}
},
computed: {
events: () => {
const date_parser = (d) => {
let date = d.split('.')
return new Date(parseInt(date[2]), parseInt(date[1])-1, parseInt(date[0]))
}
const f = (rule) => {
return (meeting) => {
date = date_parser(meeting.date)
const today = new Date()
today.setHours(0, 0, 0, 0) // only compare date
return rule(date, today)
}
}
const compare = (m1, m2) => {
let date1 = date_parser(m1.date)
let date2 = date_parser(m2.date)
return date1 > date2 ? -1 : date1 < date2 ? 1 : 0;
return (date1 > date2) ? -1 : (date1 < date2 ? 1 : 0)
}
return [
{
header: 'Upcoming',
schedule: schedule.filter(f((a, b) => a > b ? true : false)).sort(compare)
schedules: schedules.filter(f((a, b) => a >= b ? true : false)).sort(compare)
},
{
header: 'Finished',
schedule: schedule.filter(f((a, b) => a > b ? false : true)).sort(compare)
schedules: schedules.filter(f((a, b) => a < b ? true : false)).sort(compare)
}
]
}
Expand Down

0 comments on commit ea95710

Please sign in to comment.