Skip to content

Commit

Permalink
Yeah, more stuff, I know
Browse files Browse the repository at this point in the history
  • Loading branch information
rberenguel committed Nov 19, 2024
1 parent 7c8cddc commit 8321dd0
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 9 deletions.
1 change: 0 additions & 1 deletion lib/linkUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ function addLinksToDiv(links, targetDivId) {
.split(":");
console.info(`Sending ${message} to extension ${extensionId}`);
chrome.runtime.sendMessage(extensionId, { message: message });
window.close();
} else {
window.location.href = matchingLink.url;
}
Expand Down
11 changes: 11 additions & 0 deletions lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ function textToObject(text, hPos = 0, filepath) {
obj.prio = -1000;
cleaned = cleaned.replace(/\s+\(.omeday\)/, "");
}
if (
cleaned.endsWith("(reference)") ||
cleaned.endsWith("(Reference)") ||
cleaned.endsWith("(ref)")
) {
obj.reference = true;
obj.prio = -1000;
cleaned = cleaned
.replace(/\s+\(.eference\)$/, "")
.replace(/\(ref\)$/, "");
}
const linkMatch = cleaned.match(linkPlusRegex);
if (linkMatch) {
obj.text = linkMatch[1] + (linkMatch[3] ?? "");
Expand Down
30 changes: 30 additions & 0 deletions lib/taskUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ function addTasksToDiv(_tasks, targetDivId) {
}
let addedDoneSeparator = false;
let someday = false;
let reference = false;
targetDiv.addEventListener("mouseover", () => toTop(targetDiv));
let projects = [];
let wrapperNode = d();
Expand Down Expand Up @@ -258,6 +259,10 @@ function addTasksToDiv(_tasks, targetDivId) {
taskWrapper.classList.add("someday", "hide");
someday = true; // Global catch for "there is someday"
}
if (task.reference) {
taskWrapper.classList.add("reference", "hide");
reference = true; // Global catch for "there are references"
}
for (let i = 0; i < projects.length; i++) {
const _p = projects[i];
let pproj = _p;
Expand Down Expand Up @@ -432,6 +437,31 @@ function addTasksToDiv(_tasks, targetDivId) {
});
taskText.addEventListener("contextmenu", (e) => e.preventDefault());
}
if (reference) {
// I could just use count
const references = tasks.filter((t) => t.reference);
const count = references.length;
const taskWrapper = d();
taskWrapper.classList.add("taskRow");
taskWrapper.id = "reference";
const taskText = d();
taskText.classList.add("taskText");
taskWrapper.appendChild(taskText);
taskText.textContent = `References (${count})`;
taskText.style.color = `var(--task-default)`;
const firstReference = wrapperNode.querySelector(".taskRow.reference");
const hr = document.createElement("HR");
hr.style.borderColor = `var(--task-default)`;
hr.classList.add("dim");
wrapperNode.insertBefore(hr, firstReference);
wrapperNode.insertBefore(taskWrapper, firstReference);
taskText.addEventListener("click", (e) => {
e.preventDefault();
const references = document.querySelectorAll(".taskRow.reference");
Array.from(references).map((s) => s.classList.toggle("hide"));
});
taskText.addEventListener("contextmenu", (e) => e.preventDefault());
}
const dones = tasks.filter((t) => t.done);
if (dones.length) {
const count = dones.length;
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "NT",
"version": "0.2",
"version": "0.3",
"description": "Replaces the default new tab page with a custom one",
"chrome_url_overrides": {
"newtab": "index.html"
Expand Down
35 changes: 28 additions & 7 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ iframe {
.taskRow {
display: flex;
flex-direction: row;
cursor: pointer;
}

.taskText {
Expand Down Expand Up @@ -244,31 +245,51 @@ hr.dim {
height 0.5s ease-in-out;
}

#someday {
cursor: pointer;
}

.taskRow.done.hide {
.taskRow.someday.hide {
opacity: 0 !important;
visibility: hidden !important;
height: 0 !important;
transition: none;
}

.taskRow.done {
#someday {
cursor: pointer;
}

.taskRow.reference {
filter: grayscale(0.05) opacity(0.9);
font-size: 90% !important;
transition:
opacity 0.5s ease-in-out,
visibility 0.5s ease-in-out,
height 0.5s ease-in-out;
}

.taskRow.someday.hide {
.taskRow.reference.hide {
opacity: 0 !important;
visibility: hidden !important;
height: 0 !important;
transition: none;
}

#reference {
cursor: pointer;
}

.taskRow.done.hide {
opacity: 0 !important;
visibility: hidden !important;
height: 0 !important;
transition: none;
}

.taskRow.done {
transition:
opacity 0.5s ease-in-out,
visibility 0.5s ease-in-out,
height 0.5s ease-in-out;
}

#someday {
cursor: pointer;
}
Expand Down

0 comments on commit 8321dd0

Please sign in to comment.