PageSourceSearch

https://www.kabirproject.org/sites/all/modules/updates/calendar_us_r.js

js kabirproject.org collected 2026-10-02 17:00:28 UTC 13,802 bytes, 356 lines download raw bytes

1var _____WB$wombat$assign$function_____=function(name){return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name))||self[name];};if(!self.__WB_pmw){self.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{
2let window = _____WB$wombat$assign$function_____("window");
3let self = _____WB$wombat$assign$function_____("self");
4let document = _____WB$wombat$assign$function_____("document");
5let location = _____WB$wombat$assign$function_____("location");
6let top = _____WB$wombat$assign$function_____("top");
7let parent = _____WB$wombat$assign$function_____("parent");
8let frames = _____WB$wombat$assign$function_____("frames");
9let opens = _____WB$wombat$assign$function_____("opens");
10// Tigra Calendar v4.0.3 (01/12/2009) American (mm/dd/yyyy)
11// http://www.softcomplex.com/products/tigra_calendar/
12// Public Domain Software... You're welcome.
13
14// default settins
15var A_TCALDEF = {
16	'months' : ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
17	'weekdays' : ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
18	'yearscroll': true, // show year scroller
19	'weekstart': 0, // first day of week: 0-Su or 1-Mo
20	'centyear'  : 70, // 2 digit years less than 'centyear' are in 20xx, othewise in 19xx.
21	'imgpath' : 'modules/Media/images/' // directory with calendar images
22}
23// date parsing function
24function f_tcalParseDate (s_date) {
25
26	var re_date = /^\s*(\d{1,2})\/(\d{1,2})\/(\d{2,4})\s*$/;
27	if (!re_date.exec(s_date))
28		return alert ("Invalid date: '" + s_date + "'.\nAccepted format is mm/dd/yyyy.")
29	var n_day = Number(RegExp.$2),
30		n_month = Number(RegExp.$1),
31		n_year = Number(RegExp.$3);
32	
33	if (n_year < 100)
34		n_year += (n_year < this.a_tpl.centyear ? 2000 : 1900);
35	if (n_month < 1 || n_month > 12)
36		return alert ("Invalid month value: '" + n_month + "'.\nAllowed range is 01-12.");
37	var d_numdays = new Date(n_year, n_month, 0);
38	if (n_day > d_numdays.getDate())
39		return alert("Invalid day of month value: '" + n_day + "'.\nAllowed range for selected month is 01 - " + d_numdays.getDate() + ".");
40
41	return new Date (n_year, n_month - 1, n_day);
42}
43// date generating function
44function f_tcalGenerDate (d_date) {
45	return (
46		 (d_date.getMonth() < 9 ? '0' : '') + (d_date.getMonth() + 1) + "/"
47		+ (d_date.getDate() < 10 ? '0' : '') + d_date.getDate() + "/"
48		+ d_date.getFullYear()
49	);
50}
51
52// implementation
53function tcal (a_cfg, a_tpl) {
54
55	// apply default template if not specified
56	if (!a_tpl)
57		a_tpl = A_TCALDEF;
58
59	// register in global collections
60	if (!window.A_TCALS)
61		window.A_TCALS = [];
62	if (!window.A_TCALSIDX)
63		window.A_TCALSIDX = [];
64	
65	this.s_id = a_cfg.id ? a_cfg.id : A_TCALS.length;
66	window.A_TCALS[this.s_id] = this;
67	window.A_TCALSIDX[window.A_TCALSIDX.length] = this;
68	
69	// assign methods
70	this.f_show = f_tcalShow;
71	this.f_hide = f_tcalHide;
72	this.f_toggle = f_tcalToggle;
73	this.f_update = f_tcalUpdate;
74	this.f_relDate = f_tcalRelDate;
75	this.f_parseDate = f_tcalParseDate;
76	this.f_generDate = f_tcalGenerDate;
77	
78	// create calendar icon
79	this.s_iconId = 'tcalico_' + this.s_id;
80	this.e_icon = f_getElement(this.s_iconId);
81	if (!this.e_icon) {
82		document.write('<img src="' + a_tpl.imgpath + 'cal.gif" id="' + this.s_iconId + '" onclick="A_TCALS[\'' + this.s_id + '\'].f_toggle()" class="tcalIcon" alt="Open Calendar" />');
83		this.e_icon = f_getElement(this.s_iconId);
84	}
85	// save received parameters
86	this.a_cfg = a_cfg;
87	this.a_tpl = a_tpl;
88}
89
90function f_tcalShow (d_date) {
91
92	// find input field
93	if (!this.a_cfg.controlname)
94		throw("TC: control name is not specified");
95	if (this.a_cfg.formname) {
96		var e_form = document.forms[this.a_cfg.formname];
97		if (!e_form)
98			throw("TC: form '" + this.a_cfg.formname + "' can not be found");
99		this.e_input = e_form.elements[this.a_cfg.controlname];
100	}
101	else
102		this.e_input = f_getElement(this.a_cfg.controlname);
103
104	if (!this.e_input || !this.e_input.tagName || this.e_input.tagName != 'INPUT')
105		throw("TC: element '" + this.a_cfg.controlname + "' does not exist in "
106			+ (this.a_cfg.formname ? "form '" + this.a_cfg.controlname + "'" : 'this document'));
107
108	// dynamically create HTML elements if needed
109	this.e_div = f_getElement('tcal');
110	if (!this.e_div) {
111		this.e_div = document.createElement("DIV");
112		this.e_div.id = 'tcal';
113		document.body.appendChild(this.e_div);
114	}
115	this.e_shade = f_getElement('tcalShade');
116	if (!this.e_shade) {
117		this.e_shade = document.createElement("DIV");
118		this.e_shade.id = 'tcalShade';
119		document.body.appendChild(this.e_shade);
120	}
121	this.e_iframe =  f_getElement('tcalIF')
122	if (b_ieFix && !this.e_iframe) {
123		this.e_iframe = document.createElement("IFRAME");
124		this.e_iframe.style.filter = 'alpha(opacity=0)';
125		this.e_iframe.id = 'tcalIF';
126		this.e_iframe.src = this.a_tpl.imgpath + 'pixel.gif';
127		document.body.appendChild(this.e_iframe);
128	}
129	
130	// hide all calendars
131	f_tcalHideAll();
132
133	// generate HTML and show calendar
134	this.e_icon = f_getElement(this.s_iconId);
135	if (!this.f_update())
136		return;
137
138	this.e_div.style.visibility = 'visible';
139	this.e_shade.style.visibility = 'visible';
140	if (this.e_iframe)
141		this.e_iframe.style.visibility = 'visible';
142
143	// change icon and status
144	this.e_icon.src = this.a_tpl.imgpath + 'no_cal.gif';
145	this.e_icon.title = 'Close Calendar';
146	this.b_visible = true;
147}
148
149function f_tcalHide (n_date) {
150	if (n_date)
151		this.e_input.value = this.f_generDate(new Date(n_date));
152
153	// no action if not visible
154	if (!this.b_visible)
155		return;
156
157	// hide elements
158	if (this.e_iframe)
159		this.e_iframe.style.visibility = 'hidden';
160	if (this.e_shade)
161		this.e_shade.style.visibility = 'hidden';
162	this.e_div.style.visibility = 'hidden';
163	
164	// change icon and status
165	this.e_icon = f_getElement(this.s_iconId);
166	this.e_icon.src = this.a_tpl.imgpath + 'cal.gif';
167	this.e_icon.title = 'Open Calendar';
168	this.b_visible = false;
169}
170
171function f_tcalToggle () {
172	return this.b_visible ? this.f_hide() : this.f_show();
173}
174
175function f_tcalUpdate (d_date) {
176	
177	var d_today = this.a_cfg.today ? this.f_parseDate(this.a_cfg.today) : f_tcalResetTime(new Date());
178	var d_selected = this.e_input.value == ''
179		? (this.a_cfg.selected ? this.f_parseDate(this.a_cfg.selected) : d_today)
180		: this.f_parseDate(this.e_input.value);
181
182	// figure out date to display
183	if (!d_date)
184		// selected by default
185		d_date = d_selected;
186	else if (typeof(d_date) == 'number')
187		// get from number
188		d_date = f_tcalResetTime(new Date(d_date));
189	else if (typeof(d_date) == 'string')
190		// parse from string
191		this.f_parseDate(d_date);
192		
193	if (!d_date) return false;
194
195	// first date to display
196	var d_firstday = new Date(d_date);
197	d_firstday.setDate(1);
198	d_firstday.setDate(1 - (7 + d_firstday.getDay() - this.a_tpl.weekstart) % 7);
199	
200	var a_class, s_html = '<table class="ctrl"><tbody><tr>'
201		+ (this.a_tpl.yearscroll ? '<td' + this.f_relDate(d_date, -1, 'y') + ' title="Previous Year"><img src="' + this.a_tpl.imgpath + 'prev_year.gif" /></td>' : '')
202		+ '<td' + this.f_relDate(d_date, -1) + ' title="Previous Month"><img src="' + this.a_tpl.imgpath + 'prev_mon.gif" /></td><th>'
203		+ this.a_tpl.months[d_date.getMonth()] + ' ' + d_date.getFullYear()
204			+ '</th><td' + this.f_relDate(d_date, 1) + ' title="Next Month"><img src="' + this.a_tpl.imgpath + 'next_mon.gif" /></td>'
205		+ (this.a_tpl.yearscroll ? '<td' + this.f_relDate(d_date, 1, 'y') + ' title="Next Year"><img src="' + this.a_tpl.imgpath + 'next_year.gif" /></td></td>' : '')
206		+ '</tr></tbody></table><table><tbody><tr class="wd">';
207
208	// print weekdays titles
209	for (var i = 0; i < 7; i++)
210		s_html += '<th>' + this.a_tpl.weekdays[(this.a_tpl.weekstart + i) % 7] + '</th>';
211	s_html += '</tr>' ;
212
213	// print calendar table
214	var n_date, n_month, d_current = new Date(d_firstday);
215	while (d_current.getMonth() == d_date.getMonth() ||
216		d_current.getMonth() == d_firstday.getMonth()) {
217	
218		// print row heder
219		s_html +='<tr>';
220		for (var n_wday = 0; n_wday < 7; n_wday++) {
221
222			a_class = [];
223			n_date  = d_current.getDate();
224			n_month = d_current.getMonth();
225
226			// other month
227			if (d_current.getMonth() != d_date.getMonth())
228				a_class[a_class.length] = 'othermonth';
229			// weekend
230			if (d_current.getDay() == 0 || d_current.getDay() == 6)
231				a_class[a_class.length] = 'weekend';
232			// today
233			if (d_current.valueOf() == d_today.valueOf())
234				a_class[a_class.length] = 'today';
235			// selected
236			if (d_current.valueOf() == d_selected.valueOf())
237				a_class[a_class.length] = 'selected';
238
239			s_html += '<td onclick="A_TCALS[\'' + this.s_id + '\'].f_hide(' + d_current.valueOf() + '), date_selection(document.f1.testinput.value)"' + (a_class.length ? ' class="' + a_class.join(' ') + '">' : '>') + n_date + '</td>'
240
241			d_current.setDate(++n_date);
242			while (d_current.getDate() != n_date && d_current.getMonth() == n_month) {
243				d_current.setHours(d_current.getHours + 1);
244				d_current = f_tcalResetTime(d_current);
245			}
246		}
247		// print row footer
248		s_html +='</tr>';
249	}
250	s_html +='</tbody></table>';
251	
252	// update HTML, positions and sizes
253	this.e_div.innerHTML = s_html;
254
255	var n_width  = this.e_div.offsetWidth;
256	var n_height = this.e_div.offsetHeight;
257	var n_top  = f_getPosition (this.e_icon, 'Top') + this.e_icon.offsetHeight;
258	var n_left = f_getPosition (this.e_icon, 'Left') - n_width + this.e_icon.offsetWidth;
259	if (n_left < 0) n_left = 0;
260	
261	this.e_div.style.left = n_left + 'px';
262	this.e_div.style.top  = n_top + 'px';
263
264	this.e_shade.style.width = (n_width + 8) + 'px';
265	this.e_shade.style.left = (n_left - 1) + 'px';
266	this.e_shade.style.top = (n_top - 1) + 'px';
267	this.e_shade.innerHTML = b_ieFix
268		? '<table><tbody><tr><td rowspan="2" colspan="2" width="6"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td width="7" height="7" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_tr.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td height="' + (n_height - 7) + '" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_mr.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td width="7" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_bl.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_bm.png\', sizingMethod=\'scale\');" height="7" align="left"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_br.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tbody></table>'
269		: '<table><tbody><tr><td rowspan="2" width="6"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td rowspan="2"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td width="7" height="7"><img src="' + this.a_tpl.imgpath + 'shade_tr.png"></td></tr><tr><td background="' + this.a_tpl.imgpath + 'shade_mr.png" height="' + (n_height - 7) + '"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td><img src="' + this.a_tpl.imgpath + 'shade_bl.png"></td><td background="' + this.a_tpl.imgpath + 'shade_bm.png" height="7" align="left"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td><img src="' + this.a_tpl.imgpath + 'shade_br.png"></td></tr><tbody></table>';
270	
271	if (this.e_iframe) {
272		this.e_iframe.style.left = n_left + 'px';
273		this.e_iframe.style.top  = n_top + 'px';
274		this.e_iframe.style.width = (n_width + 6) + 'px';
275		this.e_iframe.style.height = (n_height + 6) +'px';
276	}
277	return true;
278}
279
280function f_getPosition (e_elemRef, s_coord) {
281	var n_pos = 0, n_offset,
282		e_elem = e_elemRef;
283
284	while (e_elem) {
285		n_offset = e_elem["offset" + s_coord];
286		n_pos += n_offset;
287		e_elem = e_elem.offsetParent;
288	}
289	// margin correction in some browsers
290	if (b_ieMac)
291		n_pos += parseInt(document.body[s_coord.toLowerCase() + 'Margin']);
292	else if (b_safari)
293		n_pos -= n_offset;
294	
295	e_elem = e_elemRef;
296	while (e_elem != document.body) {
297		n_offset = e_elem["scroll" + s_coord];
298		if (n_offset && e_elem.style.overflow == 'scroll')
299			n_pos -= n_offset;
300		e_elem = e_elem.parentNode;
301	}
302	return n_pos;
303}
304
305function f_tcalRelDate (d_date, d_diff, s_units) {
306	var s_units = (s_units == 'y' ? 'FullYear' : 'Month');
307	var d_result = new Date(d_date);
308	d_result['set' + s_units](d_date['get' + s_units]() + d_diff);
309	if (d_result.getDate() != d_date.getDate())
310		d_result.setDate(0);
311	return ' onclick="A_TCALS[\'' + this.s_id + '\'].f_update(' + d_result.valueOf() + ')"';
312	
313}
314
315/*function f_tcalHideAll () {
316	for (var i = 0; i < window.A_TCALSIDX.length; i++)
317		window.A_TCALSIDX[i].f_hide();
318
319}*/
320
321
322function f_tcalHideAll () {
323if (window.A_TCALSIDX != null){
324for (var i = 0; i < window.A_TCALSIDX.length; i++)
325window.A_TCALSIDX.f_hide();
326}
327}
328
329function f_tcalResetTime (d_date) {
330	d_date.setHours(0);
331	d_date.setMinutes(0);
332	d_date.setSeconds(0);
333	d_date.setMilliseconds(0);
334	return d_date;
335}
336
337f_getElement = document.all ?
338	function (s_id) { return document.all[s_id] } :
339	function (s_id) { return document.getElementById(s_id) };
340
341if (document.addEventListener)
342	window.addEventListener('scroll', f_tcalHideAll, false);
343if (window.attachEvent)
344	window.attachEvent('onscroll', f_tcalHideAll);
345	
346// global variables
347var s_userAgent = navigator.userAgent.toLowerCase(),
348	re_webkit = /WebKit\/(\d+)/i;
349var b_mac = s_userAgent.indexOf('mac') != -1,
350	b_ie5 = s_userAgent.indexOf('msie 5') != -1,
351	b_ie6 = s_userAgent.indexOf('msie 6') != -1 && s_userAgent.indexOf('opera') == -1;
352var b_ieFix = b_ie5 || b_ie6,
353	b_ieMac  = b_mac && b_ie5,
354	b_safari = b_mac && re_webkit.exec(s_userAgent) && Number(RegExp.$1) < 500;
355
356}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.