Changeset 2881
- Timestamp:
- 04/24/10 23:26:29
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/deployment/webuser/webapp/resources/demoskins/fbMockup/bedeworkFb.js
r2880 r2881 60 60 61 61 /* An attendee 62 * name: String - name of attendee, e.g. "Venerable Bede"63 * uid: String - attendee's uid with mailto included, e.g. "mailto:vbede@example.com"64 * freebusy : Array of rfc5545 freebusy reply values for the current attendee in the current date range65 * role: String - Attendee role, e.g. CHAIR, REQ-PARTICIPANT, etc66 * status: String - participation status (PARTSTAT)67 * type: String - person, location, other resource62 * name: String - name of attendee, e.g. "Venerable Bede" 63 * uid: String - attendee's uid with mailto included, e.g. "mailto:vbede@example.com" 64 * freebusyStrings: Array of rfc5545 freebusy reply values for the current attendee in the current date range 65 * role: String - Attendee role, e.g. CHAIR, REQ-PARTICIPANT, etc 66 * status: String - participation status (PARTSTAT) 67 * type: String - person, location, other resource 68 68 */ 69 var bwAttendee = function(name, uid, freebusy , role, status, type) {69 var bwAttendee = function(name, uid, freebusyStrings, role, status, type) { 70 70 this.name = name; 71 71 this.uid = uid; 72 this.freebusy = new bwFreeBusy(freebusy);72 this.freebusy = new Array(); 73 73 this.role = role; 74 74 this.status = status; 75 75 this.type = type; 76 77 //populate the freebusy objects 78 for (i = 0; i<freebusyStrings.length; i++) { 79 var fb = new bwFreeBusy(freebusyStrings[i]); 80 this.freebusy.push(fb); 81 } 76 82 77 83 if (this.type == null || this.type == "") { … … 83 89 * fbvals: Array of rfc5545 freebusy values 84 90 */ 85 var bwFreeBusy = function(fbVals) { 86 this.fbVals = fbVals; 87 88 // create a hash table to reference useful information about the freebusy values 89 // specifically, store start and end in milliseconds 90 this.fbHash = new Array(); 91 92 for (i = 0; i < fbVals.length; i++) { 93 // set the freebusy start date 94 var startDate = new Date(); 95 startDate.setUTCFullYear(fbVals[i].substring(0,4),fbVals[i].substring(4,6)-1,fbVals[i].substring(6,8)); 96 startDate.setUTCHours(fbVals[i].substring(9,11),fbVals[i].substring(11,13),fbVals[i].substring(13,15)); 97 98 if (fbVals[i].indexOf("P") > -1) { 99 // freebusy value is of the form: 19971015T223000Z/PT6H30M 100 // get the start date in milliseconds 101 var startMills = startDate.getTime(); 102 // extract the hours and minutes from the strings and cast as numbers 103 var durationHours = new Number(fbVals[i].substring(fbVals[i].indexOf("T")+1,fbVals[i].indexOf("H"))); 104 var durationMins = new Number(fbVals[i].substring(fbVals[i].indexOf("H")+1,fbVals[i].indexOf("M"))); 105 // calculate the duration 106 var duration = (durationHours * 3600000) + (durationMins * 60000); 107 // set start and end in milliseconds 108 this.fbHash[fbVals[i]] = {start:startMills,end:startMills+duration}; 109 } else { 110 // freebusy value is of the form: 19980314T233000Z/19980315T003000Z 111 // set the freebusy end date 112 var endDate = new Date(); 113 endDate.setUTCFullYear(fbVals[i].substring(17,21),fbVals[i].substring(21,23)-1,fbVals[i].substring(23,25)); 114 endDate.setUTCHours(fbVals[i].substring(26,28),fbVals[i].substring(28,30),fbVals[i].substring(30,32)); 115 // set the start and end date in milliseconds 116 this.fbHash[fbVals[i]] = {start:startDate.getTime(),end:endDate.getTime()}; 117 } 118 } 91 var bwFreeBusy = function(fbString) { 92 this.name = fbString; 93 94 // set the freebusy start date 95 var startDate = new Date(); 96 startDate.setUTCFullYear(this.name.substring(0,4),this.name.substring(4,6)-1,this.name.substring(6,8)); 97 startDate.setUTCHours(this.name.substring(9,11),this.name.substring(11,13),this.name.substring(13,15)); 98 99 // set the start in milliseconds 100 this.start = startDate.getTime(); 101 102 var endMs; // end in milliseconds 103 if (this.name.indexOf("P") > -1) { 104 // freebusy value is of the form: 19971015T223000Z/PT6H30M 105 // extract the hours and minutes from the strings and cast as numbers 106 var durationHours = this.name.substring(this.name.lastIndexOf("T")+1,this.name.indexOf("H")); 107 var durationMins = this.name.substring(this.name.indexOf("H")+1,this.name.indexOf("M")); 108 // calculate the duration 109 var duration = (Number(durationHours) * 3600000) + (Number(durationMins) * 60000); 110 // set start and end in milliseconds 111 endMs = this.start + duration; 112 } else { 113 // freebusy value is of the form: 19980314T233000Z/19980315T003000Z 114 // set the freebusy end date 115 var endDate = new Date(); 116 endDate.setUTCFullYear(this.name.substring(17,21),this.name.substring(21,23)-1,this.name.substring(23,25)); 117 endDate.setUTCHours(this.name.substring(26,28),this.name.substring(28,30),this.name.substring(30,32)); 118 endMs = endDate.getTime(); 119 } 120 121 // set the end in milliseconds 122 this.end = endMs; 123 119 124 120 125 // example of how to generate a date from the millisecond UTC value … … 122 127 // alert(testDate.toLocaleString()); 123 128 124 /* returns true if date String is contained in afreebusy value125 * mil ls: date/time in milliseconds129 /* returns true if date is contained in this freebusy value 130 * mils: date/time in milliseconds 126 131 */ 127 /*this.contains = function(mills) { 128 for (i = 0; i < this.fbHash.length; i++) { 129 if (mills >= this.fbHash[i].start || mills <= this.fbHash[i].end) { 130 return true; 131 } 132 this.contains = function(mils) { 133 if (mils >= this.start && mils < this.end) { 134 // should return type of freebusy if available 135 return true; 132 136 } 133 137 return false; 134 } */138 } 135 139 } 136 140 … … 184 188 this.display = function() { 185 189 try { 186 // number of days and hours each dayto display190 // number of days to display 187 191 var range = dayRange(this.startRange, this.endRange); 192 // number of hours to display 188 193 var hourRange = this.endHoursRange - this.startHoursRange; 194 var startHour = this.startHoursRange; 195 196 if (!workday) { 197 // show full 24 hours in grid 198 hourRange = 24; 199 startHour = 0; 200 } 201 189 202 var cellsInDay = hourRange * this.hourDivision; 190 203 191 // build the entire free/busy table first204 // build the entire free/busy table 192 205 var fbDisplay = document.createElement("table"); 193 206 fbDisplay.id = "bwScheduleTable"; … … 207 220 for (i=0; i < range; i++) { 208 221 var curDate = new Date(this.startRange); 209 curDate.setHours( this.startHoursRange);222 curDate.setHours(startHour); 210 223 curDate.addDays(i); 211 224 // add the time cells by iterating over the hours … … 226 239 for (i=0; i < range; i++) { 227 240 var curDate = new Date(this.startRange); 228 curDate.setHours( this.startHoursRange);241 curDate.setHours(startHour); 229 242 curDate.addDays(i); 230 243 // add the time cells by iterating over the hours … … 248 261 fbDisplayTimesRow = fbDisplay.insertRow(attendee + 3); // offset by three to account for previous special rows 249 262 var curAttendee = this.attendees[attendee]; 263 250 264 // set the status icon and class 251 265 // the status class is used for rollover descriptions of the icon … … 299 313 for (i = 0; i < range; i++) { 300 314 var curDate = new Date(this.startRange); 301 curDate.setHours( this.startHoursRange);315 curDate.setHours(startHour); 302 316 curDate.addDays(i); 303 317 // add the time cells by iterating over the hours … … 310 324 $(fbCell).addClass("hourBoundry"); 311 325 } 312 //if (curAttendee.freebusy.contains(curDate.getTime())) { 313 // $(fbCell).addClass("busy"); 314 // } 326 for (m = 0; m < curAttendee.freebusy.length; m++) { 327 var tzoffset = -curDate.getTimezoneOffset() * 60000; // in milliseconds 328 // adding the hourdivision increment in the calculation below is to correct for a bug 329 // in which the class was always offset by one table cell - should find cause 330 var curDateUTC = curDate.getTime() + tzoffset + (60/this.hourDivision*60000); 331 if (curAttendee.freebusy[m].contains(curDateUTC)) { 332 $(fbCell).addClass("busy"); 333 break; 334 } 335 } 315 336 $(fbDisplayTimesRow).append(fbCell); 316 337 curDate.addMinutes(60/this.hourDivision); trunk/deployment/webuser/webapp/resources/demoskins/fbMockup/index.html
r2880 r2881 17 17 18 18 // initialize the free/busy grid - values taken directly from the xml 19 // send params: displayId, startRange, endRange, startDate, endDate, attendees, workday, zoom19 // send params: displayId, startRange, endRange, startDate, endDate, startHourRange, endHourRange, attendees, workday, zoom 20 20 var bwGrid = new bwSchedulingGrid("bwFreeBusyDisplay","April 21, 2010","April 27, 2010","April 21, 2010 11:00:00","April 21, 2010 11:30:00",8,17,[{name:"Arlen Johnson",uid:"mailto:johnsa@rpi.edu",freebusy:["20100421T093000Z/PT2H00M","20100423T174500Z/PT8H30M"],role:"CHAIR",status:"ACCEPTED",type:"person"}],true,100); 21 21 22 22 // send in some attendees - these will come from interaction with the form 23 23 bwGrid.addAttendee("Gary Schwartz", "mailto:schwag@rpi.edu", ["20100422T090000Z/PT1H00M"], "REQ-PARTICIPANT", "NEEDS-ACTION"); 24 bwGrid.addAttendee("", "mailto:douglm@rpi.edu", ["20100421T120000Z/20100421T130000Z","2010042 1T050000Z/20100422T050000Z"], "OPT-PARTICIPANT", "DECLINED");24 bwGrid.addAttendee("", "mailto:douglm@rpi.edu", ["20100421T120000Z/20100421T130000Z","20100422T050000Z/20100422T060000Z"], "OPT-PARTICIPANT", "DECLINED"); 25 25 26 26 // set datepicker defaults
