<!doctype html>
<html>
<head>
    <title>Node Authentication</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <!-- load bootstrap css -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> <!-- load fontawesome -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/1000hz-bootstrap-validator/0.11.9/validator.js"></script>
    <style>
        body {
            background-image:url(/images/bg.png);
            background-repeat: no-repeat;
            background-position: center;
            background-attachment: fixed;
            padding-top:80px;
        }
        .whiteText {
            color: white;
        }

        @media (min-width: 768px) {
            .row-sm-offset-3 div:first-child[class*="col-"] {
                margin-left: 25%;
            }
        }

        .confirmMsg {
            font-weight: 300;
            margin-top: 0;
            font-family: HelveticaNeue-Light, "Helvetica Neue", Helvetica, sans-serif;
            font-weight: 300;
            font-size: 18px;
            line-height: 22px;
            text-align: center;
        }
        .boldEmail{
            font-weight: bold;
        }
        .resendEmail {
            font-weight: 300;
            margin-top: 0;
            font-family: HelveticaNeue-Light, "Helvetica Neue", Helvetica, sans-serif;
            font-weight: 300;
            font-size: 18px;
            line-height: 22px;
            text-align: center;
        }

        .centerText {
            text-align: center;
            line-height: 300%;
        }

        .emailConfirmText {
            font-family: HelveticaNeue-Light, "Helvetica Neue", Helvetica, sans-serif;
            font-weight: 300;
            font-size: 24px;
        }

        * {
            border-radius: 0 !important;
        }

        .cdWidth {
            width: 315px;
        }


        .spin {
            display: inline-block;
            width: 100%;
            text-align:center;
        }

        .resendDetails {
            font-weight: 300;
            margin-top: 0;
            font-family: HelveticaNeue-Light, "Helvetica Neue", Helvetica, sans-serif;
            font-weight: 300;
            font-size: 16px;
            line-height: 22px;
            text-align: center;
        }

    </style>
</head>
<body background="../appidExample.png">
<div class="container">
    <div class="row row-sm-offset-3">
        <div class="col-xs-12 col-sm-6">
            <div id="imgDiv">
                <img class="center-block" id="logo" alt="logo"
                     style="height: 140px; width: 140px; object-fit: contain;margin-top: 40px" src="/images/logo_cloud_land.png">
            </div>
            <h2 id="pageHeader" class="centerText emailConfirmText whiteText"></h2>
            <div  id="accessOk">
                <p class="confirmMsg whiteText"><%= confirmText1 %><br/><%= confirmText2 %></p>
                </br>
                </br>
                <button id="login" class="btn btn-lg btn-primary center-block btn-login" onclick="location.href = '/ibm/bluemix/appid/rop/login?language=<%= language %>'"><%= loginLabel %></button>
            </div>
            <div id="resendOption" style="display:none">
            </br>
            </br>
            <div class="spin">
                <button onclick="sendAgain();" id="resendEmailLink" class="btn btn-primary center-block btn-login"><%= resendNotificationButtonText %></button>
                <i id="spinner" class="fa fa-circle-o-notch fa-spin fa-2x" style="display:none"></i>
            </div>
            <div id="resendEmailStatus" style="display:none;"
                 class="alert alert-info center-block cdWidth text-center alert-dismissable">
                <buttton onclick="hide();" class="close" data-dismiss="alert" aria-label="close">&times;</buttton>
                <p id="msg"></p>
            </div>
            </br>
            </br>
                <p class="resendDetails whiteText"><%= text1 %><br/>
                    <%= text2 %><br/>
                    <%= text3 %><br/>
                    <%= text4 %></p>
            </div>
        </div>
    </div>

</div>
<script>
    if (!"<%= errorStatusCode %>") {
	    document.getElementById("pageHeader").innerHTML = "<%= confirmHeader1 %>";
    } else if ("<%= errorStatusCode %>" === "NOT_FOUND") {
	    document.getElementById("pageHeader").innerHTML = "<%= confirmHeader2 %>";
	    document.getElementById("resendOption").setAttribute("style", "display:visible");
	    document.getElementById("accessOk").setAttribute("style", "display:none");
    } else if ("<%= errorStatusCode %>" === "GONE") {
	    document.getElementById("pageHeader").innerHTML = "<%= confirmHeader3 %>";
    } else {
      document.getElementById("pageHeader").innerHTML = "<%= errorDescription %>";
    }

	function sendAgain() {
		document.getElementById("resendEmailLink").setAttribute("style", "display:none");
		document.getElementById("spinner").setAttribute("style", "display:visible; color: #4178be;");
		$.post("/resend/USER_VERIFICATION?language=" + "<%= language %>",
			{
              uuid: "<%= uuid %>"
			},
			function(data, status){
				document.getElementById("msg").innerHTML = data;
				document.getElementById("spinner").setAttribute("style", "display:none");
				$("#resendEmailStatus").fadeIn();
			});
	}
	function hide() {
		document.getElementById("resendEmailStatus").setAttribute("style", "display:none");
		document.getElementById("resendEmailLink").setAttribute("style", "display:visible");
	}
</script>
</body>
</html>