PageSourceSearch

https://hesabonline.com/asset/persianDatepicker-master/js/persianDatepicker.js

js hesabonline.com collected 2026-10-05 05:48:05 UTC 34,485 bytes, 1,092 lines download raw bytes

1/*!
2 * persianDatepicker v0.1.0
3 * http://github.com/behzadi/persianDatepicker/
4 *
5 * Copyright (c) 2013 Mohammad hasan Behzadi  All rights reserved.
6 *
7 * Released under the MIT license.
8 *
9 * jalali Date Functions
10 *
11 * Date: Tue Jan 1 2013
12 *
13 * Last Update: Mon April 15 2019
14 *
15 */
16(function ($) {
17  $.fn.persianDatepicker = function (options) {
18    var pluginName = "persianDatepicker";
19    var instance = this.data(pluginName);
20    if (!instance) {
21      return this.each(function () {
22        return $(this).data(pluginName, new persianDatepicker(this, options));
23      });
24    }
25    return options === true ? instance : this;
26  };
27  // persianDatepicker object
28  var persianDatepicker = (function () {
29    function persianDatepicker(element, userOptions) {
30      var defaults = {
31        months: [
32          "فروردین",
33          "اردیبهشت",
34          "خرداد",
35          "تیر",
36          "مرداد",
37          "شهریور",
38          "مهر",
39          "آبان",
40          "آذر",
41          "دی",
42          "بهمن",
43          "اسفند",
44        ],
45        dowTitle: [
46          "شنبه",
47          "یکشنبه",
48          "دوشنبه",
49          "سه شنبه",
50          "چهارشنبه",
51          "پنج شنبه",
52          "جمعه",
53        ],
54        shortDowTitle: ["ش", "ی", "د", "س", "چ", "پ", "ج"],
55        showGregorianDate: !1,
56        persianNumbers: !0,
57        formatDate: "YYYY/MM/DD",
58        selectedBefore: !1,
59        selectedDate: null,
60        startDate: null,
61        endDate: null,
62        prevArrow: '<i class="fa fa-angle-left"></i>',
63        nextArrow: '<i class="fa fa-angle-right"></i>',
64        theme: "default",
65        alwaysShow: !1,
66        selectableYears: null,
67        selectableMonths: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
68        cellWidth: 35, // by px
69        cellHeight: 35, // by px
70        fontSize: 14, // by px
71        isRTL: !1,
72        closeOnBlur: !0,
73        calendarPosition: {
74          x: 0,
75          y: 0,
76        },
77        onShow: function () {},
78        onHide: function () {},
79        onSelect: function () {},
80        onRender: function () {},
81      };
82      var self = this;
83      self.el = $(element);
84      var el = self.el;
85      self.options = $.extend(false, {}, defaults, userOptions);
86      var options = self.options;
87
88      _fontSize = options.fontSize;
89      _cw = parseInt(options.cellWidth);
90      _ch = parseInt(options.cellHeight);
91      self.cellStyle =
92        "style='width:" +
93        _cw +
94        "px;height:" +
95        _ch +
96        "px;line-height:" +
97        _ch +
98        "px; font-size:" +
99        _fontSize +
100        "px; ' ";
101      self.headerStyle =
102        "style='height:" +
103        _ch +
104        "px;line-height:" +
105        _ch +
106        "px; font-size:" +
107        (_fontSize + 4) +
108        "px;' ";
109      self.selectUlStyle =
110        "style='margin-top:" +
111        _ch +
112        "px;height:" +
113        (_ch * 7 + 20) +
114        "px; font-size:" +
115        (_fontSize - 2) +
116        "px;' ";
117      self.selectMonthLiStyle =
118        "style='height:" +
119        (_ch * 7 + 7) / 4 +
120        "px;line-height:" +
121        (_ch * 7 + 7) / 4 +
122        "px; width:" +
123        (6.7 * _cw) / 3 +
124        "px;width:" +
125        (6.7 * _cw) / 3 +
126        "px\\9;' ";
127      self.selectYearLiStyle =
128        "style='height:" +
129        (_ch * 7 + 10) / 6 +
130        "px;line-height:" +
131        (_ch * 7 + 10) / 6 +
132        "px; width:" +
133        (6.7 * _cw - 14) / 3 +
134        "px;width:" +
135        (6.7 * _cw - 15) / 3 +
136        "px\\9;' ";
137      self.footerStyle =
138        "style='height:" +
139        _ch +
140        "px;line-height:" +
141        _ch +
142        "px; font-size:" +
143        _fontSize +
144        "px;' ";
145
146      self.jDateFunctions = new jDateFunctions();
147
148      if (self.options.startDate != null) {
149        if (self.options.startDate == "today")
150          self.options.startDate = self.now().toString("YYYY/MM/DD");
151        if (self.options.endDate == "today")
152          self.options.endDate = self.now().toString("YYYY/MM/DD");
153        self.options.selectedDate = self.options.startDate;
154      }
155
156      if (
157        self.options.selectedDate == undefined &&
158        !self.options.showGregorianDate
159      ) {
160        var patt1 = new RegExp(
161          "^([1-9][0-9][0-9][0-9])/([0]?[1-9]|[1][0-2])/([0]?[1-9]|[1-2][0-9]|[3][0-1])$"
162        );
163        if (el.is("input")) {
164          if (patt1.test(el.val())) self.options.selectedDate = el.val();
165        } else {
166          if (patt1.test(el.html())) self.options.selectedDate = el.html();
167        }
168      }
169
170      self._persianDate =
171        self.options.selectedDate != undefined
172          ? new persianDate().parse(self.options.selectedDate)
173          : self.now();
174      if (
175        options.selectableYears != undefined &&
176        options.selectableYears._indexOf(self._persianDate.year) == -1
177      )
178        self._persianDate.year = options.selectableYears[0];
179      if (self.options.selectableMonths._indexOf(self._persianDate.month) == -1)
180        self._persianDate.month = options.selectableMonths[0];
181
182      self.persianDate = self._persianDate;
183      self._id = "pdp-" + Math.round(Math.random() * 1e7);
184      self.persianDate.formatDate = options.formatDate;
185      self.calendar = $(
186        '<div id="' + self._id + '" class="pdp-' + options.theme + '" />'
187      );
188
189      if (self.options.startDate != null) {
190        self.options.selectableYears = [];
191        for (
192          var i = self.persianDate.parse(self.options.startDate).year;
193          i <= self.persianDate.parse(self.options.endDate).year;
194          i++
195        )
196          self.options.selectableYears.push(i);
197      }
198
199      if (!(el.attr("pdp-id") || "").length) {
200        el.attr("pdp-id", self._id);
201      }
202
203      el.addClass("pdp-el")
204        .on("click", function (e) {
205          self.show(e);
206        })
207        .on("focus", function (e) {
208          self.show(e);
209        });
210
211      // close on blur
212      if (options.closeOnBlur) {
213        el.on("blur", function (e) {
214          if (!self.calendar.is(":hover")) self.hide(e);
215        });
216      }
217
218      if (options.selectedBefore) {
219        if (self.options.selectedDate != undefined) {
220          //>jd = self.jDateFunctions.getJulianDayFromPersian(self.persianDate.parse(self.options.selectedDate));
221          self.showDate(
222            el,
223            self.persianDate
224              .parse(self.options.selectedDate)
225              .toString(
226                "YYYY/MM/DD/" +
227                  self.jDateFunctions.getWeekday(
228                    self.persianDate.parse(self.options.selectedDate)
229                  ),
230                self.now().gDate,
231                options.showGregorianDate
232              )
233          );
234        } else {
235          //>jd = self.jDateFunctions.getJulianDayFromPersian(self.now());
236          self.showDate(
237            el,
238            self
239              .now()
240              .toString(
241                "YYYY/MM/DD/" + self.jDateFunctions.getWeekday(self.now())
242              ),
243            self.now().gDate,
244            options.showGregorianDate
245          );
246        }
247      }
248
249      if (options.isRTL) el.addClass("rtl");
250      if (self.calendar.length && !options.alwaysShow) {
251        self.calendar.hide();
252      }
253      $(document).bind("mouseup", function (e) {
254        var target = e.target;
255        var calendar = self.calendar;
256        if (
257          !el.is(target) &&
258          !calendar.is(target) &&
259          calendar.has(target).length === 0 &&
260          calendar.is(":visible")
261        ) {
262          self.hide();
263        }
264        var container = $(".pdp-" + options.theme + " .yearSelect");
265        if (!container.is(e.target) && container.has(e.target).length === 0) {
266          container.hide();
267        }
268        container = $(".pdp-" + options.theme + " .monthSelect");
269        if (!container.is(e.target) && container.has(e.target).length === 0) {
270          container.hide();
271        }
272      });
273      var onResize = function () {
274        var elPos = el.offset();
275        self.calendar.css({
276          top: elPos.top + el.outerHeight() + options.calendarPosition.y + "px",
277          left: elPos.left + options.calendarPosition.x + "px",
278        });
279      };
280      self.onresize = onResize;
281      $(window).resize(onResize);
282      $("body").append(self.calendar);
283      self.render();
284      onResize();
285    }
286
287    // persianDatepicker methods
288    persianDatepicker.prototype = {
289      show: function () {
290        this.calendar.show();
291        $.each($(".pdp-el").not(this.el), function (i, o) {
292          if (o.length) {
293            o.options.onHide(o.calendar);
294          }
295        });
296        this.options.onShow(this.calendar);
297        this.onresize();
298      },
299      hide: function () {
300        this.options.onHide(this.calendar);
301
302        if (this.options && !this.options.alwaysShow) {
303          this.calendar.hide();
304        }
305      },
306      render: function () {
307        this.calendar.children().remove();
308        this.header();
309        this.dows();
310        this.content();
311        this.footer();
312        this.options.onRender();
313      },
314      header: function () {
315        var self = this;
316        _monthYear = $('<div class="" />');
317        _monthYear.appendTo(this.calendar);
318        _head = $('<div class="pdp-header" ' + self.headerStyle + " />");
319        _head.appendTo(this.calendar);
320        _next = $('<div class="nextArrow" />')
321          .html(this.options.nextArrow)
322          .attr("title", "ماه بعد");
323
324        /*yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy*/
325        if (
326          self.options.endDate == null ||
327          self.persianDate.parse(self.options.endDate).year >
328            self.persianDate.year ||
329          self.persianDate.parse(self.options.endDate).month >
330            self.persianDate.month
331        ) {
332          _next.bind("click", function () {
333            nextMonth = self.persianDate.month + 1;
334            for (
335              ;
336              self.options.selectableMonths._indexOf(nextMonth) == -1 &&
337              nextMonth < 13;
338              nextMonth++
339            );
340            self.persianDate.addMonth(nextMonth - self.persianDate.month);
341            self.render();
342          });
343          _next.removeClass("disabled");
344        } else {
345          _next.addClass("disabled");
346        }
347
348        _next.appendTo(_head);
349        var _monthSelect = $(
350          '<ul class="monthSelect" ' + self.selectUlStyle + " />"
351        ).hide();
352        var _yearSelect = $(
353          '<ul class="yearSelect" ' + self.selectUlStyle + " />"
354        ).hide();
355        // Build month label
356        var _monthText = $("<span/>")
357          .html(self.options.months[self.persianDate.month - 1])
358          .mousedown(function () {
359            return false;
360          })
361          .click(function (e) {
362            e.stopPropagation();
363            _yearSelect.css({
364              display: "none",
365            });
366            _monthSelect.css({
367              display: "inline-block",
368            });
369          });
370        var _yearText = $("<span/>")
371          .html(
372            self.options.persianNumbers
373              ? self.jDateFunctions.toPersianNums(self.persianDate.year)
374              : self.persianDate.year
375          )
376          .mousedown(function () {
377            return false;
378          })
379          .click(function (e) {
380            e.stopPropagation();
381            _monthSelect.css({
382              display: "none",
383            });
384            _yearSelect.css({
385              display: "inline-block",
386            });
387            _yearSelect.scrollTop(70);
388          });
389
390        //----
391        _startDate =
392          self.options.startDate != null
393            ? self.persianDate.parse(self.options.startDate)
394            : self.persianDate.parse("1/1/1");
395        _endDate =
396          self.options.endDate != null
397            ? self.persianDate.parse(self.options.endDate)
398            : self.persianDate.parse("9999/1/1");
399
400        // selectable years
401        var getSelectableYears = function (f, l) {
402          var pre = !1;
403          if (f === undefined && l === undefined) {
404            b = self.persianDate.year - 7;
405            a = self.persianDate.year + 14;
406          } else if (l == 0) {
407            b = f - 6;
408            a = f;
409            pre = !0;
410          } else if (f == 0) {
411            b = l + 1;
412            a = b + 6;
413          }
414          var arr = [];
415          for (i = b; i < a && b > 0; i++) arr.push(parseInt(i));
416          $.each(
417            self.options.selectableYears || (pre ? arr.reverse() : arr),
418            function (i, v) {
419              var o = $("<li " + self.selectYearLiStyle + " />").html(
420                self.options.persianNumbers
421                  ? self.jDateFunctions.toPersianNums(v)
422                  : v
423              );
424              if (v == self.persianDate.year) {
425                o.addClass("selected");
426              }
427              o.attr("value", v);
428              o.bind("click", function () {
429                self.persianDate.date = 1;
430                self.persianDate.year = parseInt(v);
431                if (_endDate.year == v || _endDate.year == 9999)
432                  self.persianDate.month = _endDate.month;
433                if (_startDate.year == v || _startDate.year == 9999)
434                  self.persianDate.month = _startDate.month;
435                self.render();
436              });
437              pre ? _yearSelect.prepend(o) : _yearSelect.append(o);
438            }
439          );
440        };
441        getSelectableYears();
442
443        // selectable months
444        for (i = 1; i <= 12; i++) {
445          var m = self.options.months[i - 1];
446          var o =
447            self.options.selectableMonths._indexOf(i) == -1 ||
448            (_startDate.year == self.persianDate.year &&
449              _startDate.month > i) ||
450            (_endDate.year == self.persianDate.year && i > _endDate.month)
451              ? $(
452                  '<li class="disableMonth" ' + self.selectMonthLiStyle + " />"
453                ).html(m)
454              : $("<li " + self.selectMonthLiStyle + " />").html(m);
455          if (i == self.persianDate.month) {
456            o.addClass("selected");
457          }
458          o.data("month", {
459            month: m,
460            monthNum: i,
461          });
462          if (!o.hasClass("disableMonth")) {
463            o.bind("click", function () {
464              self.persianDate.date = 1;
465              self.persianDate.month = $(this).data("month").monthNum;
466              self.render();
467            });
468          }
469          _monthSelect.append(o);
470        }
471
472        // selectable years
473        _yearSelect.bind("scroll", function () {
474          if (self.options.selectableYears == undefined) {
475            c = $(this).find("li").length;
476            firstYear = parseInt($(this).children("li:first").val());
477            lastYear = parseInt($(this).children("li:last").val());
478            lisHeight = (c / 3) * ($(this).find("li:first").height() + 4);
479            _com = $(this).scrollTop().toString().length * 500;
480            if (
481              $(this).scrollTop() < _com.toString().length * 100 &&
482              firstYear >= 1
483            ) {
484              getSelectableYears(firstYear, 0);
485            }
486
487            _com = $(this).scrollTop().toString().length * 100;
488            if (
489              lisHeight - $(this).scrollTop() > -_com &&
490              lisHeight - $(this).scrollTop() < _com
491            ) {
492              getSelectableYears(0, lastYear);
493              $(this).scrollTop($(this).scrollTop() - 50);
494            }
495            if (
496              $(this).scrollTop() < _com.toString().length &&
497              firstYear >= 30
498            ) {
499              $(this).scrollTop(_com.toString().length * 100);
500            }
501          }
502        });
503        _monthYear.append(_monthSelect).append(_yearSelect);
504        var titleYearMonth = $('<div class="monthYear" />')
505          .append(_monthText)
506          .append("<span>&nbsp;&nbsp;</span>")
507          .append(_yearText);
508        _head.append(titleYearMonth);
509        _prev = $('<div class="prevArrow" />')
510          .html(this.options.prevArrow)
511          .attr("title", "ماه قبل");
512
513        if (
514          self.options.startDate == null ||
515          self.persianDate.parse(self.options.startDate).year <
516            self.persianDate.year ||
517          self.persianDate.parse(self.options.startDate).month <
518            self.persianDate.month
519        ) {
520          _prev.bind("click", function () {
521            //prevMonth = self.persianDate.month - 1;
522            //for (; self.options.selectableMonths._indexOf(prevMonth) == -1 && prevMonth > 1; prevMonth--);
523            //self.persianDate.addMonth(-(self.persianDate.month - prevMonth));
524            self.persianDate.addMonth(-1);
525            self.render();
526          });
527          _prev.removeClass("disabled");
528        } else {
529          _prev.addClass("disabled");
530        }
531
532        _prev.appendTo(_head);
533      },
534      // days of week title
535      dows: function () {
536        _row = $('<div class="dows" />');
537        for (i = 0; i < 7; i++) {
538          _cell = $('<div class="dow cell " ' + this.cellStyle + " />").html(
539            this.options.shortDowTitle[i]
540          );
541          _cell.appendTo(_row);
542        }
543        _row.appendTo(this.calendar);
544      },
545      content: function () {
546        var self = this;
547        _days = $('<div class="days" />');
548        _days.appendTo(this.calendar);
549        jd = self.persianDate;
550        jd.date = 1;
551        _start = self.jDateFunctions.getWeekday(self.persianDate);
552        _end = self.jDateFunctions.getLastDayOfMonth(self.persianDate);
553        for (var row = 0, cellIndex = 0; row < 5 + 1; row++) {
554          _row = $("<div />");
555          for (var col = 0; col < 7; col++, cellIndex++) {
556            if (cellIndex < _start || cellIndex - _start + 1 > _end) {
557              _cell = $(
558                '<div class="nul cell " ' + self.cellStyle + " />"
559              ).html("&nbsp;");
560            } else {
561              _dt = self.getDate(self.persianDate, cellIndex - _start + 1);
562              (_today = ""), (_selday = ""), (_disday = "");
563              if (self.now().compare(_dt) == 0) _today = "today";
564
565              if (
566                self.options.startDate != null &&
567                (self.persianDate.parse(self.options.startDate).compare(_dt) ==
568                  -1 ||
569                  self.persianDate.parse(self.options.endDate).compare(_dt) ==
570                    1)
571              )
572                _disday = "disday";
573
574              if (self.options.selectedDate != undefined) {
575                if (
576                  self.persianDate.parse(self.options.selectedDate).date ==
577                  cellIndex - _start + 1
578                )
579                  _selday = "selday";
580              } else if (cellIndex - _start + 1 == self.now().date)
581                _selday = "selday";
582              _fri = col == 6 ? "friday" : "";
583              _cell = $(
584                '<div class="day cell ' +
585                  _fri +
586                  " " +
587                  _today +
588                  " " +
589                  _selday +
590                  " " +
591                  _disday +
592                  '" ' +
593                  self.cellStyle +
594                  " />"
595              );
596              _cell.attr("data-jdate", _dt.toString("YYYY/MM/DD"));
597              _cell.attr(
598                "data-gdate",
599                self.jDateFunctions.getGDate(_dt)._toString("YYYY/MM/DD")
600              );
601              _cell.html(
602                self.options.persianNumbers
603                  ? self.jDateFunctions.toPersianNums(cellIndex - _start + 1)
604                  : cellIndex - _start + 1
605              );
606
607              if (
608                self.options.startDate == undefined ||
609                (self.persianDate.parse(self.options.startDate).compare(_dt) !=
610                  -1 &&
611                  self.persianDate.parse(self.options.endDate).compare(_dt) !=
612                    1)
613              )
614                _cell.bind("click", function () {
615                  self.calendar.find(".day").removeClass("selday");
616                  $(this).addClass("selday");
617                  if (self.options.showGregorianDate)
618                    self.showDate(
619                      self.el,
620                      $(this).data("jdate"),
621                      $(this).data("gdate"),
622                      !0
623                    );
624                  else
625                    self.showDate(
626                      self.el,
627                      $(this).data("jdate"),
628                      $(this).data("gdate"),
629                      !1
630                    );
631
632                  self.hide();
633                });
634            }
635            _cell.appendTo(_row);
636          }
637          _row.appendTo(_days);
638        }
639      },
640      footer: function () {
641        var self = this;
642        // _footer = $('<div class="pdp-footer" ' + self.footerStyle + ' />');
643        // _footer.appendTo(this.calendar);
644
645        if (
646          self.options.selectableMonths._indexOf(self.persianDate.month) > -1
647        ) {
648          _goToday = $('<a class="goToday" />');
649          _goToday.attr("data-jdate", self.now().toString("YYYY/MM/DD/DW"));
650          _goToday.attr("data-gdate", self.jDateFunctions.getGDate(self.now()));
651          _goToday.attr("href", "javascript:;").html("هم اکنون");
652          if (self.options.startDate == null)
653            _goToday.bind("click", function () {
654              self.persianDate = self.now();
655
656              self.showDate(
657                self.el,
658                $(this).data("jdate"),
659                $(this).data("gdate"),
660                self.options.showGregorianDate
661              );
662
663              self.calendar.find(".day").removeClass("selday");
664              self.render();
665              self.calendar.find(".today").addClass("selday");
666              self.hide();
667            });
668          // _goToday.appendTo(_footer);
669        }
670      },
671      showDate: function (el, jDate, gDate, showGdate) {
672        var self = this;
673        jDate = self.persianDate.parse(jDate).toString(self.options.formatDate);
674        gDate = new Date(gDate)._toString(self.options.formatDate);
675        if (el.is("input:text")) {
676          if (showGdate) el.val(gDate);
677          else el.val(jDate);
678        } else {
679          if (showGdate) el.html(gDate);
680          else el.html(jDate);
681        }
682
683        el.attr("data-jDate", jDate);
684        el.attr("data-gDate", gDate);
685
686        this.options.onSelect();
687      },
688      getDate: function (pd, d) {
689        pd.date = d;
690        pd.day = this.jDateFunctions.getWeekday(pd);
691        return pd;
692      },
693      now: function () {
694        return this.jDateFunctions.gregorian_to_jalali(new Date());
695      },
696    };
697    // Return the persianDatepicker plugin
698    return persianDatepicker;
699  })();
700
701  (function () {
702    //padleft
703    Number.prototype.padLeft = function (base, chr) {
704      var len = String(base || 10).length - String(this).length + 1;
705      return len > 0 ? new Array(len).join(chr || "0") + this : this;
706    };
707
708    // format Date with _toString()
709    Date.prototype._toString = function (formatDate) {
710      months = [
711        "Januray",
712        "February",
713        "March",
714        "April",
715        "May",
716        "June",
717        "Julay",
718        "August",
719        "September",
720        "October",
721        "November",
722        "December",
723      ];
724      dows = ["Sun", "Mon", "Tue", "Wed", "Tur", "Fri", "Sat"];
725      if (formatDate === undefined || formatDate == "default")
726        return this.toLocaleDateString();
727
728      return formatDate
729        .replace("YYYY", this.getFullYear())
730        .replace("MM", this.getMonth() + 1)
731        .replace("DD", this.getDate())
732        .replace(
733          "0M",
734          this.getMonth() + 1 > 9
735            ? this.getMonth() + 1
736            : "0" + (this.getMonth() + 1)
737        )
738        .replace(
739          "0D",
740          this.getDate() > 9 ? this.getDate() : "0" + this.getDate()
741        )
742        .replace(
743          "hh",
744          this.getHours() == 0 ? new Date().getHours() : this.getHours()
745        )
746        .replace(
747          "mm",
748          this.getMinutes() == 0 ? new Date().getMinutes() : this.getMinutes()
749        )
750        .replace(
751          "ss",
752          this.getSeconds() == 0 ? new Date().getSeconds() : this.getSeconds()
753        )
754        .replace(
755          "0h",
756          this.getHours() > 9 ? this.getHours() : "0" + this.getHours()
757        )
758        .replace(
759          "0m",
760          this.getMinutes() > 9 ? this.getMinutes() : "0" + this.getMinutes()
761        )
762        .replace(
763          "0s",
764          this.getSeconds() > 9 ? this.getSeconds() : "0" + this.getSeconds()
765        )
766        .replace(
767          "ms",
768          this.getMilliseconds() == 0
769            ? new Date().getMilliseconds()
770            : this.getMilliseconds()
771        )
772        .replace(
773          "tm",
774          this.getHours() >= 12 && this.getMinutes() > 0 ? "PM" : "AM"
775        )
776        .replace("NM", months[this.getMonth()])
777        .replace("DW", this.getDay())
778        .replace("ND", dows[this.getDay()]);
779    };
780    //    _indexOf() for arrays
781    Array.prototype._indexOf = function (value) {
782      return $.inArray(value, this);
783    };
784  })();
785})(jQuery); // end of persianDatepicker plugin
786
787// persianDate object
788var persianDate = (function () {
789  function persianDate() {
790    var self = this;
791    self.months = [
792      "فروردین",
793      "اردیبهشت",
794      "خرداد",
795      "تیر",
796      "مرداد",
797      "شهریور",
798      "مهر",
799      "آبان",
800      "آذر",
801      "دی",
802      "بهمن",
803      "اسفند",
804    ];
805    self.dowTitle = [
806      "شنبه",
807      "یکشنبه",
808      "دوشنبه",
809      "سه شنبه",
810      "چهارشنبه",
811      "پنج شنبه",
812      "جمعه",
813    ];
814    self.year = 1300;
815    self.month = 1;
816    self.date = 1;
817    self.day = 1;
818    self.gDate = new Date();
819  }
820  persianDate.prototype = {
821    now: function () {
822      var jdf = new jDateFunctions();
823      return jdf.gregorian_to_jalali(new Date());
824    },
825    addDay: function (d) {
826      var jdf = new jDateFunctions();
827      var to = d > 0 ? d : -d;
828      for (var i = 0; i < to; i++) {
829        var r = new persianDate();
830        r.month = this.month;
831        r.year = this.year;
832        r = r.addMonth(-1);
833        var lastDayOfMonth =
834          d > 0 ? jdf.getLastDayOfMonth(this) : jdf.getLastDayOfMonth(r);
835        d > 0 ? (this.date += 1) : (this.date -= 1);
836        if (d > 0) {
837          if (this.date > lastDayOfMonth) {
838            this.date = 1;
839            this.addMonth(1);
840          }
841        } else if (d < 0) {
842          if (this.month > 1 && this.date > lastDayOfMonth) {
843            this.date = 1;
844            this.addMonth(1);
845          } else if (this.date == 0) {
846            this.addMonth(-1);
847            this.date = lastDayOfMonth;
848          }
849        }
850      }
851      return this;
852    },
853    addMonth: function (d) {
854      var to = d > 0 ? d : -d;
855      for (var i = 0; i < to; i++) {
856        d > 0 ? (this.month += 1) : (this.month -= 1);
857        if (this.month == 13) {
858          this.month = 1;
859          this.addYear(1);
860        } else if (this.month == 0) {
861          this.month = 12;
862          this.addYear(-1);
863        }
864      }
865      return this;
866    },
867    addYear: function (d) {
868      this.year += d;
869      return this;
870    },
871    compare: function (d) {
872      if (d.year == this.year && d.month == this.month && d.date == this.date)
873        return 0;
874      if (d.year > this.year) return 1;
875      if (d.year == this.year && d.month > this.month) return 1;
876      if (d.year == this.year && d.month == this.month && d.date > this.date)
877        return 1;
878      return -1;
879    },
880    parse: function (s) {
881      arr = s.split("/");
882      y = arr[0];
883      m = arr[1];
884      d = arr[2];
885      var r = new persianDate();
886      jdf = new jDateFunctions();
887      (r.year = parseInt(y)),
888        (r.month = parseInt(m)),
889        (r.date = parseInt(d)),
890        (r.day = jdf.getWeekday(r)),
891        (r.gDate = jdf.jalali_to_gregorian(r));
892      return r;
893    },
894    toString: function (formatDate) {
895      if (formatDate === undefined)
896        return this.year + "/" + this.month + "/" + this.date;
897      return formatDate
898        .replace("YYYY", this.year)
899        .replace("MM", this.month)
900        .replace("DD", this.date)
901        .replace(
902          "0M",
903          this.month > 9 ? this.month : "0" + this.month.toString()
904        )
905        .replace("0D", this.date > 9 ? this.date : "0" + this.date.toString())
906        .replace("hh", this.gDate.getHours())
907        .replace("mm", this.gDate.getMinutes())
908        .replace("ss", this.gDate.getSeconds())
909        .replace(
910          "0h",
911          this.gDate.getHours() > 9
912            ? this.gDate.getHours()
913            : "0" + this.gDate.getHours()
914        )
915        .replace(
916          "0m",
917          this.gDate.getMinutes() > 9
918            ? this.gDate.getMinutes()
919            : "0" + this.gDate.getMinutes()
920        )
921        .replace(
922          "0s",
923          this.gDate.getSeconds() > 9
924            ? this.gDate.getSeconds()
925            : "0" + this.gDate.getSeconds()
926        )
927        .replace(
928          "tm",
929          this.gDate.getHours() >= 12 && this.gDate.getMinutes() > 0
930            ? "ب.ظ"
931            : "ق.ظ"
932        )
933        .replace("ms", this.gDate.getMilliseconds())
934        .replace("NM", this.months[this.month - 1])
935        .replace("DW", this.day)
936        .replace("ND", this.dowTitle[this.day]);
937    },
938  };
939  return persianDate;
940})();
941
942//  jalali Date Functions from NASA.gov
943var jDateFunctions = (function () {
944  function jDateFunctions() {}
945
946  jDateFunctions.prototype = {
947    toPersianNums: function (s) {
948      strnum = s.toString();
949      nums = ["Û°", "Û±", "Û²", "Û³", "Û´", "Ûµ", "Û¶", "Û·", "Û¸", "Û¹"];
950      res = "";
951      for (i = 0; i < strnum.length; i++) res += nums[parseInt(strnum[i])];
952      return res;
953    },
954
955    gregorian_to_jalali: function (dt) {
956      gy = dt.getFullYear();
957      gm = dt.getMonth() + 1;
958      gd = dt.getDate();
959      g_d_m = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
960      if (gy > 1600) {
961        jy = 979;
962        gy -= 1600;
963      } else {
964        jy = 0;
965        gy -= 621;
966      }
967      gy2 = gm > 2 ? gy + 1 : gy;
968      days =
969        365 * gy +
970        parseInt((gy2 + 3) / 4) -
971        parseInt((gy2 + 99) / 100) +
972        parseInt((gy2 + 399) / 400) -
973        80 +
974        gd +
975        g_d_m[gm - 1];
976      jy += 33 * parseInt(days / 12053);
977      days %= 12053;
978      jy += 4 * parseInt(days / 1461);
979      days %= 1461;
980      if (days > 365) {
981        jy += parseInt((days - 1) / 365);
982        days = (days - 1) % 365;
983      }
984      jm =
985        days < 186 ? 1 + parseInt(days / 31) : 7 + parseInt((days - 186) / 30);
986      jd = 1 + (days < 186 ? days % 31 : (days - 186) % 30);
987      dt = new Date();
988      pd = new persianDate();
989      pd.year = jy;
990      pd.month = jm;
991      pd.date = jd;
992      pd.gDate = dt;
993      return pd;
994    },
995
996    jalali_to_gregorian: function (pd) {
997      jy = pd.year;
998      jm = pd.month;
999      jd = pd.date;
1000      if (jy > 979) {
1001        gy = 1600;
1002        jy -= 979;
1003      } else {
1004        gy = 621;
1005      }
1006      days =
1007        365 * jy +
1008        parseInt(jy / 33) * 8 +
1009        parseInt(((jy % 33) + 3) / 4) +
1010        78 +
1011        jd +
1012        (jm < 7 ? (jm - 1) * 31 : (jm - 7) * 30 + 186);
1013      gy += 400 * parseInt(days / 146097);
1014      days %= 146097;
1015      if (days > 36524) {
1016        gy += 100 * parseInt(--days / 36524);
1017        days %= 36524;
1018        if (days >= 365) days++;
1019      }
1020      gy += 4 * parseInt(days / 1461);
1021      days %= 1461;
1022      if (days > 365) {
1023        gy += parseInt((days - 1) / 365);
1024        days = (days - 1) % 365;
1025      }
1026      gd = days + 1;
1027      sal_a = [
1028        0,
1029        31,
1030        (gy % 4 == 0 && gy % 100 != 0) || gy % 400 == 0 ? 29 : 28,
1031        31,
1032        30,
1033        31,
1034        30,
1035        31,
1036        31,
1037        30,
1038        31,
1039        30,
1040        31,
1041      ];
1042      for (gm = 0; gm < 13; gm++) {
1043        v = sal_a[gm];
1044        if (gd <= v) break;
1045        gd -= v;
1046      }
1047      dt = new Date();
1048      return new Date(
1049        gy,
1050        gm - 1,
1051        gd,
1052        dt.getHours(),
1053        dt.getMinutes(),
1054        dt.getSeconds(),
1055        dt.getMilliseconds()
1056      );
1057    },
1058    getGDate: function (pd) {
1059      return this.jalali_to_gregorian(pd);
1060      //>return this.getGCalendarDate(this.getJulianDayFromPersian(pd), "gmonth");
1061    },
1062    getWeekday: function (pd) {
1063      var gds = [1, 2, 3, 4, 5, 6, 0];
1064      return gds[this.jalali_to_gregorian(pd).getDay()];
1065    },
1066    getLastDayOfMonth: function (pd) {
1067      (y = pd.year), (m = pd.month);
1068      if (m >= 1 && m <= 6) {
1069        return 31;
1070      } else if (m >= 7 && m < 12) {
1071        return 30;
1072      } else if (this.isLeapYear(y)) {
1073      /* Esfand */
1074        /* Leap year */
1075        return 30;
1076      }
1077      return 29;
1078    },
1079    // 1244 to 1472
1080    isLeapYear: function (year) {
1081      var ary =
1082        year > 1342
1083          ? [1, 5, 9, 13, 17, 22, 26, 30]
1084          : [1, 5, 9, 13, 17, 21, 26, 30];
1085      b = year % 33;
1086      if (ary._indexOf(b) > -1) return true;
1087      return false;
1088    },
1089  }; //========
1090
1091  return jDateFunctions;
1092})();

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.