-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
113 lines (106 loc) · 3.13 KB
/
index.html
File metadata and controls
113 lines (106 loc) · 3.13 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Form Submission</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
form {
margin-bottom: 20px;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
}
label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
input[type="email"],
input[type="text"] {
width: 100%;
padding: 8px;
margin-bottom: 10px;
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box; /* Ensures padding doesn't increase total width */
}
button {
background-color: #4caf50;
color: white;
padding: 10px 15px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
}
button:hover {
background-color: #45a049;
}
#displayBlock {
margin-top: 20px;
padding: 20px;
border: 1px solid #eee;
background-color: #f9f9f9;
border-radius: 5px;
white-space: pre-wrap; /* Preserves whitespace and wraps text */
font-family: monospace;
display: none; /* Hidden by default */
}
</style>
</head>
<body>
<h1>Submission Form</h1>
<form id="myForm">
<label for="email">Email:</label>
<input type="email" id="email" name="email" required />
<label for="url">URL:</label>
<input type="text" id="url" name="url" required />
<button type="submit">Submit</button>
</form>
<div id="displayBlock">
<h2>Submitted Data (JSON):</h2>
<pre id="jsonData"></pre>
</div>
<script>
document
.getElementById("myForm")
.addEventListener("submit", function (event) {
event.preventDefault(); // Prevent default form submission
const email = document.getElementById("email").value;
const url = document.getElementById("url").value;
const testUrl = new URL(
`https://yhxzjyykdsfkdrmdxgho.supabase.co/functions/v1/junior-dev?email=${email}&url=${url}`
);
let jsonString = { error: "Never sent" };
fetch(testUrl)
.then(async (response) => {
if (!response.ok) {
jsonString = {
error: "API Response failure",
status: response.status,
message: response.body.error,
};
} else {
jsonString = await response.json();
}
})
.catch((error) => {
jsonString = {
error: "Error",
message: error,
};
})
.finally((_) => {
document.getElementById("jsonData").textContent =
JSON.stringify(jsonString);
document.getElementById("displayBlock").style.display = "block"; // Show the display block
});
});
</script>
</body>
</html>