Mercurial > code > home > repos > href
view static/gui.js @ 4:409da49c148d
partway though add
Ignore-this: 330d1f3393bb91ca56267d2138e3bb22
author | drewp@bigasterisk.com |
---|---|
date | Sun, 17 Feb 2013 21:12:53 -0800 |
parents | 80b11112c9e0 |
children | f8c4c7ce5f4a |
line wrap: on
line source
$("#filterTag").focus(); function toggleTag(tag) { var p = window.location.pathname; var comps = p.split("/"); var selected = (comps[2] || "").split("+"); var add = true; var others = []; for (var i=0; i < selected.length; i++) { if (!selected[i]) { continue; } if (selected[i] == tag) { add = false; } else { others.push(selected[i]); } } if (add) { others.push(tag); } window.location.pathname = "/" + comps[1] + "/" + others.join("+"); } function backspaceLastTag() { var p = window.location.pathname; var comps = p.split("/"); var selected = (comps[2] || "").split("+"); if (selected.length == 0) { return; } toggleTag(selected[selected.length-1]); } $("a.tag").click(function () { var tag = $(this).text(); toggleTag(tag); return false; }); $("#filterTag").change(function () { var tag = $(this).val(); toggleTag(tag); return false; }); $("#filterTag").keydown(function (ev) { if ($(this).val() == "" && ev.which == 8) { backspaceLastTag(); } });