-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcalendar.js
1 lines (1 loc) · 2.42 KB
/
calendar.js
1
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var weeks=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months=["January","February","March","April","May","June","July","August","September","October","November","December"],createCalendarHTML=function(e,a){var t=function(a,t){var n=e.parse(a,{}).filter(function(e){return"paragraph_open"!=e.type&&"paragraph_close"!=e.type});return n=n.map(function(e){return e.map&&(e.map[0]+=t,e.map[1]+=t),e}),e.renderer.render(n,{html:!1})},n=a.Year,r=a.Month,l=a.Days,i=new Date(n,r,0);i.setFullYear(n);var c=i.getDate();i.setDate(1);var d=i.getDay(),s=document.createElement("table"),o=document.createElement("th"),p=void 0,m=void 0;s.className="calendar table table-responsive container-fluid",s.setAttribute("year",n),s.setAttribute("month",r),p=s.insertRow(),p.appendChild(o),o.colSpan="7",o.className="calendar-time",o.innerHTML=months[parseInt(r)-1]+'<span class="calendar-year"> '+n+"</span>",p=s.insertRow();for(var v=0;v<7;++v)m=p.insertCell(),m.innerHTML=weeks[v],m.className="calendar-week-name";for(var u=0;u<d;++u)u%7==0&&(p=s.insertRow()),m=p.insertCell();for(var h=d;h<c+d;++h){var M=document.createElement("p"),f=h-d+1;h%7==0&&(p=s.insertRow()),m=p.insertCell(),m.className="calendar-cell",i.setDate(f),M.innerHTML=f,M.className="calendar-cell-date",m.appendChild(M),void 0!==l[i]&&function(){var e=l[i].events,a=document.createElement("div"),c=document.createElement("div");if(void 0!==l[i].title){var d=document.createElement("div"),s=t(l[i].title,l[i].startLine),o=document.createElement("div");d.innerHTML=""+s,d.className="calendar-cell-title",m.appendChild(d),o.innerHTML=s,o.className="calendar-overview-title",c.appendChild(o)}e&&e.forEach(function(e){var n=document.createElement("div"),r=document.createElement("div"),l=t(e.tag,e.startLine),i=t(e.description,e.startLine);n.innerHTML=l,e.description&&e.description.length&&(n.innerHTML+='<div class="calendar-content-tag-hover">'+i+"</div>"),n.className="calendar-content-tag",a.appendChild(n);var d=e.description&&e.description.length?l+" : ":l;r.innerHTML='<span class="calendar-overview-tag">'+d+" </span> "+i,c.appendChild(r)});var p=document.createElement("p");p.innerHTML=n+"."+r+"."+f,p.className="calendar-overview-date",c.appendChild(p),a.className="calendar-content",c.className="calendar-overview",m.appendChild(a),m.appendChild(c)}()}for(var C=c+d;C%7!=0;++C)m=p.insertCell();return s.outerHTML};exports.default=createCalendarHTML;