drop tag filter

This commit is contained in:
quenousimporte 2023-11-15 22:00:39 +01:00
parent eab69a487f
commit 4b4fbf4916
1 changed files with 4 additions and 49 deletions

53
main.js
View File

@ -13,7 +13,6 @@ var defaultsettings =
password: "", password: "",
sync: false, sync: false,
tagsinlists: true, tagsinlists: true,
tagfilter: "",
uselinkpopup: true uselinkpopup: true
}; };
@ -176,11 +175,6 @@ var commands = [
action: shownotelinks, action: shownotelinks,
shortcut: "ctrl+l" shortcut: "ctrl+l"
}, },
{
hint: "Add tag filter",
action: addtagfilter,
shortcut: "ctrl+shift+F",
},
{ {
hint: "Show stats", hint: "Show stats",
action: showinfo, action: showinfo,
@ -508,7 +502,6 @@ function showinfo()
"word count: " + getwords(), "word count: " + getwords(),
"cursor position: " + md.selectionStart + " (" + pospercent() + "%)", "cursor position: " + md.selectionStart + " (" + pospercent() + "%)",
(tags ? "tags: " + tags : ""), (tags ? "tags: " + tags : ""),
"current filter: " + settings.tagfilter || "",
"current note start: " + stat.cur.t, "current note start: " + stat.cur.t,
"current note queries: " + stat.cur.q, "current note queries: " + stat.cur.q,
"current note data sent: " + formatsize(stat.cur.d), "current note data sent: " + formatsize(stat.cur.d),
@ -525,35 +518,6 @@ function savesettings()
window.localStorage.setItem("settings", JSON.stringify(settings)); window.localStorage.setItem("settings", JSON.stringify(settings));
} }
function removetaghint()
{
return "Remove tag filter " + tagmark + settings.tagfilter;
}
function addtagfilter()
{
var command = commands.find(c => c.action == addtagfilter);
if (!settings.tagfilter)
{
tagslist()
.then(t =>
{
settings.tagfilter = t;
savesettings();
command.hint = removetaghint();
setwindowtitle();
});
}
else
{
settings.tagfilter = "";
savesettings();
command.hint = "Add tag filter";
setwindowtitle();
}
}
function descendants(note) function descendants(note)
{ {
var list = [note]; var list = [note];
@ -1337,15 +1301,6 @@ function loadsettings()
applystyle(); applystyle();
if (settings.tagfilter)
{
var command = commands.find(c => c.hint == "Add tag filter");
if (command)
{
command.hint = removetaghint();
}
}
if (settings.titlebydefault && title.hidden) if (settings.titlebydefault && title.hidden)
{ {
toggletitle(); toggletitle();
@ -1776,7 +1731,7 @@ function commandpalette()
.concat(localdata.map(n => .concat(localdata.map(n =>
{ {
return { return {
prefix: "note ", prefix: "open ",
text: n.title, text: n.title,
suffix: gettags(n).map(t => tagmark + t) suffix: gettags(n).map(t => tagmark + t)
}; };
@ -1797,7 +1752,7 @@ function commandpalette()
insert(snippet.insert, snippet.cursor); insert(snippet.insert, snippet.cursor);
md.focus(); md.focus();
} }
else if (selected.prefix == "note ") else if (selected.prefix == "open ")
{ {
loadnote(selected.text); loadnote(selected.text);
} }
@ -2743,7 +2698,7 @@ function mainkeydownhandler()
function setwindowtitle() function setwindowtitle()
{ {
document.title = (settings.tagfilter ? settings.tagfilter + " | " : "") + currentnote.title; document.title = currentnote.title;
} }
function ontitlechange() function ontitlechange()
@ -2988,7 +2943,7 @@ function defaultheaders(title, tags = "")
return [ return [
"---", "---",
"date: " + timestamp().substr(0,10), "date: " + timestamp().substr(0,10),
"tags: " + (tags || settings.tagfilter || ""), "tags: " + (tags || ""),
"---", "---",
"",""].join("\n"); "",""].join("\n");
} }