'use strict'; angular.module('simplePvrFilters', []). filter('formatEpisode', function() { return function(episodeNum) { return episodeNum ? episodeNum.replace(' .', '').replace('. ', '') : ''; } }). filter('filteredWeekdays', function() { return function(schedule) { if (!schedule.filter_by_weekday) { return ''; } var selectedWeekdays = []; if (schedule.monday) selectedWeekdays.push('Mondays'); if (schedule.tuesday) selectedWeekdays.push('Tuesdays'); if (schedule.wednesday) selectedWeekdays.push('Wednesdays'); if (schedule.thursday) selectedWeekdays.push('Thursdays'); if (schedule.friday) selectedWeekdays.push('Fridays'); if (schedule.saturday) selectedWeekdays.push('Saturdays'); if (schedule.sunday) selectedWeekdays.push('Sundays'); var days = ''; if (selectedWeekdays.length == 0) { return '' } else if (selectedWeekdays.length == 1) { days = selectedWeekdays[0]; } else if (selectedWeekdays.length == 2) { days = selectedWeekdays[0] + ' and ' + selectedWeekdays[1]; } else { for (var i=0; i 0) { return '(' + sentences.join(', ') + ')'; } return ''; } });