acceptsuiteservice/WebApp/assets/js/accept-suite/app.js
//Below function gets executed when user clicks on any of the 4 product types in dashboard page
Below function gets executed when user clicks on any of the 4 product types in dashboard page
Below function gets executed when user clicks on any of the 4 product types in dashboard page
function loadpage() {
    var pageurl = window.location.href,
        customerId = "",
        customerValidation = {},
        product = '',
        customerIdValidationStatus = false;
    elements = document.getElementsByClassName('productCont');
    Array.prototype.forEach.call(elements, function (element) {
        element.style.display = 'none';
    });
    product = getParameterByName('producttype', window.location.href.toLowerCase());
    if (pageurl.toLowerCase().indexOf('?producttype=') > 0) {
        if (product === 'acceptjs') {
            activeCont = 'acceptjs';
            checkForInvalidProduct(pageurl);
        } else if (product === 'acceptui') {
            activeCont = 'acceptui';
            checkForInvalidProduct(pageurl);
        } else if (product === 'accepthosted') { 
            if (pageurl.toLowerCase().indexOf('&') > 0) {
                if (pageurl.toLowerCase().indexOf('&customerid=') > 0) {
                    customerId = getParameterByName('customerid', window.location.href.toLowerCase());
                    customerValidation = validateCustomer(customerId);
                    if (customerValidation.valid) {
                        acceptHosted(customerId);
                    } else {
                        isInvalidCustomer();
                    }
                } else { 
                    checkForInvalidProduct('');
                }
            } else {
                acceptHosted('');
            }
        } else if (product === 'acceptcustomer') { 
            document.getElementById('txtCustomerId').value = globalVars.ValidCustomer;
            if (pageurl.toLowerCase().indexOf('&customerid=') > 0) {
                document.getElementById('acceptCustomer').style.display = 'none';
                customerId = getParameterByName('customerid', window.location.href.toLowerCase());
                customerIdValidationStatus = sessionStorage.getItem('isValidated');
                if (customerIdValidationStatus !== 'true') {
                    customerValidation = validateCustomer(customerId);
                    if (customerValidation.valid) {
                        acceptCustomer(customerId);
                    } else {
                        isInvalidCustomer();
                    }
                } else { 
                    acceptCustomer(customerId);
                    sessionStorage.setItem('isValidated', 'false');
                }
            } else {
                document.getElementById('acceptCustomer').style.display = 'block';
            }
        } else {
            checkForInvalidProduct('');
        }
    } else {
        if (document.getElementById('invalidPage') !== null) {
            checkForInvalidProduct('');
        }
    }
}
function loadpage ( ) { var pageurl = window . location . href , customerId = "" , customerValidation = { } , product = '' , customerIdValidationStatus = false ; elements = document . getElementsByClassName ( 'productCont' ) ; Array . prototype . forEach . call ( elements , function ( element ) { element . style . display = 'none' ; } ) ; product = getParameterByName ( 'producttype' , window . location . href . toLowerCase ( ) ) ; if ( pageurl . toLowerCase ( ) . indexOf ( '?producttype=' ) > 0 ) { if ( product === 'acceptjs' ) { activeCont = 'acceptjs' ; checkForInvalidProduct ( pageurl ) ; } else if ( product === 'acceptui' ) { activeCont = 'acceptui' ; checkForInvalidProduct ( pageurl ) ; } else if ( product === 'accepthosted' ) { if ( pageurl . toLowerCase ( ) . indexOf ( '&' ) > 0 ) { if ( pageurl . toLowerCase ( ) . indexOf ( '&customerid=' ) > 0 ) { customerId = getParameterByName ( 'customerid' , window . location . href . toLowerCase ( ) ) ; customerValidation = validateCustomer ( customerId ) ; if ( customerValidation . valid ) { acceptHosted ( customerId ) ; } else { isInvalidCustomer ( ) ; } } else { checkForInvalidProduct ( '' ) ; } } else { acceptHosted ( '' ) ; } } else if ( product === 'acceptcustomer' ) { document . getElementById ( 'txtCustomerId' ) . value = globalVars . ValidCustomer ; if ( pageurl . toLowerCase ( ) . indexOf ( '&customerid=' ) > 0 ) { document . getElementById ( 'acceptCustomer' ) . style . display = 'none' ; customerId = getParameterByName ( 'customerid' , window . location . href . toLowerCase ( ) ) ; customerIdValidationStatus = sessionStorage . getItem ( 'isValidated' ) ; if ( customerIdValidationStatus !== 'true' ) { customerValidation = validateCustomer ( customerId ) ; if ( customerValidation . valid ) { acceptCustomer ( customerId ) ; } else { isInvalidCustomer ( ) ; } } else { acceptCustomer ( customerId ) ; sessionStorage . setItem ( 'isValidated' , 'false' ) ; } } else { document . getElementById ( 'acceptCustomer' ) . style . display = 'block' ; } } else { checkForInvalidProduct ( '' ) ; } } else { if ( document . getElementById ( 'invalidPage' ) !== null ) { checkForInvalidProduct ( '' ) ; } } }
Below function gets executed when user clicks on any of the 4 product types in dashboard page
Below function gets executed when user clicks on any of the 4 product types in dashboard page
//On page load, the content of all the 4 product types is disabled //Below line reads the product type selected by the user in dashboard page //If the user clicks Accept.js product type in the dashboard page, the following code gets executed. //The product type selected by the user in the dashboard page is assigned to the activeCont variable which is used for future reference //Below function checks if customer ID is passed in the request URL //If the user clicks Accept.js UI product type in the dashboard page, the following code gets executed //The product type selected by the user in the dashboard page is assigned to the activeCont variable which is used for future reference //Below function checks if customer ID is passed in the request URL //If the user clicks Accept Hosted product type in the dashboard page, the following code gets executed. //Below logic is to check if there are more than one parameter passed in the URL //Customer ID is an optional parameter for Accept Hosted product type //Below code gets executed when the user passes customer id in the request URL //Validation of customer id will be done by using the below function //If the customer id is a valid id, then AcceptHosted function gets executed //If the invalid customer id declared in the URL, then user gets redirected to the error message section //Below code gets executed when the user passes when there are more than one parameters (other than customer id) which are invalid in the request URL //Below code gets executed when user passes invalid parameters in the URL //When customer id parameter is not passed in the URL, AcceptHosted function gets executed //If the user clicks Accept Customer product type in the dashboard page, the following code gets executed. //Below line populates the customer id textbox with a valid customer id //Below code gets executed when the user passes customer id in the request URL //Below line gets the customer id declared in the url by the user //Below function checks if the customer id is already validated or not //Customer id validaton occurs on click of continue button in dashboard and on accept customer page load //In order to avoid multiple validation requests to API, storing the validation status in the session storage //If customer id is not validated //Validation of customer id will be done by using the below function //If the customer id is a valid id, then AcceptCustomer function gets executed //If the invalid customer id declared in the URL, then user gets redirected to the error message section //If customer id is already validated in dashboard page //If customer id is not provided in the URL, a pop up to enter customer id is displayed. //Below code gets executed when user passes invalid product type parameters in the URL //Below code gets executed when user passes invalid product type parameters in the URL