-
Notifications
You must be signed in to change notification settings - Fork 171
/
ouical.min.js
1 lines (1 loc) · 7.79 KB
/
ouical.min.js
1
;(function(e){var t=60*1e3;var n=function(e){return e.toISOString().replace(/-|:|\.\d+/g,"")};var r=function(e){return e.end?n(e.end):n(new Date(e.start.getTime()+e.duration*t))};var i={google:function(e){var t=n(e.start);var i=r(e);var s=encodeURI(["https://www.google.com/calendar/render","?action=TEMPLATE","&text="+(e.title||""),"&dates="+(t||""),"/"+(i||""),"&details="+(e.description||""),"&location="+(e.address||""),"&sprop=&sprop=name:"].join(""));return'<a class="icon-google" target="_blank" href="'+s+'">Google Calendar</a>'},yahoo:function(e){var r=e.end?(e.end.getTime()-e.start.getTime())/t:e.duration;var i=r<600?"0"+Math.floor(r/60):Math.floor(r/60)+"";var s=r%60<10?"0"+r%60:r%60+"";var o=i+s;var u=n(new Date(e.start-e.start.getTimezoneOffset()*t))||"";var a=encodeURI(["http://calendar.yahoo.com/?v=60&view=d&type=20","&title="+(e.title||""),"&st="+u,"&dur="+(o||""),"&desc="+(e.description||""),"&in_loc="+(e.address||"")].join(""));return'<a class="icon-yahoo" target="_blank" href="'+a+'">Yahoo! Calendar</a>'},ics:function(e,t,i){var s=n(e.start);var o=r(e);var u=encodeURI("data:text/calendar;charset=utf8,"+["BEGIN:VCALENDAR","VERSION:2.0","BEGIN:VEVENT","URL:"+document.URL,"DTSTART:"+(s||""),"DTEND:"+(o||""),"SUMMARY:"+(e.title||""),"DESCRIPTION:"+(e.description||""),"LOCATION:"+(e.address||""),"END:VEVENT","END:VCALENDAR"].join("\n"));return'<a class="'+t+'" target="_blank" href="'+u+'">'+i+" Calendar</a>"},ical:function(e){return this.ics(e,"icon-ical","iCal")},outlook:function(e){return this.ics(e,"icon-outlook","Outlook")}};var s=function(e){return{google:i.google(e),yahoo:i.yahoo(e),ical:i.ical(e),outlook:i.outlook(e)}};var o=function(){if(!document.getElementById("ouical-css")){document.getElementsByTagName("head")[0].appendChild(u())}};var u=function(){var e=document.createElement("style");e.id="ouical-css";e.innerHTML="#add-to-calendar-checkbox-label{cursor:pointer}.add-to-calendar-checkbox~a{display:none}.add-to-calendar-checkbox:checked~a{display:block;width:150px;margin-left:20px}input[type=checkbox].add-to-calendar-checkbox{position:absolute;top:-9999px;left:-9999px}.add-to-calendar-checkbox~a:before{width:16px;height:16px;display:inline-block;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFQAAAAQCAYAAACIoli7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo0MzJCRDU2NUE1MDIxMUUyOTY1Q0EwNTkxNEJDOUIwNCIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZ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pzah3SWj3n6GQMKf7/wAmP6/65fq6uubGpsaOFntLuqPdARe5v4fY2emi1uej/OBmjjan3+V2tfi8voZYLFoXlaJnjQZDhZoJgi7GXX4IQPNN+Th9sJuhmKuCWM5w5pvqNiSLlfg/yhcLx2PEqA+QqhR/wX5jHirrdbIJI24A/lG9Gqt/U45NWz7Ey9s/BzQ3QpUQQajdjMS0NixdtQhFxTfTGzVQDc6rFJ/85Zdfem6ePr29dMuWdGKi5PV6Ov2BQFMoFL5INXqtx+upd3d21rXY7Y5AIMBvTp8FCJeXl/nVBKNFRa7Ag+xgsnH2K0p79+474Ix1IJWy5qgXuw40MPb8dwFkOFfngA0nY9zqQe1WnrQtzQRSBgwGEXs2zqUHmXvFvCCFLwP/Lw6PdhQLjVqFVIwSkCRFIgdPVp+sI66d7ury1Xrc7saGhkZ7OBziAEpxGotXYYQg/J4CReZwh3fdriqM2IQkrZN1mg/H9joY+4DMvSyt+eQlTL71uf8a+65VfvVw5nDh5Jpl58NHMK5FCT88diaSGi4DFYnTHvDkgTUyl/8IMABtKh8piZwIuwAAAABJRU5ErkJggg==);margin-right:.5em;content:' '}.icon-ical:before{background-position:-68px 0}.icon-outlook:before{}.icon-yahoo:before{background-position:-36px +4px}.icon-google:before{background-position:-52px 0}";return e};var a=function(e){return e.data!==undefined&&e.data.start!==undefined&&(e.data.end!==undefined||e.data.duration!==undefined)};var f=function(e,t,n){var r=document.createElement("div");r.innerHTML='<label for="checkbox-for-'+n+'" class="add-to-calendar-checkbox">+ Add to my Calendar</label>';r.innerHTML+='<input name="add-to-calendar-checkbox" class="add-to-calendar-checkbox" id="checkbox-for-'+n+'" type="checkbox">';Object.keys(e).forEach(function(t){r.innerHTML+=e[t]});r.className="add-to-calendar";if(t!==undefined){r.className+=" "+t}o();r.id=n;return r};var l=function(e){if(e.options&&e.options.class){return e.options.class}};var c=function(e){return e.options&&e.options.id?e.options.id:Math.floor(Math.random()*1e6)};e.createCalendar=function(e){if(!a(e)){console.log("Event details missing.");return}return f(s(e.data),l(e),c(e))}})(this);