File size: 3,205 Bytes
8a21bc0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f37aff9
 
 
 
 
 
 
8a21bc0
 
 
 
 
 
 
 
 
f37aff9
 
 
 
 
8a21bc0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f37aff9
8a21bc0
 
 
 
f37aff9
babceda
8a21bc0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<html>

<head>
    <title>Private Domain Checker | ToKnow.ai</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
</head>

<body class="bg-light">
    <div class="container mt-5">
        <div class="row justify-content-center">
            <div class="col-md-6">
                <div class="card">
                    <div class="card-body">
                        <h3 class="text-center">Private Domain Checker</h3>
                        <p class="text-center text-body-secondary">
                            <a href="https://toknow.ai" class="text-decoration-none text-reset">
                                ToKnow.ai
                            </a>
                        </p>
                        <form id="searchForm" class="mb-3 mt-4">
                            <div class="input-group">
                                <input type="text" id="domain" class="form-control" placeholder="Enter domain name...">
                                <button class="btn btn-primary" type="submit">Check</button>
                            </div>
                        </form>
                        <div id="result" class="text-center d-none">
                            <div class="spinner-border text-primary d-none" id="spinner"></div>
                            <div id="resultText"></div>
                        </div>
                        <p class="text-center text-body-secondary mt-4">
                            <a href="https://toknow.ai/about" class="text-decoration-none">
                                Get help at ToKnow.ai
                            </a>
                        </p>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        document.getElementById('searchForm').onsubmit = async (e) => {
            e.preventDefault();
            const domain = document.getElementById('domain').value;
            const result = document.getElementById('result');
            const spinner = document.getElementById('spinner');
            const resultText = document.getElementById('resultText');

            result.classList.remove('d-none');
            spinner.classList.remove('d-none');
            resultText.innerHTML = '';

            try {
                const response = await fetch(`/check/${domain}`, { method: 'POST' });
                const data = await response.json();

                resultText.innerHTML = `
                <div class="alert ${data.available ? 'alert-success' : 'alert-danger'} mt-3">
                    <strong>${data.domain ?? domain}</strong> is ${data.available ? 'available' : 'not available'}
                    ${data.method ? `<br><i>(${data.method})</i>` : ''}
                </div>
            `;
            } catch (err) {
                resultText.innerHTML = `
                <div class="alert alert-warning mt-3">
                    Error checking domain
                </div>
            `;
            }
            spinner.classList.add('d-none');
        };
    </script>
</body>

</html>