Mercurial > code > home > repos > href
annotate 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 |
rev | line source |
---|---|
4 | 1 |
2 $("#filterTag").focus(); | |
2
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
3 |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
4 function toggleTag(tag) { |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
5 var p = window.location.pathname; |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
6 var comps = p.split("/"); |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
7 var selected = (comps[2] || "").split("+"); |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
8 var add = true; |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
9 var others = []; |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
10 for (var i=0; i < selected.length; i++) { |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
11 if (!selected[i]) { |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
12 continue; |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
13 } |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
14 if (selected[i] == tag) { |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
15 add = false; |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
16 } else { |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
17 others.push(selected[i]); |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
18 } |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
19 } |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
20 if (add) { |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
21 others.push(tag); |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
22 } |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
23 window.location.pathname = "/" + comps[1] + "/" + others.join("+"); |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
24 } |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
25 |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
26 function backspaceLastTag() { |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
27 var p = window.location.pathname; |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
28 var comps = p.split("/"); |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
29 var selected = (comps[2] || "").split("+"); |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
30 if (selected.length == 0) { |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
31 return; |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
32 } |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
33 toggleTag(selected[selected.length-1]); |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
34 } |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
35 |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
36 $("a.tag").click(function () { |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
37 var tag = $(this).text(); |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
38 toggleTag(tag); |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
39 return false; |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
40 }); |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
41 |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
42 $("#filterTag").change(function () { |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
43 var tag = $(this).val(); |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
44 toggleTag(tag); |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
45 return false; |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
46 }); |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
47 |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
48 $("#filterTag").keydown(function (ev) { |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
49 if ($(this).val() == "" && ev.which == 8) { |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
50 backspaceLastTag(); |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
51 } |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
52 }); |