Untitled

mail@pastecode.io avatar
unknown
javascript
9 days ago
1.1 kB
3
Indexable
Never
$('#add-task-btn').on('click', function() {
    let taskText = $('#new-task').val();
    let deadline = $('#deadline').val();
    if (taskText === "" || deadline === "") return;

    let taskItem = $('<li></li>');
    taskItem.html(`<input type="checkbox"> ${taskText} <span class="deadline">[Rok: ${deadline}]</span> <button class="delete-btn">Obriši</button>`);
    $('#task-list').append(taskItem);
    $('#new-task').val('');
    $('#deadline').val('');

    // Označavanje završenih zadataka
    taskItem.find('input[type="checkbox"]').on('change', function() {
        taskItem.toggleClass('completed');
    });

    // Brisanje zadatka
    taskItem.find('.delete-btn').on('click', function() {
        taskItem.remove();
    });

    // Provjera rokova
    setInterval(function() {
        let currentTime = new Date().toISOString();
        if (currentTime > deadline && !taskItem.hasClass('completed')) {
            taskItem.addClass('overdue');
        }
    }, 1000);
});

// CSS za overdue zadatke
$('.overdue').css('border', '2px solid red');
Leave a Comment