Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<script src="js/ical_parser.js"></script>
<script src="js/moment-with-langs.min.js"></script>
<script src="js/config.js"></script>
<script src="js/rrule.js"></script>
<script src="js/main.js?nocache=<?php echo md5(microtime()) ?>"></script>
<script src="js/socket.io.min.js"></script>

Expand Down
31 changes: 29 additions & 2 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,36 @@ jQuery(document).ready(function($) {
}else {
var time_string = moment(startDate).calendar()
}
eventList.push({'description':e.SUMMARY,'seconds':seconds,'days':time_string});
if (!e.RRULE) {
eventList.push({'description':e.SUMMARY,'seconds':seconds,'days':time_string});
}
e.seconds = seconds;
}
};

// Special handling for rrule events
if (e.RRULE) {
var options = new RRule.parseString(e.RRULE);
options.dtstart = e.startDate;
var rule = new RRule(options);

// TODO: don't use fixed end date here, use something like now() + 1 year
var dates = rule.between(new Date(), new Date(2016,11,31), true, function (date, i){return i < 10});
for (date in dates) {
var dt = new Date(dates[date]);
var days = moment(dt).diff(moment(), 'days');
var seconds = moment(dt).diff(moment(), 'seconds');
var startDate = moment(dt);
if (seconds >= 0) {
if (seconds <= 60*60*5 || seconds >= 60*60*24*2) {
var time_string = moment(dt).fromNow();
} else {
var time_string = moment(dt).calendar()
}
eventList.push({'description':e.SUMMARY,'seconds':seconds,'days':time_string});
}
}
}
};
eventList.sort(function(a,b){return a.seconds-b.seconds});

setTimeout(function() {
Expand Down
Loading