diff --git a/js/dycalendar-jquery.js b/js/dycalendar-jquery.js index 5272870..ce514d6 100644 --- a/js/dycalendar-jquery.js +++ b/js/dycalendar-jquery.js @@ -353,9 +353,9 @@ result.today.year = dateString[3]; //get month-year first day - dateObj.setFullYear(year); - dateObj.setMonth(month); dateObj.setDate(1); + dateObj.setMonth(month); + dateObj.setFullYear(year); dateString = dateObj.toString().split(" "); idx = dayName.ddd.indexOf(dateString[0]); diff --git a/js/dycalendar-jquery.min.js b/js/dycalendar-jquery.min.js index 4a60a9a..0bb3411 100644 --- a/js/dycalendar-jquery.min.js +++ b/js/dycalendar-jquery.min.js @@ -1,2 +1,2 @@ /*! dyCalendarJS | (c) 2016 Yusuf Shakeel | https://github.com/yusufshakeel/dyCalendarJS */ -!function(a,t){"use strict";function e(a,e){var d,n,r,o,l,y;for(d=t(""),n=t(""),l=0;6>=l;l+=1)r=t(""),l=0;6>=l&&l!==a.firstDayIndex;l+=1)r=t(""),l=0;6>=l;l+=1){if(y>a.totaldays)return d.append(n),d;r=t("
"),r.html("SMTWTFS"[l]),n.append(r);for(d.append(n),n=t("
"),n.append(r);for(y=1;6>=l;)r=t(""),r.html(y),a.today.date===y&&a.today.monthIndex===a.monthIndex&&e.highlighttoday===!0&&r.addClass("dycalendar-today-date"),e.date===y&&e.month===a.monthIndex&&e.highlighttargetdate===!0&&r.addClass("dycalendar-target-date"),n.append(r),y+=1,l+=1;for(d.append(n),o=3;7>=o;o+=1){for(n=t("
"),r.html(y),a.today.date===y&&a.today.monthIndex===a.monthIndex&&e.highlighttoday===!0&&r.addClass("dycalendar-today-date"),e.date===y&&e.month===a.monthIndex&&e.highlighttargetdate===!0&&r.addClass("dycalendar-target-date"),y+=1,n.append(r)}d.append(n)}return d}function d(a,d){var n,r,o,l;return n=e(a,d),o=t("
"),o.addClass("dycalendar-month-container"),r=t("
"),r.addClass("dycalendar-header"),r.attr("data-option",JSON.stringify(d)),"show"===d.prevnextbutton&&(l=t(""),l.addClass("dycalendar-prev-next-btn prev-btn"),l.attr("data-date",d.date),l.attr("data-month",d.month),l.attr("data-year",d.year),l.attr("data-btn","prev"),l.html("<"),r.append(l)),l=t(""),l.addClass("dycalendar-span-month-year"),"mmm"===d.monthformat?l.html(a.monthName+" "+a.year):"full"===d.monthformat&&l.html(a.monthNameFull+" "+a.year),r.append(l),"show"===d.prevnextbutton&&(l=t(""),l.addClass("dycalendar-prev-next-btn next-btn"),l.attr("data-date",d.date),l.attr("data-month",d.month),l.attr("data-year",d.year),l.attr("data-btn","next"),l.html(">"),r.append(l)),o.append(r),r=t("
"),r.addClass("dycalendar-body"),r.append(n),o.append(r),o}function n(a,e){var d,n,r;return n=t("
"),n.addClass("dycalendar-day-container"),d=t("
"),d.addClass("dycalendar-header"),r=t(""),r.addClass("dycalendar-span-day"),"ddd"===e.dayformat?r.html(p.ddd[a.targetedDayIndex]):"full"===e.dayformat&&r.html(p.full[a.targetedDayIndex]),d.append(r),n.append(d),d=t("
"),d.addClass("dycalendar-body"),r=t(""),r.addClass("dycalendar-span-date"),r.html(a.date),d.append(r),n.append(d),d=t("
"),d.addClass("dycalendar-footer"),r=t(""),r.addClass("dycalendar-span-month-year"),"mmm"===e.monthformat?r.html(a.monthName+" "+a.year):"full"===e.monthformat&&r.html(a.monthNameFull+" "+a.year),d.append(r),n.append(d),n}function r(a,t){var e;for(e in t)a.hasOwnProperty(e)===!1&&(a[e]=t[e]);return a}function o(t,e,d){var n,r,o=new Date,l={};return m>t||t>s?(a.console.error("Invalid Year"),!1):e>11||0>e?(a.console.error("Invalid Month"),!1):d>31||1>d?(a.console.error("Invalid Date"),!1):(l.year=t,l.month=e,l.date=d,l.today={},n=o.toString().split(" "),r=p.ddd.indexOf(n[0]),l.today.dayIndex=r,l.today.dayName=n[0],l.today.dayFullName=p.full[r],r=i.mmm.indexOf(n[1]),l.today.monthIndex=r,l.today.monthName=n[1],l.today.monthNameFull=i.full[r],l.today.date=o.getDate(),l.today.year=n[3],o.setFullYear(t),o.setMonth(e),o.setDate(1),n=o.toString().split(" "),r=p.ddd.indexOf(n[0]),l.firstDayIndex=r,l.firstDayName=n[0],l.firstDayFullName=p.full[r],r=i.mmm.indexOf(n[1]),l.monthIndex=r,l.monthName=n[1],l.monthNameFull=i.full[r],o.setFullYear(t),o.setMonth(e+1),o.setDate(0),l.totaldays=o.getDate(),o.setFullYear(t),o.setMonth(e),o.setDate(d),n=o.toString().split(" "),r=p.ddd.indexOf(n[0]),l.targetedDayIndex=r,l.targetedDayName=n[0],l.targetedDayFullName=p.full[r],l)}function l(){t("body").on("click",".dycalendar-prev-next-btn",function(a){a.preventDefault();var e=t(this).data("date"),d=t(this).data("month"),n=t(this).data("year"),r=t(this).data("btn"),o=t(this).parent().data("option");"prev"===r?(d-=1,0>d&&(n-=1,d=11)):"next"===r&&(d+=1,d>11&&(n+=1,d=0)),o.date=e,o.month=d,o.year=n,y(o)}),t("body").on("click",".dycalendar-span-month-year",function(a){a.preventDefault();var e=t(this).parent().data("option"),d=new Date;e.date=d.getDate(),e.month=d.getMonth(),e.year=d.getFullYear(),y(e)})}function y(e){var r,l;switch(e.type){case"day":r=o(e.year,e.month,e.date),l=n(r,e);break;case"month":r=o(e.year,e.month,e.date),l=d(r,e);break;default:return a.console.error("Invalid type"),!1}t(e.target).html(l)}var h={},m=(a.document,1900),s=9999,i={full:["January","February","March","April","May","June","July","August","September","October","November","December"],mmm:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]},p={full:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],d:["S","M","T","W","T","F","S"],dd:["Su","Mo","Tu","We","Th","Fr","Sa"],ddd:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]};h.draw=function(t){if("undefined"==typeof t)return a.console.error("Option missing"),!1;var e=new Date,d={type:"day",month:e.getMonth(),year:e.getFullYear(),date:e.getDate(),monthformat:"full",dayformat:"full",highlighttoday:!1,highlighttargetdate:!1,prevnextbutton:"hide"};t=r(t,d),y(t)},l(),a.dycalendar=h}("undefined"!=typeof window?window:this,"undefined"!=typeof jQuery?jQuery:void 0); +!function(a,t){"use strict";function e(a,e){var d,n,r,o,l,y;for(d=t(""),n=t(""),l=0;l<=6;l+=1)(r=t(""),l=0;l<=6&&l!==a.firstDayIndex;l+=1)r=t(""),l=0;l<=6;l+=1){if(y>a.totaldays)return d.append(n),d;(r=t("
")).html("SMTWTFS"[l]),n.append(r);for(d.append(n),n=t("
"),n.append(r);for(y=1;l<=6;)(r=t("")).html(y),a.today.date===y&&a.today.monthIndex===a.monthIndex&&!0===e.highlighttoday&&r.addClass("dycalendar-today-date"),e.date===y&&e.month===a.monthIndex&&!0===e.highlighttargetdate&&r.addClass("dycalendar-target-date"),n.append(r),y+=1,l+=1;for(d.append(n),o=3;o<=7;o+=1){for(n=t("
")).html(y),a.today.date===y&&a.today.monthIndex===a.monthIndex&&!0===e.highlighttoday&&r.addClass("dycalendar-today-date"),e.date===y&&e.month===a.monthIndex&&!0===e.highlighttargetdate&&r.addClass("dycalendar-target-date"),y+=1,n.append(r)}d.append(n)}return d}function d(a,d){var n,r,o,l;return n=e(a,d),(o=t("
")).addClass("dycalendar-month-container"),(r=t("
")).addClass("dycalendar-header"),r.attr("data-option",JSON.stringify(d)),"show"===d.prevnextbutton&&((l=t("")).addClass("dycalendar-prev-next-btn prev-btn"),l.attr("data-date",d.date),l.attr("data-month",d.month),l.attr("data-year",d.year),l.attr("data-btn","prev"),l.html("<"),r.append(l)),(l=t("")).addClass("dycalendar-span-month-year"),"mmm"===d.monthformat?l.html(a.monthName+" "+a.year):"full"===d.monthformat&&l.html(a.monthNameFull+" "+a.year),r.append(l),"show"===d.prevnextbutton&&((l=t("")).addClass("dycalendar-prev-next-btn next-btn"),l.attr("data-date",d.date),l.attr("data-month",d.month),l.attr("data-year",d.year),l.attr("data-btn","next"),l.html(">"),r.append(l)),o.append(r),(r=t("
")).addClass("dycalendar-body"),r.append(n),o.append(r),o}function n(a,e){var d,n,r;return(n=t("
")).addClass("dycalendar-day-container"),(d=t("
")).addClass("dycalendar-header"),(r=t("")).addClass("dycalendar-span-day"),"ddd"===e.dayformat?r.html(i.ddd[a.targetedDayIndex]):"full"===e.dayformat&&r.html(i.full[a.targetedDayIndex]),d.append(r),n.append(d),(d=t("
")).addClass("dycalendar-body"),(r=t("")).addClass("dycalendar-span-date"),r.html(a.date),d.append(r),n.append(d),(d=t("
")).addClass("dycalendar-footer"),(r=t("")).addClass("dycalendar-span-month-year"),"mmm"===e.monthformat?r.html(a.monthName+" "+a.year):"full"===e.monthformat&&r.html(a.monthNameFull+" "+a.year),d.append(r),n.append(d),n}function r(a,t){var e;for(e in t)!1===a.hasOwnProperty(e)&&(a[e]=t[e]);return a}function o(t,e,d){var n,r,o=new Date,l={};return tm?(a.console.error("Invalid Year"),!1):e>11||e<0?(a.console.error("Invalid Month"),!1):d>31||d<1?(a.console.error("Invalid Date"),!1):(l.year=t,l.month=e,l.date=d,l.today={},n=o.toString().split(" "),r=i.ddd.indexOf(n[0]),l.today.dayIndex=r,l.today.dayName=n[0],l.today.dayFullName=i.full[r],r=s.mmm.indexOf(n[1]),l.today.monthIndex=r,l.today.monthName=n[1],l.today.monthNameFull=s.full[r],l.today.date=o.getDate(),l.today.year=n[3],o.setDate(1),o.setMonth(e),o.setFullYear(t),n=o.toString().split(" "),r=i.ddd.indexOf(n[0]),l.firstDayIndex=r,l.firstDayName=n[0],l.firstDayFullName=i.full[r],r=s.mmm.indexOf(n[1]),l.monthIndex=r,l.monthName=n[1],l.monthNameFull=s.full[r],o.setFullYear(t),o.setMonth(e+1),o.setDate(0),l.totaldays=o.getDate(),o.setFullYear(t),o.setMonth(e),o.setDate(d),n=o.toString().split(" "),r=i.ddd.indexOf(n[0]),l.targetedDayIndex=r,l.targetedDayName=n[0],l.targetedDayFullName=i.full[r],l)}function l(e){var r;switch(e.type){case"day":r=n(o(e.year,e.month,e.date),e);break;case"month":r=d(o(e.year,e.month,e.date),e);break;default:return a.console.error("Invalid type"),!1}t(e.target).html(r)}var y={},h=(a.document,1900),m=9999,s={full:["January","February","March","April","May","June","July","August","September","October","November","December"],mmm:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]},i={full:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],d:["S","M","T","W","T","F","S"],dd:["Su","Mo","Tu","We","Th","Fr","Sa"],ddd:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]};y.draw=function(t){if(void 0===t)return a.console.error("Option missing"),!1;var e=new Date;l(t=r(t,{type:"day",month:e.getMonth(),year:e.getFullYear(),date:e.getDate(),monthformat:"full",dayformat:"full",highlighttoday:!1,highlighttargetdate:!1,prevnextbutton:"hide"}))},function(){t("body").on("click",".dycalendar-prev-next-btn",function(a){a.preventDefault();var e=t(this).data("date"),d=t(this).data("month"),n=t(this).data("year"),r=t(this).data("btn"),o=t(this).parent().data("option");"prev"===r?(d-=1)<0&&(n-=1,d=11):"next"===r&&(d+=1)>11&&(n+=1,d=0),o.date=e,o.month=d,o.year=n,l(o)}),t("body").on("click",".dycalendar-span-month-year",function(a){a.preventDefault();var e=t(this).parent().data("option"),d=new Date;e.date=d.getDate(),e.month=d.getMonth(),e.year=d.getFullYear(),l(e)})}(),a.dycalendar=y}("undefined"!=typeof window?window:this,"undefined"!=typeof jQuery?jQuery:void 0); \ No newline at end of file diff --git a/js/dycalendar.js b/js/dycalendar.js index c2a64e1..00a04a5 100755 --- a/js/dycalendar.js +++ b/js/dycalendar.js @@ -12,12 +12,12 @@ * Date: 2014-08-17 sunday */ /*! dyCalendarJS | (c) 2016 Yusuf Shakeel | https://github.com/yusufshakeel/dyCalendarJS */ -(function(global) { +(function (global) { "use strict"; var - //this will be used by the user. + //this will be used by the user. dycalendar = {}, //window document @@ -99,7 +99,7 @@ //create remaining rows for (r = 3; r <= 7; r = r + 1) { tr = document.createElement("tr"); - for(c = 0; c <= 6; c = c + 1) { + for (c = 0; c <= 6; c = c + 1) { if (count > data.totaldays) { table.appendChild(tr); return table; @@ -302,12 +302,12 @@ /** * This function will return calendar detail. * - * @param integer year 1900-9999 (optional) if not set will consider + * @param integer year 1900-9999 (optional) if not set will consider * the current year. - * @param integer month 0-11 (optional) 0 = Jan, 1 = Feb, ... 11 = Dec, + * @param integer month 0-11 (optional) 0 = Jan, 1 = Feb, ... 11 = Dec, * if not set will consider the current month. * @param integer date 1-31 (optional) - * @return boolean|object if error return false, else calendar detail + * @return boolean|object if error return false, else calendar detail */ function getCalendar(year, month, date) { @@ -353,9 +353,9 @@ result.today.year = dateString[3]; //get month-year first day - dateObj.setFullYear(year); - dateObj.setMonth(month); dateObj.setDate(1); + dateObj.setMonth(month); + dateObj.setFullYear(year); dateString = dateObj.toString().split(" "); idx = dayName.ddd.indexOf(dateString[0]); @@ -392,7 +392,7 @@ /** * this function will handle the on click event. */ - function onClick () { + function onClick() { document.body.onclick = function (e) { @@ -476,7 +476,7 @@ dycalendar.draw = function (option) { //check if option is passed or not - if(typeof option === "undefined") { + if (typeof option === "undefined") { global.console.error("Option missing"); return false; } @@ -488,15 +488,15 @@ //default settings defaults = { - type : "day", - month : dateObj.getMonth(), - year : dateObj.getFullYear(), - date : dateObj.getDate(), - monthformat : "full", - dayformat : "full", - highlighttoday : false, - highlighttargetdate : false, - prevnextbutton : "hide" + type: "day", + month: dateObj.getMonth(), + year: dateObj.getFullYear(), + date: dateObj.getDate(), + monthformat: "full", + dayformat: "full", + highlighttoday: false, + highlighttargetdate: false, + prevnextbutton: "hide" }; //extend user options with predefined options @@ -511,7 +511,7 @@ /** * this function will draw the calendar inside the target container. */ - function drawCalendar (option) { + function drawCalendar(option) { var //variables for creating calendar @@ -533,23 +533,23 @@ //get calendar HTML switch (option.type) { - case "day": - //get calendar detail - calendar = getCalendar(option.year, option.month, option.date); - //get calendar html - calendarHTML = drawCalendarDay(calendar, option); - break; - - case "month": - //get calendar detail - calendar = getCalendar(option.year, option.month, option.date); - //get calendar html - calendarHTML = drawCalendarMonthTable(calendar, option); - break; - - default: - global.console.error("Invalid type"); - return false; + case "day": + //get calendar detail + calendar = getCalendar(option.year, option.month, option.date); + //get calendar html + calendarHTML = drawCalendarDay(calendar, option); + break; + + case "month": + //get calendar detail + calendar = getCalendar(option.year, option.month, option.date); + //get calendar html + calendarHTML = drawCalendarMonthTable(calendar, option); + break; + + default: + global.console.error("Invalid type"); + return false; } //draw calendar diff --git a/js/dycalendar.min.js b/js/dycalendar.min.js index 8df7100..8722f38 100755 --- a/js/dycalendar.min.js +++ b/js/dycalendar.min.js @@ -1,2 +1,2 @@ /*! dyCalendarJS | (c) 2016 Yusuf Shakeel | https://github.com/yusufshakeel/dyCalendarJS */ -!function(t){"use strict";function e(t,e){var a,n,r,d,l,i;for(a=s.createElement("table"),n=s.createElement("tr"),l=0;6>=l;l+=1)r=s.createElement("td"),r.innerHTML="SMTWTFS"[l],n.appendChild(r);for(a.appendChild(n),n=s.createElement("tr"),l=0;6>=l&&l!==t.firstDayIndex;l+=1)r=s.createElement("td"),n.appendChild(r);for(i=1;6>=l;)r=s.createElement("td"),r.innerHTML=i,t.today.date===i&&t.today.monthIndex===t.monthIndex&&e.highlighttoday===!0&&r.setAttribute("class","dycalendar-today-date"),e.date===i&&e.month===t.monthIndex&&e.highlighttargetdate===!0&&r.setAttribute("class","dycalendar-target-date"),n.appendChild(r),i+=1,l+=1;for(a.appendChild(n),d=3;7>=d;d+=1){for(n=s.createElement("tr"),l=0;6>=l;l+=1){if(i>t.totaldays)return a.appendChild(n),a;r=s.createElement("td"),r.innerHTML=i,t.today.date===i&&t.today.monthIndex===t.monthIndex&&e.highlighttoday===!0&&r.setAttribute("class","dycalendar-today-date"),e.date===i&&e.month===t.monthIndex&&e.highlighttargetdate===!0&&r.setAttribute("class","dycalendar-target-date"),i+=1,n.appendChild(r)}a.appendChild(n)}return a}function a(t,a){var n,r,d,l;return n=e(t,a),d=s.createElement("div"),d.setAttribute("class","dycalendar-month-container"),r=s.createElement("div"),r.setAttribute("class","dycalendar-header"),r.setAttribute("data-option",JSON.stringify(a)),"show"===a.prevnextbutton&&(l=s.createElement("span"),l.setAttribute("class","dycalendar-prev-next-btn prev-btn"),l.setAttribute("data-date",a.date),l.setAttribute("data-month",a.month),l.setAttribute("data-year",a.year),l.setAttribute("data-btn","prev"),l.innerHTML="<",r.appendChild(l)),l=s.createElement("span"),l.setAttribute("class","dycalendar-span-month-year"),"mmm"===a.monthformat?l.innerHTML=t.monthName+" "+t.year:"full"===a.monthformat&&(l.innerHTML=t.monthNameFull+" "+t.year),r.appendChild(l),"show"===a.prevnextbutton&&(l=s.createElement("span"),l.setAttribute("class","dycalendar-prev-next-btn next-btn"),l.setAttribute("data-date",a.date),l.setAttribute("data-month",a.month),l.setAttribute("data-year",a.year),l.setAttribute("data-btn","next"),l.innerHTML=">",r.appendChild(l)),d.appendChild(r),r=s.createElement("div"),r.setAttribute("class","dycalendar-body"),r.appendChild(n),d.appendChild(r),d}function n(t,e){var a,n,r;return n=s.createElement("div"),n.setAttribute("class","dycalendar-day-container"),a=s.createElement("div"),a.setAttribute("class","dycalendar-header"),r=s.createElement("span"),r.setAttribute("class","dycalendar-span-day"),"ddd"===e.dayformat?r.innerHTML=c.ddd[t.targetedDayIndex]:"full"===e.dayformat&&(r.innerHTML=c.full[t.targetedDayIndex]),a.appendChild(r),n.appendChild(a),a=s.createElement("div"),a.setAttribute("class","dycalendar-body"),r=s.createElement("span"),r.setAttribute("class","dycalendar-span-date"),r.innerHTML=t.date,a.appendChild(r),n.appendChild(a),a=s.createElement("div"),a.setAttribute("class","dycalendar-footer"),r=s.createElement("span"),r.setAttribute("class","dycalendar-span-month-year"),"mmm"===e.monthformat?r.innerHTML=t.monthName+" "+t.year:"full"===e.monthformat&&(r.innerHTML=t.monthNameFull+" "+t.year),a.appendChild(r),n.appendChild(a),n}function r(t,e){var a;for(a in e)t.hasOwnProperty(a)===!1&&(t[a]=e[a]);return t}function d(e,a,n){var r,d,l=new Date,i={};return m>e||e>u?(t.console.error("Invalid Year"),!1):a>11||0>a?(t.console.error("Invalid Month"),!1):n>31||1>n?(t.console.error("Invalid Date"),!1):(i.year=e,i.month=a,i.date=n,i.today={},r=l.toString().split(" "),d=c.ddd.indexOf(r[0]),i.today.dayIndex=d,i.today.dayName=r[0],i.today.dayFullName=c.full[d],d=y.mmm.indexOf(r[1]),i.today.monthIndex=d,i.today.monthName=r[1],i.today.monthNameFull=y.full[d],i.today.date=l.getDate(),i.today.year=r[3],l.setFullYear(e),l.setMonth(a),l.setDate(1),r=l.toString().split(" "),d=c.ddd.indexOf(r[0]),i.firstDayIndex=d,i.firstDayName=r[0],i.firstDayFullName=c.full[d],d=y.mmm.indexOf(r[1]),i.monthIndex=d,i.monthName=r[1],i.monthNameFull=y.full[d],l.setFullYear(e),l.setMonth(a+1),l.setDate(0),i.totaldays=l.getDate(),l.setFullYear(e),l.setMonth(a),l.setDate(n),r=l.toString().split(" "),d=c.ddd.indexOf(r[0]),i.targetedDayIndex=d,i.targetedDayName=r[0],i.targetedDayFullName=c.full[d],i)}function l(){s.body.onclick=function(e){e=t.event||e;var a,n,r,d,l,o,s=e.target||e.srcElement;s&&s.classList&&s.classList.contains("dycalendar-prev-next-btn")&&(a=parseInt(s.getAttribute("data-date")),n=parseInt(s.getAttribute("data-month")),r=parseInt(s.getAttribute("data-year")),d=s.getAttribute("data-btn"),l=JSON.parse(s.parentElement.getAttribute("data-option")),"prev"===d?(n-=1,0>n&&(r-=1,n=11)):"next"===d&&(n+=1,n>11&&(r+=1,n=0)),l.date=a,l.month=n,l.year=r,i(l)),s&&s.classList&&s.classList.contains("dycalendar-span-month-year")&&(l=JSON.parse(s.parentElement.getAttribute("data-option")),o=new Date,l.date=o.getDate(),l.month=o.getMonth(),l.year=o.getFullYear(),i(l))}}function i(e){var r,l,i,o,m,u,y="id";switch("#"===e.target[0]?y="id":"."===e.target[0]&&(y="class"),i=e.target.substring(1),e.type){case"day":r=d(e.year,e.month,e.date),l=n(r,e);break;case"month":r=d(e.year,e.month,e.date),l=a(r,e);break;default:return t.console.error("Invalid type"),!1}if("id"===y)s.getElementById(i).innerHTML=l.outerHTML;else if("class"===y)for(u=s.getElementsByClassName(i),o=0,m=u.length;m>o;o+=1)u[o].innerHTML=l.outerHTML}var o={},s=t.document,m=1900,u=9999,y={full:["January","February","March","April","May","June","July","August","September","October","November","December"],mmm:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]},c={full:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],d:["S","M","T","W","T","F","S"],dd:["Su","Mo","Tu","We","Th","Fr","Sa"],ddd:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]};o.draw=function(e){if("undefined"==typeof e)return t.console.error("Option missing"),!1;var a=new Date,n={type:"day",month:a.getMonth(),year:a.getFullYear(),date:a.getDate(),monthformat:"full",dayformat:"full",highlighttoday:!1,highlighttargetdate:!1,prevnextbutton:"hide"};e=r(e,n),i(e)},l(),t.dycalendar=o}("undefined"!=typeof window?window:this); +!function(t){"use strict";function e(t,e){var a,n,r,d,l,i;for(a=o.createElement("table"),n=o.createElement("tr"),l=0;l<=6;l+=1)(r=o.createElement("td")).innerHTML="SMTWTFS"[l],n.appendChild(r);for(a.appendChild(n),n=o.createElement("tr"),l=0;l<=6&&l!==t.firstDayIndex;l+=1)r=o.createElement("td"),n.appendChild(r);for(i=1;l<=6;)(r=o.createElement("td")).innerHTML=i,t.today.date===i&&t.today.monthIndex===t.monthIndex&&!0===e.highlighttoday&&r.setAttribute("class","dycalendar-today-date"),e.date===i&&e.month===t.monthIndex&&!0===e.highlighttargetdate&&r.setAttribute("class","dycalendar-target-date"),n.appendChild(r),i+=1,l+=1;for(a.appendChild(n),d=3;d<=7;d+=1){for(n=o.createElement("tr"),l=0;l<=6;l+=1){if(i>t.totaldays)return a.appendChild(n),a;(r=o.createElement("td")).innerHTML=i,t.today.date===i&&t.today.monthIndex===t.monthIndex&&!0===e.highlighttoday&&r.setAttribute("class","dycalendar-today-date"),e.date===i&&e.month===t.monthIndex&&!0===e.highlighttargetdate&&r.setAttribute("class","dycalendar-target-date"),i+=1,n.appendChild(r)}a.appendChild(n)}return a}function a(t,a){var n,r,d,l;return n=e(t,a),(d=o.createElement("div")).setAttribute("class","dycalendar-month-container"),(r=o.createElement("div")).setAttribute("class","dycalendar-header"),r.setAttribute("data-option",JSON.stringify(a)),"show"===a.prevnextbutton&&((l=o.createElement("span")).setAttribute("class","dycalendar-prev-next-btn prev-btn"),l.setAttribute("data-date",a.date),l.setAttribute("data-month",a.month),l.setAttribute("data-year",a.year),l.setAttribute("data-btn","prev"),l.innerHTML="<",r.appendChild(l)),(l=o.createElement("span")).setAttribute("class","dycalendar-span-month-year"),"mmm"===a.monthformat?l.innerHTML=t.monthName+" "+t.year:"full"===a.monthformat&&(l.innerHTML=t.monthNameFull+" "+t.year),r.appendChild(l),"show"===a.prevnextbutton&&((l=o.createElement("span")).setAttribute("class","dycalendar-prev-next-btn next-btn"),l.setAttribute("data-date",a.date),l.setAttribute("data-month",a.month),l.setAttribute("data-year",a.year),l.setAttribute("data-btn","next"),l.innerHTML=">",r.appendChild(l)),d.appendChild(r),(r=o.createElement("div")).setAttribute("class","dycalendar-body"),r.appendChild(n),d.appendChild(r),d}function n(t,e){var a,n,r;return(n=o.createElement("div")).setAttribute("class","dycalendar-day-container"),(a=o.createElement("div")).setAttribute("class","dycalendar-header"),(r=o.createElement("span")).setAttribute("class","dycalendar-span-day"),"ddd"===e.dayformat?r.innerHTML=y.ddd[t.targetedDayIndex]:"full"===e.dayformat&&(r.innerHTML=y.full[t.targetedDayIndex]),a.appendChild(r),n.appendChild(a),(a=o.createElement("div")).setAttribute("class","dycalendar-body"),(r=o.createElement("span")).setAttribute("class","dycalendar-span-date"),r.innerHTML=t.date,a.appendChild(r),n.appendChild(a),(a=o.createElement("div")).setAttribute("class","dycalendar-footer"),(r=o.createElement("span")).setAttribute("class","dycalendar-span-month-year"),"mmm"===e.monthformat?r.innerHTML=t.monthName+" "+t.year:"full"===e.monthformat&&(r.innerHTML=t.monthNameFull+" "+t.year),a.appendChild(r),n.appendChild(a),n}function r(t,e){var a;for(a in e)!1===t.hasOwnProperty(a)&&(t[a]=e[a]);return t}function d(e,a,n){var r,d,l=new Date,i={};return em?(t.console.error("Invalid Year"),!1):a>11||a<0?(t.console.error("Invalid Month"),!1):n>31||n<1?(t.console.error("Invalid Date"),!1):(i.year=e,i.month=a,i.date=n,i.today={},r=l.toString().split(" "),d=y.ddd.indexOf(r[0]),i.today.dayIndex=d,i.today.dayName=r[0],i.today.dayFullName=y.full[d],d=u.mmm.indexOf(r[1]),i.today.monthIndex=d,i.today.monthName=r[1],i.today.monthNameFull=u.full[d],i.today.date=l.getDate(),i.today.year=r[3],l.setDate(1),l.setMonth(a),l.setFullYear(e),r=l.toString().split(" "),d=y.ddd.indexOf(r[0]),i.firstDayIndex=d,i.firstDayName=r[0],i.firstDayFullName=y.full[d],d=u.mmm.indexOf(r[1]),i.monthIndex=d,i.monthName=r[1],i.monthNameFull=u.full[d],l.setFullYear(e),l.setMonth(a+1),l.setDate(0),i.totaldays=l.getDate(),l.setFullYear(e),l.setMonth(a),l.setDate(n),r=l.toString().split(" "),d=y.ddd.indexOf(r[0]),i.targetedDayIndex=d,i.targetedDayName=r[0],i.targetedDayFullName=y.full[d],i)}function l(e){var r,l,i,s,m,u="id";switch("#"===e.target[0]?u="id":"."===e.target[0]&&(u="class"),l=e.target.substring(1),e.type){case"day":r=n(d(e.year,e.month,e.date),e);break;case"month":r=a(d(e.year,e.month,e.date),e);break;default:return t.console.error("Invalid type"),!1}if("id"===u)o.getElementById(l).innerHTML=r.outerHTML;else if("class"===u)for(i=0,s=(m=o.getElementsByClassName(l)).length;i11&&(r+=1,n=0),i.date=a,i.month=n,i.year=r,l(i)),s&&s.classList&&s.classList.contains("dycalendar-span-month-year")&&(i=JSON.parse(s.parentElement.getAttribute("data-option")),o=new Date,i.date=o.getDate(),i.month=o.getMonth(),i.year=o.getFullYear(),l(i))}}(),t.dycalendar=i}("undefined"!=typeof window?window:this); \ No newline at end of file