⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 icalendar.js

📁 dojo与json创建无限级树的时候,当在父结点下添加了一个新结点,我怎么让父亲结点重新调用json加载一下子结点内容.
💻 JS
📖 第 1 页 / 共 2 页
字号:
/*	Copyright (c) 2004-2006, The Dojo Foundation	All Rights Reserved.	Licensed under the Academic Free License version 2.1 or above OR the	modified BSD license. For more information on Dojo licensing, see:		http://dojotoolkit.org/community/licensing.shtml*/dojo.provide("dojo.iCalendar");dojo.require("dojo.text.textDirectory");dojo.require("dojo.date");dojo.require("dojo.lang");dojo.iCalendar.fromText =  function (/* string */text) {	// summary	// Parse text of an iCalendar and return an array of iCalendar objects	var properties = dojo.textDirectoryTokeniser.tokenise(text);	var calendars = [];	//dojo.debug("Parsing iCal String");	for (var i = 0, begun = false; i < properties.length; i++) {		var prop = properties[i];		if (!begun) {			if (prop.name == 'BEGIN' && prop.value == 'VCALENDAR') {				begun = true;				var calbody = [];			}		} else if (prop.name == 'END' && prop.value == 'VCALENDAR') {			calendars.push(new dojo.iCalendar.VCalendar(calbody));			begun = false;		} else {			calbody.push(prop);		}	}	return /* array */calendars;}dojo.iCalendar.Component = function (/* string */ body ) {	// summary	// A component is the basic container of all this stuff. 	if (!this.name) {		this.name = "COMPONENT"	}	this.properties = [];	this.components = [];	if (body) {		for (var i = 0, context = ''; i < body.length; i++) {			if (context == '') {				if (body[i].name == 'BEGIN') {					context = body[i].value;					var childprops = [];				} else {					this.addProperty(new dojo.iCalendar.Property(body[i]));				}			} else if (body[i].name == 'END' && body[i].value == context) {				if (context=="VEVENT") {					this.addComponent(new dojo.iCalendar.VEvent(childprops));				} else if (context=="VTIMEZONE") {					this.addComponent(new dojo.iCalendar.VTimeZone(childprops));				} else if (context=="VTODO") {					this.addComponent(new dojo.iCalendar.VTodo(childprops));				} else if (context=="VJOURNAL") {					this.addComponent(new dojo.iCalendar.VJournal(childprops));				} else if (context=="VFREEBUSY") {					this.addComponent(new dojo.iCalendar.VFreeBusy(childprops));				} else if (context=="STANDARD") {					this.addComponent(new dojo.iCalendar.Standard(childprops));				} else if (context=="DAYLIGHT") {					this.addComponent(new dojo.iCalendar.Daylight(childprops));				} else if (context=="VALARM") {					this.addComponent(new dojo.iCalendar.VAlarm(childprops));				}else {					dojo.unimplemented("dojo.iCalendar." + context);				}				context = '';			} else {				childprops.push(body[i]);			}		}		if (this._ValidProperties) {			this.postCreate();		}	}}dojo.lang.extend(dojo.iCalendar.Component, {	addProperty: function (prop) {		// summary		// push a new property onto a component.		this.properties.push(prop);		this[prop.name.toLowerCase()] = prop;	},	addComponent: function (prop) {		// summary		// add a component to this components list of children.		this.components.push(prop);	},	postCreate: function() {		for (var x=0; x<this._ValidProperties.length; x++) {			var evtProperty = this._ValidProperties[x];			var found = false;				for (var y=0; y<this.properties.length; y++) {					var prop = this.properties[y];				var propName = prop.name.toLowerCase();				if (dojo.lang.isArray(evtProperty)) {					var alreadySet = false;					for (var z=0; z<evtProperty.length; z++) {						var evtPropertyName = evtProperty[z].name.toLowerCase();						if((this[evtPropertyName])  && (evtPropertyName != propName )) {							alreadySet=true;						} 					}					if (!alreadySet) {						this[propName] = prop;					}				} else {					if (propName == evtProperty.name.toLowerCase()) {						found = true;						if (evtProperty.occurance == 1){							this[propName] = prop;						} else {							found = true;							if (!dojo.lang.isArray(this[propName])) {							 	this[propName] = [];							}							this[propName].push(prop);						}					}				}			}			if (evtProperty.required && !found) {					dojo.debug("iCalendar - " + this.name + ": Required Property not found: " + evtProperty.name);			}		}		// parse any rrules				if (dojo.lang.isArray(this.rrule)) {			for(var x=0; x<this.rrule.length; x++) {				var rule = this.rrule[x].value;				//add a place to cache dates we have checked for recurrance				this.rrule[x].cache = function() {};								var temp = rule.split(";");				for (var y=0; y<temp.length; y++) {					var pair = temp[y].split("=");					var key = pair[0].toLowerCase();					var val = pair[1];					if ((key == "freq") || (key=="interval") || (key=="until")) {						this.rrule[x][key]= val;					} else {						var valArray = val.split(",");						this.rrule[x][key] = valArray; 					}				}				}			this.recurring = true;		}	}, 	toString: function () {		// summary		// output a string representation of this component.		return "[iCalendar.Component; " + this.name + ", " + this.properties.length +			" properties, " + this.components.length + " components]";	}});dojo.iCalendar.Property = function (prop) {	// summary	// A single property of a component.	// unpack the values	this.name = prop.name;	this.group = prop.group;	this.params = prop.params;	this.value = prop.value;}dojo.lang.extend(dojo.iCalendar.Property, {	toString: function () {			// summary		// output a string reprensentation of this component.		return "[iCalenday.Property; " + this.name + ": " + this.value + "]";	}});// This is just a little helper function for the Component Propertiesvar _P = function (n, oc, req) {	return {name: n, required: (req) ? true : false,		occurance: (oc == '*' || !oc) ? -1 : oc}}/* * VCALENDAR */dojo.iCalendar.VCalendar = function (/* string */ calbody) {	// summary	// VCALENDAR Component	this.name = "VCALENDAR";	this.recurring = [];	this.nonRecurringEvents = function(){};	dojo.iCalendar.Component.call(this, calbody);}dojo.inherits(dojo.iCalendar.VCalendar, dojo.iCalendar.Component);dojo.lang.extend(dojo.iCalendar.VCalendar, {	addComponent: function (prop) {		// summary		// add component to the calenadar that makes it easy to pull them out again later.		this.components.push(prop);		if (prop.name.toLowerCase() == "vevent") {			if (prop.rrule) {				this.recurring.push(prop);			} else {				var startDate = prop.getDate();				var month = startDate.getMonth() + 1;				var dateString= month + "-" + startDate.getDate() + "-" + startDate.getFullYear();				if (!dojo.lang.isArray(this[dateString])) {					this.nonRecurringEvents[dateString] = [];				}				this.nonRecurringEvents[dateString].push(prop);			}		}	},	preComputeRecurringEvents: function(until) {		var calculatedEvents = function(){};		for(var x=0; x<this.recurring.length; x++) {			var dates = this.recurring[x].getDates(until);			for (var y=0; y<dates.length;y++) {				var month = dates[y].getMonth() + 1;				var dateStr = month + "-" + dates[y].getDate() + "-" + dates[y].getFullYear();				if (!dojo.lang.isArray(calculatedEvents[dateStr])) {					calculatedEvents[dateStr] = [];				}				if (!dojo.lang.inArray(calculatedEvents[dateStr], this.recurring[x])) { 					calculatedEvents[dateStr].push(this.recurring[x]);				} 			}		}		this.recurringEvents = calculatedEvents;		},	getEvents: function(/* Date */ date) {		// summary		// Gets all events occuring on a particular date		var events = [];		var recur = [];		var nonRecur = [];		var month = date.getMonth() + 1;		var dateStr= month + "-" + date.getDate() + "-" + date.getFullYear();		if (dojo.lang.isArray(this.nonRecurringEvents[dateStr])) {			nonRecur= this.nonRecurringEvents[dateStr];			dojo.debug("Number of nonRecurring Events: " + nonRecur.length);		} 				if (dojo.lang.isArray(this.recurringEvents[dateStr])) {			recur= this.recurringEvents[dateStr];		} 		events = recur.concat(nonRecur);		if (events.length > 0) {			return events;		} 		return null;				}});/* * STANDARD */var StandardProperties = [	_P("dtstart", 1, true), _P("tzoffsetto", 1, true), _P("tzoffsetfrom", 1, true),	_P("comment"), _P("rdate"), _P("rrule"), _P("tzname")];dojo.iCalendar.Standard = function (/* string */ body) {	// summary	// STANDARD Component	this.name = "STANDARD";	this._ValidProperties = StandardProperties;	dojo.iCalendar.Component.call(this, body);}dojo.inherits(dojo.iCalendar.Standard, dojo.iCalendar.Component);/* * DAYLIGHT */var DaylightProperties = [	_P("dtstart", 1, true), _P("tzoffsetto", 1, true), _P("tzoffsetfrom", 1, true),	_P("comment"), _P("rdate"), _P("rrule"), _P("tzname")];dojo.iCalendar.Daylight = function (/* string */ body) {	// summary	// Daylight Component	this.name = "DAYLIGHT";	this._ValidProperties = DaylightProperties;	dojo.iCalendar.Component.call(this, body);}dojo.inherits(dojo.iCalendar.Daylight, dojo.iCalendar.Component);/* * VEVENT */var VEventProperties = [	// these can occur once only	_P("class", 1), _P("created", 1), _P("description", 1), _P("dtstart", 1),	_P("geo", 1), _P("last-mod", 1), _P("location", 1), _P("organizer", 1),	_P("priority", 1), _P("dtstamp", 1), _P("seq", 1), _P("status", 1),	_P("summary", 1), _P("transp", 1), _P("uid", 1), _P("url", 1), _P("recurid", 1),	// these two are exclusive	[_P("dtend", 1), _P("duration", 1)],	// these can occur many times over	_P("attach"), _P("attendee"), _P("categories"), _P("comment"), _P("contact"),	_P("exdate"), _P("exrule"), _P("rstatus"), _P("related"), _P("resources"),	_P("rdate"), _P("rrule")];dojo.iCalendar.VEvent = function (/* string */ body) {	// summary 	// VEVENT Component	this._ValidProperties = VEventProperties;	this.name = "VEVENT";	dojo.iCalendar.Component.call(this, body);	this.recurring = false;	this.startDate = dojo.date.fromIso8601(this.dtstart.value);}dojo.inherits(dojo.iCalendar.VEvent, dojo.iCalendar.Component);dojo.lang.extend(dojo.iCalendar.VEvent, {		getDates: function(until) {			var dtstart = this.getDate();			var recurranceSet = [];			var weekdays=["su","mo","tu","we","th","fr","sa"];			var order = { 				"daily": 1, "weekly": 2, "monthly": 3, "yearly": 4,				"byday": 1, "bymonthday": 1, "byweekno": 2, "bymonth": 3, "byyearday": 4};			// expand rrules into the recurrance 			for (var x=0; x<this.rrule.length; x++) {				var rrule = this.rrule[x];				var freq = rrule.freq.toLowerCase();				var interval = 1;				if (rrule.interval > interval) {					interval = rrule.interval;				}				var set = [];				var freqInt = order[freq];				if (rrule.until) {					var tmpUntil = dojo.date.fromIso8601(rrule.until);				} else {					var tmpUntil = until				}				if (tmpUntil > until) {					tmpUntil = until				}				if (dtstart<tmpUntil) {					var expandingRules = function(){};					var cullingRules = function(){};					expandingRules.length=0;					cullingRules.length =0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -