chaospott-site/web/js/ical.min.js

4 lines
78 KiB
JavaScript
Raw Normal View History

2018-01-19 18:08:11 +00:00
"object"==typeof module?ICAL=module.exports:"object"!=typeof ICAL&&(this.ICAL={}),ICAL.foldLength=75,ICAL.newLineChar="\r\n",ICAL.helpers={isStrictlyNaN:function(a){return"number"==typeof a&&isNaN(a)},strictParseInt:function(a){var b=parseInt(a,10);if(ICAL.helpers.isStrictlyNaN(b))throw new Error('Could not extract integer from "'+a+'"');return b},formatClassType:function(a,b){if("undefined"!=typeof a)return a instanceof b?a:new b(a)},unescapedIndexOf:function(a,b,c){for(;(c=a.indexOf(b,c))!==-1;){if(!(c>0&&"\\"===a[c-1]))return c;c+=1}return-1},binsearchInsert:function(a,b,c){if(!a.length)return 0;for(var d,e,f=0,g=a.length-1;f<=g;)if(d=f+Math.floor((g-f)/2),e=c(b,a[d]),e<0)g=d-1;else{if(!(e>0))break;f=d+1}return e<0?d:e>0?d+1:d},dumpn:function(){ICAL.debug&&("undefined"!=typeof console&&"log"in console?ICAL.helpers.dumpn=function(a){console.log(a)}:ICAL.helpers.dumpn=function(a){dump(a+"\n")},ICAL.helpers.dumpn(arguments[0]))},clone:function(a,b){if(a&&"object"==typeof a){if(a instanceof Date)return new Date(a.getTime());if("clone"in a)return a.clone();if(Array.isArray(a)){for(var c=[],d=0;d<a.length;d++)c.push(b?ICAL.helpers.clone(a[d],!0):a[d]);return c}var e={};for(var f in a)Object.prototype.hasOwnProperty.call(a,f)&&(b?e[f]=ICAL.helpers.clone(a[f],!0):e[f]=a[f]);return e}return a},foldline:function(a){for(var b="",c=a||"";c.length;)b+=ICAL.newLineChar+" "+c.substr(0,ICAL.foldLength),c=c.substr(ICAL.foldLength);return b.substr(ICAL.newLineChar.length+1)},pad2:function(a){"string"!=typeof a&&("number"==typeof a&&(a=parseInt(a)),a=String(a));var b=a.length;switch(b){case 0:return"00";case 1:return"0"+a;default:return a}},trunc:function(a){return a<0?Math.ceil(a):Math.floor(a)},inherits:function(a,b,c){function d(){}d.prototype=a.prototype,b.prototype=new d,c&&ICAL.helpers.extend(c,b.prototype)},extend:function(a,b){for(var c in a){var d=Object.getOwnPropertyDescriptor(a,c);d&&!Object.getOwnPropertyDescriptor(b,c)&&Object.defineProperty(b,c,d)}return b}},ICAL.design=function(){"use strict";function a(a,b){var d={matches:/.*/,fromICAL:function(b,d){return c(b,a,d)},toICAL:function(a,c){var d=b;return c&&(d=new RegExp(d.source+"|"+c)),a.replace(d,function(a){switch(a){case"\\":return"\\\\";case";":return"\\;";case",":return"\\,";case"\n":return"\\n";default:return a}})}};return d}function b(a){switch(a){case"\\\\":return"\\";case"\\;":return";";case"\\,":return",";case"\\n":case"\\N":return"\n";default:return a}}function c(a,c,d){return a.indexOf("\\")===-1?a:(d&&(c=new RegExp(c.source+"|\\\\"+d)),a.replace(c,b))}var d=/\\\\|\\;|\\,|\\[Nn]/g,e=/\\|;|,|\n/g,f=/\\\\|\\,|\\[Nn]/g,g=/\\|,|\n/g,h={defaultType:"text"},i={defaultType:"text",multiValue:","},j={defaultType:"text",structuredValue:";"},k={defaultType:"integer"},l={defaultType:"date-time",allowedTypes:["date-time","date"]},m={defaultType:"date-time"},n={defaultType:"uri"},o={defaultType:"utc-offset"},p={defaultType:"recur"},q={defaultType:"date-and-or-time",allowedTypes:["date-time","date","text"]},r={categories:i,url:n,version:h,uid:h},s={boolean:{values:["TRUE","FALSE"],fromICAL:function(a){switch(a){case"TRUE":return!0;case"FALSE":return!1;default:return!1}},toICAL:function(a){return a?"TRUE":"FALSE"}},float:{matches:/^[+-]?\d+\.\d+$/,fromICAL:function(a){var b=parseFloat(a);return ICAL.helpers.isStrictlyNaN(b)?0:b},toICAL:function(a){return String(a)}},integer:{fromICAL:function(a){var b=parseInt(a);return ICAL.helpers.isStrictlyNaN(b)?0:b},toICAL:function(a){return String(a)}},"utc-offset":{toICAL:function(a){return a.length<7?a.substr(0,3)+a.substr(4,2):a.substr(0,3)+a.substr(4,2)+a.substr(7,2)},fromICAL:function(a){return a.length<6?a.substr(0,3)+":"+a.substr(3,2):a.substr(0,3)+":"+a.substr(3,2)+":"+a.substr(5,2)},decorate:function(a){return ICAL.UtcOffset.fromString(a)},undecorate:function(a){return a.toString()}}},t={cutype:{values:["INDIVIDUAL","GROUP","RESOURCE","ROOM","UNKNOWN"],allowXName:!0,allowIanaToken:!0},"delegated-from":{valueType:"cal-address",multiValue:",",multiValueSeparateDQuote:!0},"delegated-to":{valueType:"cal-address",multiValue:",",mu
a+="P",this.weeks&&(a+=this.weeks+"W"),this.days&&(a+=this.days+"D"),(this.hours||this.minutes||this.seconds)&&(a+="T",this.hours&&(a+=this.hours+"H"),this.minutes&&(a+=this.minutes+"M"),this.seconds&&(a+=this.seconds+"S")),a},toICALString:function(){return this.toString()}},ICAL.Duration.fromSeconds=function(a){return(new ICAL.Duration).fromSeconds(a)},ICAL.Duration.isValueString=function(a){return"P"===a[0]||"P"===a[1]},ICAL.Duration.fromString=function(c){for(var d=0,e=Object.create(null),f=0;(d=c.search(b))!==-1;){var g=c[d],h=c.substr(0,d);c=c.substr(d+1),f+=a(g,h,e)}if(f<2)throw new Error('invalid duration value: Not enough duration components in "'+c+'"');return new ICAL.Duration(e)},ICAL.Duration.fromData=function(a){return new ICAL.Duration(a)}}(),function(){var a=["tzid","location","tznames","latitude","longitude"];ICAL.Timezone=function(a){this.wrappedJSObject=this,this.fromData(a)},ICAL.Timezone.prototype={tzid:"",location:"",tznames:"",latitude:0,longitude:0,component:null,expandedUntilYear:0,icalclass:"icaltimezone",fromData:function(b){if(this.expandedUntilYear=0,this.changes=[],b instanceof ICAL.Component)this.component=b;else{if(b&&"component"in b)if("string"==typeof b.component){var c=ICAL.parse(b.component);this.component=new ICAL.Component(c)}else b.component instanceof ICAL.Component?this.component=b.component:this.component=null;for(var d in a)if(a.hasOwnProperty(d)){var e=a[d];b&&e in b&&(this[e]=b[e])}}return this.component instanceof ICAL.Component&&!this.tzid&&(this.tzid=this.component.getFirstPropertyValue("tzid")),this},utcOffset:function(a){if(this==ICAL.Timezone.utcTimezone||this==ICAL.Timezone.localTimezone)return 0;if(this._ensureCoverage(a.year),!this.changes.length)return 0;for(var b={year:a.year,month:a.month,day:a.day,hour:a.hour,minute:a.minute,second:a.second},c=this._findNearbyChange(b),d=-1,e=1;;){var f=ICAL.helpers.clone(this.changes[c],!0);f.utcOffset<f.prevUtcOffset?ICAL.Timezone.adjust_change(f,0,0,0,f.utcOffset):ICAL.Timezone.adjust_change(f,0,0,0,f.prevUtcOffset);var g=ICAL.Timezone._compare_change_fn(b,f);if(g>=0?d=c:e=-1,e==-1&&d!=-1)break;if(c+=e,c<0)return 0;if(c>=this.changes.length)break}var h=this.changes[d],i=h.utcOffset-h.prevUtcOffset;if(i<0&&d>0){var j=ICAL.helpers.clone(h,!0);if(ICAL.Timezone.adjust_change(j,0,0,0,j.prevUtcOffset),ICAL.Timezone._compare_change_fn(b,j)<0){var k=this.changes[d-1],l=!1;h.is_daylight!=l&&k.is_daylight==l&&(h=k)}}return h.utcOffset},_findNearbyChange:function(a){var b=ICAL.helpers.binsearchInsert(this.changes,a,ICAL.Timezone._compare_change_fn);return b>=this.changes.length?this.changes.length-1:b},_ensureCoverage:function(a){if(ICAL.Timezone._minimumExpansionYear==-1){var b=ICAL.Time.now();ICAL.Timezone._minimumExpansionYear=b.year}var c=a;if(c<ICAL.Timezone._minimumExpansionYear&&(c=ICAL.Timezone._minimumExpansionYear),c+=ICAL.Timezone.EXTRA_COVERAGE,c>ICAL.Timezone.MAX_YEAR&&(c=ICAL.Timezone.MAX_YEAR),!this.changes.length||this.expandedUntilYear<a){for(var d=this.component.getAllSubcomponents(),e=d.length,f=0;f<e;f++)this._expandComponent(d[f],c,this.changes);this.changes.sort(ICAL.Timezone._compare_change_fn),this.expandedUntilYear=c}},_expandComponent:function(a,b,c){function d(a){return a.factor*(3600*a.hours+60*a.minutes)}function e(){var b={};return b.is_daylight="daylight"==a.name,b.utcOffset=d(a.getFirstProperty("tzoffsetto").getFirstValue()),b.prevUtcOffset=d(a.getFirstProperty("tzoffsetfrom").getFirstValue()),b}if(!a.hasProperty("dtstart")||!a.hasProperty("tzoffsetto")||!a.hasProperty("tzoffsetfrom"))return null;var f,g=a.getFirstProperty("dtstart").getFirstValue();if(a.hasProperty("rrule")||a.hasProperty("rdate")){var h=a.getAllProperties("rdate");for(var i in h)if(h.hasOwnProperty(i)){var j=h[i],k=j.getFirstValue();f=e(),f.year=k.year,f.month=k.month,f.day=k.day,k.isDate?(f.hour=g.hour,f.minute=g.minute,f.second=g.second,g.zone!=ICAL.Timezone.utcTimezone&&ICAL.Timezone.adjust_change(f,0,0,0,-f.prevUtcOffset)):(f.hour=k.hour,f.minute=k.minute,f.second=k.second,k.zone!=ICAL.Timezone.utcTimezone&&ICAL.Timezone.adjust_change
this.last.day=c.day,this.last.month=c.month},ruleDayOfWeek:function(a){var b=a.match(/([+-]?[0-9])?(MO|TU|WE|TH|FR|SA|SU)/);if(b){var c=parseInt(b[1]||0,10);return a=ICAL.Recur.icalDayToNumericDay(b[2]),[c,a]}return[0,0]},next_generic:function(a,b,c,d,e){var f=a in this.by_data,g=this.rule.freq==b,h=0;if(e&&0==this[e]())return h;if(f){this.by_indices[a]++;var i=(this.by_indices[a],this.by_data[a]);this.by_indices[a]==i.length&&(this.by_indices[a]=0,h=1),this.last[c]=i[this.by_indices[a]]}else g&&this["increment_"+c](this.rule.interval);return f&&h&&g&&this["increment_"+d](1),h},increment_monthday:function(a){for(var b=0;b<a;b++){var c=ICAL.Time.daysInMonth(this.last.month,this.last.year);this.last.day++,this.last.day>c&&(this.last.day-=c,this.increment_month())}},increment_month:function(){if(this.last.day=1,this.has_by_data("BYMONTH"))this.by_indices.BYMONTH++,this.by_indices.BYMONTH==this.by_data.BYMONTH.length&&(this.by_indices.BYMONTH=0,this.increment_year(1)),this.last.month=this.by_data.BYMONTH[this.by_indices.BYMONTH];else{"MONTHLY"==this.rule.freq?this.last.month+=this.rule.interval:this.last.month++,this.last.month--;var a=ICAL.helpers.trunc(this.last.month/12);this.last.month%=12,this.last.month++,0!=a&&this.increment_year(a)}},increment_year:function(a){this.last.year+=a},increment_generic:function(a,b,c,d){this.last[b]+=a;var e=ICAL.helpers.trunc(this.last[b]/c);this.last[b]%=c,0!=e&&this["increment_"+d](e)},has_by_data:function(a){return a in this.rule.parts},expand_year_days:function(a){var b=new ICAL.Time;this.days=[];var c={},d=["BYDAY","BYWEEKNO","BYMONTHDAY","BYMONTH","BYYEARDAY"];for(var e in d)if(d.hasOwnProperty(e)){var f=d[e];f in this.rule.parts&&(c[f]=this.rule.parts[f])}if("BYMONTH"in c&&"BYWEEKNO"in c){var g=1,h={};b.year=a,b.isDate=!0;for(var i=0;i<this.by_data.BYMONTH.length;i++){var j=this.by_data.BYMONTH[i];b.month=j,b.day=1;var k=b.weekNumber(this.rule.wkst);b.day=ICAL.Time.daysInMonth(j,a);var l=b.weekNumber(this.rule.wkst);for(i=k;i<l;i++)h[i]=1}for(var m=0;m<this.by_data.BYWEEKNO.length&&g;m++){var n=this.by_data.BYWEEKNO[m];n<52?g&=h[m]:g=0}g?delete c.BYMONTH:delete c.BYWEEKNO}var o=Object.keys(c).length;if(0==o){var p=this.dtstart.clone();p.year=this.last.year,this.days.push(p.dayOfYear())}else if(1==o&&"BYMONTH"in c){for(var q in this.by_data.BYMONTH)if(this.by_data.BYMONTH.hasOwnProperty(q)){var r=this.dtstart.clone();r.year=a,r.month=this.by_data.BYMONTH[q],r.isDate=!0,this.days.push(r.dayOfYear())}}else if(1==o&&"BYMONTHDAY"in c){for(var s in this.by_data.BYMONTHDAY)if(this.by_data.BYMONTHDAY.hasOwnProperty(s)){var t=this.dtstart.clone(),u=this.by_data.BYMONTHDAY[s];if(u<0){var v=ICAL.Time.daysInMonth(t.month,a);u=u+v+1}t.day=u,t.year=a,t.isDate=!0,this.days.push(t.dayOfYear())}}else if(2==o&&"BYMONTHDAY"in c&&"BYMONTH"in c){for(var q in this.by_data.BYMONTH)if(this.by_data.BYMONTH.hasOwnProperty(q)){var w=this.by_data.BYMONTH[q],v=ICAL.Time.daysInMonth(w,a);for(var s in this.by_data.BYMONTHDAY)if(this.by_data.BYMONTHDAY.hasOwnProperty(s)){var u=this.by_data.BYMONTHDAY[s];u<0&&(u=u+v+1),b.day=u,b.month=w,b.year=a,b.isDate=!0,this.days.push(b.dayOfYear())}}}else if(1==o&&"BYWEEKNO"in c);else if(2==o&&"BYWEEKNO"in c&&"BYMONTHDAY"in c);else if(1==o&&"BYDAY"in c)this.days=this.days.concat(this.expand_by_day(a));else if(2==o&&"BYDAY"in c&&"BYMONTH"in c){for(var q in this.by_data.BYMONTH)if(this.by_data.BYMONTH.hasOwnProperty(q)){var j=this.by_data.BYMONTH[q],v=ICAL.Time.daysInMonth(j,a);b.year=a,b.month=this.by_data.BYMONTH[q],b.day=1,b.isDate=!0;var x=b.dayOfWeek(),y=b.dayOfYear()-1;b.day=v;var z=b.dayOfWeek();if(this.has_by_data("BYSETPOS")){for(var A=[],B=1;B<=v;B++)b.day=B,this.is_day_in_byday(b)&&A.push(B);for(var C=0;C<A.length;C++)(this.check_set_position(C+1)||this.check_set_position(C-A.length))&&this.days.push(y+A[C])}else for(var D in this.by_data.BYDAY)if(this.by_data.BYDAY.hasOwnProperty(D)){var E,F=this.by_data.BYDAY[D],G=this.ruleDayOfWeek(F),H=G[0],I=G[1],J=(I+7-x)%7+1,K=v-(z+7-I)%7;if(0==H)for(var B=J;B<=v;B+=7)this.days.push(y+B);else H>0?(E=J+7*(H-1),E<=v&&this.days.
//# sourceMappingURL=ical.min.js.map