# HG changeset patch # User Drew Perttula # Date 1362640944 28800 # Node ID be339aa223bf00b4baf98b3fc7b8acd0e3469e4e # Parent 93d94f327e8287aa57e83c46c1bcd1eee8873600 tag/filter autocompelte Ignore-this: f6235de879c1ce62a8fc41e890edd0d2 diff -r 93d94f327e82 -r be339aa223bf static/gui.js --- a/static/gui.js Wed Mar 06 23:18:39 2013 -0800 +++ b/static/gui.js Wed Mar 06 23:22:24 2013 -0800 @@ -1,6 +1,10 @@ $("#filterTag").focus(); +var model = { + filterTags: ko.observableArray(currentFilter()) +}; + function currentFilter() { var p = window.location.pathname; var comps = p.split("/"); @@ -19,7 +23,11 @@ } else { selected.splice(selected.indexOf(tag), 1); } + setPageTags(selected); +} +function setPageTags(tags) { + var newPath = window.location.pathname; if (toRoot == ".") { newPath += "/"; @@ -28,8 +36,8 @@ /(.*\/)[^\/]*$/, "$1") } console.log("user root", newPath); - if (selected.length) { - newPath += selected.join("+") + if (tags.length) { + newPath += tags.join("+") } else { newPath = newPath.substr(0, newPath.length - 1); } @@ -55,8 +63,8 @@ }); $("#filterTag").change(function () { - var tag = $(this).val(); - toggleTag(tag); + var tags = $(this).val(); + setPageTags(tags); return false; }); @@ -65,3 +73,11 @@ backspaceLastTag(); } }); + +$("#filterTag").chosen({ + + }); + +ko.applyBindings(model); +$("#filterTag").trigger("liszt:updated"); +