--- livetable.js.1 2009-08-17 14:39:17.000000000 +0200
+++ livetable.js 2009-10-06 18:19:26.000000000 +0200
@@ -86,8 +86,15 @@
this.observeSortableColumns();
+ // Code to retrieve the current filters in the target part of the url
+ var currentFilter = location.hash;
+ if (currentFilter && currentFilter!="" && this.filters!=currentFilter) {
+ this.lastoffset = this.filter.updateFilters(currentFilter.substring(1));
+ this.filters = this.filter.getFilters();
+ }
+
// Show initial rows
- this.showRows(1, this.limit);
+ this.showRows(this.lastoffset,this.limit)
},
/**
@@ -213,6 +220,10 @@
showRows: function(offset, limit)
{
this.lastoffset = offset;
+
+ // Set the target part of the URL to have the filters be sticky
+ location = "#offset=" + this.lastoffset + this.filters;
+
// This is some debugging string.
var buff = 'request to display rows '+offset+' to '+(offset+limit)+'
\n';
@@ -528,6 +539,54 @@
return filterString;
},
+ updateFilters:function(filterString){
+ // populating the filter objects
+ this.filters=new Object();
+ var filtervalues = filterString.split('&');
+ for (var i = 0;i< filtervalues.length; i++) {
+ var filterkeyvalue = filtervalues[i];
+ var pos = filterkeyvalue.indexOf("=");
+ if (pos!=-1) {
+ this.filters[filterkeyvalue.substring(0, pos)] = filterkeyvalue.substring(pos + 1);
+ }
+ }
+
+ // set the offset which was in the query string
+ var offset;
+ if (this.filters["offset"])
+ offset = parseInt(this.filters["offset"]);
+ else
+ offset = 1;
+
+ var inputs=this.filterNode.getElementsByTagName("input");
+ for(var i=0;i