-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselect.html
92 lines (83 loc) · 2.49 KB
/
select.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gender Updater</title>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Roboto', sans-serif;
text-align: center;
margin: 50px;
}
label {
font-size: 18px;
}
select {
font-size: 16px;
padding: 8px;
}
button {
margin-top: 10px;
padding: 10px 20px;
font-size: 16px;
border: none;
border-radius: 4px;
cursor: pointer;
outline: none;
transition: background-color 0.3s ease, box-shadow 0.3s ease;
background-color: #E0B0FF; /* Lavender */
color: #fff;
}
button:hover {
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}
</style>
</head>
<body>
<h2>Gender Updater</h2>
<form id="genderForm">
<label for="gender">Select gender:</label>
<select id="gender" name="gender">
<option value="unknown" selected>Unknown</option>
<option value="boy">Boy</option>
<option value="girl">Girl</option>
</select>
<br>
<button type="button" onclick="updateGender()">Update Gender</button>
</form>
<script>
function updateGender() {
const selectedGender = document.getElementById('gender').value;
const filePath = 'gender.json'; // Adjust the path as needed
// Use the GitHub API to create the file
fetch(`https://api.github.com/repos/templargin/myweb/contents/${filePath}`, {
method: 'POST', // Change to POST
headers: {
Authorization: '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', // Replace with your actual token
Accept: 'application/vnd.github.v3+json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
message: 'Create gender information',
content: btoa(JSON.stringify({ gender: selectedGender }, null, 2)),
}),
})
.then(response => {
if (response.ok) {
return response.json();
} else {
return Promise.reject(response.statusText);
}
})
.then(createdData => {
console.log('File created successfully:', createdData);
})
.catch(error => {
console.error('Error creating file:', error);
});
}
</script>
</body>
</html>