Skip to content

Commit 873326c

Browse files
Create app.js
Pew pew pew! KittyTasker now has a JavaScript file! Starting off with basic DOM integration, but their'll be more later!
1 parent 513379e commit 873326c

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

app.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* KittyTasker - A cute and useful to-do list app for cat lovers!
3+
*
4+
* This JavaScript file contains the funcationality for the KittyTasker to-do list app!
5+
* It allows users to create, mark complete and delete tasks.
6+
*/
7+
8+
console.log('KittyTasker app intitalises now!');
9+
10+
// Global variables for application state
11+
var tasks = [];
12+
var currentFilter = "all";
13+
14+
// Global variables for DOM elements
15+
var taskForm;
16+
var taskInput;
17+
var taskPriority;
18+
var taskDate;
19+
var taskList;
20+
var itemsLeft;
21+
var filterButtons;
22+
23+
// Updates the document title with task count
24+
function updateDocumentTitle () {
25+
document.title = "KittyTasker - " + tasks.length + " Tasks";
26+
}
27+
28+
// Intitalise the application
29+
function initApp() {
30+
console.log('Intialising KittyTasker app.');
31+
32+
// Select form elements
33+
taskForm = document.getElementById('task-form');
34+
taskInput = document.getElementById('task-input');
35+
taskPriority = document.getElementById('task-priority');
36+
taskDate = document.getElementById('task-date');
37+
38+
// Select task list elements
39+
taskList = document.getElementById('task-list');
40+
itemsLeft = document.getElementById('items-left');
41+
42+
// Select filter buttons
43+
filterButtons = document.querySelectorAll('.filter-btn');
44+
45+
// Log elements to verify selections
46+
console.log('Form element:', taskForm);
47+
console.log('Filter buttons:', filterButtons);
48+
49+
// Update the document title
50+
updateDocumentTitle();
51+
52+
console.log('KittyTasker app intialised');
53+
}
54+
55+
// Intialise when DOM is loaded
56+
document.addEventListener('DOMContentLoaded', initApp);

0 commit comments

Comments
 (0)