PageSourceSearch

https://app.realplans.com/Scripts/New_Scripts/jsRapCalendar.js

js realplans.com collected 2026-10-02 04:57:06 UTC 14,722 bytes, 336 lines download raw bytes

1function D3ToStr(y, m, d) {
2    m++;
3    if (m < 10) m = '0' + m;
4    if (d < 10) d = '0' + d;
5    return y + '-' + m + '-' + d;
6}
7function D3ToDate(y, m, d) {
8    return new Date(y, m, d, 0, 0, 0, 0);
9}
10function DateToD3(date) {
11    date = new Date(date);
12    var y = date.getFullYear();
13    var m = date.getMonth();
14    var d = date.getDate();
15    return { y: y, m: m, d: d };
16}
17function DateToStr(date) {
18    var d3 = DateToD3(date);
19    return D3ToStr(d3.y, d3.m, d3.d);
20}
21function DaysInMonth(year, month) {
22    return new Date(year, month, 0).getDate();
23}
24function StrToDate(s) {
25    var y = parseInt(s.substring(0, 4), 10);
26    var m = parseInt(s.substring(5, 7), 10);
27    var d = parseInt(s.substring(8, 10), 10);
28    return D3ToDate(y, m - 1, d);
29}
30
31var hoverStyle = false
32var startDate = '';
33var endDate = '';
34var EndMonth;
35(function ($) {
36    $.fn.jsRapCalendar = function (options) {
37        return this.each(function () {
38            var d = new Date();
39            if (options.date != null && Option.date != undefined) {
40                d= options.date
41            }
42            this.opt = $.extend({
43                enabled: true,
44                showCaption: true,
45                showYear: true,
46                showArrows: true,
47                notShowSheduleOptions: false,
48                scheduleButton: "Schedule",
49                IsWhole30Setting: false,
50                IsMealPlantemplate: false,
51                Customercallcalendar: false,
52                PlannerAction:false,
53                MaxDay: 0,
54                CurrentPlanMindate: null,
55                CurrentPlanMaxdate: null,
56                minDate: DateToStr(d),
57                date: d,
58                daysName: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
59                monthsNames: ['January', 'February', 'March', 'April', 'May', 'Jun', 'July', 'August', 'September', 'October', 'November', 'December'],
60                onClick: null,
61                onmouseover: null,
62                onmouseout: null,
63
64            }, options);
65            var base = this;
66            d3 = DateToD3(this.opt.date);
67            this.curYear = d3.y;
68            this.curMonth = d3.m;
69            this.curDay = d3.d;
70            var curWeek = this.opt.date.getDay();
71            this.selY = this.curYear;
72            this.selM = this.curMonth;
73            this.selD = this.curDay;
74            if (this.opt.IsMealPlantemplate) {
75                startDate = DateToStr(d);
76                var dt = new Date();
77                dt.setDate(dt.getDate() + this.opt.MaxDay);
78
79                endDate = DateToStr(dt);
80                EndMonth = DateToD3(endDate).m;
81            }
82            hoverStyle = this.opt.notShowSheduleOptions;
83            $(this).addClass('rapCalendar');
84            var table = $('<table class="day">').appendTo($(this));
85            if (this.opt.showCaption) {
86                this.caption = $('<caption>').appendTo(table);
87                this.cap = $('<span>').appendTo(this.caption);
88                if (this.opt.showArrows) {
89                    this.larr = $('<div>').addClass('larr').addClass("cal-disabled").prependTo(this.caption);
90                    this.rarr = $('<div>').addClass('rarr').appendTo(this.caption);
91
92                }
93            } else
94                this.caption = false;
95            var head = $('<thead>').appendTo(table);
96            var dayNames = $('<tr>').appendTo(head);
97            for (var n = 0; n < 7; n++)
98                $('<th>').text(this.opt.daysName[(n + 7 - this.opt.week) % 7]).appendTo(dayNames);
99            var tbody = $('<tbody>').appendTo(table);
100            $(this.larr).bind({
101
102                click: function (e) {
103                    dataValue = 0;
104                    isDayGetSelected = false;
105                    selectedHtml = "";
106                    if ($(this).hasClass("cal-disabled")) {
107                        return false
108                    }
109                    else {
110                        base.ShowMonth(base.curYear, base.curMonth, -1);
111                    }
112                }
113            });
114
115            $(this.rarr).bind({
116                click: function (e) {
117                    dataValue = 0;
118                    isDayGetSelected = false;
119                    selectedHtml = "";
120                    if ($(this).hasClass("cal-disabled")) {
121                        return false
122                    }
123                    else {
124                        base.ShowMonth(base.curYear, base.curMonth, 1);
125                    }
126                }
127            });
128
129            this.ShowMonth = function (year, month, del) {
130                this.curYear = year;
131                this.curMonth = month + del;
132                if (this.curMonth < 0) {
133                    this.curMonth = 11;
134                    this.curYear--;
135                }
136                if (this.curMonth > 11) {
137                    this.curMonth = 0;
138                    this.curYear++;
139                }
140                if (this.caption) {
141                    var s = this.opt.monthsNames[this.curMonth];
142                    if (this.opt.showYear)
143                        s += ' ' + this.curYear;
144                    $(this.cap).text(s);
145                }
146                $(tbody).empty();
147                var dim = DaysInMonth(this.curYear, this.curMonth + 1);
148                var tr = $('<tr>').appendTo(tbody);
149                var td = null;
150                var fd = (new Date(this.curYear, this.curMonth, 1).getDay() + this.opt.week) % 7;
151                var todayDay = new Date().getDate();
152                var todayMonth = new Date().getMonth();
153                var Mindatecurrplan = DateToStr(this.opt.CurrentPlanMindate);
154                var MaxdateCurrPlan = DateToStr(this.opt.CurrentPlanMaxdate);
155                var CurrentDate;
156                //Enable of disabled Month arrow
157                if (todayMonth != this.curMonth) {
158                    this.larr.removeClass("cal-disabled");
159                }
160                else {
161                    this.larr.addClass("cal-disabled");
162                }
163                var todayYear = new Date().getFullYear();
164                for (var n = 0; n < fd; n++)
165                    td = $('<td>').appendTo(tr);
166                for (var n = 1; n <= dim; n++) {
167                    if ($(tr).children().length > 6)
168                        tr = $('<tr>').appendTo(tbody);
169                    var d = $("<a>").text(n).appendTo($('<td>').appendTo(tr));
170                    if (!this.opt.notShowSheduleOptions) {
171                        if (this.opt.PlannerAction) {
172                            CurrentDate = D3ToStr(this.curYear, this.curMonth, n)
173                            if (CurrentDate < Mindatecurrplan || CurrentDate > MaxdateCurrPlan) {
174                                d.addClass('calDisable');
175                            }
176                            else if (this.opt.enabled)
177                                d.addClass('calSelectable');
178                            this.larr.removeClass("cal-disabled");
179                        } else {
180                            if (D3ToStr(this.curYear, this.curMonth, n) < this.opt.minDate)
181                                d.addClass('calDisable');
182                            else if (this.opt.enabled)
183                                d.addClass('calSelectable');
184                        }
185                    }
186                    else {
187
188                        if (this.opt.IsWhole30Setting) {
189                            CurrentDate = D3ToStr(this.curYear, this.curMonth, 1)
190                            var dt = new Date();
191                            dt.setDate(dt.getDate() - 30);
192                            this.opt.minDate = dt;
193                            this.opt.minDate = DateToStr(this.opt.minDate)
194                            if (D3ToStr(this.curYear, this.curMonth, n) < this.opt.minDate)
195                                d.addClass('calDisable');
196                            else if (this.opt.enabled)
197                                d.addClass('calSelectable');
198                        }
199                        else if (this.opt.IsMealPlantemplate) {
200                            var fixed = D3ToStr(this.curYear, this.curMonth, n)
201                            if (startDate > fixed || endDate < fixed)
202                                d.addClass('calDisable');
203                            else
204                                d.addClass('calSelectable');
205                        }
206                        else if (this.opt.Customercallcalendar) {
207                            d.addClass('calSelectable');
208                        }
209                        else {
210                            CurrentDate = D3ToStr(this.curYear, this.curMonth, n)
211                            if (CurrentDate < Mindatecurrplan || CurrentDate > MaxdateCurrPlan) {
212                                d.addClass('calDisable');
213                            }
214                            else if (this.opt.enabled)
215                                d.addClass('calSelectable');
216                            this.larr.removeClass("cal-disabled");
217
218                        }
219
220                    }
221                    if ((todayYear == this.curYear) && (todayMonth == this.curMonth) && (todayDay == n)) {
222                        $(d).addClass('calSelectedtoday');
223                    }
224                }
225                if (this.opt.notShowSheduleOptions) {
226                    if (this.opt.IsWhole30Setting) {
227                        if (CurrentDate > this.opt.minDate)
228                            this.larr.removeClass("cal-disabled");
229                        else {
230                            this.larr.addClass("cal-disabled");
231                        }
232                    }
233                    else if (this.opt.IsMealPlantemplate) {
234                        //this.larr.addClass("cal-disabled");
235                        if (this.curMonth >= EndMonth)
236                            this.rarr.addClass("cal-disabled");
237                        else
238                            this.rarr.removeClass("cal-disabled");
239                    }
240                    else if (this.opt.Customercallcalendar) {
241                        this.larr.removeClass("cal-disabled");
242                        this.larr.removeClass("cal-disabled");
243                    }
244                    else {
245                        if (CurrentDate < Mindatecurrplan)
246                            this.larr.addClass("cal-disabled");
247                        else
248                            this.larr.removeClass("cal-disabled");
249
250                        if (CurrentDate > MaxdateCurrPlan)
251                            this.rarr.addClass("cal-disabled");
252                        else
253                            this.rarr.removeClass("cal-disabled");
254                    }
255                }
256                else {
257
258                    var datavalue = 0;
259                    switch (this.opt.scheduleButton) {
260                        case "Schedule":
261                            datavalue = 4;
262                            break;
263                        case "Move meal":
264                            datavalue = 5;
265                            break;
266                        case "Copy meal":
267                            datavalue = 6;
268                            break;
269                        default:
270                            this.opt.scheduleButton = "scheduleButton";
271                            datavalue = 4;
272                    }
273
274
275                    var html = "";
276                    $('.schedule_html').remove();
277                    html = "<div style='margin-top:5px;' class='schedule_html'>"
278                   + "<table><tr>"
279                   + "<td colspan='3'>"
280                   + " <div class='recipesDetail' id='_scheduledRecipes'></div>"
281                   + "</td></tr><tr>"
282                   + "<td><button class='btn btn-sm btn-realplans' data-value='1' href='javascript:void(0);'>Breakfast</button></td>"
283                   + "<td><button class='btn btn-sm btn-realplans' data-value='2' href='javascript:void(0);'>Lunch</button></td>"
284                   + "<td><button class='btn btn-sm btn-realplans' data-value='3' href='javascript:void(0);'>Dinner</button></td>"
285                   + "</tr><tr>"
286                   + "<td colspan='3'> <button class='btn btn-sm btn-realplans'disabled='true' id='calSchedule' data-value='" + datavalue + "' href='javascript:void(0);'>" + this.opt.scheduleButton + "</button></td></tr>"
287                   + "</div>";
288                    $(this).append(html);
289                }
290                $('.calSelectable', this).bind({
291                    click: function (e) {
292                        $('td a', base).removeClass('calSelected');
293                        $(this).addClass('calSelected');
294                        base.selY = base.curYear;
295                        base.selM = base.curMonth;
296                        base.selD = $(this).text();
297                        if (base.opt.onClick)
298                            base.opt.onClick.call(this, base.selY, base.selM, base.selD);
299                    },
300                    mouseover: function (e) {
301                        if (hoverStyle) {
302                            $('td a', base).removeClass('calSelected');
303                            $(this).addClass('calSelected');
304                        }
305                        base.selY = base.curYear;
306                        base.selM = base.curMonth;
307                        base.selD = $(this).text();
308                        if (base.opt.onmouseover)
309                            base.opt.onmouseover.call(this, base.selY, base.selM, base.selD);
310                    },
311                    mouseout: function (e) {
312                        if (hoverStyle) {
313                            $('td', base).removeClass('calSelected');
314                            $(this).removeClass('calSelected');
315                            $(this).addClass('calCellHover');
316                        }
317                        base.selY = base.curYear;
318                        base.selM = base.curMonth;
319                        base.selD = $(this).text();
320                        if (base.opt.onmouseout)
321                            base.opt.onmouseout.call(this, base.selY, base.selM, base.selD);
322                    },
323                });
324            }
325
326            this.ShowMonth(this.curYear, this.curMonth, 0);
327
328        })
329    }
330})(jQuery);
331
332
333
334
335
336

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.