Skip to content

Commit

Permalink
Issue #16: Use window.history.pushState to filter without reload
Browse files Browse the repository at this point in the history
  • Loading branch information
magiconair committed Nov 28, 2015
1 parent 9743902 commit d9cfc51
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions ui/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,24 @@ var htmlTable = `
$(function(){
var $filter = $('#filter');
var params={};window.location.search.replace(/[?&]+([^=&]+)=([^&]*)/gi,function(str,key,value){params[key] = value;});
if (params.filter) {
$filter.val(params.filter);
$("td.route:not(:contains('"+params.filter+"'))").each(function() {
function doFilter(v) {
$("tr").show();
$filter.val(v);
if (!v || v == "") return;
$("td.route:not(:contains('"+v+"'))").each(function() {
$(this).parent("tr").hide();
});
}
var params={};window.location.search.replace(/[?&]+([^=&]+)=([^&]*)/gi,function(str,key,value){params[key] = value;});
doFilter(params.filter);
$filter.focus();
$filter.keyup(function() {
var url = window.location.href.split('?')[0];
if ($filter.val() != '') {
url += "?filter=" +$filter.val();
}
window.location = url;
})
var v = $filter.val();
window.history.pushState(null, null, "?filter=" +v);
doFilter(v);
});
})
</script>
Expand Down

0 comments on commit d9cfc51

Please sign in to comment.