<!DOCTYPE html>
<html lang="en" >
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge, Chrome=1">
    <meta http-equiv="Cache-Control" content="no-cache">
    <title>驗證信箱</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp"
        crossorigin="anonymous">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>

    <!-- Google Tag Manager -->
    <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
    new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
    j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
    'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
    })(window,document,'script','dataLayer','GTM-5M8S4GH');</script>
    <!-- End Google Tag Manager -->

    <style>
      .h2 {
          text-align: center;
          font-size: 2rem;
          font-weight: 500;
          margin-top: 2rem;
      }
      .imgfr {
        width: 70%;
        max-width: 800px;
        min-width: 300px;
      }
      .imgfr img {
        width: 100%;
      }
      .pl-0 {
          padding-left: 0;
      }
      .link {
        text-decoration: none;
      }
    </style>
</head>
<body>
  <!-- Google Tag Manager (noscript) -->
  <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5M8S4GH"
  height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
  <!-- End Google Tag Manager (noscript) -->

  <div class="container">
    <main>
      <div class="m-auto text-center">
        <div class="block-validating">
          <h2 class="h2">
            <img src="https://i.imgur.com/crQ3rg6.png" alt="" width="36" class="me-2">
            <span class="validating-text">驗證中...</span></h2>
        </div>
        <div class="block-success">
          <h2 class="h2">
            <img src="https://i.imgur.com/crQ3rg6.png" alt="">
            <img src="https://i.imgur.com/eFBgdgI.png" width="36" class="me-2">
            驗證成功!</h2>
          <p>立即至<a href="./login.html" class="link">登入頁</a>,以繼續使用服務</p>
        </div>
        <!-- <div><img src="../html/static/img/Spinner-1s-181px.gif" width="36" alt=""></div> -->
        <div class="imgfr mx-auto">
          <img src="https://i.imgur.com/EqED9CY.png" alt="">
        </div>
        
      </div>
    </main>      
  </div>
  <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
  <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js'></script>
  <script>
    $('.block-success').css('display', 'none');
    function getCode(){
      let id = window.location.search.split('?').pop();
      return id.split('=')[1];
    }
    axios({
      method: 'get',
      url: `https://www.choozmo.com:8887/verify_email?code=${getCode()}`,
      headers: { 
          'accept': 'application/json',
      }
    }).then(res => {
      console.log(res.data);
      if(res.data.msg == 'ok') {
        $('.block-success').css('display', 'block');
        $('.block-validating').css('display', 'none');
        window.setTimeout(() => {
          window.location.href = './login.html';
        }, 3500);
      }
    }).catch(err => {
      console.log(err);
      $('.validating-text').text('驗證失敗,請再重新點擊驗證信連結')
    });
  </script>
</body>
</html>