From c54dd07563306992589def3bb869c04b3b03f6a3 Mon Sep 17 00:00:00 2001 From: hummypkg Date: Tue, 14 Apr 2015 21:15:20 +0000 Subject: [PATCH] dayfilter git-svn-id: file:///root/webif/svn/pkg/webif/trunk@2395 2a923420-c742-0410-a762-8d5b09965624 --- webif/html/sched/script.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/webif/html/sched/script.js b/webif/html/sched/script.js index 2180f7e..601d334 100755 --- a/webif/html/sched/script.js +++ b/webif/html/sched/script.js @@ -363,12 +363,26 @@ $('#mrform input.time').timepicker({ step:5 }); +function dayfilter(date) +{ + var cur = $('#mrrepeat').val(); + if (cur < 3) return [1, ""]; + + var day = date.getDay(); + if (cur == 3) // Weekdays only + return [(day > 0 && day < 6), ""]; + else // Weekends only + return [day == 0 || day >= 6, ""]; +} + $('#mrsdate').datepicker({ + firstDay: 1, defaultDate: 0, minDate: 0, maxDate: "+1Y", dateFormat: "D, dd/mm/yy", autoclose: true, + beforeShowDay: dayfilter, onClose: function(s) { var dat = $(this).datepicker('getDate'); if (dat) @@ -381,11 +395,17 @@ $('#mrsdate').datepicker({ }); $('#mredate').datepicker({ + firstDay: 1, defaultDate: 0, minDate: 0, maxDate: "+1Y", autoclose: true, dateFormat: "D, dd/mm/yy", + beforeShowDay: dayfilter +}); + +$('#mrrepeat').on('change', function() { + $('#mrform input.date').datepicker('refresh'); }); $('#mrform').datepair({