+++ /dev/null
-/**
- * author: Timothy Groves - http://www.brandspankingnew.net
- * version: 1.0 - 2006-08-04
- *
- * requires: nothing
- *
- */
-
-var useBSNns;
-
-if (useBSNns)
-{
- if (typeof(bsn) == "undefined")
- bsn = {}
- _bsn = bsn;
-}
-else
-{
- _bsn = this;
-}
-
-
-
-
-
-
-
-
-
-_bsn.Ajax = function ()
-{
- this.req = {};
- this.isIE = false;
-}
-
-
-
-_bsn.Ajax.prototype.makeRequest = function (url, meth, onComp, onErr)
-{
-
- if (meth != "POST")
- meth = "GET";
-
- this.onComplete = onComp;
- this.onError = onErr;
-
- var pointer = this;
-
- // branch for native XMLHttpRequest object
- if (window.XMLHttpRequest)
- {
- this.req = new XMLHttpRequest();
- this.req.onreadystatechange = function () { pointer.processReqChange() };
- this.req.open("GET", url, true); //
- this.req.send(null);
- // branch for IE/Windows ActiveX version
- }
- else if (window.ActiveXObject)
- {
- this.req = new ActiveXObject("Microsoft.XMLHTTP");
- if (this.req)
- {
- this.req.onreadystatechange = function () { pointer.processReqChange() };
- this.req.open(meth, url, true);
- this.req.send();
- }
- }
-}
-
-
-_bsn.Ajax.prototype.processReqChange = function()
-{
-
- // only if req shows "loaded"
- if (this.req.readyState == 4) {
- // only if "OK"
- if (this.req.status == 200)
- {
- this.onComplete( this.req );
- } else {
- this.onError( this.req.status );
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-/**
- * author: Timothy Groves - http://www.brandspankingnew.net
- * version: 1.0 - 2006-08-03
- *
- * requires: bsn.DOM.js
- * bsn.Ajax.js
- *
- */
-
-var useBSNns;
-
-if (useBSNns)
-{
- if (typeof(bsn) == "undefined")
- bsn = {}
- _bsn = bsn;
-}
-else
-{
- _bsn = this;
-}
-
-
-if (typeof(_bsn.DOM) == "undefined")
- _bsn.DOM = {}
-
-
-
-
-
-
-
-
-_bsn.AutoSuggest = function (fldID, param)
-{
- if (!document.getElementById)
- return false;
-
- this.fld = _bsn.DOM.getElement(fldID);
-
- if (!this.fld)
- return false;
-
-
- this.nInputChars = 0;
- this.aSuggestions = [];
- this.iHighlighted = 0;
-
-
- // parameters object
- this.oP = (param) ? param : {};
- // defaults
- if (!this.oP.minchars) this.oP.minchars = 1;
- if (!this.oP.method) this.oP.meth = "get";
- if (!this.oP.varname) this.oP.varname = "input";
- if (!this.oP.className) this.oP.className = "autosuggest";
- if (!this.oP.timeout) this.oP.timeout = 2500;
- if (!this.oP.delay) this.oP.delay = 500;
- if (!this.oP.maxheight && this.oP.maxheight !== 0) this.oP.maxheight = 250;
- if (!this.oP.cache) this.oP.cache = true;
-
- var pointer = this;
-
- this.fld.onkeyup = function () { pointer.getSuggestions( this.value ) };
- this.fld.setAttribute("autocomplete","off");
-}
-
-
-
-_bsn.AutoSuggest.prototype.getSuggestions = function (val)
-{
-
- if (val.length == this.nInputChars)
- return false;
-
- if (val.length < this.oP.minchars)
- {
- this.nInputChars = val.length;
- this.aSuggestions = [];
- this.clearSuggestions();
- return false;
- }
-
-
- if (val.length>this.nInputChars && this.aSuggestions.length && this.oP.cache)
- {
- // get from cache
- var arr = [];
- for (var i=0;i<this.aSuggestions.length;i++)
- {
- if (this.aSuggestions[i].substr(0,val.length).toLowerCase() == val.toLowerCase())
- arr.push( this.aSuggestions[i] );
- }
-
- this.nInputChars = val.length;
- this.aSuggestions = arr;
-
-
- this.createList( this.aSuggestions );
-
- return false;
- }
-
-
- this.nInputChars = val.length;
-
- var pointer = this;
- clearTimeout(this.ajID);
- this.ajID = setTimeout( function() { pointer.doAjaxRequest() }, this.oP.delay );
-
-
- return false;
-}
-
-
-
-
-
-_bsn.AutoSuggest.prototype.doAjaxRequest = function ()
-{
- var pointer = this;
-
- // create ajax request
- var url = this.oP.script+this.oP.varname+"="+this.fld.value;
- var meth = this.oP.meth;
-
- var onSuccessFunc = function (req) { pointer.setSuggestions(req) };
- var onErrorFunc = function (status) { alert("AJAX error: "+status); };
-
- var myAjax = new _bsn.Ajax;
- myAjax.makeRequest( url, meth, onSuccessFunc, onErrorFunc );
-}
-
-
-
-
-
-_bsn.AutoSuggest.prototype.setSuggestions = function (req)
-{
-
- var xml = req.responseXML;
-
- // traverse xml
- //
- this.aSuggestions = [];
- var results = xml.getElementsByTagName('results')[0].childNodes;
-
- for (var i=0;i<results.length;i++)
- {
- if (results[i].hasChildNodes())
- this.aSuggestions.push( results[i].childNodes[0].nodeValue );
- }
-
-
- this.idAs = "as_"+this.fld.id;
-
-
- this.createList(this.aSuggestions);
-
-}
-
-
-
-
-
-_bsn.AutoSuggest.prototype.createList = function(arr)
-{
- // clear previous list
- this.clearSuggestions();
-
- // create and populate ul
- var ul = _bsn.DOM.createElement("ul", {id:this.idAs, className:this.oP.className});
-
-
- var pointer = this;
- for (var i=0;i<arr.length;i++)
- {
- var a = _bsn.DOM.createElement("a", { href:"#" }, arr[i]);
- a.onclick = function () { pointer.setValue( this.childNodes[0].nodeValue ); return false; }
- var li = _bsn.DOM.createElement( "li", {className:this.oP.className}, a );
- ul.appendChild( li );
- }
-
- var pos = _bsn.DOM.getPos(this.fld);
-
- ul.style.left = pos.x + "px";
- ul.style.top = ( pos.y + this.fld.offsetHeight ) + "px";
- ul.style.width = this.fld.offsetWidth+"px";
- ul.onmouseover = function(){ pointer.killTimeout() }
- ul.onmouseout = function(){ pointer.resetTimeout() }
-
-
- document.getElementsByTagName("body")[0].appendChild(ul);
-
- if (ul.offsetHeight > this.oP.maxheight && this.oP.maxheight != 0)
- {
- ul.style['height'] = this.oP.maxheight;
- }
-
-
- var TAB = 9;
- var ESC = 27;
- var KEYUP = 38;
- var KEYDN = 40;
- var RETURN = 13;
-
-
-
- this.fld.onkeydown = function(ev)
- {
- var key = (window.event) ? window.event.keyCode : ev.keyCode;
-
- switch(key)
- {
- case TAB:
- pointer.setHighlightedValue();
- break;
-
- case ESC:
- pointer.clearSuggestions();
- break;
-
- case KEYUP:
- pointer.changeHighlight(key);
- return false;
- break;
-
- case KEYDN:
- pointer.changeHighlight(key);
- return false;
- break;
- }
-
- };
-
- this.iHighlighted = 0;
-
-
- // remove autosuggest after an interval
- //
- clearTimeout(this.toID);
- var pointer = this;
- this.toID = setTimeout(function () { pointer.clearSuggestions() }, this.oP.timeout);
-}
-
-
-
-
-
-
-
-
-
-_bsn.AutoSuggest.prototype.changeHighlight = function(key)
-{
- var list = _bsn.DOM.getElement(this.idAs);
- if (!list)
- return false;
-
-
- if (this.iHighlighted > 0)
- list.childNodes[this.iHighlighted-1].className = "";
-
- if (key == 40)
- this.iHighlighted ++;
- else if (key = 38)
- this.iHighlighted --;
-
-
- if (this.iHighlighted > list.childNodes.length)
- this.iHighlighted = list.childNodes.length;
- if (this.iHighlighted < 1)
- this.iHighlighted = 1;
-
- list.childNodes[this.iHighlighted-1].className = "highlight";
-
- //alert( list.childNodes[this.iHighlighted-1].firstChild.firstChild.nodeValue );
-
- this.killTimeout();
-}
-
-
-
-
-
-
-
-
-_bsn.AutoSuggest.prototype.killTimeout = function()
-{
- clearTimeout(this.toID);
-}
-
-_bsn.AutoSuggest.prototype.resetTimeout = function()
-{
- clearTimeout(this.toID);
- var pointer = this;
- this.toID = setTimeout(function () { pointer.clearSuggestions() }, 1000);
-}
-
-
-
-
-
-
-
-_bsn.AutoSuggest.prototype.clearSuggestions = function ()
-{
- if (document.getElementById(this.idAs))
- _bsn.DOM.removeElement(this.idAs);
- this.fld.onkeydown = null;
-}
-
-
-
-
-
-
-
-_bsn.AutoSuggest.prototype.setHighlightedValue = function ()
-{
- if (this.iHighlighted)
- {
- this.fld.value = document.getElementById(this.idAs).childNodes[this.iHighlighted-1].firstChild.firstChild.nodeValue;
- this.killTimeout();
- this.clearSuggestions();
- }
-}
-
-
-
-_bsn.AutoSuggest.prototype.setValue = function (val)
-{
- this.fld.value = val;
- this.resetTimeout();
-}
\ No newline at end of file
+++ /dev/null
-/**
- * author: Timothy Groves - http://www.brandspankingnew.net
- * version: 1.5 - 2006-08-03
- *
- * requires: nothing
- *
- */
-
-var useBSNns;
-
-if (useBSNns)
-{
- if (typeof(bsn) == "undefined")
- bsn = {}
- _bsn = bsn;
-}
-else
-{
- _bsn = this;
-}
-
-
-if (typeof(_bsn.DOM) == "undefined")
- _bsn.DOM = {}
-
-
-
-
-_bsn.DOM.createElement = function ( type, attr, cont, html )
-{
- var ne = document.createElement( type );
- if (!ne)
- return false;
-
- for (var a in attr)
- ne[a] = attr[a];
-
- if (typeof(cont) == "string" && !html)
- ne.appendChild( document.createTextNode(cont) );
- else if (typeof(cont) == "string" && html)
- ne.innerHTML = cont;
- else if (typeof(cont) == "object")
- ne.appendChild( cont );
-
- return ne;
-}
-
-
-
-
-
-_bsn.DOM.clearElement = function ( id )
-{
- var ele = this.getElement( id );
-
- if (!ele)
- return false;
-
- while (ele.childNodes.length)
- ele.removeChild( ele.childNodes[0] );
-
- return true;
-}
-
-
-
-
-
-
-
-
-
-_bsn.DOM.removeElement = function ( ele )
-{
- var e = this.getElement(ele);
-
- if (!e)
- return false;
- else if (e.parentNode.removeChild(e))
- return true;
- else
- return false;
-}
-
-
-
-
-
-_bsn.DOM.replaceContent = function ( id, cont, html )
-{
- var ele = this.getElement( id );
-
- if (!ele)
- return false;
-
- this.clearElement( ele );
-
- if (typeof(cont) == "string" && !html)
- ele.appendChild( document.createTextNode(cont) );
- else if (typeof(cont) == "string" && html)
- ele.innerHTML = cont;
- else if (typeof(cont) == "object")
- ele.appendChild( cont );
-}
-
-
-
-
-
-
-
-
-
-_bsn.DOM.getElement = function ( ele )
-{
- if (typeof(ele) == "undefined")
- {
- return false;
- }
- else if (typeof(ele) == "string")
- {
- var re = document.getElementById( ele );
- if (!re)
- return false;
- else if (typeof(re.appendChild) != "undefined" ) {
- return re;
- } else {
- return false;
- }
- }
- else if (typeof(ele.appendChild) != "undefined")
- return ele;
- else
- return false;
-}
-
-
-
-
-
-
-
-_bsn.DOM.appendChildren = function ( id, arr )
-{
- var ele = this.getElement( id );
-
- if (!ele)
- return false;
-
-
- if (typeof(arr) != "object")
- return false;
-
- for (var i=0;i<arr.length;i++)
- {
- var cont = arr[i];
- if (typeof(cont) == "string")
- ele.appendChild( document.createTextNode(cont) );
- else if (typeof(cont) == "object")
- ele.appendChild( cont );
- }
-}
-
-
-
-
-
-// var opt = new Array( '1'=>'lorem', '2'=>'ipsum' );
-// var sel = '2';
-
-_bsn.DOM.createSelect = function ( attr, opt, sel )
-{
- var select = this.createElement( 'select', attr );
- for (var a in opt)
- {
-
- var o = {id:a};
- if (a == sel) o.selected = "selected";
- select.appendChild( this.createElement( 'option', o, opt[a] ) );
-
- }
-
- return select;
-}
-
-
-
-
-_bsn.DOM.getPos = function ( ele )
-{
- var ele = this.getElement(ele);
-
- var obj = ele;
-
- var curleft = 0;
- if (obj.offsetParent)
- {
- while (obj.offsetParent)
- {
- curleft += obj.offsetLeft
- obj = obj.offsetParent;
- }
- }
- else if (obj.x)
- curleft += obj.x;
-
-
- var obj = ele;
-
- var curtop = 0;
- if (obj.offsetParent)
- {
- while (obj.offsetParent)
- {
- curtop += obj.offsetTop
- obj = obj.offsetParent;
- }
- }
- else if (obj.y)
- curtop += obj.y;
-
- return {x:curleft, y:curtop}
-}
\ No newline at end of file
display:block;
line-height:2em;
border:1px solid #fff;
- background:#fff url(../media/gradient.gif) repeat-x 0 -20px;
+ background:#fff url(/planetlab/icons/tablesort_gradient.gif) repeat-x 0 -20px;
}
ul.fdtablePaginater li a
{
tbody.className=cn;
}
-// /* scan the table, and mark as visible the rows that have at least one cell that contains the pattern */
-function plc_table_filter (table_id,pattern_id) {
+/* scan the table, and mark as visible
+ the rows that match (either AND or OR the patterns) */
+function plc_table_filter (table_id,pattern_id,and_id) {
var tbody = document.getElementById(table_id).getElementsByTagName("tbody")[0];
var rows=tbody.rows;
- var pattern_text = document.getElementById(pattern_id).value;
+ var pattern_area = document.getElementById(pattern_id);
+ var pattern_text = pattern_area.value;
var row_index, row, cells, cell_index, cell, visible;
var pattern,i;
var matching_entries=0;
+ var and_button=document.getElementById(and_id);
+ var and_if_true=and_button.checked;
+
// remove whitespaces at the beginning and end
pattern_text = pattern_text.replace(/[ \t]+$/,"");
pattern_text = pattern_text.replace(/^[ \t]+/,"");
+ if (pattern_text.indexOf ("&") != -1) {
+ pattern_text = pattern_text.replace(/&$/,"").replace(/&/," ");
+ pattern_area.value=pattern_text;
+ and_button.checked=true;
+ return;
+ } else if (pattern_text.indexOf ("|") != -1 ) {
+ pattern_text = pattern_text.replace(/\|$/,"").replace(/\|/," ");
+ pattern_area.value=pattern_text;
+ and_button.checked=false;
+ return;
+ }
+
var patterns = pattern_text.split(" ");
for (row_index = 0; row=rows[row_index]; row_index++) {
+ cells=row.cells;
- /* xxx deal with empty patterns and whitespaces */
+ /*empty pattern */
if (patterns.length == 0) {
visible=true;
+ } else if (and_if_true) {
+ /* AND mode: all patterns must match */
+ visible=true;
+ for (i in patterns) {
+ var pattern_matched=false;
+ pattern=patterns[i];
+ for (cell_index = 0; cell=cells[cell_index]; cell_index++) {
+ if ( cell.innerHTML.match(pattern)) pattern_matched=true;
+ }
+ if ( ! pattern_matched ) visible=false;
+ }
} else {
+ /* OR mode: any match is good enough */
visible=false;
- cells=row.cells;
for (cell_index = 0; cell=cells[cell_index]; cell_index++) {
for (i in patterns) {
pattern=patterns[i];
/* $Id$ */
/* when a table gets paginated, displays context info */
-function plc_table_update_paginaters (opts,tablename) {
+function plc_table_paginator (opts,tablename) {
if(!("currentPage" in opts)) { return; }
var t = document.getElementById(tablename+'-fdtablePaginaterWrapTop');
var b = document.getElementById(tablename+'-fdtablePaginaterWrapBottom');
+ /* when there's no visible entry, the pagination code removes the wrappers */
+ if ( (!t) || (!b) ) return;
+
/* get how many entries are matching:
opts.visibleRows only holds the contents of the current page
so we store the number of matching entries in the tbody's classname
var label;
- /* when there's no visible entry, the pagination code removes the wrappers */
- if (totalMatches == 0) return;
-
var matches_text;
if (totalMatches != opts.totalRows) {
matches_text = totalMatches + "/" + opts.totalRows;
// Print header
require_once 'plc_drupal.php';
-drupal_set_title('Nodes');
include 'plc_header.php';
// Common functions
$_person= $plc->person;
$_roles= $_person['role_ids'];
-$header_autocomplete_js='
-<script type="text/javascript" src="/planetlab/bsn/bsn.Ajax.js"></script>
-<script type="text/javascript" src="/planetlab/bsn/bsn.DOM.js"></script>
-<script type="text/javascript" src="/planetlab/bsn/bsn.AutoSuggest.js"></script>
-';
-
$header_tablesort_js='
<script type="text/javascript" src="/planetlab/tablesort/tablesort.js"></script>
<script type="text/javascript" src="/planetlab/tablesort/customsort.js"></script>
<link href="/planetlab/css/plc_paginate.css" rel="stylesheet" type="text/css" />
';
-drupal_set_html_head($header_autocomplete_js);
drupal_set_html_head($header_tablesort_js);
drupal_set_html_head($header_tablesort_css);
list ( $peer_filter, $peer_label) = plc_peer_info($api,$_GET['peerscope']);
$node_filter=array_merge($node_filter,$peer_filter);
+$title='Nodes';
+if ($nodepattern) {
+ $title .= " matching " . $nodepattern;
+ }
+$title .= ' (' . $peer_label . ')';
+drupal_set_title($title);
+
+// go
$nodes=$api->GetNodes($node_filter,$node_columns);
// build site_ids - interface_ids
?>
+<!------------------------------------------------------------>
+<!-- instantiate generic mechanisms for nodes -->
+<script type"text/javascript">
+function nodes_paginator (opts) {
+ plc_table_paginator (opts,"nodes");
+}
+function nodes_filter () {
+ plc_table_filter("nodes","search_text","nodes_and");
+}
+</script>
+
<!------------------------------------------------------------>
<table class='table_dialogs'> <tr>
<td class='table_flushleft'>
<input class='table_size_input' type='text' id='tablesize_text' value="<?php echo $tablesize; ?>"
onkeyup='plc_table_setsize("nodes","tablesize_text", "<?php echo $tablesize; ?>" );'
size=3 maxlength=3 />
- <label class='table_size_label'> items per page </label>
+ <label class='table_size_label'> Items per page </label>
<img class='table_reset' src="/planetlab/icons/clear.png"
onmousedown='plc_table_size_reset("nodes","tablesize_text","999");'>
</form>
<td class='table_flushright'>
<form class='table_search'>
- <label class='table_search_label'> search </label>
+ <label class='table_search_label'> Search </label>
<input class='table_search_input' type='text' id='search_text'
- onkeyup='plc_table_filter("nodes","search_text");'
+ onkeyup='nodes_filter();'
size=40 maxlength=256 />
+ <label>and</label>
+ <input id='nodes_and' class='table_search_and'
+ type='checkbox' checked='checked' onchange='nodes_filter();' />
<img class='table_reset' src="/planetlab/icons/clear.png"
onmousedown='plc_table_filter_reset("nodes","search_text");'>
</form>
</tr></table>
<!------------------------------------------------------------>
-<div class="fdtablePaginaterWrap" id="nodes-fdtablePaginaterWrapTop"><p></p></div>
+<!-- <div class="fdtablePaginaterWrap" id="nodes-fdtablePaginaterWrapTop"><p></p></div> -->
<!------------------------------------------------------------>
<table id="nodes" cellpadding="0" cellspacing="0" border="0"
-class="plc_table sortable-onload-4 rowstyle-alt colstyle-alt no-arrow paginationcallback-nodesTextInfo max-pages-15 paginate-<?php print $tablesize; ?>">
+class="plc_table sortable-onload-4 rowstyle-alt colstyle-alt no-arrow paginationcallback-nodes_paginator max-pages-15 paginate-<?php print $tablesize; ?>">
<thead>
<tr>
<th class="sortable plc_table">Peer</th>
</tfoot>
</table>
-<div class="fdtablePaginaterWrap" id="nodes-fdtablePaginaterWrapBottom"><p></p></div>
+<!-- <div class="fdtablePaginaterWrap" id="nodes-fdtablePaginaterWrapBottom"><p></p></div> -->
<p class='plc_filter_note'>
-Notes: Several words in pattern are combined with <em> OR </em>
+Notes: Enter & or | in the search area to alternate between <bold>AND</bold> and <bold>OR</bold> search modes
<br/>
Hold down the shift key to select multiple columns to sort
</p>
-<!------------------------------------------------------------>
-<hr>
-<hr>
-<p> This section is for trying out server-side filtering </p>
-<hr>
-<hr>
-
-<script type"text/javascript">
- /* instantiate generic mechanisms for nodes */
-function nodesTextInfo (opts) {
- plc_table_update_paginaters (opts,"nodes");
-}
-var options = {
- script:"/planetlab/nodes/test.php?",
- varname:"input",
- minchars:1
-};
-var as = new AutoSuggest('nodepattern', options);
-</script>
-
-<!------------------------------------------------------------>
-<div class="plc_filter">
-<form method='get' id='filter_nodes'>
-<table>
-
-<tr>
-<th><label for='peerscope'>Federation scope </label></th>
-<td colspan=2><select id='peerscope' name='peerscope' onChange='submit()'>
-<?php echo plc_peers_option_list($api); ?>
-</select></td>
-</tr>
-
-<tr>
-<th><label for='nodepattern'>Hostname (server-side pattern)</label></th>
-<td><input type='text' id='nodepattern' name='nodepattern'
- size=40 value='<?php print $nodepattern; ?>'/></td>
-<td><input id='go' rowspan=2 type=submit value='Go' /></td>
-</tr>
-
-<tr>
-<th><label for='tablesize'>Table size</label></th>
-<td> <input type='text' id='tablesize' name='tablesize'
- size=3 value='<?php print $tablesize; ?>'/></td>
-</tr>
-</table>
-</form>
-</div>
-
-<!-- trash -->
-<script type="text/javascript">
- function foo () {
- var tbody=document.getElementById("nodes").getElementsByTagName("tbody")[0];
- alert ('current classname = [' + tbody.className + "]");
- }
-</script>
-
-<hr>
-<form> <input type='button' onclick="foo()" value='debug classname'> </form>
-