-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathapp.js
More file actions
92 lines (76 loc) · 3.35 KB
/
Copy pathapp.js
File metadata and controls
92 lines (76 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Main application logic
console.log("app.js loaded");
// Sem imports - os componentes são carregados diretamente pelo HTML
document.addEventListener('DOMContentLoaded', () => {
// Inicialização dos componentes
// Verifica se cada componente foi inicializado corretamente
if (typeof initTodoList === 'function' && !window.todoListInitialized) {
initTodoList();
window.todoListInitialized = true;
}
if (typeof initPomodoroTimer === 'function' && !window.pomodoroTimerInitialized) {
initPomodoroTimer();
window.pomodoroTimerInitialized = true;
}
if (typeof initMediaEmbed === 'function' && !window.mediaEmbedInitialized) {
initMediaEmbed();
window.mediaEmbedInitialized = true;
}
// Contador de tarefas
updateTasksCounter();
// Theme Toggler Logic
const themeToggleButton = document.getElementById('theme-toggle');
if (themeToggleButton) {
const currentTheme = localStorage.getItem('focusOnTheme') || 'light';
document.body.classList.toggle('dark-mode', currentTheme === 'dark');
themeToggleButton.addEventListener('click', () => {
document.body.classList.toggle('dark-mode');
const theme = document.body.classList.contains('dark-mode') ? 'dark' : 'light';
localStorage.setItem('focusOnTheme', theme);
});
}
// Toggle para mostrar/esconder o campo de entrada de tarefas
const addTaskButton = document.getElementById('show-add-task');
const taskInputContainer = document.getElementById('task-input');
if (addTaskButton && taskInputContainer) {
addTaskButton.addEventListener('click', () => {
taskInputContainer.classList.toggle('active');
if (taskInputContainer.classList.contains('active')) {
document.getElementById('task').focus();
}
});
}
});
// Função para atualizar o contador de tarefas
function updateTasksCounter() {
const tasksCounter = document.getElementById('tasks-count');
const tasksList = document.getElementById('tasks');
if (tasksCounter && tasksList) {
// Ignorar a mensagem de "nenhuma tarefa" na contagem
const emptyMessage = tasksList.querySelector('.empty-tasks-message');
const totalTasks = emptyMessage ? 0 : tasksList.children.length;
const completedTasks = tasksList.querySelectorAll('.completed').length;
tasksCounter.textContent = totalTasks === 0
? 'Nenhuma tarefa'
: totalTasks === 1
? '1 tarefa'
: `${totalTasks} tarefas (${completedTasks} completas)`;
}
}
// Função global para ser chamada do todoList.js quando tarefas são atualizadas
window.updateTasksCounter = updateTasksCounter;
// Função para alternar para o tema Harry Potter
function toggleHarryPotterTheme() {
const body = document.body;
if (body.classList.contains('hp-theme')) {
body.classList.remove('hp-theme');
} else {
body.classList.add('hp-theme');
}
}
// Adicionando botão para alternar tema Harry Potter
const hpThemeButton = document.createElement('button');
hpThemeButton.textContent = '⚡ Tema Harry Potter';
hpThemeButton.classList.add('theme-toggle', 'hp-theme');
hpThemeButton.addEventListener('click', toggleHarryPotterTheme);
document.body.appendChild(hpThemeButton);