-This feature is still experimental; feedback is appreciated at <a href="mailto:devel@planet-lab.org">devel@planet-lab.org</a>
-</td><td valign=top><span onClick=closeMessage('reservable')><img class='reset' src="/planetlab/icons/clear.png" alt="hide message"></span>
-</td></tr></table>
-</div>
-EOF;
-}
-
- // get settings from environment, otherwise set to defaults
- // when to start, in hours in the future from now
- $leases_offset=$_GET['leases_offset'];
- if ( ! $leases_offset ) $leases_offset=0;
- // how many timeslots to show
- $leases_slots=$_GET['leases_slots'];
- if ( ! $leases_slots ) $leases_slots = 48;
- // offset in hours (in the future) from now
- $leases_w = $_GET['leases_w'];
- if ( ! $leases_w) $leases_w=14;
- // number of timeslots to display
-
- $granularity=$api->GetLeaseGranularity();
-
- // these elements are for passing data to the javascript layer
- echo "<span class='hidden' id='leases_slicename'>" . $slice['name'] . "</span>";
- echo "<span class='hidden' id='leases_slice_id'>" . $slice['slice_id']. "</span>";
- echo "<span class='hidden' id='leases_granularity'>" . $granularity . "</span>";
- // ditto, and editable - very rough for now
- echo "<div class='center' id='leases_settings'>";
- echo "<label id='leases_offset_label' class='leases_label'>start, in hours from now</label>";
- echo "<input type='text' class='leases_input' id='leases_offset_input' value='$leases_offset' />";
- echo "<label id='leases_slots_label' class='leases_label'># of timeslots</label>";
- echo "<input type='text' class='leases_input' id='leases_slots_input' value='$leases_slots' />";
- echo "<label id='leases_w_label' class='leases_label'>slot width, in pixels</label>";
- echo "<input type='text' class='leases_input' id='leases_w_input' value='$leases_w' />";
- echo "</div>";
-
- // leases_data is the name used by leases.js to locate this place
- // first population will be triggered by init_scheduler from leases.js
- echo "<table id='leases_data' class='hidden'></table>";
-
- // the general layout for the scheduler
- echo <<< EOF
+This feature is still experimental; feedback is appreciated at <a href='mailto:devel@planet-lab.org'>devel@planet-lab.org</a>
+";
+$count = count($reservable_nodes);
+if ($count && $privileges) {
+ // include leases.js only if needed
+ drupal_set_html_head('<script src="/planetlab/slices/leases.js" type="text/javascript" charset="utf-8"></script>');
+
+ // having reservable nodes in white lists looks a bit off scope for now...
+ $toggle_nodes = new PlekitToggle('my-slice-nodes-reserve',
+ "Leases - " . count($reservable_nodes) . " reservable node(s)",
+ array('visible' => get_arg('show_nodes_resa'),
+ 'info-text' => $leases_info,
+ 'info-visible' => $show_reservable_info));
+ $toggle_nodes->start();
+
+ // get settings from environment, otherwise set to defaults
+ // when to start, in hours in the future from now
+ $leases_offset = get_array($_GET, 'leases_offset');
+ if (!$leases_offset) {
+ $leases_offset = 0;
+ }
+
+ // how many timeslots to show
+ $leases_slots = get_array($_GET, 'leases_slots');
+ if (!$leases_slots) {
+ $leases_slots = 36;
+ }
+
+ // offset in hours (in the future) from now
+ $leases_w = get_array($_GET, 'leases_w');
+ if (!$leases_w) {
+ $leases_w = 18;
+ }
+
+ // number of timeslots to display
+
+ $granularity = $api->GetLeaseGranularity();
+
+ // these elements are for passing data to the javascript layer
+ echo "<span class='hidden' id='leases_slicename'>" . $slice['name'] . "</span>";
+ echo "<span class='hidden' id='leases_slice_id'>" . $slice['slice_id'] . "</span>";
+ echo "<span class='hidden' id='leases_granularity'>" . $granularity . "</span>";
+ // ditto, and editable - very rough for now
+ echo "<div class='center' id='leases_settings'>";
+ echo "<label id='leases_offset_label' class='leases_label'>start, in hours from now</label>";
+ echo "<input type='text' class='leases_input' id='leases_offset_input' value='$leases_offset' />";
+ echo "<label id='leases_slots_label' class='leases_label'># of timeslots</label>";
+ echo "<input type='text' class='leases_input' id='leases_slots_input' value='$leases_slots' />";
+ echo "<label id='leases_w_label' class='leases_label'>slot width, in pixels</label>";
+ echo "<input type='text' class='leases_input' id='leases_w_input' value='$leases_w' />";
+ echo "</div>";
+
+ // leases_data is the name used by leases.js to locate this place
+ // first population will be triggered by init_scheduler from leases.js
+ echo "<table id='leases_data' class='hidden'></table>";
+
+ // the general layout for the scheduler
+ echo <<< EOF