Changeset 2904
- Timestamp:
- 05/12/10 17:30:02
- Files:
-
- trunk/deployment/webuser/webapp/resources/demoskins/themes/bedeworkTheme/head.xsl (modified) (1 diff)
- trunk/deployment/webuser/webapp/resources/demoskins/themes/bedeworkTheme/javascript/bedeworkScheduling.js (modified) (19 diffs)
- trunk/deployment/webuser/webapp/resources/demoskins/themes/bedeworkTheme/javascript/freebusy.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/deployment/webuser/webapp/resources/demoskins/themes/bedeworkTheme/head.xsl
r2903 r2904 174 174 // send params: displayId, startRange, endRange, startDate, endDate, startHourRange, endHourRange, attendees, workday, zoom, browserResourcesRoot, fbUrl, organizerUri 175 175 // example: var bwGrid = new bwSchedulingGrid("bwFreeBusyDisplay","May 5, 2010","May 17, 2010","May 10, 2010 11:00:00","May 10, 2010 11:30:00",8,17,[{name:"Arlen Johnson",uid:"mailto:johnsa@rpi.edu",role:"CHAIR",status:"ACCEPTED",type:"person"}],true,100,"<xsl:value-of select="$resourcesRoot"/>","<xsl:value-of select="$requestFreeBusy"/>",""); 176 var bwGrid = new bwSchedulingGrid("bwFreeBusyDisplay","May 5, 2010","May 17, 2010","May 10, 2010 11:00:00","May 10, 2010 11:30:00",8,17,[],true,100,"<xsl:value-of select="$resourcesRoot"/>","<xsl:value-of select="$resourcesRoot"/>/javascript/freebusy.js","");176 var bwGrid = new bwSchedulingGrid("bwFreeBusyDisplay","May 11, 2010","May 17, 2010","May 13, 2010 11:00:00","May 13, 2010 11:30:00",8,17,[{name:"Arlen Johnson",uid:"mailto:johnsa@mysite.edu",role:"CHAIR",status:"ACCEPTED",type:"person"},{name:"",uid:"mailto:douglm@mysite.edu",role:"REQ-PARTICIPANT",status:"NEEDS-ACTION",type:"person"}],true,100,"<xsl:value-of select="$resourcesRoot"/>","<xsl:value-of select="$resourcesRoot"/>/javascript/freebusy.js",""); 177 177 178 178 // send in some attendees - these will come from interaction with the form 179 bwGrid.updateAttendee("Arlen Johnson", "mailto:johnsa@mysite.edu", "CHAIR", "ACCEPTED", "person"); 180 bwGrid.updateAttendee("Gary Schwartz", "mailto:schwag@mysite.edu", "REQ-PARTICIPANT", "NEEDS-ACTION"); 181 bwGrid.updateAttendee("", "mailto:douglm@mysite.edu", "OPT-PARTICIPANT", "DECLINED"); 179 // bwGrid.updateAttendee("Gary Schwartz", "mailto:schwag@mysite.edu", "OPT-PARTICIPANT", "DECLINED"); 182 180 183 181 // now initialize the grid trunk/deployment/webuser/webapp/resources/demoskins/themes/bedeworkTheme/javascript/bedeworkScheduling.js
r2903 r2904 86 86 87 87 // function to populate the freebusy objects 88 // freebusyStrings: Array of rfc5545 freebusy reply values for the current attendee in the current date range 89 this.updateFreeBusy = function(fbStrings) { 90 // empty the freebusy array (to refresh on updates) 91 this.freebusy.length = 0; 92 // push the new freebusy strings into the array 93 for (i = 0; i<fbStrings.length; i++) { 94 var fb = new bwFreeBusy(fbStrings[i]); 95 this.freebusy.push(fb); 96 } 97 } 88 // fbObj: JSON representation of rfc5545 freebusy reply values and types for the current attendee in the current date range 89 // as supplied by Bedework 90 91 this.updateFreeBusy = function(fbObj) { 92 if (fbObj) { 93 // empty the freebusy array (to refresh on updates) 94 this.freebusy.length = 0; 95 // push the new freebusy strings into the array 96 for (var i = 0; i < fbObj.length; i++) { 97 var type = fbObj[i].fbtype.value; 98 for (var j = 0; j < fbObj[i].periods.length; j++) { 99 var fb = new bwFreeBusy(fbObj[i].periods[j].value, type); 100 this.freebusy.push(fb); 101 } 102 } 103 } 104 } 98 105 } 99 106 100 107 /* A Freebusy object 101 108 * Provides methods to work on freebusy values 102 * fbString: an rfc5545 freebusy string, including FBTYPE parameter if present 109 * fbString: an rfc5545 freebusy string 110 * fbType: rfc5545 FBTYPE parameter 103 111 */ 104 var bwFreeBusy = function(fbString) { 105 this.name = fbString; 106 this.params = ""; // if there are parameters, we will split them from the name and put them here 107 this.type = bwFreeBusyDispTypeBusy; // default rfc5545 FBTYPE, "BUSY" 112 var bwFreeBusy = function(fbString, fbType) { 113 this.value = fbString; 114 this.params = ""; // placeholder for parameters if we use them 115 this.type = fbType; 116 this.typeDisplay = bwFreeBusyDispTypeBusy; // default rfc5545 FBTYPE, "BUSY" 108 117 this.start = ""; // will hold the UTC start value in milliseconds 109 118 this.end = ""; // will hold the UTC end value in milliseconds 110 119 111 if (this.name.match(":")) { 112 // parameters are included with the freebusy string 113 // e.g. FBTYPE=BUSY:19980415T133000Z/19980415T170000Z 114 this.name = fbString.substr(fbString.indexOf(":")+1); 115 this.params = fbString.substring(0,fbString.indexOf(":")); 116 } 117 118 if (this.params.match("FBTYPE=BUSY-TENTATIVE")) { 119 this.type = bwFreeBusyDispTypeTentative; 120 if (this.type = "BUSY-TENTATIVE") { 121 this.typeDisplay = bwFreeBusyDispTypeTentative; 120 122 } 121 123 122 124 // set the freebusy start date 123 125 var startDate = new Date(); 124 startDate.setUTCFullYear(this. name.substring(0,4),this.name.substring(4,6)-1,this.name.substring(6,8));125 startDate.setUTCHours(this. name.substring(9,11),this.name.substring(11,13),this.name.substring(13,15));126 startDate.setUTCFullYear(this.value.substring(0,4),this.value.substring(4,6)-1,this.value.substring(6,8)); 127 startDate.setUTCHours(this.value.substring(9,11),this.value.substring(11,13),this.value.substring(13,15)); 126 128 127 129 // set the start in milliseconds … … 129 131 130 132 var endMs; // end in milliseconds 131 if (this. name.indexOf("P") > -1) {133 if (this.value.indexOf("P") > -1) { 132 134 // freebusy value is of the form: 19971015T223000Z/PT6H30M 133 135 // extract the hours and minutes from the strings and cast as numbers 134 var durationHours = this.name.substring(this.name.lastIndexOf("T")+1,this.name.indexOf("H")); 135 var durationMins = this.name.substring(this.name.indexOf("H")+1,this.name.indexOf("M")); 136 var durationHours = this.value.substring(this.value.lastIndexOf("T")+1,this.value.indexOf("H")); 137 var durationMins = 0; 138 if (this.value.indexOf("M") > -1) { 139 durationMins = this.value.substring(this.value.indexOf("H") + 1, this.value.indexOf("M")); 140 } 136 141 // calculate the duration 137 142 var duration = (Number(durationHours) * 3600000) + (Number(durationMins) * 60000); … … 142 147 // set the freebusy end date 143 148 var endDate = new Date(); 144 endDate.setUTCFullYear(this. name.substring(17,21),this.name.substring(21,23)-1,this.name.substring(23,25));145 endDate.setUTCHours(this. name.substring(26,28),this.name.substring(28,30),this.name.substring(30,32));149 endDate.setUTCFullYear(this.value.substring(17,21),this.value.substring(21,23)-1,this.value.substring(23,25)); 150 endDate.setUTCHours(this.value.substring(26,28),this.value.substring(28,30),this.value.substring(30,32)); 146 151 endMs = endDate.getTime(); 147 152 } … … 225 230 // initialize any incoming attendees on first load 226 231 // while iterating, build up the array of requests 227 for ( i = 0; i < attendees.length; i++) {232 for (var i = 0; i < attendees.length; i++) { 228 233 var newAttendee = new bwAttendee(attendees[i].name,attendees[i].uid, attendees[i].role,attendees[i].status,attendees[i].type); 229 234 this.attendees.push(newAttendee); … … 231 236 232 237 // now go get the freebusy information for the attendees 233 this.requestFreeBusy(this.fbUrl); 238 if (this.attendees.length) { 239 this.requestFreeBusy(this.fbUrl); 240 } 234 241 } 235 242 236 243 // add/update attendees 237 244 /* examples: 238 bwGrid.updateAttendee("Venerable Bede", "mailto:vbede@mysite.edu", ["20100421T093000Z/PT2H00M","20100423T174500Z/PT8H30M"],"CHAIR", "ACCEPTED", "person");239 bwGrid.updateAttendee("Samual Clemens", "mailto:sclemens@mysite.edu", ["20100422T090000Z/PT1H00M"],"REQ-PARTICIPANT", "NEEDS-ACTION");240 bwGrid.updateAttendee("", "mailto:noname@mysite.edu", ["FBTYPE=BUSY-TENTATIVE:20100421T120000Z/20100421T130000Z","20100422T050000Z/20100422T060000Z"],"OPT-PARTICIPANT", "DECLINED");245 bwGrid.updateAttendee("Venerable Bede", "mailto:vbede@mysite.edu", "CHAIR", "ACCEPTED", "person"); 246 bwGrid.updateAttendee("Samual Clemens", "mailto:sclemens@mysite.edu", "REQ-PARTICIPANT", "NEEDS-ACTION"); 247 bwGrid.updateAttendee("", "mailto:noname@mysite.edu", "OPT-PARTICIPANT", "DECLINED"); 241 248 */ 242 249 this.updateAttendee = function(name, uid, role, status, type) { … … 245 252 246 253 // check to see if attendee already exists 247 for (i=0; i < this.attendees.length; i++) { 248 //alert(newAttendee.uid + " -- " + this.attendees[i].uid); 254 for (var i=0; i < this.attendees.length; i++) { 249 255 if (newAttendee.uid == this.attendees[i].uid) { 250 256 attendeeIsNew = false; … … 254 260 255 261 if (attendeeIsNew) { 256 this.attendees.push(newAttendee); 257 }258 259 this.display();262 this.attendees.push(newAttendee); 263 this.requestFreeBusy(this.fbUrl); 264 } 265 260 266 } 261 267 262 268 this.removeAttendee = function(index) { 263 269 this.attendees.splice(index, 1); 264 this. display();270 this.requestFreeBusy(this.fbUrl); 265 271 } 266 272 267 273 this.requestFreeBusy = function(fburl) { 268 274 $.getJSON(fburl, function(fb) { 269 for ( i=0; i < fb.microformats["schedule-response"].length; i++) {275 for (var i=0; i < fb.microformats["schedule-response"].length; i++) { 270 276 var r = fb.microformats["schedule-response"][i]; // reference the current response 271 272 // prepare the freebusy strings for the attendee 273 var fbStrings = new Array(); 274 for (j=0; j < r["calendar-data"].freebusy.periods.length; j++) { 275 fbStrings[j] = r["calendar-data"].freebusy.periods[j].value; 276 } 277 278 // find the attendee and update freebusy 279 for (j=0; j < bwGrid.attendees.length; j++) { 280 //alert(r["calendar-data"].attendee[0].value + " : " + bwGrid.attendees[j].uid); 281 if (r["calendar-data"].attendee[0].value == bwGrid.attendees[j].uid) { 282 bwGrid.attendees[j].updateFreeBusy(fbStrings); 277 278 // find the attendee and pass in the freebusy object 279 for (var j=0; j < bwGrid.attendees.length; j++) { 280 if (bwGrid.attendees[j].uid == r["calendar-data"].attendee[0].value) { 281 bwGrid.attendees[j].updateFreeBusy(r["calendar-data"].freebusy); 283 282 } 284 283 } … … 347 346 // now look over the next group of cells to see if the range 348 347 // we want to select is busy. If not, store the value for lookup. 349 for ( i=0; i <= this.fb.length - cellsInDuration; i++) {348 for (var i=0; i <= this.fb.length - cellsInDuration; i++) { 350 349 var rangeNotBusy = true; 351 for ( j = i; j < i + cellsInDuration; j++) {350 for (var j = i; j < i + cellsInDuration; j++) { 352 351 if (this.fb[j][1]) { // we hit a busy cell 353 352 rangeNotBusy = false; … … 388 387 var fbDisplayDateRow = fbDisplay.insertRow(fbDisplay.rows.length); 389 388 $(fbDisplayDateRow).html('<td rowspan="2" colspan="4" class="corner"></td><td class="fbBoundry"></td>'); 390 for ( i=0; i < range; i++) {389 for (var i=0; i < range; i++) { 391 390 var curDate = new Date(this.startRange); 392 391 curDate.addDays(i); … … 397 396 fbDisplayTimesRow = fbDisplay.insertRow(fbDisplay.rows.length); 398 397 $(fbDisplayTimesRow).html('<td class="fbBoundry"></td>'); 399 for ( i=0; i < range; i++) {398 for (var i=0; i < range; i++) { 400 399 var curDate = new Date(this.startRange); 401 400 curDate.setHours(startHour); … … 419 418 $(fbDisplayTimesRow).addClass("allAttendees"); 420 419 $(fbDisplayTimesRow).html('<td class="status"></td><td class="role"></td><td class="name">All Attendees</td><td></td><td class="fbBoundry"></td>'); 421 for ( i=0; i < range; i++) {420 for (var i=0; i < range; i++) { 422 421 var curDate = new Date(this.startRange); 423 422 curDate.setHours(startHour); 424 423 curDate.addDays(i); 425 424 // add the time cells by iterating over the hours 426 for ( j = 0; j < hourRange; j++) {427 for ( k = 0; k < this.hourDivision; k++) {425 for (var j = 0; j < hourRange; j++) { 426 for (var k = 0; k < this.hourDivision; k++) { 428 427 var fbCell = document.createElement("td"); 429 428 var timeClass = curDate.getTime().toString(); … … 438 437 // set busy if any freebusy in this timeperiod 439 438 loop1: // since we only need to know if anyone is busy, provide a simple means of breaking from the inner loop 440 for ( att = 0; att < this.attendees.length; att++) {441 for ( m = 0; m < this.attendees[att].freebusy.length; m++) {439 for (var att = 0; att < this.attendees.length; att++) { 440 for (var m = 0; m < this.attendees[att].freebusy.length; m++) { 442 441 var tzoffset = -curDate.getTimezoneOffset() * 60000; // in milliseconds 443 442 // adding the hourdivision increment in the calculation below is to correct for a bug … … 535 534 536 535 // build the time row for an attendee 537 for ( i = 0; i < range; i++) {536 for (var i = 0; i < range; i++) { 538 537 var curDate = new Date(this.startRange); 539 538 curDate.setHours(startHour); 540 539 curDate.addDays(i); 541 540 // add the time cells by iterating over the hours 542 for ( j = 0; j < hourRange; j++) {543 for ( k = 0; k < this.hourDivision; k++) {541 for (var j = 0; j < hourRange; j++) { 542 for (var k = 0; k < this.hourDivision; k++) { 544 543 var fbCell = document.createElement("td"); 545 544 fbCell.id = curDate.getTime() + "-" + curAttendee.uid.substr(curAttendee.uid.lastIndexOf(":") + 1); … … 549 548 $(fbCell).addClass("hourBoundry"); 550 549 } 551 for ( m = 0; m < curAttendee.freebusy.length; m++) {550 for (var m = 0; m < curAttendee.freebusy.length; m++) { 552 551 var tzoffset = -curDate.getTimezoneOffset() * 60000; // in milliseconds 553 552 // adding the hourdivision increment in the calculation below is to correct for a bug … … 555 554 var curDateUTC = curDate.getTime() + tzoffset + (60 / this.hourDivision * 60000); 556 555 if (curAttendee.freebusy[m].contains(curDateUTC)) { 557 if (curAttendee.freebusy[m].type .match("TENTATIVE")) {556 if (curAttendee.freebusy[m].typeDisplay.match("TENTATIVE")) { 558 557 $(fbCell).addClass("tentative"); 559 558 } else { … … 561 560 } 562 561 $(fbCell).addClass("activeCell"); 563 $(fbCell).append('<span class="tip">' + curAttendee.freebusy[m].type + '</span>');562 $(fbCell).append('<span class="tip">' + curAttendee.freebusy[m].typeDisplay + '</span>'); 564 563 break; 565 564 } … … 573 572 } 574 573 574 /* DEPRECATED - don't put in grid 575 575 // generate the "add attendee" row 576 576 fbDisplayAddAttendeeRow = fbDisplay.insertRow(fbDisplay.rows.length); … … 607 607 } 608 608 $(fbDisplayAddAttendeeRow).append('<td class="dayBoundry"></td>'); 609 } 609 } */ 610 610 611 611 // generate a blank row at the end (this is just for visual padding) 612 612 fbDisplayBlankRow = fbDisplay.insertRow(fbDisplay.rows.length); 613 613 $(fbDisplayBlankRow).html('<td class="status"></td><td class="role"></td><td class="name"></td><td></td><td class="fbBoundry"></td>'); 614 for ( i = 0; i < range; i++) {614 for (var i = 0; i < range; i++) { 615 615 var curDate = new Date(this.startRange); 616 616 curDate.setHours(startHour); 617 617 curDate.addDays(i); 618 618 // add the time cells by iterating over the hours 619 for ( j = 0; j < hourRange; j++) {620 for ( k = 0; k < this.hourDivision; k++) {619 for (var j = 0; j < hourRange; j++) { 620 for (var k = 0; k < this.hourDivision; k++) { 621 621 var fbCell = document.createElement("td"); 622 622 fbCell.id = curDate.getTime() + "-blank"; … … 683 683 684 684 // set the freeTimeIndex to the nearest index for the pickNext/previous buttons 685 for ( i = 0; i < bwGrid.freeTime.length; i++) {685 for (var i = 0; i < bwGrid.freeTime.length; i++) { 686 686 if (Number(bwGrid.freeTime[i]) >= Number(startSelectionMils)) { 687 687 bwGrid.freeTimeIndex = i - 1; // this will make pick previous jump an extra gap after clicking in a busy space, but it makes pick next work correctly in the same circumstance trunk/deployment/webuser/webapp/resources/demoskins/themes/bedeworkTheme/javascript/freebusy.js
r2903 r2904 34 34 "periods" : [ 35 35 { 36 "value" : "20100513T180000Z \/PT2H"36 "value" : "20100513T180000Z/PT2H" 37 37 }, 38 38 { 39 "value" : "20100514T120000Z \/PT4H"39 "value" : "20100514T120000Z/PT4H" 40 40 } 41 41 ] … … 76 76 "periods" : [ 77 77 { 78 "value" : "20100512T180000Z \/PT3H"78 "value" : "20100512T180000Z/PT3H" 79 79 }, 80 80 { 81 "value" : "20100514T140000Z \/PT1H"81 "value" : "20100514T140000Z/PT1H" 82 82 } 83 83 ]
