diff --git a/configs.js b/configs.js index eb28947..03f2198 100644 --- a/configs.js +++ b/configs.js @@ -2,8 +2,11 @@ const configs = (function () { "use strict"; // settings - const enableLimit = true; // true or false - const limit = 5; // integer + const enableLimit = false; // true or false + const limit = 10; // integer + + const modifyLocalStorage = true; // true or false + const showOnlyStreamerTasks = false; // true or false // animation const scrollSpeed = 40; // milliseconds @@ -12,11 +15,11 @@ const configs = (function () { // STYLES // task list const taskListBackgroundColor = "#000000"; // hex only - const taskListBackgroundOpacity = 0; // 0.0 - 1.0 + const taskListBackgroundOpacity = 1; // 0.0 - 1.0 const taskListBorderWidth = "0px"; // px const taskListBorderColor = "#ffffff"; // hex or name - const taskListBorderRadius = "5px"; // px + const taskListBorderRadius = "0px"; // px const taskListHorizontalPadding = "0px"; // px const taskListVerticalPadding = "0px"; // px @@ -25,12 +28,12 @@ const configs = (function () { const headerHorizontalPadding = "10px"; // px const headerVerticalPadding = "10px"; // px - const headerBackgroundColor = "#000000"; // hex only - const headerBackgroundOpacity = 0.8; // 0.0 - 1.0 + const headerBackgroundColor = "#000"; // hex only + const headerBackgroundOpacity = 1; // 0.0 - 1.0 const headerBorderWidth = "2px"; // px const headerBorderColor = "#ffffff"; // hex or name - const headerBorderRadius = "5px"; // px + const headerBorderRadius = "3px"; // px const headerFontFamily = "Fredoka"; // font name const headerGoogleFont = true; // true: use google font, false: use system font @@ -38,10 +41,10 @@ const configs = (function () { const headerFontSize = "25px"; // px const headerFontWeight = "bold"; // normal or bold or number - const headerFontColor = "#ffffff"; // hex or name + const headerFontColor = "#fff"; // hex or name // body - const bodyBackgroundColor = "#000000"; // hex only + const bodyBackgroundColor = "#fff"; // hex only const bodyBackgroundOpacity = 0; // 0.0 - 1.0 const bodyBorderWidth = "0px"; // px @@ -51,24 +54,24 @@ const configs = (function () { // task const lineHeight = 1.5; // number const usernameFontWeight = "bold"; // normal or bold or number - const usernameColor = "#ffc0cb"; // hex or name or "" for twitch user color + const usernameColor = "pink"; // hex or name or "" for twitch user color const taskWidth = "100%"; - const taskBackgroundColor = "#000000"; // hex only - const taskBackgroundOpacity = 0.7; // 0.0 - 1.0 + const taskBackgroundColor = "#fff"; // hex only + const taskBackgroundOpacity = 0; // 0.0 - 1.0 const taskFontFamily = "Poppins"; // font name const taskGoogleFont = true; // true: use google font, false: use system font const taskFontSize = "20px"; // px - const taskFontColor = "#ffffff"; // hex or name + const taskFontColor = "#fff"; // hex or name - const taskBorderColor = "#000000"; // hex or name + const taskBorderColor = "#fff"; // hex or name const taskBorderWidth = "0px"; // px - const taskBorderRadius = "5px"; // px + const taskBorderRadius = "10px"; // px - const taskMarginBottom = "5px"; // px + const taskMarginBottom = "10px"; // px const taskHorizontalPadding = "20px"; // px const taskVerticalPadding = "10px"; // px @@ -81,6 +84,7 @@ const configs = (function () { "!task", "!add", "!todo", + "!a", ]; // Edit task commands - please add commands in the exact format @@ -90,11 +94,11 @@ const configs = (function () { "!etask", "!edittask", "!edit", + "!e", ]; // Delete task commands - please add commands in the exact format const deleteTaskCommands = [ - "!taskd", "!taskdel", "!taskdelete", "!deltask", @@ -105,6 +109,7 @@ const configs = (function () { "!removetask", "!remove", "!delete", + "!r", ]; // Finish task commands - please add commands in the exact format @@ -120,6 +125,7 @@ const configs = (function () { "!finish", "!done", "!finished", + "!f", ]; // Unfinish task commands - please add commands in the exact format @@ -134,6 +140,7 @@ const configs = (function () { "!undone", "!unfinish", "!unfinished", + "!u", ]; // Check task commands - please add commands in the exact format @@ -250,6 +257,8 @@ const configs = (function () { limit, headerGoogleFont, taskGoogleFont, + modifyLocalStorage, + showOnlyStreamerTasks, }; const styles = { @@ -276,6 +285,7 @@ const configs = (function () { bodyBorderWidth, bodyBorderColor, bodyBorderRadius, + taskWidth, lineHeight, usernameFontWeight, diff --git a/scripts/index.js b/scripts/index.js index 3f2a5f4..e5bbde0 100644 --- a/scripts/index.js +++ b/scripts/index.js @@ -3,17 +3,6 @@ const responses = configs.responses; let params = {}; -function respond(template, params) { - ComfyJS.Say( - template - .replace("{user}", `@${params.user}`) - .replace("{message}", params.message) - .replace("{mentioned}", `@${params.mentioned}`) - .replace("{task}", params.task) - .replace("{originalTask}", params.originalTask) - ); -} - function isMod(flags) { return flags.broadcaster || flags.mod; } @@ -21,205 +10,54 @@ function isMod(flags) { ComfyJS.onCommand = (user, command, message, flags, extra) => { command = `!${command.toLowerCase()}`; - params = { - user: user, - message: message, - mentioned: "", - task: "", - originalTask: "", - }; - if (commands.addTaskCommands.includes(command)) { - let addStatus = addTask(user, extra.userColor, message); - - if (addStatus === 0) { - // limit has reached - respond(responses.noTaskAdded, params); - } else if (addStatus === 1) { - // duplicate task - respond(responses.duplicateTask, params); - } else if (addStatus === 2) { - // task has no content - respond(responses.noTaskContent, params); - } else { - let addResponse = responses.taskAdded; - params.task = addStatus.task; - - if (addStatus.tasksFailedToAdd !== "") { - addResponse += ` | Failed to add task(s): "${addStatus.tasksFailedToAdd}"`; - } - - // task added - respond(addResponse, params); - } + addTask(user, extra.userColor, message); } else if (commands.editTaskCommands.includes(command)) { - let editStatus = editTask(user, message); - - if (editStatus === 0) { - // no task - respond(responses.noTask, params); - } else if (editStatus === 1) { - // invalid input - respond(responses.noTaskEdit, params); - } else { - // task edited - params.task = editStatus[1]; - params.originalTask = editStatus[0]; - respond(responses.taskEdited, params); - } + return editTask(user, message); } else if (commands.deleteTaskCommands.includes(command)) { - let removeStatus = removeTask(user, message); - if (removeStatus === 0) { - // no task - respond(responses.noTask, params); - } else if (removeStatus === 1) { - // invalid input - respond(responses.specifyTaskIndex, params); - } else { - // task deleted - let deletedResponse = responses.taskDeleted; - params.task = removeStatus.removedTasks; - - if (removeStatus.failedTasks !== "") { - deletedResponse += ` | Failed to delete task(s): "${removeStatus.failedTasks}"`; - } - - respond(deletedResponse, params); - } + removeTask(user, message); } else if (commands.finishTaskCommands.includes(command)) { if (message === "all") { - let finishAllStatus = markAllTasksAsDone(user); - - if (finishAllStatus === 0) { - // user has no tasks - respond(responses.noTask, params); - } else { - // all tasks finished - let finishedResponse = responses.allTasksFinished; - - respond(finishedResponse, params); - } - - return; + return markAllTasksAsDone(user); } - let finishStatus = markTaskDone(user, message); - - if (finishStatus === 0) { - // user has no tasks - respond(responses.noTask, params); - } else if (finishStatus === 1) { - // invalid input - respond(responses.specifyTaskIndex, params); - } else { - // task finished - let finishedResponse = responses.taskFinished; - - params.task = finishStatus.markedTasks; - - if (finishStatus.failedTasks !== "") { - finishedResponse += ` | Failed to finish task(s): "${finishStatus.failedTasks}"`; - } - - respond(finishedResponse, params); - } + return markTaskDone(user, message); } else if (commands.unfinishTaskCommands.includes(command)) { - let unfinishStatus = markTaskUndone(user, message); - - if (unfinishStatus === 0) { - // user has no tasks - respond(responses.noTask, params); - } else if (unfinishStatus === 1) { - // invalid input - respond(responses.specifyTaskIndex, params); - } else { - // task unfinished - let unfinishedResponse = responses.taskUnfinished; - - params.task = unfinishStatus.markedTasks; - - if (unfinishStatus.failedTasks !== "") { - unfinishedResponse += ` | Failed to unfinish task(s): "${unfinishStatus.failedTasks}"`; - } - - respond(unfinishedResponse, params); - } - } else if (commands.checkCommands.includes(command)) { - if (message === "") { - let response = checkTasks(user); - if (response === 0) { - return respond(responses.noTask, params); - } - return ComfyJS.Say(response); - } else { - let mentioned = message.replace("@", ""); - let response = checkTasks(mentioned); - if (response === 0) { - // no tasks - return respond(responses.noTaskA, params); - } - return ComfyJS.Say(response); - } + markTaskUndone(user, message); } else if (commands.adminDeleteCommands.includes(command)) { if (!isMod(flags)) { - respond(responses.notMod, params); return; } let mentioned = message.replace("@", ""); if (mentioned === "") { - respond(responses.specifyUser, params); return; } clearUserTasks(mentioned); - - params.mentioned = mentioned; - respond(responses.adminDeleteTasks, params); - return mentioned; } else if (commands.adminClearDoneCommands.includes(command)) { if (!isMod(flags)) { - respond(responses.notMod, params); return; } else { clearAllDoneTasks(); - respond(responses.clearedDone, params); } } else if (commands.adminClearAllCommands.includes(command)) { if (!isMod(flags)) { - respond(responses.notMod, params); return; } else { clearAllTasks(); - respond(responses.clearedAll, params); } } else if (commands.clearMyDoneCommands.includes(command)) { - let response = clearOwnDoneTasks(user); - - if (response === 0) { - // no tasks - respond(responses.noTask, params); - return; - } - - respond(responses.clearedMyDone, params); + clearOwnDoneTasks(user); } else if (commands.adminClearNotStreamerCommands.includes(command)) { - clearAllExceptStreamer(auth.channel); - respond(responses.clearTasksExceptBroadcaster, params); - } else if (commands.helpCommands.includes(command)) { - respond(responses.help, params); - } else if (commands.listCommands.includes(command)) { - let response = listTasks(user); - if (response === 0) { - respond(responses.noTask, params); + if (!isMod(flags)) { return; + } else { + clearAllExceptStreamer(auth.channel); } - ComfyJS.Say(response); - } else if (commands.additionalCommands[command]) { - respond(commands.additionalCommands[command], params); - } else { - // command not found } }; -ComfyJS.Init(auth.username, `oauth:${auth.oauth}`, [auth.channel]); +if (configs.settings.modifyLocalStorage) { + ComfyJS.Init(auth.username, `oauth:${auth.oauth}`, [auth.channel]); +} diff --git a/scripts/taskList.js b/scripts/taskList.js index 965d2c6..0ba1771 100644 --- a/scripts/taskList.js +++ b/scripts/taskList.js @@ -262,7 +262,9 @@ function removeTask(username, task) { if (isInt(t)) { index = parseInt(t) - 1; // ACTUAL INDEX } else if (incompleteTasks.length === 1) { - index = tasks[username].todos.findIndex((t) => !t.done); + index = tasks[username].todos.findIndex( + (t) => !t.done + ); tasksRemoved.push(tasks[username].todos[index].text); removedTaskIndex.push(index); } else { @@ -401,8 +403,12 @@ function markTaskDone(username, task) { if (isInt(t)) { index = parseInt(t) - 1; // ACTUAL INDEX } else if (incompleteTasks.length === 1) { - index = tasks[username].todos.findIndex((t) => !t.done); - tasksMarkedComplete.push(tasks[username].todos[index].text); + index = tasks[username].todos.findIndex( + (t) => !t.done + ); + tasksMarkedComplete.push( + tasks[username].todos[index].text + ); } else { tasksFailedToComplete.push(t); continue; @@ -412,7 +418,9 @@ function markTaskDone(username, task) { tasksFailedToComplete.push(t); continue; } else { - tasksMarkedComplete.push(tasks[username].todos[index].text); + tasksMarkedComplete.push( + tasks[username].todos[index].text + ); } } else { tasksMarkedComplete.push(tasks[username].todos[index].text); @@ -526,7 +534,9 @@ function markTaskUndone(username, task) { tasksFailedToMarkUndone.push(t); continue; } else { - tasksMarkedUndone.push(tasks[username].todos[index].text); + tasksMarkedUndone.push( + tasks[username].todos[index].text + ); } } else { tasksMarkedUndone.push(tasks[username].todos[index].text); @@ -775,7 +785,7 @@ function clearAllExceptStreamer(streamer) { } function renderTaskListToDOM() { - const tasks = JSON.parse(localStorage.tasks); + let tasks = JSON.parse(localStorage.tasks); const taskContainers = document.querySelectorAll(".task-container"); taskContainers.forEach((taskList) => { @@ -783,6 +793,17 @@ function renderTaskListToDOM() { let totalTaskCount = 0; let completedTasksCount = 0; + + if (settings.showOnlyStreamerTasks) { + // filter out tasks that are not from the streamer + tasks = Object.keys(tasks).reduce((obj, key) => { + if (key.toLowerCase() === auth.channel.toLowerCase()) { + obj[key] = tasks[key]; + } + return obj; + }, {}); + } + for (const user in tasks) { const userTasks = tasks[user]; if (userTasks.todos.length === 0) { @@ -954,7 +975,7 @@ function cancelAnimation() { secondaryAnimation.cancel(); } scrolling = false; - console.log("animation cancelled"); + // console.log("animation cancelled"); } (function () { diff --git a/styles/taskList.css b/styles/taskList.css index 50f4a88..5cf1b9d 100644 --- a/styles/taskList.css +++ b/styles/taskList.css @@ -43,10 +43,6 @@ box-sizing: border-box; } -body { - background-color: gray; -} - #main-container { width: 100%; height: 100vh;