(wip)
[myslice.git] / plugins / scheduler / static / js / scheduler.js
1 /**
2  * Description: display a query result in a Google map
3  * Copyright (c) 2012-2013 UPMC Sorbonne Universite - INRIA
4  * License: GPLv3
5  */
6
7 /* based on the leases.js code in PLE WWW interface for MyPLC by Thierry Parmentelat -- INRIA */
8
9 /* XXX Those declarations should not be part of the js file... */
10
11 /* decorations / headers */
12 /* note: looks like the 'font' attr is not effective... */
13
14 // vertical rules
15 var attr_rules={'fill':"#888", 'stroke-dasharray':'- ', 'stroke-width':0.5};
16 // set font-size separately in here rather than depend on the height
17 var txt_timelabel = {"font": 'Times, "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif', 
18              stroke: "none", fill: "#008", 'font-size': 9};
19 var txt_allnodes = {"font": '"Trebuchet MS", Verdana, Arial, Helvetica, sans-serif', stroke: "none", fill: "#404"};
20 var txt_nodelabel = {"font": '"Trebuchet MS", Verdana, Arial, Helvetica, sans-serif', stroke: "none", fill: "#008"};
21
22 var attr_timebutton = {'fill':'#bbf', 'stroke': '#338','stroke-width':1, 
23                'stroke-linecap':'round', 'stroke-linejoin':'miter', 'stroke-miterlimit':3};
24 var attr_daymarker = {'stroke':'#000','stroke-width':2};
25 var attr_half_daymarker = {'stroke':'#444','stroke-width':2};
26
27 /* lease dimensions and colors */
28 /* refrain from using gradient color, seems to not be animated properly */
29 /* lease was originally free and is still free */
30 var attr_lease_free_free={'fill':"#def", 'stroke-width':0.5, 'stroke-dasharray':''};
31 /* lease was originally free and is now set for our usage */
32 var attr_lease_free_mine={'fill':"green", 'stroke-width':1, 'stroke-dasharray':'-..'};
33 /* was mine and is still mine */
34 var attr_lease_mine_mine={'fill':"#beb", 'stroke-width':0.5, 'stroke-dasharray':''};
35 /* was mine and is about to be released */
36 var attr_lease_mine_free={'fill':"white", 'stroke-width':1, 'stroke-dasharray':'-..'};
37 var attr_lease_other={'fill':"#f88"};
38
39 /* other slices name */
40 var txt_otherslice = {"font": '"Trebuchet MS", Verdana, Arial, Helvetica, sans-serif', stroke: "none", fill: "#444", "font-size": "12px"};
41
42 (function($){
43
44     var Scheduler = Plugin.extend({
45
46         init: function(options, element) 
47         {
48             this._super(options, element);
49
50             /* Member variables */
51             this._canvas_id = this.id('leases_area');
52
53             this.query_uuid = options.query_uuid;
54             this.rows = null;
55             // XXX TODEL
56             //this.current_resources = Array();
57             //this.current_leases = Array();
58
59             /* Managing asynchronous reception of resources and leases */
60             this._tmp_resources = Array();
61             this.listLeases    = Array();
62             this._received_resources = false;
63             this._received_leases    = false;
64
65             this.myLeases = Array();
66             this.allLeases = Array();
67
68             this.axisx = Array();
69             this.resources = Array();
70             this.data = Array();
71             this.default_granularity = 1800; /* 30 min */
72             this.initial_timestamp = null;
73
74             /* This should be updated to be the ppcm of all granularities */
75             this.min_granularity = this.default_granularity;
76
77             // the data contains slice names, and lease_id, we need this to find our own leases (mine)
78             this.paper=null;
79
80             /* XXX Events */
81
82             /* XXX Keys */
83
84             /* Listening to queries */
85             this.listen_query(options.query_uuid);
86             this.listen_query(options.query_lease_uuid, 'lease');
87
88             /* XXX GUI setup and event binding */
89             jQuery("#datepicker").datetimepicker({
90                 //Timezone wise selection option
91                 //timeFormat: 'hh:mm tt z',
92                 //showTimezone: true,
93                 
94                 onSelect: function(value) { 
95                     //console.log(value);
96                     //converting time to timestamp
97                     currentDate= Math.round(Date.parse(value)/ 1000);
98                     // TODO -- DONE
99                     // convert value to timestamp --done
100                     // Get jQuery("#timepicker").val(); - no need anymore
101                     // convert timepicker into seconds - no need
102                     // Add time to date - done
103                     // pass the result to init_axisx - done
104                     //console.log(currentDate);
105                     s.clear();
106                     s.init_axisx(currentDate);
107                     s.draw();
108                     // Do we need to populate the timeslots with existing leases? 
109                     // Look how to populate with initial_leases [we have to show the leases]
110                     
111                 } 
112             });
113             //console.log(s.nodelabels[1]);
114             // Do we need to populate the timeslots with existing leases? 
115             // Look how to populate with initial_leases
116             
117             // TODO -- DONE  Note: autocomplete is not search box
118             // Implement a filtering functionality, on the name of the node
119             // http://jqueryui.com/autocomplete/
120             // pass s.nodelabels to autocomplete function
121             //jQuery("#search").autocomplete('s.nodelabel');
122             //console.log(s.nodelabel);
123             
124             /*
125              * TODO
126              * During init, there are no resources
127              * So the list of nodes is empty
128              * The function triggered by the subscription to the resources query
129              * var RESULTS_RESOURCES = '/results/' + options.resource_query_uuid + '/changed';
130              * $.subscribe(RESULTS_RESOURCES, function(e, resources) { s.set_resources(resources);   });
131              * Will have to update the list of nodes available through autocomplete (availableTags)
132              * 
133              * Be inspired by QueryEditor plugin
134              * 
135              * Resources informations in s.axisy ???
136              * 
137              * Filter what has been selected in other plugins:
138              * QueryEditor
139              * QuickFilter
140              * AdvancedFilter
141              * 
142              * Implement an action of filtering while typing
143              * filter what correspond to the user choice
144              * 
145             $(function() {
146                 var availableTags = ['omf','nitos','ple', s.nodelabel];
147             $( "#search" ).autocomplete({
148               source: availableTags
149                 });
150             });
151              */
152
153             this.init_axisx('');
154             this.draw();
155
156         }, /* init */
157
158         /* Default settings */
159         default_options: {
160             leases_offset:       0,
161             leases_slots:        36,
162             leases_w:            180,
163             leases_granularity:  3600,
164
165             x_nodelabel:         200,   /* space for the nodenames */
166             x_sep:               20,    /* right space after the nodename - removed from the above */
167             y_header:            12,    /* height for the (two) rows of timelabels */
168             y_sep:               10,    /* space between nodes */
169             leases_w:            20,    /* 1-grain leases attributes */
170             y_node:              15,
171             radius:              6,
172             anim_delay:          350,
173             checkboxes:          false,
174             resource_query_uuid: null,  /* resources */
175             lease_query_uuid:    null,  /* leases */
176         },
177
178         /* PLUGIN EVENTS */
179
180         /* GUI EVENTS */
181
182         /* GUI MANIPULATION */
183
184         /* TEMPLATES */
185
186         /*************************** RECORD HANDLER ***************************/
187
188         /* ------------------------------------------------------------------
189          * Resources
190          * ------------------------------------------------------------------ */
191
192         on_new_record: function(record)
193         {
194             if ((typeof record.exclusive != 'undefined') && (record.exclusive)) {
195                 this.resources.push(Array(record.urn, record.record_hrn, record.type));
196             }
197             // ... if we do not have information about slivers (first update), update it
198             if (typeof record.sliver != 'undefined') {
199                 // XXX
200             }
201         },
202
203         on_query_in_progress: function() {
204             this.spin();
205         },
206
207         on_query_done: function() {
208             /* We have received all leases */
209             if (this._received_resources) {
210                 this.draw(this._canvas_id);
211                 this.unspin();
212             }
213             this._received_leases = true;
214         },
215         /* ------------------------------------------------------------------
216          * Leases
217          * ------------------------------------------------------------------ */
218         
219         on_lease_new_record: function(record)
220         {
221             this.listLeases.push(record);
222             // this.initial_leases=leases;
223         },
224
225         on_lease_query_done: function(record)
226         {
227             /* We have received all resources */
228             if (this._received_leases) {
229                 this.draw(this._canvas_id);
230                 this.unspin();
231             }
232             this._received_resources = true;
233         },
234
235         /* INTERNAL FUNCTIONS */
236
237         /**
238          * @brief Return the number of time slots
239          */
240         nb_grains: function () 
241         {
242             return this.axisx.length; 
243         },
244
245         /**
246          * @brief Returns whether there is a pending lease at this timestamp
247          */
248         find_lease: function(urn, timestamp)
249         {
250             var scheduler = this;
251             var result = null;
252
253             $.each(Array(scheduler.myLeases, scheduler.allLeases), function(i, array) {
254                 $.each(array, function(i, lease) {
255                     if (lease[0] == urn) {
256                         if ((timestamp >= lease[1]) && (timestamp < (lease[1] + lease[2] * 1800))) {
257                             result = lease;
258                             
259                             return false;
260                         }
261                     }
262                 });
263                 if (result)
264                     return false;
265             });
266             return result;
267         },
268
269         /**
270          * @brief Draw
271          */
272         draw: function() 
273         { 
274             var canvas_id = this._canvas_id;
275             var o = this.options;
276             var total_width = o.x_nodelabel + this.nb_grains() * this.options.leases_w;
277             var total_height = 2 * o.y_header /* the timelabels */
278                              + 2 * o.y_sep    /* extra space */
279                              + o.y_node          /* all-nodes & timebuttons row */ 
280                              + (this.resources.length)*(o.y_node+o.y_sep);  /* the regular nodes and preceding space */
281
282             /* reuse for paper if exists with same size, or (re-)create otherwise */
283             var paper;
284             if (this.paper == null) {
285                 paper = Raphael (canvas_id, total_width+o.x_sep, total_height);
286             } else if (this.paper.width==total_width && this.paper.height==total_height) {
287                 paper=this.paper;
288                 paper.clear();
289             } else {
290                 $("#"+canvas_id)[0].innerHTML="";
291                 paper = Raphael (canvas_id, total_width+o.x_sep, total_height);
292             }
293             this.paper=paper;
294
295             /* the path for the triangle-shaped buttons */
296             this.timebutton_path = "M1,0L"+(this.options.leases_w-1)+",0L"+(this.options.leases_w/2)+","+o.y_header+"L1,0";
297
298             var axisx = this.axisx;
299             var axisy = this.resources;
300
301             /* maintain the list of nodelabels for the 'all nodes' button */
302             this.nodelabels=[];
303             
304
305             /* create the time slots legend */
306             var top = 0;
307             var left = o.x_nodelabel;
308
309             var daymarker_height= 2*o.y_header + 2*o.y_sep + (axisy.length+1)*(o.y_node+o.y_sep);
310             var daymarker_path="M0,0L0," + daymarker_height;
311
312             var half_daymarker_off= 2*o.y_header + o.y_sep;
313             var half_daymarker_path="M0," + half_daymarker_off + "L0," + daymarker_height;
314
315             var col=0;
316             for (var i=0, len=axisx.length; i < len; ++i) {
317                 /* pick the printable part */
318                 var timelabel=axisx[i][1];
319                 var y = top + o.y_header;
320                 if (col%2 == 0) y += o.y_header;
321                 col +=1;
322                 /* display time label */
323                 var timelabel=paper.text(left,y,timelabel).attr(txt_timelabel).attr({"text-anchor":"middle"});
324                 /* draw vertical line */
325                 var path_spec="M"+left+" "+(y+o.y_header/2)+"L"+left+" "+this.total_height;
326                 var rule=paper.path(path_spec).attr(attr_rules);
327                 /* show a day marker when relevant */
328                 var timestamp=parseInt(axisx[i][0]);
329                 if ( (timestamp%(24*3600))==0) {
330                     paper.path(daymarker_path).attr({'translation':left+','+top}).attr(attr_daymarker);
331                 } else if ( (timestamp%(12*3600))==0) {
332                     paper.path(half_daymarker_path).attr({'translation':left+','+top}).attr(attr_daymarker);
333                 }
334                 left += this.options.leases_w;
335             }
336
337             ////////// the row with the timeslot buttons (the one labeled 'All nodes')
338             this.granularity= this.min_granularity; // XXX axisx[1][0]-axisx[0][0];
339
340             // move two lines down
341             top += 2*o.y_header + 2*o.y_sep;
342             left=o.x_nodelabel;
343             // all nodes buttons
344             var allnodes = paper.text (o.x_nodelabel-o.x_sep,top+o.y_node/2,"All nodes").attr(txt_allnodes)
345                 .attr ({"font-size":o.y_node, "text-anchor":"end","baseline":"bottom"});
346             allnodes.scheduler=this;
347             allnodes.click(this.allnodes_methods.click);
348             
349             // timeslot buttons [it's the triangles above the slots]
350             for (var i=0, len=axisx.length; i < len; ++i) {
351                 var timebutton=paper.path(this.timebutton_path).attr({'translation':left+','+top}).attr(attr_timebutton);
352                 timebutton.from_time=axisx[i][0];
353                 timebutton.scheduler=this;
354                 timebutton.click(this.timebutton_methods.click);
355                 left+=(this.options.leases_w);
356             }
357             
358             //////// the body of the scheduler : loop on nodes
359             top += o.y_node + o.y_sep;
360             var data_index=0;
361             this.leases=[];
362             for (var i=0, len=axisy.length; i<len; ++i) {
363                 var urn=axisy[i][0];
364                 var nodename=axisy[i][1];
365                 var type=axisy[i][2];
366                 left=0;            
367                 /*
368                  *  MODIFIED font-size
369                 var nodelabel = paper.text(o.x_nodelabel-x_sep,top+y_node/2,nodename).attr(txt_nodelabel)
370                 .attr ({"font-size":y_node, "text-anchor":"end","baseline":"bottom"});
371                 */
372                 var nodelabel = paper.text(o.x_nodelabel-o.x_sep,top+o.y_node/3,nodename).attr(txt_nodelabel)
373                 .attr ({"font-size":"12px", "text-anchor":"end","baseline":"bottom"});    
374                 //console.log(nodelabel);
375                 this.nodelabel_methods.selected(nodelabel,1);
376                 //nodelabel_methods.selected( this, ! this.selected );
377                 nodelabel.click(this.nodelabel_methods.click); //click action works here
378                 //timebutton.click(timebutton_methods.click);
379                 
380                // lease_methods.init_free(nodelabel.click, lease_methods.click_mine);
381                //lease_methods.init_free(nodelabel.lease);
382                 this.nodelabels.push(nodelabel);
383                 
384                 left += o.x_nodelabel;
385                 var grain=0;
386                 // data index contains the full array of leases
387                 // not the same amount of grains per node
388
389                 // NOTE: remembering the previous lease might help for long leases.
390                 while (grain < this.nb_grains()) {
391
392                     if (l = this.find_lease(urn, this.initial_timestamp + grain * 1800)) {
393                         slicename = l.slice_id;
394                     } else {
395                         slicename = "";
396                     }
397
398                     //lease_id  = this.data[data_index][0];
399                     //slicename = this.data[data_index][1];
400                     /* Duration should not be the lease duration, but the grain */
401                     var duration = 1; // this.data[data_index][2];
402
403                     var lease=paper.rect (left,top,this.options.leases_w*duration,o.y_node,o.radius);
404                     // record scheduler in lease - early as we need this in init_other
405                     lease.scheduler=this;
406                     //lease.lease_id=lease_id;
407                     lease.nodename=nodename;
408                     lease.urn=urn;
409                     lease.nodelabel=nodelabel;
410                     if (slicename == "") {
411                         lease.initial="free";
412                         lease_methods.init_free(lease);
413                     } else if (slicename == this.options.slicename) {
414                         lease.initial="mine";
415                         lease_methods.init_mine(lease);
416                     } else {
417                         lease.initial="other";
418                         lease_methods.init_other(lease,slicename);
419                     }
420                     lease.from_time = axisx[grain%this.nb_grains()][0];
421                     grain += duration;
422                     lease.until_time = axisx[grain%this.nb_grains()][0];
423                     // and vice versa
424                     this.leases.push(lease);
425                     // move on with the loop
426                     left += this.options.leases_w*duration;
427                     data_index +=1;
428                 }
429                 top += o.y_node + o.y_sep;
430             };
431         }, /* draw */
432
433         init_axisx: function(currentDate) 
434         {
435             this.axisx = Array();
436     
437             if(currentDate=="") {
438                 // creating timestamp of the current time
439                 currentDate = new Date().getTime() / 1000;
440             }
441             this.initial_timestamp = currentDate;
442             //console.log(currentDate);
443     
444             // round it by granularity (becomes an Int)
445             var rounded = Math.round(currentDate/this.min_granularity)*this.min_granularity;
446             // Convert Int to Date
447             rounded = new Date(rounded*1000);
448             // get hours and minutes in a 24h format 00:00
449             var roundedHours=(rounded.getHours()<10?'0':'') + rounded.getHours();
450             var roundedMinutes=(rounded.getMinutes()<10?'0':'') + rounded.getMinutes();
451     
452             //timeFrame.push(rounded);
453             this.axisx.push(Array(rounded, roundedHours+":"+roundedMinutes));
454     
455             // Generate as man slots as we need
456             for(i=0; i<this.options.leases_slots;i++) {
457                 rounded = this.min_granularity+(rounded.getTime()/1000);
458                 rounded = new Date(rounded*1000);
459                 roundedHours=(rounded.getHours()<10?'0':'') + rounded.getHours();
460                 roundedMinutes=(rounded.getMinutes()<10?'0':'') + rounded.getMinutes();
461     
462                 //timeFrame.push(rounded);
463                 this.axisx.push(Array(rounded, roundedHours+":"+roundedMinutes));
464             }
465         },
466
467         clear: function ()
468         {
469             for (var i=0, len=this.leases.length; i<len; ++i) {
470                 var lease=this.leases[i];
471                 if (lease.current != lease.initial) {
472                 if (lease.initial == 'free') lease_methods.init_free(lease,lease_methods.click_mine);
473                 else                             lease_methods.init_mine(lease,lease_methods.click_free);
474                 }
475             }
476         },
477
478         // XXX Couldn't find how to inhererit from the raphael objects...
479
480         /* ---------------------------------------------------------------------
481          * The 'all nodes' button
482          */
483         allnodes_methods: {
484             click: function (event) {
485                 var scheduler=this.scheduler;
486                 /* decide what to do */
487                 var unselected=0;
488                 for (var i=0, len=scheduler.nodelabels.length; i<len; ++i) 
489                     if (! scheduler.nodelabels[i].selected) unselected++;
490                 /* if at least one is not selected : select all */
491                 var new_state = (unselected >0) ? 1 : 0;
492                 for (var i=0, len=scheduler.nodelabels.length; i<len; ++i) 
493                     this.nodelabel_methods.selected(scheduler.nodelabels[i],new_state);
494             }
495         },
496
497         /* ---------------------------------------------------------------------
498          * The buttons for managing the whole timeslot
499          */
500         timebutton_methods: {
501
502             /* clicking */
503             click: function (event) {
504                 var scheduler = this.scheduler;
505                 var from_time = this.from_time;
506                 var until_time = from_time + scheduler.granularity;
507                 /* scan leases on selected nodes, store in two arrays */
508                 var relevant_free=[], relevant_mine=[];
509                 for (var i=0,len=scheduler.leases.length; i<len; ++i) {
510                     var scan=scheduler.leases[i];
511                     if ( ! scan.nodelabel.selected) continue;
512                     // overlap ?
513                     if (scan.from_time<=from_time && scan.until_time>=until_time) {
514                     if (scan.current == "free")       relevant_free.push(scan);
515                     else if (scan.current == "mine")  relevant_mine.push(scan);
516                     }
517                 }
518                 // window.console.log("Found " + relevant_free.length + " free and " + relevant_mine.length + " mine");
519                 /* decide what to do, whether book or release */
520                 if (relevant_mine.length==0 && relevant_free.length==0) {
521                     alert ("Nothing to do in this timeslot on the selected nodes");
522                     return;
523                 }
524                 // if at least one is free, let's book
525                 if (relevant_free.length > 0) {
526                     for (var i=0, len=relevant_free.length; i<len; ++i) {
527                         var lease=relevant_free[i];
528                         lease_methods.init_mine(lease,lease_methods.click_free);
529                     }
530                 // otherwise we unselect
531                 } else {
532                     for (var i=0, len=relevant_mine.length; i<len; ++i) {
533                         var lease=relevant_mine[i];
534                         lease_methods.init_free(lease,lease_methods.click_mine);
535                     }
536                 }
537             } /* click */
538         }, 
539
540         /* ---------------------------------------------------------------------
541          * The nodelabel buttons
542          */
543         nodelabel_methods: {
544             
545             // set selected mode and render visually
546             selected: function (nodelabel, flag) {
547                 nodelabel.selected=flag;
548                 nodelabel.attr({'font-weight': (flag ? 'bold' : 'normal')});
549                 // TODO
550                 // 
551                 // loop on axis x and select each timebutton
552                 // for (var i=0, len=axisx.length; i < len; ++i)
553                 // figure out how to use timebutton_methods.click();
554                     
555             },
556
557             // toggle selected
558             click: function (event) {
559                 nodelabel_methods.selected( this, ! this.selected );
560             }
561         },
562
563
564         /* ---------------------------------------------------------------------
565          * The lease buttons
566          */
567         lease_methods: {
568         
569             init_free: function (lease, unclick) {
570                 var o = lease.scheduler.options;
571                 lease.current="free";
572                 // set color
573                 lease.animate((lease.initial=="free") ? attr_lease_free_free : attr_lease_mine_free, o.anim_delay);
574                 // keep track of the current status
575                 // record action
576                 lease.click (lease_methods.click_free);
577                 if (unclick) lease.unclick(unclick);
578             },
579                      
580             // find out all the currently free leases that overlap this one
581             click_free: function (event) {
582                 var scheduler = this.scheduler;
583                 lease_methods.init_mine(this,lease_methods.click_free);        
584                 //publish
585                 //this.from_time
586                 //this.urn
587                 //this.until_time
588                 var urn = this.urn
589                 var start_time=new Date(this.from_time).getTime() / 1000;        
590                 var end_time=new Date(this.until_time).getTime() / 1000;
591                 var duration=(end_time-start_time)/1800; // XXX HARDCODED LEASE GRAIN
592
593                 /* Add a new lease : XXX should be replaced by a dictionary */
594                 // Do we have a lease with the same urn  just before or just after ?
595                 var removeIdBefore = null;
596                 var removeIdAfter = null;
597                 jQuery.each(scheduler.listLeases, function(i, lease) {
598                     if (lease[0] == urn) {
599                         if (lease[1] + lease[2] * 1800 == start_time) { // XXX HARDCODED LEASE GRAIN
600                             // Merge with previous lease
601                             removeIdBefore = i;
602                             start_time = lease[1];
603                             duration += lease[2];
604                         }
605                         if (lease[1] == end_time) {
606                             // Merge with following lease
607                             removeIdAfter = i;
608                             duration += lease[2];
609                         }
610                     }
611                 });
612                 if (removeIdBefore != null) {
613                     scheduler.listLeases.splice(removeIdBefore , 1);
614                     if (removeIdAfter != null)
615                         removeIdAfter -= 1;
616                 }
617                 if (removeIdAfter != null) {
618                     scheduler.listLeases.splice(removeIdAfter , 1);
619                 }
620
621                 scheduler.listLeases.push([this.urn, start_time, duration]);
622
623                 console.log(scheduler.listLeases);
624                 //jQuery.publish('/update-set/' + scheduler.options.query_uuid, [scheduler.listLeases]);
625                 jQuery.publish('/update-set/' + scheduler.options.lease_query_uuid, [scheduler.listLeases]);
626             },
627
628             init_mine: function (lease, unclick) {
629                 var o = lease.scheduler.options;
630                 lease.current="mine";
631                 lease.animate((lease.initial=="mine") ? attr_lease_mine_mine : attr_lease_free_mine,o.anim_delay);
632                 lease.click (lease_methods.click_mine);
633                 if (unclick) lease.unclick(unclick);
634             },
635             
636             /* TODO: remove selected lease from array listLeases and publish change */
637             click_mine: function (event) {
638                 var scheduler = this.scheduler;
639                 // this lease was originally free but is now marked for booking
640                 // we free just this lease
641                 //console.log('this is mine');
642                 lease_methods.init_free(this, lease_methods.click_mine);
643             },
644
645
646             init_other: function (lease, slicename) {
647                 lease.animate (attr_lease_other,anim_delay);
648                 /* a text obj to display the name of the slice that owns that lease */
649                 var otherslicelabel = lease.scheduler.paper.text (lease.attr("x")+lease.attr("width")/2,
650                                           // xxx
651                                           lease.attr("y")+lease.attr("height")/2,slicename).attr(txt_otherslice);
652                 /* hide it right away */
653                 otherslicelabel.hide();
654                 /* record it */
655                 lease.label=otherslicelabel;
656                 lease.hover ( function (e) {this.label.toFront();this.label.show();},
657                           function (e) {this.label.hide();} ); 
658             }
659         }
660
661     });
662
663     $.plugin('Scheduler', Scheduler);
664
665 })(jQuery);