Commit 8ed7a17e authored by ransome1's avatar ransome1
Browse files

Added option for case sensitive search

parent cad089db
{
"name": "sleek",
"productName": "sleek",
"version": "1.2.2",
"version": "1.2.3-rc.1",
"description": "todo.txt manager for Linux, Windows and MacOS, free and open-source (FOSS)",
"synopsis": "todo.txt manager for Linux, Windows and MacOS, free and open-source (FOSS)",
"category": "ProjectManagement",
......@@ -19,7 +19,7 @@
"main": "src/main.js",
"buildResources": "src",
"build": {
"buildVersion": "20",
"buildVersion": "21",
"files": [
"!flatpak-node${/*}",
"!snap${/*}",
......
......@@ -503,12 +503,12 @@
</td>
</tr>
</table>
<!-- <table id="getPageTitlesRow" class="settings">
<table id="getPageTitlesRow" class="settings">
<tr>
<th colspan="100%" id="getPageTitlesHeadline">Replace links with website titles</th>
</tr>
<tr>
<td id="getPageTitlesBody">Description text</td>
<td id="getPageTitlesBody">[PLACEHOLDER for description text]</td>
<td>
<span class="toggle">
<label class="switch" for="getPageTitles">
......@@ -518,7 +518,23 @@
</span>
</td>
</tr>
</table> -->
</table>
<table id="caseSensitiveRow" class="settings">
<tr>
<th colspan="100%" id="caseSensitiveHeadline">Searching and filtering case sensitive</th>
</tr>
<tr>
<td id="caseSensitiveBody">[PLACEHOLDER for description text]</td>
<td>
<span class="toggle">
<label class="switch" for="caseSensitive">
<input type="checkbox" id="caseSensitive" class="toggle" tabindex="0">
<span class="slider round"></span>
</label>
</span>
</td>
</tr>
</table>
<table class="settings">
<tr>
<th colspan="100%" id="zoomHeadline"></th>
......
......@@ -70,7 +70,13 @@ function runQuery(item, compiledQuery) {
break;
case "string":
next = q.shift(); // the string value to match
stack.push(item.toString().toLowerCase().indexOf(next.toLowerCase()) !== -1);
if(!userData.caseSensitive) {
next = next.toLowerCase();
item.raw = item.raw.toLowerCase();
}
stack.push(item.raw.indexOf(next) !== -1);
break;
case "regex":
next = q.shift(); // the regex to match
......@@ -114,9 +120,15 @@ function runQuery(item, compiledQuery) {
stack.push(item.projects && item.projects.includes(next.slice(1,-1)));
} else {
// case-insensitive match for next as a substring of the project name
let pattern = next.toLowerCase();
let pattern = next;
stack.push(item.projects && item.projects.findIndex(function(p) {
return p.toLowerCase().indexOf(pattern) > -1;
if(!userData.caseSensitive) {
pattern = pattern.toLowerCase();
p = p.toLowerCase();
}
return p.indexOf(pattern) > -1;
}) > -1);
}
break;
......@@ -128,9 +140,14 @@ function runQuery(item, compiledQuery) {
stack.push(item.contexts && item.contexts.includes(next.slice(1,-1)));
} else {
// case-insensitive match for next as a substring of the context name
let pattern = next.toLowerCase();
let pattern = next;
stack.push(item.contexts && item.contexts.findIndex(function(c) {
return c.toLowerCase().indexOf(pattern) > -1;
if(!userData.caseSensitive) {
pattern = pattern.toLowerCase();
c = c.toLowerCase();
}
return c.indexOf(pattern) > -1;
}) > -1);
}
break;
......
......@@ -191,8 +191,13 @@ function applySearchInput(queryString) {
// the query is not syntactically correct and isn't a longer version
// of the last working query, so let's assume that it is a
// plain-text query.
items.filtered = items.filtered.filter(function(item) {
return item.toString().toLowerCase().indexOf(queryString.toLowerCase()) !== -1;
if(!userData.caseSensitive) {
queryString = queryString.toLowerCase();
item.raw = item.raw.toLowerCase();
}
return item.raw.indexOf(queryString) !== -1;
});
}
}
......@@ -592,7 +597,13 @@ function generateFilterData(autoCompleteCategory, autoCompleteValue, autoComplet
});
// search within filters according to autoCompleteValue
if(autoCompletePrefix) filters = filters.filter(function(filter) { return filter.toString().toLowerCase().includes(autoCompleteValue.toLowerCase()); })
// if(autoCompletePrefix) filters = filters.filter(function(filter) {
// // (!userData.caseSensitive)
// // autoCompleteValue = queryString.toLowerCase();
// // filter.raw = item.raw.toLowerCase();
// return filter.toString().toLowerCase().includes(autoCompleteValue.toLowerCase());
// })
// remove duplicates, create the count object and avoid counting filters of hidden todos
filtersCounted = filters.reduce(function(filters, filter) {
......
......@@ -62,6 +62,9 @@ function configureMatomo() {
if(typeof userData.showEmptyFilters === "boolean")_paq.push(["setCustomDimension", 20, userData.showEmptyFilters]);
if(items && typeof items.objects === "object") _paq.push(["setCustomDimension", 21, todoRange(items.objects.length)]);
if(typeof userData.deferredTodos === "boolean")_paq.push(["setCustomDimension", 22, userData.deferredTodos]);
if(typeof userData.getPageTitles === "boolean")_paq.push(["setCustomDimension", 23, userData.getPageTitles]);
if(typeof userData.caseSensitive === "boolean")_paq.push(["setCustomDimension", 24, userData.caseSensitive]);
_paq.push(["requireConsent"]);
_paq.push(["setConsentGiven"]);
_paq.push(["trackPageView"]);
......
......@@ -74,7 +74,7 @@ todoTableWrapper.onscroll = function(event) {
}
// receives a page title and if found replaces the link with it
function getAndsetPageTitle(linkId, href) {
function getAndSetPageTitle(linkId, href) {
const pageBody = fetch(href);
pageBody.then(response => response.text()).then(async data => {
const regExp = new RegExp("<title[^>]*>(.*?)</title>");
......@@ -399,7 +399,7 @@ function generateTableRow(todo) {
link(href, title, text) {
const linkId = Math.random().toString(36).slice(2);
if(userData.getPageTitles) getAndsetPageTitle(linkId, text);
if(userData.getPageTitles) getAndSetPageTitle(linkId, text);
return `<span id="linkId${linkId}" class="linkText">${text}</span> <a href="${href}" target="_blank"><i class="fas fa-external-link-alt"></i></a>`;
}
......
......@@ -337,6 +337,7 @@ function getUserData() {
if(typeof userData.data.autoUpdate != "boolean") userData.data.autoUpdate = false;
if(typeof userData.data.theme != "string") userData.set("theme", "system");
if(typeof userData.data.getPageTitles != "boolean") userData.data.getPageTitles = true;
if(typeof userData.data.caseSensitive != "boolean") userData.data.caseSensitive = false;
//TODO remove this after 1.1.7 has been fully distributed
const indexOfDueString = userData.data.sortBy.indexOf("dueString");
......
......@@ -604,13 +604,13 @@ cli-truncate@^2.1.0:
slice-ansi "^3.0.0"
string-width "^4.2.0"
cliui@^7.0.2:
version "7.0.4"
resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f"
integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==
cliui@^8.0.1:
version "8.0.1"
resolved "https://registry.yarnpkg.com/cliui/-/cliui-8.0.1.tgz#0c04b075db02cbfe60dc8e6cf2f5486b1a3608aa"
integrity sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==
dependencies:
string-width "^4.2.0"
strip-ansi "^6.0.0"
strip-ansi "^6.0.1"
wrap-ansi "^7.0.0"
clone-response@^1.0.2:
......@@ -1649,9 +1649,9 @@ jake@^10.8.5:
minimatch "^3.0.4"
js-sdsl@^4.1.4:
version "4.1.4"
resolved "https://registry.yarnpkg.com/js-sdsl/-/js-sdsl-4.1.4.tgz#78793c90f80e8430b7d8dc94515b6c77d98a26a6"
integrity sha512-Y2/yD55y5jteOAmY50JbUZYwk3CP3wnLPEZnlR1w9oKhITrBEtAxwuWKebFf8hMrPMgbYwFoWK/lH2sBkErELw==
version "4.1.5"
resolved "https://registry.yarnpkg.com/js-sdsl/-/js-sdsl-4.1.5.tgz#1ff1645e6b4d1b028cd3f862db88c9d887f26e2a"
integrity sha512-08bOAKweV2NUC1wqTtf3qZlnpOX/R2DU9ikpjOHs0H+ibQv3zpncVQg6um4uYtRtrwIX8M4Nh3ytK4HGlYAq7Q==
js-yaml@^4.1.0:
version "4.1.0"
......@@ -1785,9 +1785,9 @@ make-dir@^3.0.0:
semver "^6.0.0"
marked@^4.0.12:
version "4.1.0"
resolved "https://registry.yarnpkg.com/marked/-/marked-4.1.0.tgz#3fc6e7485f21c1ca5d6ec4a39de820e146954796"
integrity sha512-+Z6KDjSPa6/723PQYyc1axYZpYYpDnECDaU6hkaf5gqBieBkMKYReL5hteF2QizhlMbgbo8umXl/clZ67+GlsA==
version "4.1.1"
resolved "https://registry.yarnpkg.com/marked/-/marked-4.1.1.tgz#2f709a4462abf65a283f2453dc1c42ab177d302e"
integrity sha512-0cNMnTcUJPxbA6uWmCmjWz4NJRe/0Xfk2NhXCUHjew9qJzFN20krFnsUe7QynwqOwa5m1fZ4UDg0ycKFVC0ccw==
matcher@^3.0.0:
version "3.0.0"
......@@ -2599,11 +2599,11 @@ yargs-parser@^21.0.0:
integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==
yargs@^17.0.1:
version "17.5.1"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.5.1.tgz#e109900cab6fcb7fd44b1d8249166feb0b36e58e"
integrity sha512-t6YAJcxDkNX7NFYiVtKvWUz8l+PaKTLiL63mJYWR2GnHq2gjEWISzsLp9wg3aY36dY1j+gfIEL3pIF+XlJJfbA==
version "17.6.0"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.6.0.tgz#e134900fc1f218bc230192bdec06a0a5f973e46c"
integrity sha512-8H/wTDqlSwoSnScvV2N/JHfLWOKuh5MVla9hqLjK3nsfyy6Y4kDSYSvkU5YCUEPOSnRXfIyx3Sq+B/IWudTo4g==
dependencies:
cliui "^7.0.2"
cliui "^8.0.1"
escalade "^3.1.1"
get-caller-file "^2.0.5"
require-directory "^2.1.1"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment