(function($){

    // define the class
    var PostmanOffice365 = function() {

    }

    // behavior for handling the user's transport change
    PostmanOffice365.prototype.handleTransportChange = function(transportName) {
        if (transportName == 'zohomail_api') {
            hide('div.transport_setting');
            hide('div.authentication_setting');
            show('div#zohomail_settings');
        }
    }

    // behavior for handling the wizard configuration from the
    // server (after the port test)
    PostmanOffice365.prototype.handleConfigurationResponse = function(response) {
        var transportName = response.configuration.transport_type;
        if (transportName == 'zohomail_api') {
            show('section.wizard_office365');
        } else {
            hide('section.wizard_office365');
        }
    }

    // add this class to the global transports
    var transport = new PostmanOffice365();
    transports.push(transport);

    // since we are initialize the screen, check if needs to be modded by this
    // transport
    var transportName = jQuery('select#input_transport_type').val();
    transport.handleTransportChange(transportName);

})(jQuery)

function copyRedirectURI( btn ) {
    var copyText = document.getElementById("psses-redirect-uri");
    const textArea = document.createElement("textarea");
    textArea.value = copyText.value;
    document.body.appendChild(textArea);
    textArea.focus();
    textArea.select();
    document.execCommand('copy');
    document.body.removeChild(textArea);
    btn.children[0].innerHTML = "Copied";
    
    setTimeout(function() {
        btn.children[0].innerHTML = "";
    }, 1500);
}