From: Thierry Parmentelat Date: Tue, 13 Jan 2009 13:54:34 +0000 (+0000) Subject: * nodes page looks good, going generic X-Git-Tag: PLEWWW-4.3-1~123 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=20be01f8a8d015edab9f16d41653ad0050c30d09;p=plewww.git * nodes page looks good, going generic * server-side filtering still on (set nodepattern/peerscope in the url) * but associated dialogs have gone * removed bsn stuff --- diff --git a/planetlab/bsn/bsn.Ajax.js b/planetlab/bsn/bsn.Ajax.js deleted file mode 100644 index aeec8af..0000000 --- a/planetlab/bsn/bsn.Ajax.js +++ /dev/null @@ -1,84 +0,0 @@ -/** - * 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 diff --git a/planetlab/bsn/bsn.AutoSuggest.js b/planetlab/bsn/bsn.AutoSuggest.js deleted file mode 100644 index fcea5e5..0000000 --- a/planetlab/bsn/bsn.AutoSuggest.js +++ /dev/null @@ -1,336 +0,0 @@ -/** - * 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.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 diff --git a/planetlab/bsn/bsn.DOM.js b/planetlab/bsn/bsn.DOM.js deleted file mode 100644 index 2b98e42..0000000 --- a/planetlab/bsn/bsn.DOM.js +++ /dev/null @@ -1,223 +0,0 @@ -/** - * 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'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 diff --git a/planetlab/css/plc_paginate.css b/planetlab/css/plc_paginate.css index 407de16..0163d8c 100644 --- a/planetlab/css/plc_paginate.css +++ b/planetlab/css/plc_paginate.css @@ -58,7 +58,7 @@ ul.fdtablePaginater li div span 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 { diff --git a/planetlab/js/plc_filter.js b/planetlab/js/plc_filter.js index 78b41ee..f11c72c 100644 --- a/planetlab/js/plc_filter.js +++ b/planetlab/js/plc_filter.js @@ -22,29 +22,58 @@ function plc_table_tbody_matching (tbody, matching) { 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]; diff --git a/planetlab/js/plc_paginate.js b/planetlab/js/plc_paginate.js index 68c228f..861bd77 100644 --- a/planetlab/js/plc_paginate.js +++ b/planetlab/js/plc_paginate.js @@ -1,7 +1,7 @@ /* $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; } @@ -9,6 +9,9 @@ function plc_table_update_paginaters (opts,tablename) { 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 @@ -23,9 +26,6 @@ function plc_table_update_paginaters (opts,tablename) { 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; diff --git a/planetlab/nodes/newindex.php b/planetlab/nodes/newindex.php index 6c215fb..90c14e4 100644 --- a/planetlab/nodes/newindex.php +++ b/planetlab/nodes/newindex.php @@ -11,7 +11,6 @@ global $plc, $api, $adm; // Print header require_once 'plc_drupal.php'; -drupal_set_title('Nodes'); include 'plc_header.php'; // Common functions @@ -22,12 +21,6 @@ require_once 'plc_sorts.php'; $_person= $plc->person; $_roles= $_person['role_ids']; -$header_autocomplete_js=' - - - -'; - $header_tablesort_js=' @@ -42,7 +35,6 @@ $header_tablesort_css=' '; -drupal_set_html_head($header_autocomplete_js); drupal_set_html_head($header_tablesort_js); drupal_set_html_head($header_tablesort_css); @@ -70,6 +62,14 @@ if ($nodepattern) { 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 @@ -112,6 +112,17 @@ foreach ($peers as $peer) { ?> + + + +
@@ -119,7 +130,7 @@ foreach ($peers as $peer) { - + @@ -127,10 +138,13 @@ foreach ($peers as $peer) { @@ -138,11 +152,11 @@ foreach ($peers as $peer) {
-

+ +class="plc_table sortable-onload-4 rowstyle-alt colstyle-alt no-arrow paginationcallback-nodes_paginator max-pages-15 paginate-"> @@ -196,70 +210,11 @@ foreach ($nodes as $node) {
Peer
-

+

-Notes: Several words in pattern are combined with OR +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

- -
-
-

This section is for trying out server-side filtering

-
-
- - - - -
-
- - - - - - - - - - - - - - - - - -
-
-
- - - - -
-
-