scripts/aiv_ui.js
/**
     * @function effectorDropdownSelect2 - UI functionality for adding the dropdown list of effectors in our database
     */
@function effectorDropdownSelect2 - UI functionality for adding the dropdown list of effectors in our database
@function effectorDropdownSelect2 - UI functionality for adding the dropdown list of effectors in our database
function effectorDropdownSelect2() {
        $.ajax({
            url: "//bar.utoronto.ca/interactions2/cgi-bin/get_effectors.php",
            type: "GET"
        })
            .then((res)=>{
                if (res.status === "success"){
                    let effectorSelect$ = $('#effectorSelect');
                    effectorSelect$.empty();
                    for (let i = 0; i < res.data.length; i++){
                        let option = res.data[i];
                        let element = document.createElement('option');
                        element.textContent = option;
                        element.value = option;
                        document.getElementById('effectorSelect').appendChild(element);
                    }
                    effectorSelect$.select2({
                        dropdownParent: $('#formModal')
                    });
                    document.getElementById('addEffectorButton').addEventListener('click', function(e){
                        let latestFormEntry = document.getElementById('genes').value.split('\n').pop();
                        console.log(latestFormEntry);
                        if (latestFormEntry.match(/^AT[1-5MC]G\d{5}$/i) || res.data.indexOf(latestFormEntry) >= 0){
                            document.getElementById('genes').value += "\n" + effectorSelect$.val();
                        }
                        else if (latestFormEntry === "\n" || latestFormEntry === ""){
                            document.getElementById('genes').value += effectorSelect$.val();
                        }
                        else{
                            $('#formErrorModal').modal('show');
                        }
                    });
                }
                else {
                    throw new Error('loading effectors failed');
                }
            })
            .catch((err)=>{
                document.getElementById('loadingEffectors').innerText = "Error loading effectors";
            });
    }
function effectorDropdownSelect2 ( ) { $ . ajax ( { url : "//bar.utoronto.ca/interactions2/cgi-bin/get_effectors.php" , type : "GET" } ) . then ( ( res ) => { if ( res . status === "success" ) { let effectorSelect$ = $ ( '#effectorSelect' ) ; effectorSelect$ . empty ( ) ; for ( let i = 0 ; i < res . data . length ; i ++ ) { let option = res . data [ i ] ; let element = document . createElement ( 'option' ) ; element . textContent = option ; element . value = option ; document . getElementById ( 'effectorSelect' ) . appendChild ( element ) ; } effectorSelect$ . select2 ( { dropdownParent : $ ( '#formModal' ) } ) ; document . getElementById ( 'addEffectorButton' ) . addEventListener ( 'click' , function ( e ) { let latestFormEntry = document . getElementById ( 'genes' ) . value . split ( '\n' ) . pop ( ) ; console . log ( latestFormEntry ) ; if ( latestFormEntry . match ( / ^AT[1-5MC]G\d{5}$ / i ) || res . data . indexOf ( latestFormEntry ) >= 0 ) { document . getElementById ( 'genes' ) . value += "\n" + effectorSelect$ . val ( ) ; } else if ( latestFormEntry === "\n" || latestFormEntry === "" ) { document . getElementById ( 'genes' ) . value += effectorSelect$ . val ( ) ; } else { $ ( '#formErrorModal' ) . modal ( 'show' ) ; } } ) ; } else { throw new Error ( 'loading effectors failed' ) ; } } ) . catch ( ( err ) => { document . getElementById ( 'loadingEffectors' ) . innerText = "Error loading effectors" ; } ) ; }
@function effectorDropdownSelect2 - UI functionality for adding the dropdown list of effectors in our database
@function effectorDropdownSelect2 - UI functionality for adding the dropdown list of effectors in our database