Revision: 2089
          http://mrbs.svn.sourceforge.net/mrbs/?rev=2089&view=rev
Author:   cimorrison
Date:     2011-10-14 11:00:37 +0000 (Fri, 14 Oct 2011)
Log Message:
-----------
Added data attributes to row and column label cells in the day and week views

Modified Paths:
--------------
    mrbs/branches/draggable_bookings/web/day.php
    mrbs/branches/draggable_bookings/web/functions.inc
    mrbs/branches/draggable_bookings/web/week.php

Modified: mrbs/branches/draggable_bookings/web/day.php
===================================================================
--- mrbs/branches/draggable_bookings/web/day.php        2011-10-14 09:01:30 UTC 
(rev 2088)
+++ mrbs/branches/draggable_bookings/web/day.php        2011-10-14 11:00:37 UTC 
(rev 2089)
@@ -254,12 +254,16 @@
     $column_width = (int)(95 / $n_slots);
     $header .= "<th class=\"first_last\">" . get_vocab("room") . ":</th>";
     for (
-         $t = mktime($morningstarts, $morningstarts_minutes, 0, $month, 
$day+$j, $year);
+         $t = mktime($morningstarts, $morningstarts_minutes, 0, $month, 
$day+$j, $year),
+           $slot_seconds = $start_first_slot * 60;
          $t <= mktime($eveningends, $eveningends_minutes, 0, $month, $day+$j, 
$year);
-         $t += $resolution
+         $t += $resolution,
+           $slot_seconds += $resolution
         )
     {
-      $header .= "<th style=\"width: $column_width%\">";
+      // Put the number of seconds since the start of the day (nominal, 
ignoring DST)
+      // in a data attribure so that JavaScript can pick it up
+      $header .= "<th data-seconds=\"$slot_seconds\" style=\"width: 
$column_width%\">";
       if ( $enable_periods )
       {
         // convert timestamps to HHMM format without leading zeros
@@ -289,7 +293,8 @@
     $column_width = (int)(95 / sql_count($res));
     for ($i = 0; ($row = sql_row_keyed($res, $i)); $i++)
     {
-      $header .= "<th style=\"width: $column_width%\">
+      // Put the room_id in a data attrribute so that JavaScript can pick it up
+      $header .= "<th data-room=\"" . $row['id'] . "\" style=\"width: 
$column_width%\">
                   <a 
href=\"week.php?year=$year&amp;month=$month&amp;day=$day&amp;area=$area&amp;room=".$row['id']."\"
                   title=\"" . get_vocab("viewweek") . " 
&#10;&#10;".$row['description']."\">" .
                   htmlspecialchars($row['room_name']) . ($row['capacity'] > 0 
? "(".$row['capacity'].")" : "") . "</a></th>";
@@ -383,9 +388,12 @@
   {
     // the standard view, with rooms along the top and times down the side
     for (
-         $t = mktime($morningstarts, $morningstarts_minutes, 0, $month, 
$day+$j, $year);
+         $t = mktime($morningstarts, $morningstarts_minutes, 0, $month, 
$day+$j, $year),
+           $slot_seconds = (($morningstarts * 60) + $morningstarts_minutes) * 
60;
          $t <= mktime($eveningends, $eveningends_minutes, 0, $month, $day+$j, 
$year);
-         $t += $resolution, $row_class = ($row_class == 
"even_row")?"odd_row":"even_row"
+         $t += $resolution,
+           $slot_seconds += $resolution,
+           $row_class = ($row_class == "even_row") ? "odd_row" : "even_row"
         )
     {
       // convert timestamps to HHMM format without leading zeros
@@ -409,7 +417,7 @@
         $url = $base_url . "&amp;timetohighlight=$time_t";
       }
       echo "<tr class=\"$class\">\n";
-      draw_time_cell($t, $time_t, $time_t_stripped, $url);
+      draw_time_cell($t, $time_t, $time_t_stripped, $slot_seconds, $url);
   
       // Loop through the list of rooms we have for this area
       while (list($key, $room_id) = each($rooms))
@@ -430,7 +438,7 @@
       // next lines to display times on right side
       if ( FALSE != $row_labels_both_sides )
       {
-        draw_time_cell($t, $time_t, $time_t_stripped, $url);
+        draw_time_cell($t, $time_t, $time_t_stripped, $slot_seconds, $url);
       }
   
       echo "</tr>\n";

Modified: mrbs/branches/draggable_bookings/web/functions.inc
===================================================================
--- mrbs/branches/draggable_bookings/web/functions.inc  2011-10-14 09:01:30 UTC 
(rev 2088)
+++ mrbs/branches/draggable_bookings/web/functions.inc  2011-10-14 11:00:37 UTC 
(rev 2089)
@@ -945,15 +945,29 @@
 // $colclass is an entry type (A-J), zebra stripes if
 // empty or row_highlight if highlighted.
 // $slots is the number of time slots high that the cell should be
+//
+// $data is an optional third parameter which if set passes the data name and 
value
+// for use in the data- attribute.  It is an associative array with two 
elements,
+// data['name'] and data['value'].
 function tdcell($colclass, $slots)
 {
   global $times_along_top;
+  
+  if (func_num_args() > 2)
+  {
+    $data = func_get_arg(2);
+  }
+  
   echo "<td class=\"$colclass\"";
   if ($slots > 1)
   // No need to output more HTML than necessary
   {
     echo " " . (($times_along_top) ? "colspan" : "rowspan") . "=\"$slots\"";
   }
+  if (isset($data))
+  {
+    echo " data-" . $data['name'] . "=\"" . $data['value'] . "\"";
+  }
   echo ">\n";
 }
 
@@ -1809,12 +1823,13 @@
 //    $t                 the timestamp for the start of the slot
 //    $time_t            the time converted to HHMM format without leading 
zeros
 //    $time_t_stripped   a stripped version of the time for use with periods
+//    $slot_seconds      the number of seconds since the start of the day 
(nominal - not adjusted for DST)
 //    $url               the url to form the basis of the link in the time cell
-function draw_time_cell($t, $time_t, $time_t_stripped, $url)
+function draw_time_cell($t, $time_t, $time_t_stripped, $slot_seconds, $url)
 {
   global $enable_periods, $periods;
   
-  tdcell("row_labels", 1);
+  tdcell("row_labels", 1, array('name' => 'seconds', 'value' => 
$slot_seconds));
   echo "<div class=\"celldiv slots1\">\n";
   if ( $enable_periods )
   {
@@ -1837,7 +1852,7 @@
 //    $link    the href to be used for the link
 function draw_room_cell($row, $link)
 {
-  tdcell("row_labels", 1);
+  tdcell("row_labels", 1, array('name' => 'room', 'value' => $row['id']));
   echo "<div class=\"celldiv slots1\">\n";
   echo "<a href=\"$link\" title=\"" . get_vocab("viewweek") . " &#10;&#10;" . 
$row['description'] . "\">";
   echo htmlspecialchars($row['room_name']) . ($row['capacity'] > 0 ? 
"(".$row['capacity'].")" : "");
@@ -1848,9 +1863,10 @@
 // Draw a day cell to be used in the first and last columns of the week view
 //    $text    contains the date, formatted as a string
 //    $link    the href to be used for the link
-function draw_day_cell($text, $link)
+//    $t       the time stamp
+function draw_day_cell($text, $link, $t)
 {
-  tdcell("row_labels", 1);
+  tdcell("row_labels", 1, array('name' => 'time', 'value' => $t));
   echo "<div class=\"celldiv slots1\">\n";
   echo "<a href=\"$link\" title=\"" . get_vocab("viewday") . "\">$text</a>\n";
   echo "</div></td>\n";

Modified: mrbs/branches/draggable_bookings/web/week.php
===================================================================
--- mrbs/branches/draggable_bookings/web/week.php       2011-10-14 09:01:30 UTC 
(rev 2088)
+++ mrbs/branches/draggable_bookings/web/week.php       2011-10-14 11:00:37 UTC 
(rev 2089)
@@ -237,12 +237,16 @@
   $column_width = (int)(95 / $n_slots);
   $header .= "<th class=\"first_last\">" . get_vocab("date") . ":</th>";
   for (
-       $t = mktime($morningstarts, $morningstarts_minutes, 0, $month, 
$day_start_week+$j, $year);
+       $t = mktime($morningstarts, $morningstarts_minutes, 0, $month, 
$day_start_week+$j, $year),
+         $slot_seconds = $start_first_slot * 60;
        $t <= mktime($eveningends, $eveningends_minutes, 0, $month, 
$day_start_week+$j, $year);
-       $t += $resolution
+       $t += $resolution,
+         $slot_seconds += $resolution
       )
   {
-    $header .= "<th style=\"width: $column_width%\">";
+    // Put the seconds since the start of the day (nominal, not adjusted for 
DST)
+    // into a data attribute so that it can be picked up by JavaScript
+    $header .= "<th data-seconds=\"$slot_seconds\" style=\"width: 
$column_width%\">";
     if ( $enable_periods )
     {
       // convert timestamps to HHMM format without leading zeros
@@ -280,8 +284,9 @@
     }
   
     else  
-    {  
-      $header .= "<th><a href=\"day.php?year=" . strftime("%Y", $t) . 
+    {
+      // Put the timestamp into a data attribute so that it can be picked up 
by JavaScript
+      $header .= "<th data-time=\"$t\"><a href=\"day.php?year=" . 
strftime("%Y", $t) . 
                  "&amp;month=" . strftime("%m", $t) . "&amp;day=" . 
strftime("%d", $t) . 
                  "&amp;area=$area\" title=\"" . get_vocab("viewday") . "\">" .
                  utf8_strftime($dformat, $t) . "</a></th>\n";
@@ -348,7 +353,7 @@
                        "&amp;day=" . strftime("%d", $wt) . 
                        "&amp;area=$area";
                        
-      draw_day_cell($day_cell_text, $day_cell_link);
+      draw_day_cell($day_cell_text, $day_cell_link, $wt);
       for (
            $t = mktime($morningstarts, $morningstarts_minutes, 0, $month, 
$day_start_week+$j, $year);
            $t <= mktime($eveningends, $eveningends_minutes, 0, $month, 
$day_start_week+$j, $year);
@@ -379,7 +384,7 @@
       }  // end looping through the time slots
       if ( FALSE != $row_labels_both_sides )
       {
-        draw_day_cell($day_cell_text, $day_cell_link);
+        draw_day_cell($day_cell_text, $day_cell_link, $wt);
       }
       echo "</tr>\n";
     }
@@ -392,9 +397,12 @@
 {
   // the standard view, with days of the week along the top and times down the 
side
   for (
-       $t = mktime($morningstarts, $morningstarts_minutes, 0, $month, 
$day_start_week+$j, $year);
+       $t = mktime($morningstarts, $morningstarts_minutes, 0, $month, 
$day_start_week+$j, $year),
+         $slot_seconds = (($morningstarts * 60) + $morningstarts_minutes) * 60;
        $t <= mktime($eveningends, $eveningends_minutes, 0, $month, 
$day_start_week+$j, $year);
-       $t += $resolution, $row_class = ($row_class == 
"even_row")?"odd_row":"even_row"
+       $t += $resolution,
+         $slot_seconds += $resolution,
+         $row_class = ($row_class == "even_row") ? "odd_row" : "even_row"
   )
   {
     // use hour:minute format
@@ -418,7 +426,7 @@
       $url = $base_url . "&amp;timetohighlight=$time_t";
     }
     echo "<tr class=\"$class\">";
-    draw_time_cell($t, $time_t, $time_t_stripped, $url);
+    draw_time_cell($t, $time_t, $time_t_stripped, $slot_seconds, $url);
   
   
     // See note above: weekday==0 is day $weekstarts, not necessarily Sunday.
@@ -455,7 +463,7 @@
     // next lines to display times on right side
     if ( FALSE != $row_labels_both_sides )
       {
-        draw_time_cell($t, $time_t, $time_t_stripped, $url);
+        draw_time_cell($t, $time_t, $time_t_stripped, $slot_seconds, $url);
       }
   
     echo "</tr>\n";

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to