4 <script type="text/javascript" src="/planetlab/tablesort/tablesort.js"></script>
5 <script type="text/javascript" src="/planetlab/tablesort/customsort.js"></script>
6 <script type="text/javascript" src="/planetlab/tablesort/paginate.js"></script>
7 <script type="text/javascript" src="/planetlab/js/plc_tables.js"></script>
8 <link href="/planetlab/css/plc_tables.css" rel="stylesheet" type="text/css" />
12 ////////////////////////////////////////
13 function plc_table_cell($cell) {
14 printf ('<td class="plc_table"> %s </td>',$cell);
17 ////////////////////////////////////////
18 // table_id: <table>'s id tag
19 // headers: an associative array "label"=>"type"
20 // column_sort: the column to sort on at load-time
21 // options : an associative array to override options (should be passed to both _stsart and _end)
22 // - search_area : boolean (default true)
23 // - notes_area : boolean (default true)
24 // - notes : an array of additional notes
25 // - pagesize: the initial pagination size
26 // - pagesize_def: the page size when one clicks the pagesize reset button
27 // - max_pages: the max number of pages to display in the paginator
28 function plc_table_start ($table_id, $headers, $column_sort, $options) {
29 $search_area = array_key_exists('search_area',$options) ? $options['search_area'] : true;
30 $max_pages = array_key_exists('max_pages',$options) ? $options['max_pages'] : 10;
31 $pagesize = array_key_exists('pagesize',$options) ? $options['pagesize'] : 25;
32 $pagesize_def = array_key_exists('pagesize_def',$options) ? $options['pagesize_def'] : 999;
35 plc_table_search_area($table_id,$pagesize,$pagesize_def);
36 plc_table_head($table_id,$headers,$column_sort,$max_pages,$pagesize);
39 function plc_table_end ($options) {
41 $notes_area = array_key_exists('notes_area',$options) ? $options['notes_area'] : true;
43 plc_table_notes($options);
47 function plc_table_search_area ($table_id,$pagesize,$pagesize_def) {
48 $pagesize_text_id = $table_id . "_pagesize";
49 $search_text_id = $table_id . "_search";
50 $search_reset_id = $table_id . "_search_reset";
51 $search_and_id = $table_id . "_search_and";
53 <table class='table_dialogs'> <tr>
54 <td class='table_flushleft'>
55 <form class='pagesize'>
56 <input class='pagesize_input' type='text' id="$pagesize_text_id" value=$pagesize
57 onkeyup='plc_pagesize_set("$table_id","$pagesize_text_id", $pagesize);'
59 <label class='pagesize_label'> items/page </label>
60 <img class='table_reset' src="/planetlab/icons/clear.png"
61 onmousedown='plc_pagesize_reset("$table_id","$pagesize_text_id",$pagesize_def);'>
65 <td class='table_flushright'>
66 <form class='table_search'>
67 <label class='table_search_label'> Search </label>
68 <input class='table_search_input' type='text' id='$search_text_id'
69 onkeyup='plc_table_filter("$table_id","$search_text_id","$search_and_id");'
70 size=40 maxlength=256 />
72 <input id='$search_and_id' class='table_search_and'
73 type='checkbox' checked='checked'
74 onchange='plc_table_filter("$table_id","$search_text_id","$search_and_id");' />
75 <img class='table_reset' src="/planetlab/icons/clear.png"
76 onmousedown='plc_table_filter_reset("$table_id","$search_text_id","$search_and_id");'>
83 ////////////////////////////////////////
84 function plc_table_head ($table_id,$headers,$column_sort,$max_pages,$pagesize) {
85 $paginator=$table_id."_paginator";
86 $classname="paginationcallback-".$paginator;
87 $classname.=" max-pages-" . $max_pages;
88 $classname.=" paginate-" . $pagesize;
90 <!-- instantiate paginator callback -->
91 <script type="text/javascript">
92 function $paginator (opts) { plc_table_paginator (opts,"$table_id"); }
95 <table id="$table_id" cellpadding="0" cellspacing="0" border="0"
96 class="plc_table sortable-onload-$column_sort rowstyle-alt colstyle-alt no-arrow $classname">
101 foreach ($headers as $label => $type) {
102 if ($type == "none" ) {
105 if ($type == "string") $type="";
106 if ($type == "int") $type="";
107 if ($type == "float") $type="";
109 if ( ! empty($type)) $class .= "-sort" . $type;
111 printf ('<th class="%s plc_table">%s</th>',$class,$label);
121 ////////////////////////////////////////
122 function plc_table_foot () {
131 ////////////////////////////////////////
132 function plc_table_notes ($options) {
134 <p class='plc_filter_note'>
135 Notes: Enter & or | in the search area to alternate between <bold>AND</bold> and <bold>OR</bold> search modes
137 Hold down the shift key to select multiple columns to sort
139 if (array_key_exists('notes',$options)) {
140 foreach ($options['notes'] as $line) {
141 print "<br/>" . $line . "\n";
147 ////////////////////////////////////////
148 function plc_table_title ($text) {
149 print "<h2> $text </h2>\n";
152 function plc_table_row_start ($id="") {
154 printf ('<tr id="%s">',$id);
159 function plc_table_row_end () {