JavaScript controller pattern



  • You're probably familiar with the MVC pattern. It's a good fit for most webapps, but what do you do when you want to redirect to different web frameworks with the same controller? If you're this major bank, you write a JavaScript function.

    Have to think this has something to do with the slow login. Just clocked 42 seconds from login to page rendering on a decent connection.

    function doLogin() {
    var f = document.forms[0];
    var dd = f['objContent0_ctl05_loginOption'];

        switch (dd.options[dd.selectedIndex].value) {
            
            case 'pf':
                if (window.dcsMultiTrack) dcsMultiTrack('DCS.dcsuri', '/onlinebanking/login.asp', 'WT.ti', 'Online Banking Login');
                window.location.href = 'https://www.citizensbankonline.com';
                break;
                
            case 'cs':
                if (window.dcsMultiTrack) dcsMultiTrack('DCS.dcsuri', '/onlinebanking/login.asp', 'WT.ti', 'Online Banking Login');
                window.location.href = 'https://www.citizensbankmoneymanagergps.com';
                break;
                
            case 'cc':window.location.href = 'https://www.accessmycardonline.com/RBS_Consumer/SecuredLogin.do?promoCode=CTZ';
                break;
                
            case 'mor':window.location.href = 'https://carenet.fnfismd.com/cco/ACCLogin.jsp';
                break;
                
            case 'sl':window.location.href = '/student-services/access-my-student-loan/';
                break;
                
            case '401k':
                if (window.dcsMultiTrack) dcsMultiTrack('DCS.dcsuri', '/onlinebanking/login.asp', 'WT.ti', 'Online Banking Login');
                window.location.href = '/401K_notice.aspx';
                break;
                
            case 'bk':window.location.href = 'https://www.mystreetscape.com/my/citizensinvest';
                break;
                
            case 'ctp':window.location.href = '/customer-service/pay-my-loan.aspx';
                break;
                
        }
    }
    function doLoginHelper(action) {
        if (window.dcsMultiTrack) dcsMultiTrack('DCS.dcsuri', '/onlinebanking/login.asp', 'WT.ti', 'Online Banking Login');
    
        var f = document.forms[0];
        var dd = f['objContent0_ctl05_loginOption'];
        switch (dd.options[dd.selectedIndex].value) {
            
    
            case 'pf':
                if (window.dcsMultiTrack) dcsMultiTrack('DCS.dcsuri', '/onlinebanking/login.asp', 'WT.ti', 'Online Banking Login');
                
                switch (action) {
                    case 'enroll':
                        window.location.href = 'https://www.citizensbankonline.com/efs/servlet/efs/default-enroll.jsp?BrandSettingsFile=citSettings.jsp';
                        break;
                    case 'LoginTrouble':
                        window.location.href = 'https://www.citizensbankonline.com/efs/servlet/efs/login-assistance.jsp';
                        break;
                }
    
                
    
                break;
                
    
            case 'cs':
                if (window.dcsMultiTrack) dcsMultiTrack('DCS.dcsuri', '/onlinebanking/login.asp', 'WT.ti', 'Online Banking Login');
                
    
                window.location.href = 'https://www.citizensbankmoneymanagergps.com';
                
    
                break;
                
    
            case 'cc':
    
                window.location.href = 'https://www.accessmycardonline.com/RBS_Consumer/SecuredLogin.do?promoCode=CTZ';
                
    
                break;
                
    
            case 'mor':
    
                window.location.href = 'https://carenet.fnfismd.com/cco/ACCLogin.jsp';
                
    
                break;
                
    
            case 'sl':
    
                window.location.href = '/student-services/access-my-student-loan/';
                
    
                break;
                
    
            case '401k':
                if (window.dcsMultiTrack) dcsMultiTrack('DCS.dcsuri', '/onlinebanking/login.asp', 'WT.ti', 'Online Banking Login');
                
    
                window.location.href = '/401K_notice.aspx';
                
    
                break;
                
    
            case 'bk':
    
                window.location.href = 'https://www.mystreetscape.com/my/citizensinvest';
                
    
                break;
                
    
            case 'ctp':
    
                window.location.href = '/customer-service/pay-my-loan.aspx';
                
    
                break;
                
               
        }


  • Fixed this for you:

       function doLogin() {
            var f = document.forms[0];
            var dd = f['objContent0_ctl05_loginOption'];
    
            switch (dd.options[dd.selectedIndex].value) {
                
                case 'pf':
                    if (window.dcsMultiTrack) dcsMultiTrack('DCS.dcsuri', '/onlinebanking/login.asp', 'WT.ti', 'Online Banking Login');
                    window.location.href = 'https://www.citizensbankonline.com';
    	            break;
    	            
                case 'cs':
                    if (window.dcsMultiTrack) dcsMultiTrack('DCS.dcsuri', '/onlinebanking/login.asp', 'WT.ti', 'Online Banking Login');
                    window.location.href = 'https://www.citizensbankmoneymanagergps.com';
    	            break;
    	            
                case 'cc':window.location.href = 'https://www.accessmycardonline.com/RBS_Consumer/SecuredLogin.do?promoCode=CTZ';
    	            break;
    	            
                case 'mor':window.location.href = 'https://carenet.fnfismd.com/cco/ACCLogin.jsp';
    	            break;
    	            
                case 'sl':window.location.href = '/student-services/access-my-student-loan/';
    	            break;
    	            
                case '401k':
                    if (window.dcsMultiTrack) dcsMultiTrack('DCS.dcsuri', '/onlinebanking/login.asp', 'WT.ti', 'Online Banking Login');
                    window.location.href = '/401K_notice.aspx';
    	            break;
    	            
                case 'bk':window.location.href = 'https://www.mystreetscape.com/my/citizensinvest';
    	            break;
    	            
                case 'ctp':window.location.href = '/customer-service/pay-my-loan.aspx';
    	            break;
    	            
            }
        }
        function doLoginHelper(action) {
            if (window.dcsMultiTrack) dcsMultiTrack('DCS.dcsuri', '/onlinebanking/login.asp', 'WT.ti', 'Online Banking Login');
    
            var f = document.forms[0];
            var dd = f['objContent0_ctl05_loginOption'];
            switch (dd.options[dd.selectedIndex].value) {
                
    
                case 'pf':
                    if (window.dcsMultiTrack) dcsMultiTrack('DCS.dcsuri', '/onlinebanking/login.asp', 'WT.ti', 'Online Banking Login');
                    
                    switch (action) {
                        case 'enroll':
                            window.location.href = 'https://www.citizensbankonline.com/efs/servlet/efs/default-enroll.jsp?BrandSettingsFile=citSettings.jsp';
                            break;
                        case 'LoginTrouble':
                            window.location.href = 'https://www.citizensbankonline.com/efs/servlet/efs/login-assistance.jsp';
                            break;
                    }
    
                    
    
                    break;
                    
    
                case 'cs':
                    if (window.dcsMultiTrack) dcsMultiTrack('DCS.dcsuri', '/onlinebanking/login.asp', 'WT.ti', 'Online Banking Login');
                    
    
                    window.location.href = 'https://www.citizensbankmoneymanagergps.com';
                    
    
                    break;
                    
    
                case 'cc':
    
                    window.location.href = 'https://www.accessmycardonline.com/RBS_Consumer/SecuredLogin.do?promoCode=CTZ';
                    
    
                    break;
                    
    
                case 'mor':
    
                    window.location.href = 'https://carenet.fnfismd.com/cco/ACCLogin.jsp';
                    
    
                    break;
                    
    
                case 'sl':
    
                    window.location.href = '/student-services/access-my-student-loan/';
                    
    
                    break;
                    
    
                case '401k':
                    if (window.dcsMultiTrack) dcsMultiTrack('DCS.dcsuri', '/onlinebanking/login.asp', 'WT.ti', 'Online Banking Login');
                    
    
                    window.location.href = '/401K_notice.aspx';
                    
    
                    break;
                    
    
                case 'bk':
    
                    window.location.href = 'https://www.mystreetscape.com/my/citizensinvest';
                    
    
                    break;
                    
    
                case 'ctp':
    
                    window.location.href = '/customer-service/pay-my-loan.aspx';
                    
    
                    break;
                    
                   
            }

  • Discourse touched me in a no-no place

    @cmccormick said:

    You're probably familiar with the MVC pattern. It's a good fit for most webapps, but what do you do when you want to redirect to different web frameworks with the same controller? If you're this major bank, you write a JavaScript function.

    Have to think this has something to do with the slow login. Just clocked 42 seconds from login to page rendering on a decent connection.

    So, either they're loading things from lots of different sites (or one site that DNS is having problems looking up), or they've wedged a vast quantity of crap onto the page that must be loaded before the page can render. The browser's page developer tools would probably tell you which quite rapidly.


  • @dkf said:

    @cmccormick said:
    You're probably familiar with the MVC pattern. It's a good fit for most webapps, but what do you do when you want to redirect to different web frameworks with the same controller? If you're this major bank, you write a JavaScript function.

    Have to think this has something to do with the slow login. Just clocked 42 seconds from login to page rendering on a decent connection.

    So, either they're loading things from lots of different sites (or one site that DNS is having problems looking up), or they've wedged a vast quantity of crap onto the page that must be loaded before the page can render. The browser's page developer tools would probably tell you which quite rapidly.

    I don't see any of those thing in this code - aside from an unnecessary code repetition, which probably would slow things down by a milisecond or two (unless it's a coding pattern on that site). It seems like a switch-redirect which would redirect you to one of those pages. Then again, I'm not a JS expert.


  • Discourse touched me in a no-no place

    @Maciejasjmj said:

    I don't see any of those thing in this code
    Nor do I; I'm guessing that the real problems are elsewhere. But ranting about the inability of people to tell us about real WTFs seems a little churlish, so I took the opportunity to comment just based on the text description. (It was more interesting than some poor — but not very poor — code.)


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.