<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>丸の色とアイコン切り替え</title>
    <style>
        .container {
            width: 128px;
            height: 128px;
            position: relative;
            margin: 0 auto;
        }

        .spinner {
            position: absolute;
            width: 128px;
            height: 128px;
            border: 8px solid transparent;
            border-top: 8px solid blue;
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }

        .circle {
            position: absolute;
            width: 128px;
            height: 128px;
            border: 8px solid transparent; /* デフォルトは透明 */
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
        }

        .icon {
            width: 64px;
            height: 64px;
            font-size: 64px;
            line-height: 64px;
            text-align: center;
            opacity: 0;
            transform: scale(0);
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        @keyframes fadeIn {
            0% { opacity: 0; transform: scale(0); }
            100% { opacity: 1; transform: scale(1); }
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="spinner" id="spinner"></div>
        <div class="circle" id="circle">
            <div class="icon" id="icon"></div>
        </div>
    </div>
    <div class="tyuuou">
    <p>レクリエーション係アクセス解析&リダイレクト dy SogouSystem</p>
    <p>レクリエーション係、SogouSystemが管理していないページに移動します</p>
    <p id="msg"></p>
    </div>
    

    <script>
      
        // 丸とアイコンを切り替えて表示する関数
        function showResult(symbol, color) {
            const spinner = document.getElementById('spinner');
            const circle = document.getElementById('circle');
            const icon = document.getElementById('icon');

            // スピナーを非表示
            spinner.style.display = 'none';

            // 丸の色を設定して表示
            circle.style.borderColor = color; // 緑か赤を設定
            circle.style.opacity = '1';

            // アイコンを設定して表示
            icon.textContent = symbol; // ✔または✖
            icon.style.color = color; // アイコンの色を丸に合わせる
            icon.style.animation = 'fadeIn 0.5s forwards';
        }
        window.onload = function() {
          var msg = document.getElementById('msg'); msg.innerText = 'Googleアカウントのアドレスを取得しています・・・';
          setTimeout(var msg = document.getElementById('msg'); msg.innerText = '5-4であるか確認しています';,500);
        }
        // ページ読み込み時にスピナーを表示
        window.onload = function() {
            const spinner = document.getElementById('spinner');

            // スピナーを回転
            spinner.style.display = 'block';
            //ロードメッセージ
            var msg = document.getElementById('msg'); msg.innerText = 'Googleアカウントのアドレスを取得しています・・・';
            setTimeout(function(){var msg = document.getElementById('msg'); msg.innerText = '5-4であるか確認しています・・・';},500);
            //結果表示&リダイレクト
            google.script.run.withSuccessHandler(function(status){if(status == 'ok'){showResult('✓', 'green');google.script.run.withFailureHandler().モニタリング();setTimeout(function() {window.location.href = '<?=url?>'}, 3000);}else{showResult('×', 'red')}}).withFailureHandler(function(err){var msg = document.getElementById('msg'); msg.innerText = '問題が発生しました　詳細:' + err; showResult('×', 'red')}).certification()
        };
    </script>
</body>
</html>
