+++ /dev/null
-var todos = {
- uncompleted: [],
- completed: []
-};
-var archived = [];
-var theme = {
- colorScheme: "default",
- css: "",
- showCompleted: false
-};
-
-if (localStorage.getItem("todos")) {
-
- todos = JSON.parse(localStorage.getItem("todos"));
-}
-
-if (localStorage.getItem("archived")) {
-
- archived = JSON.parse(localStorage.getItem("archived"));
-}
-
-if (localStorage.getItem("theme")) {
-
- theme = JSON.parse(localStorage.getItem("theme"));
-}
-
-const backupData = () => {
-
- localStorage.setItem("todos", JSON.stringify(todos));
- localStorage.setItem("archived", JSON.stringify(archived));
- localStorage.setItem("theme", JSON.stringify(theme));
-}
-
-const archivedElement = document.getElementById("archived");
-
-const todoElement = (item, index) => {
-
- return `
- <todo id="todo-archived-${index}">
- <div class="data">
- <textarea id="todo-archived-${index}-description">${item.description}</textarea>
- <div>
- <p id="todo-archived-${index}-restore">restore</p>
- <p id="todo-archived-${index}-delete">delete</p>
- </div>
- </div>
- </todo>
- `;
-}
-
-const resizeTextHeights = () => {
-
- for (const element of document.querySelectorAll("todo textarea")) {
-
- element.style.height = "0";
- element.style.height = element.scrollHeight + "px";
- }
-}
-
-const applyListeners = () => {
-
- resizeTextHeights();
-
- for (var i = 0; i < archived.length; i++) {
-
- let index = i; // fixes scoping issue - what a disaster
-
- document.getElementById(`todo-archived-${i}-description`).addEventListener("input", (event) => {
-
- event.target.style.height = "0";
- event.target.style.height = event.target.scrollHeight + "px";
-
- archived[index].description = event.target.value;
-
- backupData();
- });
-
- document.getElementById(`todo-archived-${i}-restore`).addEventListener("click", (event) => {
-
- todos.uncompleted = [
- archived[index]
- ].concat(todos.uncompleted);
- archived.splice(index, 1);
-
- hydrateTodos();
- backupData();
- });
-
- document.getElementById(`todo-archived-${i}-delete`).addEventListener("click", (event) => {
-
- archived.splice(index, 1);
-
- hydrateTodos();
- backupData();
- });
- }
-}
-
-const hydrateTodos = () => {
-
- if (archived.length > 0) archivedElement.innerHTML = archived
- .map((x, index) => todoElement(x, index))
- .join("");
- else archivedElement.innerHTML = "<p>no archived todos for now…</p>";
-
- applyListeners();
-};
-
-hydrateTodos();
-
-const updateTheme = (force = false) => {
-
- if (theme.colorScheme != "default") {
-
- document.getElementsByTagName("body")[0].className = theme.colorScheme;
- }
-
- if (theme.css != "" || force) {
-
- const cssOverride = document.createElement("style");
- cssOverride.setAttribute("id", "styleOverride");
- cssOverride.innerHTML = theme.css.replaceAll("<", "<").replaceAll(">", ">");
- if (document.getElementById("styleOverride")) document.getElementById("styleOverride").remove();
- document.getElementsByTagName("head")[0].appendChild(cssOverride);
- }
-}
-
-updateTheme();
border-bottom-right-radius: var(--border-radius-outer) !important;
}
+a, a:visited, a:active {
+ color: var(--text-primary);
+ text-decoration: none;
+ &:not(.embedded) {
+ background-color: var(--background-secondary);
+ padding: 0.25rem;
+ border-radius: 0.5rem;
+ }
+}
+
todo {
background-color: var(--background-secondary);
border-radius: var(--border-radius-inner);
flex-wrap: wrap;
justify-content: right;
gap: 0.5rem;
- & > p {
+ & > p, & > a {
/* user-select: none; */
font-size: 0.9rem;
margin: 0;
background-color: var(--background-secondary);
}
-a, a:visited, a:active {
- color: var(--text-primary);
- background-color: var(--background-secondary);
- text-decoration: none;
- padding: 0.25rem;
- border-radius: 0.5rem;
-}
-
button:active, a:hover {
background-color: var(--background-tertiary);
}
h3 {
font-size: 1.5rem !important;
}
- p {
+ p, a {
font-size: 1rem !important;
}
button {