root/trunk/deployment/webadmin/webapp/resources/resources/bedeworkEventForm.js

Revision 2850 (checked in by bleibson, 6 months ago)

o update javascript files to have Jasig licensing info.
o remove RPI copyright notice

Line 
1 /*
2    Licensed to Jasig under one or more contributor license
3    agreements. See the NOTICE file distributed with this work
4    for additional information regarding copyright ownership.
5    Jasig licenses this file to you under the Apache License,
6    Version 2.0 (the "License"); you may not use this file
7    except in compliance with the License. You may obtain a
8    copy of the License at:
9  
10    http://www.apache.org/licenses/LICENSE-2.0
11  
12    Unless required by applicable law or agreed to in writing,
13    software distributed under the License is distributed on
14    an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15    KIND, either express or implied. See the License for the
16    specific language governing permissions and limitations
17    under the License. 
18 */
19
20 // Bedework event form functions
21
22 // ========================================================================
23 //   Language and customization
24 //   These should come from values in the header or included as a separate cutomization
25 //   file.
26
27 var rdateDeleteStr = "remove";
28
29 // ========================================================================
30 // rdate functions
31 // ========================================================================
32
33 /* An rdate
34  * date: String: internal date
35  * time: String
36  * tzid: timezone id or null
37  */
38 function BwREXdate(date, time, allDay, floating, utc, tzid) {
39   this.date = date;
40   this.time = time;
41   this.allDay = allDay;
42   this.floating = floating;
43   this.utc = utc;
44   this.tzid = tzid;
45
46   this.toString = function() {
47   }
48
49   /* varName: NOT GOOD - name of object
50    * reqPar: request par for hidden field
51    * row: current table row
52    * rdi: index of rdate fro delete
53    */
54   this.toFormRow = function(varName, row, rdi) {
55     row.insertCell(0).appendChild(document.createTextNode(this.date));
56     row.insertCell(1).appendChild(document.createTextNode(this.time));
57     row.insertCell(2).appendChild(document.createTextNode(this.tzid));
58     row.insertCell(3).innerHTML = "<a href=\"javascript:" + varName + ".deleteDate('" +
59                                    rdi + "')\">" + rdateDeleteStr + "</a>";
60   }
61
62   this.format = function() {
63     var res = this.date + "\t" + this.time + "\t";
64
65     if (this.tzid != null) {
66       res += this.tzid;
67     }
68
69     return res;
70   }
71
72   this.equals = function(that) {
73     return this.compareTo(that) == 0;
74   }
75
76   this.compareTo = function(that) {
77     var res = compareTo(that.date, this.date);
78     if (res != 0) {
79       return res;
80     }
81
82     res = compareTo(that.time, this.time);
83     if (res != 0) {
84       return res;
85     }
86
87     return compareTo(that.tzid, this.tzid);
88   }
89 }
90
91 function compareTo(thys, that) {
92   if (that < thys) {
93     return -1;
94   }
95
96   if (that > thys) {
97     return 1;
98   }
99
100   return 0;
101 }
102
103 function sortCompare(thys, that) {
104   return thys.compareTo(that);
105 }
106
107 var bwRdates = new BwREXdates("bwRdates", "bwRdatesField",
108                               "bwCurrentRdates", "bwCurrentRdatesNone",
109                               "visible", "invisible", 2);
110 var bwExdates = new BwREXdates("bwExdates", "bwExdatesField",
111                                "bwCurrentExdates", "bwCurrentExdatesNone",
112                                "visible", "invisible", 2);
113
114 /** Manipulate table of exception or recurrence dates.
115  *
116  * @param varName: NOT GOOD - name of object
117  * @param reqParId: id of hidden field we update
118  * @param tableId:   id of table we are manipulating
119  * @param noDatesId: some info to display when we have nothing
120  * @param visibleClass: class to set to make something visible
121  * @param invisibleClass: class to set to make something invisible
122  * @param numHeaderRows: Number of header rows in the table.
123  */
124 function BwREXdates(varName, reqParId, tableId, noDatesId,
125                     visibleClass, invisibleClass, numHeaderRows) {
126   var dates = new Array();
127
128   this.varName = varName;
129   this.reqParId = reqParId;
130   this.tableId = tableId;
131   this.noDatesId = noDatesId;
132   this.visibleClass = visibleClass;
133   this.invisibleClass = invisibleClass;
134   this.numHeaderRows = numHeaderRows;
135
136   /* val: String: internal date
137    * dateOnly: boolean
138    * tzid: String or null
139    */
140   this.addRdate = function(date, time, allDay, floating, utc, tzid) {
141     var newRdate = new BwREXdate(date, time, allDay, floating, utc, tzid);
142
143     if (!this.contains(newRdate)) {
144       dates.push(newRdate);
145     }
146   }
147
148   this.contains = function(rdate) {
149     for (var j = 0; j < dates.length; j++) {
150       var curRdate = dates[j];
151       if (curRdate.equals(rdate)) {
152         return true;
153       }
154     }
155
156     return false;
157   }
158
159   // Update the list -
160   this.update = function(date, time, allDay, floating, utc, tzid) {
161     this.addRdate(date, time, allDay, floating, utc, tzid);
162
163     // redraw the display
164     this.display();
165   }
166
167   this.deleteDate = function(index) {
168     dates.splice(index, 1);
169
170     // redraw the display
171     this.display();
172   }
173
174   // update the rdates table displayed on screen
175   this.display = function() {
176     try {
177       // get the table body
178       var rdTableBody = document.getElementById(tableId).tBodies[0];
179
180       // remove existing rows
181       for (i = rdTableBody.rows.length - 1; i >= numHeaderRows; i--) {
182         rdTableBody.deleteRow(i);
183       }
184
185       dates.sort(sortCompare);
186
187       // recreate the table rows
188       for (var j = 0; j < dates.length; j++) {
189         var curDate = dates[j];
190         var tr = rdTableBody.insertRow(j + numHeaderRows);
191
192         curDate.toFormRow(varName, tr, j);
193       }
194
195       if (dates.length == 0) {
196         changeClass(tableId, invisibleClass);
197         changeClass(noDatesId, visibleClass);
198       } else {
199         changeClass(tableId, visibleClass);
200         changeClass(noDatesId, invisibleClass);
201       }
202
203       /* Update the hidden field */
204
205       var formAcl = document.getElementById(reqParId);
206       formAcl.value = this.format();
207
208     } catch (e) {
209       alert(e);
210     }
211   }
212
213   this.format = function() {
214     var res = "";
215
216     for (var j = 0; j < dates.length; j++) {
217       var curDate = dates[j];
218
219       res += "DATE\t" + curDate.format();
220     }
221
222     return res;
223   }
224 }
225 // ========================================================================
226 // Submitted event comments
227 // ========================================================================
228
229 /* A comment accompanying a submitted event.
230  * These values come from sumbitted x-properties
231  * locationAddress: value of property X-BEDEWORK-LOCATION
232  * locationSubaddress: value of location's parameter X-BEDEWORK-SUBADDRESS
233  * locationUrl: value of location's parameter X-BEDEWORK-PARAM-URL
234  * contactName: value of x-property X-BEDEWORK-CONTACT
235  * contactPhone: value of contact's parameter X-BEDEWORK-PARAM-PHONE
236  * contactUrl: value of contact's parameter X-BEDEWORK-PARAM-URL
237  * contactEmail: value of contact's parameter X-BEDEWORK-PARAM-EMAIL
238  * topicalAreas: list of submitted topical areas (may not match the event admin's view
239  * category: value of x-property X-BEDEWORK-CATEGORIES - a freeform user suggestion
240  * notes: value of the x-property X-BEDEWORK-SUBMIT-COMMENT
241  */
242 function bwSubmitComment(locationAddress,locationSubaddress,locationUrl,contactName,contactPhone,contactUrl,contactEmail,topicalAreas,category,notes) {
243   this.locationAddress = locationAddress;
244   this.locationSubaddress = locationSubaddress;
245   this.locationUrl = locationUrl;
246   this.contactName = contactName;
247   this.contactPhone = contactPhone;
248   this.contactUrl = contactUrl;
249   this.contactEmail = contactEmail;
250   this.topicalAreas = topicalAreas;
251   this.category = category;
252   this.notes = notes;
253
254   this.render = function() {
255     var output = "";
256     if (this.locationAddress != "" || this.locationSubaddress != "" || this.locationUrl != "") {
257       output += '<table>';
258       output += '<tr><th colspan="2">Suggested Location:</th></tr>';
259       output += '<tr><td>Address:</td><td>' + this.locationAddress + '</td>';
260       output += '<tr><td>Subaddress:</td><td>' + this.locationSubaddress + '</td>';
261       output += '<tr><td>URL:</td><td>' + this.locationUrl + '</td>';
262       output += '</table>';
263     }
264     if (this.contactName != "" || this.contactPhone != "" || this.contactEmail != "" || this.contactUrl != "") {
265       output += '<table>';
266       output += '<tr><th colspan="2">Suggested Contact:</th></tr>';
267       output += '<tr><td>Name:</td><td>' + this.contactName + '</td></tr>';
268       output += '<tr><td>Phone:</td><td>' + this.contactPhone + '</td></tr>';
269       output += '<tr><td>URL:</td><td>' + this.contactUrl + '</td></tr>';
270       output += '<tr><td>Email:</td><td>' + this.contactEmail + '</td></tr>';
271       output += '</table>';
272     }
273     if (this.topicalAreas != "") {
274       output += '<table>';
275       output += '<tr><th>Suggested Topical Areas:</th></tr>';
276       output += '<tr><td>' + this.topicalAreas + '</td></tr>';
277       output += '</table>';
278     }
279     if (this.category != "") {
280       output += '<p><strong>Suggested Type of Event:</strong><br/>';
281       output += this.category;
282       output += '</p>';
283     }
284     output += '<p>';
285     if (this.notes != "") {
286       output += '<strong>Notes:</strong><br/>';
287       output += this.notes;
288     }
289     output += '</p>';
290
291     return output;
292   }
293
294   this.display = function(displayId) {
295     var showComment = document.getElementById(displayId);
296     showComment.innerHTML = this.render();
297   }
298
299   // launch comment in a pop-up window
300   this.launch = function() {
301     var commentWindow = window.open("", "commentWindow", "width=800,height=400,scrollbars=yes,resizable=yes,alwaysRaised=yes,menubar=no,toolbar=no");
302     commentWindow.document.open();
303     commentWindow.document.writeln("<html><head><title>Submitted Event Comments</title>");
304     commentWindow.document.writeln('<style type="text/css">');
305     commentWindow.document.writeln('body{background-color: #ffe; color: black; padding: 1em; font-size: 0.9em; font-family: Arial,sans-serif;}');
306     commentWindow.document.writeln('table{float: left; margin: 1em 1em 0 0; padding: 0.5em; border: 1px solid #ccc; font-size: 0.9em;}');
307     commentWindow.document.writeln('th{text-align: left;}');
308     commentWindow.document.writeln('td{padding-left: 2em;}');
309     commentWindow.document.writeln('p{clear:both; padding-top: 1em;}');
310     commentWindow.document.writeln('</style></head>');
311     commentWindow.document.writeln("<body><h3>Comments from Submitter</h3>");
312     commentWindow.document.writeln(this.render());
313     commentWindow.document.writeln("</body></html>");
314     commentWindow.document.close();
315     commentWindow.focus();
316   }
317 }
318
319 // ========================================================================
320 // ========================================================================
321
322 function setEventFields(formObj,portalFriendly,submitter) {
323   if (!portalFriendly) {
324     setDates(formObj);
325   }
326   if(formObj.freq){
327     setRecurrence(formObj);
328   } // else we are editing an instance of a recurrence
329   setBedeworkXProperties(formObj,submitter);
330 }
331
332 /* Set dates based on jQuery widgets */
333 function setDates(formObj) {
334   var startDate = new Date();
335   startDate = $("#bwEventWidgetStartDate").datepicker("getDate");
336   formObj["eventStartDate.year"].value = startDate.getFullYear();
337   formObj["eventStartDate.month"].value = startDate.getMonth() + 1;
338   formObj["eventStartDate.day"].value = startDate.getDate();
339
340   var endDate = new Date();
341   endDate = $("#bwEventWidgetEndDate").datepicker("getDate");
342   formObj["eventEndDate.year"].value = endDate.getFullYear();
343   formObj["eventEndDate.month"].value = endDate.getMonth() + 1;
344   formObj["eventEndDate.day"].value = endDate.getDate();
345 }
346 function setBedeworkXProperties(formObj,submitter) {
347   // Set up specific Bedework X-Properties on event form submission
348   // Depends on bedeworkXProperties.js
349   // Set application local x-properties here.
350
351   // X-BEDEWORK-IMAGE and its parameters:
352   if (formObj["xBwImageHolder"] && formObj["xBwImageHolder"].value != '') {
353     bwXProps.update(bwXPropertyImage,
354                   [[bwXParamDescription,''],
355                    [bwXParamWidth,''],
356                    [bwXParamHeight,'']],
357                    formObj["xBwImageHolder"].value,true);
358   }
359
360   // X-BEDEWORK-SUBMITTEDBY
361   bwXProps.update(bwXPropertySubmittedBy,[],submitter,true);
362
363   // commit all xproperties back to the form
364   bwXProps.generate(formObj);
365 }
366 function toggleBedeworkXProperty(xprop,value,checked) {
367   if (!checked) {
368     bwXProps.removeByValue(xprop, value);
369   } else {
370     bwXProps.update(bwXPropertyAlias,[],value,false);
371   }
372 }
373 function claimPendingEvent(group,user) {
374   bwXProps.update(bwXPropertySubmissionClaimant,[[bwXParamClaimantUser,user]],group,true);
375 }
376 function releasePendingEvent() {
377   bwXProps.remove(bwXPropertySubmissionClaimant);
378 }
379 function swapAllDayEvent(obj) {
380   allDayStartDateField = document.getElementById("allDayStartDateField");
381   allDayEndDateField = document.getElementById("allDayEndDateField");
382   durDays = document.getElementById("durationDays");
383   if (obj.checked) {
384     // show or hide time fields and set the days duration
385     changeClass('startTimeFields','invisible');
386     changeClass('endTimeFields','invisible');
387     changeClass('durationHrMin','invisible');
388     allDayStartDateField.value = "true";
389     allDayEndDateField.value = "true";
390     durDays.value = 1;
391   } else {
392     changeClass('startTimeFields','timeFields');
393     changeClass('endTimeFields','timeFields');
394     changeClass('durationHrMin','shown');
395     allDayStartDateField.value = "false";
396     allDayEndDateField.value = "false";
397     durDays.value = 0;
398   }
399 }
400 function swapFloatingTime(obj) {
401   startTimezone = document.getElementById("startTzid");
402   endTimezone = document.getElementById("endTzid");
403   startFloating = document.getElementById("startFloating");
404   endFloating = document.getElementById("endFloating");
405   if (obj.checked) {
406     document.getElementById("storeUTCFlag").checked = false;
407     startTimezone.disabled = true;
408     endTimezone.disabled = true;
409     startFloating.value = "true";
410     endFloating.value = "true";
411   } else {
412     startTimezone.disabled = false;
413     endTimezone.disabled = false;
414     startFloating.value = "false";
415     endFloating.value = "false";
416   }
417 }
418 function swapStoreUTC(obj) {
419   startTimezone = document.getElementById("startTzid");
420   endTimezone = document.getElementById("endTzid");
421   startStoreUTC = document.getElementById("startStoreUTC");
422   endStoreUTC = document.getElementById("endStoreUTC");
423   if (obj.checked) {
424     document.getElementById("floatingFlag").checked = false;
425     startTimezone.disabled = false;
426     endTimezone.disabled = false;
427     startStoreUTC.value = "true";
428     endStoreUTC.value = "true";
429   } else {
430     startStoreUTC.value = "false";
431     endStoreUTC.value = "false";
432   }
433 }
434 function swapRdateAllDay(obj) {
435   if (obj.checked) {
436     changeClass('rdateTimeFields','invisible');
437   } else {
438     changeClass('rdateTimeFields','timeFields');
439   }
440 }
441 function swapRdateFloatingTime(obj) {
442   rdateTimezone = document.getElementById("rdateTzid");
443   rdateFloating = document.getElementById("rdateFloating");
444   if (obj.checked) {
445     document.getElementById("rdateStoreUTC").checked = false;
446     rdateTimezone.disabled = true;
447   } else {
448     rdateTimezone.disabled = false;
449     rdateFloating.value = "false";
450   }
451 }
452 function swapRdateStoreUTC(obj) {
453   rdateTimezone = document.getElementById("rdateTzid");
454   rdateStoreUTC = document.getElementById("rdateStoreUTC");
455   if (obj.checked) {
456     document.getElementById("rdateFloating").checked = false;
457     rdateTimezone.disabled = false;
458     rdateStoreUTC.value = "true";
459   } else {
460     rdateStoreUTC.value = "false";
461   }
462 }
463 function swapDurationType(type) {
464   // get the components we need to manipulate
465   daysDurationElement = document.getElementById("durationDays");
466   hoursDurationElement = document.getElementById("durationHours");
467   minutesDurationElement = document.getElementById("durationMinutes");
468   weeksDurationElement = document.getElementById("durationWeeks");
469   if (type == 'week') {
470     weeksDurationElement.disabled = false;
471     daysDurationElement.disabled = true;
472     hoursDurationElement.disabled = true;
473     minutesDurationElement.disabled = true;
474   } else {
475     daysDurationElement.disabled = false;
476     hoursDurationElement.disabled = false;
477     minutesDurationElement.disabled = false;
478     // we are using day, hour, minute -- zero out the weeks.
479     weeksDurationElement.value = "0";
480     weeksDurationElement.disabled = true;
481   }
482 }
483 function swapRecurrence(obj) {
484   if (obj.value == 'true') {
485     changeClass('recurrenceFields','visible');
486     if (document.getElementById('rrulesSwitch')) {
487       changeClass('rrulesSwitch','visible');
488     }
489   } else {
490     changeClass('recurrenceFields','invisible');
491     if (document.getElementById('rrulesSwitch')) {
492       changeClass('rrulesSwitch','invisible');
493     }
494   }
495 }
496 function swapRrules(obj) {
497   if (obj.checked) {
498     changeClass('rrulesTable','visible');
499     changeClass('rrulesUiSwitch','visible');
500     if (document.getElementById('recurrenceInfo')) {
501       changeClass('recurrenceInfo','invisible');
502     }
503   } else {
504     changeClass('rrulesTable','invisible');
505     changeClass('rrulesUiSwitch','invisible');
506     if (document.getElementById('recurrenceInfo')) {
507       changeClass('recurrenceInfo','visible');
508     }
509   }
510 }
511 function showRrules(freq) {
512   // reveal and hide rrules fields
513   changeClass('recurrenceUntilRules','visible');
514
515   if (freq == 'NONE') {
516     changeClass('noneRecurrenceRules','visible');
517     changeClass('recurrenceUntilRules','invisible');
518   } else {
519     changeClass('noneRecurrenceRules','invisible');
520   }
521   if (freq == 'HOURLY') {
522     changeClass('hourlyRecurrenceRules','visible');
523   } else {
524     changeClass('hourlyRecurrenceRules','invisible');
525   }
526   if (freq == 'DAILY') {
527     changeClass('dailyRecurrenceRules','visible');
528   } else {
529     changeClass('dailyRecurrenceRules','invisible');
530   }
531   if (freq == 'WEEKLY') {
532     changeClass('weeklyRecurrenceRules','visible');
533   } else {
534     changeClass('weeklyRecurrenceRules','invisible');
535   }
536   if (freq == 'MONTHLY') {
537     changeClass('monthlyRecurrenceRules','visible');
538   } else {
539     changeClass('monthlyRecurrenceRules','invisible');
540   }
541   if (freq == 'YEARLY') {
542     changeClass('yearlyRecurrenceRules','visible');
543   } else {
544     changeClass('yearlyRecurrenceRules','invisible');
545   }
546 }
547 function recurSelectWeekends(id) {
548   chkBoxCollection = document.getElementById(id).getElementsByTagName('input');
549   if (chkBoxCollection) {
550     if (typeof chkBoxCollection.length != 'undefined') {
551       for (i = 0; i < chkBoxCollection.length; i++) {
552         if (chkBoxCollection[i].value == 'SU' || chkBoxCollection[i].value == 'SA') {
553            chkBoxCollection[i].checked = true;
554         } else {
555           chkBoxCollection[i].checked = false;
556         }
557       }
558     }
559   }
560 }
561 function recurSelectWeekdays(id) {
562   chkBoxCollection = document.getElementById(id).getElementsByTagName('input');
563   if (chkBoxCollection) {
564     if (typeof chkBoxCollection.length != 'undefined') {
565       for (i = 0; i < chkBoxCollection.length; i++) {
566         if (chkBoxCollection[i].value == 'SU' || chkBoxCollection[i].value == 'SA') {
567            chkBoxCollection[i].checked = false;
568         } else {
569           chkBoxCollection[i].checked = true;
570         }
571       }
572     }
573   }
574 }
575 function selectRecurCountUntil(id) {
576   document.getElementById(id).checked = true;
577 }
578 // Assemble the recurrence rules if recurrence is specified.
579 // Request params to set ('freq' is always set):
580 // interval, count, until (count OR until, not both)
581 // possibly: byday, bymonthday, bymonth, byyearday
582 function setRecurrence(formObj) {
583   var freq = getSelectedRadioButtonVal(formObj.freq);
584   if (freq != 'NONE') {
585     // build up recurrence rules
586     switch (freq) {
587       case "DAILY":
588         var bymonth = new Array();
589         // get the bymonth values
590         bymonth = collectRecurChkBoxVals(bymonth,document.getElementById('dayMonthCheckBoxList').getElementsByTagName('input'),false);
591         // set the form values
592         formObj.bymonth.value = bymonth.join(',');
593         formObj.interval.value = formObj.dailyInterval.value;
594         break;
595       case "WEEKLY":
596         var byday = new Array();
597         byday = collectRecurChkBoxVals(byday, document.getElementById('weekRecurFields').getElementsByTagName('input'),false);
598         formObj.byday.value = byday.join(',');
599         if (formObj.weekWkst.selectedIndex != -1) {
600           formObj.wkst.value = formObj.weekWkst[formObj.weekWkst.selectedIndex].value;
601         }
602         formObj.interval.value = formObj.weeklyInterval.value;
603         break;
604       case "MONTHLY":
605         var i = 1;
606         var monthByDayId = 'monthRecurFields' + i;
607         var byday = new Array();
608         var bymonthday = new Array();
609         var byyearday = new Array();
610         // get the byday values
611         while (document.getElementById(monthByDayId)) {
612           var monthFields = document.getElementById(monthByDayId);
613           var dayPosSelect = monthFields.getElementsByTagName('select');
614           var dayPos = dayPosSelect[0][dayPosSelect[0].selectedIndex].value;
615           if (dayPos) {
616             byday = collectRecurChkBoxVals(byday,monthFields.getElementsByTagName('input'),dayPos);
617           }
618           monthByDayId = monthByDayId.substring(0,monthByDayId.length-1) + ++i;
619         }
620         // get the bymonthday values
621         bymonthday = collectRecurChkBoxVals(bymonthday,document.getElementById('monthDaysCheckBoxList').getElementsByTagName('input'),false);
622         // set the form values
623         formObj.byday.value = byday.join(',');
624         formObj.bymonthday.value = bymonthday.join(',');
625         formObj.interval.value = formObj.monthlyInterval.value;
626         break;
627       case "YEARLY":
628         var i = 1;
629         var yearByDayId = 'yearRecurFields' + i;
630         var byday = new Array();
631         var bymonthday = new Array();
632         var bymonth = new Array();
633         var byweekno = new Array();
634         var byyearday = new Array();
635         // get the byday values
636         while (document.getElementById(yearByDayId)) {
637           var yearFields = document.getElementById(yearByDayId);
638           var dayPosSelect = yearFields.getElementsByTagName('select');
639           var dayPos = dayPosSelect[0][dayPosSelect[0].selectedIndex].value;
640           if (dayPos) {
641             byday = collectRecurChkBoxVals(byday,yearFields.getElementsByTagName('input'),dayPos);
642           }
643           yearByDayId = yearByDayId.substring(0,yearByDayId.length-1) + ++i;
644         }
645         // get the bymonth values
646         bymonth = collectRecurChkBoxVals(bymonth,document.getElementById('yearMonthCheckBoxList').getElementsByTagName('input'),false);
647         // get the bymonthday values
648         bymonthday = collectRecurChkBoxVals(bymonthday,document.getElementById('yearMonthDaysCheckBoxList').getElementsByTagName('input'),false);
649         // get the byweekno values
650         byweekno = collectRecurChkBoxVals(byweekno,document.getElementById('yearWeeksCheckBoxList').getElementsByTagName('input'),false);
651         // get the byyearday values
652         byyearday = collectRecurChkBoxVals(byyearday,document.getElementById('yearDaysCheckBoxList').getElementsByTagName('input'),false);
653
654         // set the form values
655         formObj.byday.value = byday.join(',');
656         formObj.bymonth.value = bymonth.join(',');
657         formObj.bymonthday.value = bymonthday.join(',');
658         formObj.byweekno.value = byweekno.join(',');
659         formObj.byyearday.value = byyearday.join(',');
660         if (formObj.yearWkst.selectedIndex != -1) {
661           formObj.wkst.value = formObj.yearWkst[formObj.yearWkst.selectedIndex].value;
662         }
663         formObj.interval.value = formObj.yearlyInterval.value;
664         break;
665     }
666     // build up count or until values
667     var recur = getSelectedRadioButtonVal(formObj.recurCountUntil);
668     switch (recur) {
669       case "forever":
670         // do nothing
671         break;
672       case "count":
673         formObj.count.value = formObj.countHolder.value;
674         break;
675       case "until":
676         // the following will not be adequate for recurrences smaller than a day;
677         // we will need to set the time properly at that point.
678         // Dojo is deprecated:
679         //formObj.until.value = dojo.widget.byId("bwEventWidgetUntilDate").getValue() + "T000000";
680         formObj.until.value = formObj.bwEventUntilDate.value + "T000000";
681         break;
682     }
683   }
684
685   if (debug) {
686     alert("frequency: " + freq + "\ninterval: " + formObj.interval.value + "\ncount: " + formObj.count.value + "\nuntil: " + formObj.until.value + "\nbyday: " + formObj.byday.value + "\nbymonthday: " + formObj.bymonthday.value + "\nbymonth: " + formObj.bymonth.value + "\nbyyearday: " + formObj.byyearday.value + "\nwkst: " + formObj.wkst.value);
687     var formFields = '';
688     for (i = 0; i < formObj.length; i++) {
689       formFields += formObj[i].name + ": " + formObj[i].value + "\n";
690     }
691     alert(formFields);
692   }
693   return true;
694 }
695
696 function resetPublishBox(calSelectId) {
697   // User has closed the publish box without publishing.
698   // Reset the calendar select box to default value and hide the publishBox.
699   var calSelect = document.getElementById(calSelectId);
700   calSelect.selectedIndex = 0;
701   changeClass('publishBox','invisible');
702 }
703
704 function doPublishEvent(publishingCal,eventTitle,eventUrlPrefix,formObj) {
705   // User has submitted the event when there is only a single publishing calendar.
706   // Update the newCalPath to reflect the publishing calendar:
707   newCalPath = document.getElementById("newCalPath");
708   newCalPath.value = publishingCal;
709
710   // If email notification is enabled, set field to true
711   // (set to 'true' for now to get the feature working)
712   submitNotification = document.getElementById("submitNotification");
713   submitNotification.value = true;
714
715   // set the email field values
716   snsubject = document.getElementById("snsubject");
717   snsubject.value = "Event Approved: " + eventTitle;
718   sntext = document.getElementById("sntext");
719   var message;
720   message = "Your event has been approved and is now published.\n\n";
721   message += "EVENT DETAILS\n-------------\n";
722   message += "Title: " + eventTitle + "\n";
723   message += "URL: " + eventUrlPrefix + "&calPath=" + publishingCal;
724   sntext.value = message;
725
726   // Send the names of xproperties we wish to retain after we publish.
727   // Those not listed will be thrown away
728   // but must first be passed to the backend for use
729   // (e.g. the email address of the submitter).
730   var xpropPreserve = [bwXPropertyAlias, bwXPropertyImage, bwXPropertySubmittedBy];
731
732   for (var i = 0; i < xpropPreserve.length; i++) {
733     var xpropPreserveField = document.createElement("input");
734     xpropPreserveField.type = "hidden"; // change type prior to appending to DOM
735     formObj.appendChild(xpropPreserveField);
736     xpropPreserveField.name = "xprop-preserve";
737     xpropPreserveField.value = xpropPreserve[i];
738   }
739 }
740
741 function doRejectEvent(formObj, eventTitle, eventDatesForEmail){
742   // If email notification is enabled, set field to true
743   // (set to 'true' for now to get the feature working)
744   formObj.submitNotification.value = true;
745
746   // set the email field values
747   formObj.snsubject.value = "Event Rejected: " + eventTitle;
748
749   var message;
750   message = "Your event has been rejected.\n\n";
751   message += "EVENT DETAILS\n-------------\n";
752   message += "Event Title: " + eventTitle + "\n";
753   message += "Event Dates: " + eventDatesForEmail + "\n\n\n";
754   if (trim(formObj.reason.value) != '') {
755     message += "Reason:\n";
756     message += formObj.reason.value;
757   }
758   formObj.sntext.value = message;
759 }
760
761
Note: See TracBrowser for help on using the browser.