comparison static/gui.js @ 5:f8c4c7ce5f4a

lots of href additions: add/edit, nav fixes Ignore-this: 863335c4680ac9bcc6a7fc5867638d61
author Drew Perttula <drewp@bigasterisk.com>
date Thu, 21 Feb 2013 01:39:01 -0800
parents 409da49c148d
children be339aa223bf
comparison
equal deleted inserted replaced
4:409da49c148d 5:f8c4c7ce5f4a
1 1
2 $("#filterTag").focus(); 2 $("#filterTag").focus();
3 3
4 function toggleTag(tag) { 4 function currentFilter() {
5 var p = window.location.pathname; 5 var p = window.location.pathname;
6 var comps = p.split("/"); 6 var comps = p.split("/");
7 var selected = (comps[2] || "").split("+"); 7 if (toRoot == ".") {
8 var add = true; 8 return [];
9 var others = []; 9 } else {
10 for (var i=0; i < selected.length; i++) { 10 return (comps[comps.length-1] || "").split("+");
11 if (!selected[i]) {
12 continue;
13 }
14 if (selected[i] == tag) {
15 add = false;
16 } else {
17 others.push(selected[i]);
18 }
19 } 11 }
20 if (add) { 12 }
21 others.push(tag); 13
14 function toggleTag(tag) {
15 var selected = currentFilter();
16
17 if (selected.indexOf(tag) == -1) {
18 selected.push(tag);
19 } else {
20 selected.splice(selected.indexOf(tag), 1);
22 } 21 }
23 window.location.pathname = "/" + comps[1] + "/" + others.join("+"); 22
23 var newPath = window.location.pathname;
24 if (toRoot == ".") {
25 newPath += "/";
26 } else {
27 newPath = newPath.replace(
28 /(.*\/)[^\/]*$/, "$1")
29 }
30 console.log("user root", newPath);
31 if (selected.length) {
32 newPath += selected.join("+")
33 } else {
34 newPath = newPath.substr(0, newPath.length - 1);
35 }
36 console.log("done", newPath);
37
38 window.location.pathname = newPath;
24 } 39 }
25 40
26 function backspaceLastTag() { 41 function backspaceLastTag() {
27 var p = window.location.pathname; 42 var p = window.location.pathname;
28 var comps = p.split("/"); 43 var comps = p.split("/");
29 var selected = (comps[2] || "").split("+"); 44 var selected = (comps[comps.length-1] || "").split("+");
30 if (selected.length == 0) { 45 if (selected.length == 0) {
31 return; 46 return;
32 } 47 }
33 toggleTag(selected[selected.length-1]); 48 toggleTag(selected[selected.length-1]);
34 } 49 }