Changeset 2880

Show
Ignore:
Timestamp:
04/23/10 17:25:46
Author:
johnsa
Message:

ongoing update to free/busy mockup

Files:

Legend:

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

    r2879 r2880  
    7070  this.name = name; 
    7171  this.uid = uid; 
    72   this.freebusy = freebusy
     72  this.freebusy = new bwFreeBusy(freebusy)
    7373  this.role = role; 
    7474  this.status = status; 
     
    7878    this.type == bwAttendeeTypePerson; 
    7979  } 
     80} 
     81/* Freebusy data 
     82 * Provides methods to work on freebusy values 
     83 * fbvals: Array of rfc5545 freebusy values  
     84 */ 
     85var 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  } 
     119   
     120  // example of how to generate a date from the millisecond UTC value   
     121  // var testDate = new Date(this.fbHash[fbVals[0]].start); //fbVals[0] = a freebusy string 
     122  // alert(testDate.toLocaleString()); 
     123     
     124  /* returns true if dateString is contained in a freebusy value 
     125   * mills: date/time in milliseconds 
     126   */   
     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    } 
     133    return false; 
     134  }*/ 
    80135} 
    81136 
     
    102157  this.zoom = zoom; 
    103158  this.workday = workday; 
    104   this.attendees = attendees; 
    105    
     159  this.attendees = new Array();  // array of bwAttendee objects 
     160   
     161  // initialize any incoming attendees on first load 
     162  for (i = 0; i < attendees.length; i++) { 
     163    var newAttendee = new bwAttendee(attendees[i].name,attendees[i].uid ,attendees[i].freebusy,attendees[i].role,attendees[i].status,attendees[i].type); 
     164    this.attendees.push(newAttendee);  
     165  } 
     166     
    106167  // how much will we divide the hour in the grid? 
    107168  // this is a constant for now, but could be variable. 
    108169  // ALWAYS set as a factor of 60 
    109170  this.hourDivision = 4; 
    110    
    111   this.addAttendee = function(name, uid, freebusy, role, status) { 
    112     var newAttendee = new bwAttendee(name, uid, freebusy, role, status); 
    113     attendees.push(newAttendee); 
     171 
     172  this.addAttendee = function(name, uid, freebusy, role, status, type) { 
     173    var newAttendee = new bwAttendee(name, uid, freebusy, role, status, type); 
     174    this.attendees.push(newAttendee); 
    114175     
    115176    this.display(); 
     
    117178   
    118179  this.deleteAttendee = function(index) { 
    119     attendees.splice(index, 1); 
     180    this.attendees.splice(index, 1); 
    120181    this.diplay(); 
    121182  } 
     
    173234            fbCell.id = curDate.getTime() + "-AllAttendees"; 
    174235            $(fbCell).addClass("fbcell"); 
    175             if (curDate.getMinutes() == 0) { 
     236            if (curDate.getMinutes() == 0 && j != 0) { 
    176237              $(fbCell).addClass("hourBoundry"); 
    177238            }  
     
    184245       
    185246      // generate the regular attendees rows 
    186       for (attendee = 0; attendee < attendees.length; attendee++) { 
     247      for (attendee = 0; attendee < this.attendees.length; attendee++) { 
    187248        fbDisplayTimesRow = fbDisplay.insertRow(attendee + 3); // offset by three to account for previous special rows 
    188         var curAttendee = attendees[attendee]; 
     249        var curAttendee = this.attendees[attendee]; 
    189250        // set the status icon and class  
    190251        // the status class is used for rollover descriptions of the icon 
     
    246307              fbCell.id = curDate.getTime() + "-" + curAttendee.uid.substr(curAttendee.uid.lastIndexOf(":")+1); 
    247308              $(fbCell).addClass("fbcell"); 
    248               if (curDate.getMinutes() == 0) { 
     309              if (curDate.getMinutes() == 0 && j != 0) { 
    249310                $(fbCell).addClass("hourBoundry"); 
    250311              }  
    251               //switch (bwFreeBusycurDate.getTime()) 
     312              //if (curAttendee.freebusy.contains(curDate.getTime())) { 
     313              //  $(fbCell).addClass("busy"); 
     314             // } 
    252315              $(fbDisplayTimesRow).append(fbCell); 
    253316              curDate.addMinutes(60/this.hourDivision); 
  • trunk/deployment/webuser/webapp/resources/demoskins/fbMockup/index.html

    r2879 r2880  
    1818      // initialize the free/busy grid - values taken directly from the xml 
    1919      // send params: displayId, startRange, endRange, startDate, endDate, attendees, workday, zoom 
    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:["20100421T050000Z/PT2H00M","20100423T050000Z/PT8H30M"],role:"CHAIR",status:"ACCEPTED",type:"person"}],true,100); 
     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); 
    2121       
    2222      // send in some attendees - these will come from interaction with the form 
    23       bwGrid.addAttendee("Gary Schwartz", "mailto:schwag@rpi.edu", ["20100422T050000Z/PT1H00M"], "REQ-PARTICIPANT", "NEEDS-ACTION"); 
     23      bwGrid.addAttendee("Gary Schwartz", "mailto:schwag@rpi.edu", ["20100422T090000Z/PT1H00M"], "REQ-PARTICIPANT", "NEEDS-ACTION"); 
    2424      bwGrid.addAttendee("", "mailto:douglm@rpi.edu", ["20100421T120000Z/20100421T130000Z","20100421T050000Z/20100422T050000Z"], "OPT-PARTICIPANT", "DECLINED"); 
    2525