From 066eb7470d86bbcec802f3cf6cbf5b4e4d05a5a3 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Wed, 14 Jan 2009 17:29:10 +0000 Subject: [PATCH] 4ward --- planetlab/css/plc_tables.css | 2 +- planetlab/includes/plc_tables.php | 82 ++++++++++++++++++++++++++++--- planetlab/js/plc_tables.js | 4 +- planetlab/nodes/newindex.php | 66 +++++++------------------ 4 files changed, 96 insertions(+), 58 deletions(-) diff --git a/planetlab/css/plc_tables.css b/planetlab/css/plc_tables.css index f82053c..2f17ed7 100644 --- a/planetlab/css/plc_tables.css +++ b/planetlab/css/plc_tables.css @@ -107,7 +107,7 @@ table.table_dialogs { width:100%; border:1px; } -.table_size_label{ +.pagesize_label{ font-weight:bold; } .table_search_label{ diff --git a/planetlab/includes/plc_tables.php b/planetlab/includes/plc_tables.php index 95e23be..a5f92f3 100644 --- a/planetlab/includes/plc_tables.php +++ b/planetlab/includes/plc_tables.php @@ -1,20 +1,24 @@ 's id tag +// pagesize_init: the initial pagination size +// pagesize_def: the page size when one clisks the pagesize reset button +function plc_table_search_area ($table_id,$pagesize_init,$pagesize_def) { + $pagesize_text_id = $table_id . "_pagesize"; $search_text_id = $table_id . "_search"; $search_reset_id = $table_id . "_search_reset"; $search_and_id = $table_id . "_search_and"; print <<< EOF @@ -35,5 +39,67 @@ function plc_table_header ($table_id,$size_init,$size_def) {
-
- + - + + onmousedown='plc_pagesize_reset("$table_id","$pagesize_text_id",$pagesize_def);'>
EOF; } + +//////////////////////////////////////// +// table_id: 's id tag +// headers: an associative array "label"=>"type" +// pagesize: the initial page +// column_init_sort: the column to sort on at load-time +// max_pages: the max number of pages to display in the paginator +function plc_table_head ($table_id,$headers,$pagesize,$column_init_sort,$max_pages) { + $paginator=$table_id."_paginator"; + $classname="paginationcallback-".$paginator; + $classname.=" max-pages-" . $max_pages; + $classname.=" paginate-" . $pagesize; + print <<< EOF + + +
+
+ + +EOF; + + foreach ($headers as $label => $type) { + if ($type == "string") $type=""; + if ($type == "int") $type=""; + if ($type == "float") $type=""; + $class="sortable"; + if ( ! empty($type)) $class .= "-" . $type; + print '\n"; + } + + print <<< EOF + + + +EOF; +} + +//////////////////////////////////////// +function plc_table_foot () { + print <<< EOF + + + +
' . $label . "
+EOF; +} + +//////////////////////////////////////// +function plc_table_notes () { + print <<< EOF +

+Notes: Enter & or | in the search area to alternate between AND and OR search modes +
+Hold down the shift key to select multiple columns to sort +

+EOF; +} + + ?> diff --git a/planetlab/js/plc_tables.js b/planetlab/js/plc_tables.js index 7226ab4..aecc1a2 100644 --- a/planetlab/js/plc_tables.js +++ b/planetlab/js/plc_tables.js @@ -47,7 +47,7 @@ function plc_table_paginator (opts,tablename) { /* locates a table from its id and alters the classname to reflect new table size */ -function plc_table_setsize (table_id,size_id,def_size) { +function plc_pagesize_set (table_id,size_id,def_size) { var table=document.getElementById(table_id); var size_area=document.getElementById(size_id); if ( ! size_area.value ) { @@ -58,7 +58,7 @@ function plc_table_setsize (table_id,size_id,def_size) { tablePaginater.init(table_id); } -function plc_table_size_reset(table_id, size_id, size) { +function plc_pagesize_reset(table_id, size_id, size) { var table=document.getElementById(table_id); var size_area=document.getElementById(size_id); size_area.value=size; diff --git a/planetlab/nodes/newindex.php b/planetlab/nodes/newindex.php index d19e706..8660e05 100644 --- a/planetlab/nodes/newindex.php +++ b/planetlab/nodes/newindex.php @@ -109,43 +109,21 @@ foreach ($peers as $peer) { $peer_hash[$peer['peer_id']]=$peer; } -?> - - - - - - - -
- - - - - - - - - - - - - - - - - -"string", + "Region"=>"string", + "Site"=>"string", + "State"=>"string", + "Hostname"=>"string", + "IP"=>"IPAddress", + "Load"=>"int", + "Avg Load"=>"float"); + +plc_table_head("nodes",$columns,$pagesize,"4",15); + +// write rows +$fake1=1; $fake2=3.14; $fake_i=0; foreach ($nodes as $node) { $hostname=$node['hostname']; $node_id=$node['node_id']; @@ -176,14 +154,8 @@ foreach ($nodes as $node) { $fake_i += 1; } +plc_table_foot(); + +plc_table_notes(); ?> - - - -
PeerRegionSiteStateHostnameIPLoadAvg Load
- -

-Notes: Enter & or | in the search area to alternate between AND and OR search modes -
-Hold down the shift key to select multiple columns to sort -

+ -- 2.43.0