task.js
// Get the data from the planner page
Get the data from the planner page
Get the data from the planner page
function taskPage() {
    chrome.storage.sync.get(['new_task_lesson'], function (items) {
        if ('new_task_lesson' in items) {
            var lesson = items["new_task_lesson"];
            lesson.start = new Date(lesson.startstr);
            lesson.end = new Date(lesson.endstr);
            console.log(lesson);
            var deleted = false;
            console.log(document.title)
            if (document.title.includes("TaskNotFoundException")) {
                deleted = true;
            } else {
                var messages = $(".ff_module-form-completed__message");
                for (index = 0; index < messages.length; ++index) {
                    var message = messages[index];
                    console.log(message.innerText)
                    if (message.innerText === "This task has been deleted") {
                        deleted = true;
                    }
                }
            }
            if (!deleted) {
                chrome.storage.sync.remove(['new_task_lesson']);
                var waitForDeleteButton = setInterval(function(){
                    if( $( ".ReactModalPortal" ).length ){
                        $( ".ReactModalPortal" ).find( "button[data-testid='discard']").click(  { "lesson" : lesson } ,onDiscardButton );
                        clearInterval(waitForDeleteButton) ;
                    }
                }, 500);
                prime_data_fields(lesson);
            } else {
                removeLessonLink(lesson);
                window.close();
            }
        }
    });
}
function taskPage ( ) { chrome . storage . sync . get ( [ 'new_task_lesson' ] , function ( items ) { if ( 'new_task_lesson' in items ) { var lesson = items [ "new_task_lesson" ] ; lesson . start = new Date ( lesson . startstr ) ; lesson . end = new Date ( lesson . endstr ) ; console . log ( lesson ) ; var deleted = false ; console . log ( document . title ) if ( document . title . includes ( "TaskNotFoundException" ) ) { deleted = true ; } else { var messages = $ ( ".ff_module-form-completed__message" ) ; for ( index = 0 ; index < messages . length ; ++ index ) { var message = messages [ index ] ; console . log ( message . innerText ) if ( message . innerText === "This task has been deleted" ) { deleted = true ; } } } if ( ! deleted ) { chrome . storage . sync . remove ( [ 'new_task_lesson' ] ) ; var waitForDeleteButton = setInterval ( function ( ) { if ( $ ( ".ReactModalPortal" ) . length ) { $ ( ".ReactModalPortal" ) . find ( "button[data-testid='discard']" ) . click ( { "lesson" : lesson } , onDiscardButton ) ; clearInterval ( waitForDeleteButton ) ; } } , 500 ) ; prime_data_fields ( lesson ) ; } else { removeLessonLink ( lesson ) ; window . close ( ) ; } } } ) ; }
Get the data from the planner page
Get the data from the planner page
//check that this task exists // delete this temp data //add button behaviour //fill in the data we have from the planner //delete the task