list tasks command, fixed gapbetweenscrolls
This commit is contained in:
parent
740230840c
commit
44ab279ab3
3 changed files with 55 additions and 7 deletions
10
configs.js
10
configs.js
|
|
@ -6,9 +6,8 @@ const configs = (function () {
|
|||
const limit = 5; // integer
|
||||
|
||||
// animation
|
||||
const scrollSpeed = 30; // milliseconds
|
||||
const pauseBetweenScrolls = 2000; // milliseconds
|
||||
const gapBetweenScrolls = "50px"; // px
|
||||
const scrollSpeed = 40; // milliseconds
|
||||
const gapBetweenScrolls = 100; // px
|
||||
|
||||
// STYLES
|
||||
// task list
|
||||
|
|
@ -150,6 +149,9 @@ const configs = (function () {
|
|||
"!check",
|
||||
];
|
||||
|
||||
// List tasks commands - please add commands in the exact format
|
||||
const listCommands = ["!taskl", "!tasklist", "!listtasks", "!list"];
|
||||
|
||||
// Clear my done commands - please add commands in the exact format
|
||||
const clearMyDoneCommands = ["!clearmydone"];
|
||||
|
||||
|
|
@ -298,7 +300,6 @@ const configs = (function () {
|
|||
|
||||
const animation = {
|
||||
scrollSpeed,
|
||||
pauseBetweenScrolls,
|
||||
gapBetweenScrolls,
|
||||
titles,
|
||||
};
|
||||
|
|
@ -311,6 +312,7 @@ const configs = (function () {
|
|||
unfinishTaskCommands,
|
||||
helpCommands,
|
||||
checkCommands,
|
||||
listCommands,
|
||||
clearMyDoneCommands,
|
||||
adminDeleteCommands,
|
||||
adminClearNotStreamerCommands,
|
||||
|
|
|
|||
|
|
@ -173,6 +173,7 @@ ComfyJS.onCommand = (user, command, message, flags, extra) => {
|
|||
}
|
||||
|
||||
clearUserTasks(mentioned);
|
||||
|
||||
params.mentioned = mentioned;
|
||||
respond(responses.adminDeleteTasks, params);
|
||||
return mentioned;
|
||||
|
|
@ -207,6 +208,13 @@ ComfyJS.onCommand = (user, command, message, flags, extra) => {
|
|||
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);
|
||||
return;
|
||||
}
|
||||
ComfyJS.Say(response);
|
||||
} else if (commands.additionalCommands[command]) {
|
||||
respond(commands.additionalCommands[command], params);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -678,6 +678,36 @@ function checkTasks(username) {
|
|||
return reply;
|
||||
}
|
||||
|
||||
// 0: user has no tasks
|
||||
function listTasks(username) {
|
||||
const tasks = JSON.parse(localStorage.tasks);
|
||||
if (!tasks[username]) {
|
||||
return 0;
|
||||
}
|
||||
// filter completed tasks
|
||||
const incompleteTasks = tasks[username].todos.filter((t) => !t.done);
|
||||
|
||||
if (incompleteTasks.length === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// format incomplete tasks into string: 1. task 1 | 2. task 2 | 3. task 3...
|
||||
let reply = `@${username} `;
|
||||
let taskIndex;
|
||||
for (let i = 0; i < incompleteTasks.length; i++) {
|
||||
// get index of task by task name
|
||||
taskIndex =
|
||||
tasks[username].todos.findIndex(
|
||||
(t) =>
|
||||
t.text.toLowerCase() ===
|
||||
incompleteTasks[i].text.toLowerCase()
|
||||
) + 1;
|
||||
reply += `${incompleteTasks[i].text}, `;
|
||||
}
|
||||
reply = reply.slice(0, -2);
|
||||
return reply;
|
||||
}
|
||||
|
||||
function incompleteTasksCount(username) {
|
||||
const tasks = JSON.parse(localStorage.tasks);
|
||||
if (!tasks[username]) {
|
||||
|
|
@ -686,11 +716,18 @@ function incompleteTasksCount(username) {
|
|||
return tasks[username].todos.filter((t) => !t.done).length;
|
||||
}
|
||||
|
||||
// 0: user has no tasks
|
||||
function clearUserTasks(username) {
|
||||
const tasks = JSON.parse(localStorage.tasks);
|
||||
if (!tasks[username]) {
|
||||
return;
|
||||
// find username where lowercase matches username
|
||||
username = Object.keys(tasks).find(
|
||||
(user) => user.toLowerCase() === username.toLowerCase()
|
||||
);
|
||||
|
||||
if (!username) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
tasks[username].todos = [];
|
||||
|
||||
localStorage.setItem(`tasks`, JSON.stringify(tasks));
|
||||
|
|
@ -842,7 +879,8 @@ async function checkToAnimate() {
|
|||
if (!scrolling) {
|
||||
document.querySelector(".secondary").style.display = "flex";
|
||||
|
||||
let finalHeight = taskContainerHeight + 100;
|
||||
let finalHeight =
|
||||
taskContainerHeight + configs.animation.gapBetweenScrolls;
|
||||
|
||||
let primaryKeyFrames = [
|
||||
{ transform: `translateY(0)` },
|
||||
|
|
|
|||
Loading…
Reference in a new issue