Changeset 2881

Show
Ignore:
Timestamp:
04/24/10 23:26:29
Author:
johnsa
Message:

ongoing updates to freebusy mockup

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/deployment/webuser/webapp/resources/demoskins/fbMockup/bedeworkFb.js

    r2880 r2881  
    6060 
    6161/* 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 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 
     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 * 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 
    6868 */ 
    69 var bwAttendee = function(name, uid, freebusy, role, status, type) { 
     69var bwAttendee = function(name, uid, freebusyStrings, role, status, type) { 
    7070  this.name = name; 
    7171  this.uid = uid; 
    72   this.freebusy = new bwFreeBusy(freebusy); 
     72  this.freebusy = new Array(); 
    7373  this.role = role; 
    7474  this.status = status; 
    7575  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  } 
    7682   
    7783  if (this.type == null || this.type == "") { 
     
    8389 * fbvals: Array of rfc5545 freebusy values  
    8490 */ 
    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   } 
     91var 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 
    119124   
    120125  // example of how to generate a date from the millisecond UTC value   
     
    122127  // alert(testDate.toLocaleString()); 
    123128     
    124   /* returns true if dateString is contained in a freebusy value 
    125    * mills: date/time in milliseconds 
     129  /* returns true if date is contained in this freebusy value 
     130   * mils: date/time in milliseconds 
    126131   */   
    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; 
    132136    } 
    133137    return false; 
    134   }*/ 
     138  } 
    135139} 
    136140 
     
    184188  this.display = function() { 
    185189    try { 
    186       // number of days and hours each day to display 
     190      // number of days to display 
    187191      var range = dayRange(this.startRange, this.endRange); 
     192      // number of hours to display 
    188193      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       
    189202      var cellsInDay = hourRange * this.hourDivision; 
    190203     
    191       // build the entire free/busy table first 
     204      // build the entire free/busy table 
    192205      var fbDisplay = document.createElement("table"); 
    193206      fbDisplay.id = "bwScheduleTable"; 
     
    207220      for (i=0; i < range; i++) { 
    208221        var curDate = new Date(this.startRange);  
    209         curDate.setHours(this.startHoursRange); 
     222        curDate.setHours(startHour); 
    210223        curDate.addDays(i); 
    211224        // add the time cells by iterating over the hours 
     
    226239      for (i=0; i < range; i++) { 
    227240        var curDate = new Date(this.startRange);  
    228         curDate.setHours(this.startHoursRange); 
     241        curDate.setHours(startHour); 
    229242        curDate.addDays(i); 
    230243        // add the time cells by iterating over the hours 
     
    248261        fbDisplayTimesRow = fbDisplay.insertRow(attendee + 3); // offset by three to account for previous special rows 
    249262        var curAttendee = this.attendees[attendee]; 
     263         
    250264        // set the status icon and class  
    251265        // the status class is used for rollover descriptions of the icon 
     
    299313        for (i = 0; i < range; i++) { 
    300314          var curDate = new Date(this.startRange); 
    301           curDate.setHours(this.startHoursRange); 
     315          curDate.setHours(startHour); 
    302316          curDate.addDays(i); 
    303317          // add the time cells by iterating over the hours 
     
    310324                $(fbCell).addClass("hourBoundry"); 
    311325              }  
    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              } 
    315336              $(fbDisplayTimesRow).append(fbCell); 
    316337              curDate.addMinutes(60/this.hourDivision); 
  • trunk/deployment/webuser/webapp/resources/demoskins/fbMockup/index.html

    r2880 r2881  
    1717     
    1818      // initialize the free/busy grid - values taken directly from the xml 
    19       // send params: displayId, startRange, endRange, startDate, endDate, attendees, workday, zoom 
     19      // send params: displayId, startRange, endRange, startDate, endDate, startHourRange, endHourRange, attendees, workday, zoom 
    2020      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); 
    2121       
    2222      // send in some attendees - these will come from interaction with the form 
    2323      bwGrid.addAttendee("Gary Schwartz", "mailto:schwag@rpi.edu", ["20100422T090000Z/PT1H00M"], "REQ-PARTICIPANT", "NEEDS-ACTION"); 
    24       bwGrid.addAttendee("", "mailto:douglm@rpi.edu", ["20100421T120000Z/20100421T130000Z","20100421T050000Z/20100422T050000Z"], "OPT-PARTICIPANT", "DECLINED"); 
     24      bwGrid.addAttendee("", "mailto:douglm@rpi.edu", ["20100421T120000Z/20100421T130000Z","20100422T050000Z/20100422T060000Z"], "OPT-PARTICIPANT", "DECLINED"); 
    2525 
    2626      // set datepicker defaults