This repository has been archived by the owner on Nov 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
witness.html
172 lines (141 loc) · 5.54 KB
/
witness.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<!-- public/witness-register.html -->
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>실종 동물 목격 등록 서비스</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Gothic+A1:wght@100;300;400;500;700&display=swap">
<style>
body {
font-family: 'Gothic A1', sans-serif;
margin: 20px;
background-color: #001f3f;
color: #fff;
}
#witnessPetForm {
max-width: 400px;
margin: auto;
background-color: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}
#witnessForm label {
display: flex;
flex-direction: row;
align-items: center;
margin-bottom: 10px;
color: #000;
}
#witnessForm label input,
#witnessForm label textarea {
width: 60%;
margin-left: 10px;
color: #000;
}
#witnessForm button {
width: 100%;
padding: 10px;
font-size: 16px;
background-color: #001f3f;
color: #fff;
border: none;
cursor: pointer;
}
#witnessPetsList {
list-style: none;
padding: 0;
}
#witnessConfirmationWindow {
display: none;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #001f3f;
color: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}
#witnessConfirmationWindow p {
margin-bottom: 10px;
}
#witnessConfirmationWindow button {
width: 100%;
padding: 10px;
font-size: 16px;
background-color: #fff;
color: #000;
border: none;
cursor: pointer;
}
</style>
</head>
<body>
<h1 style="text-align: center; color: #fff;">목격 정보 등록 서비스</h1>
<div id="witnessPetForm">
<h2 style="text-align: center; color: #000;">목격 정보 등록</h2>
<form id="witnessForm">
<label for="witnessPetName">지역/발견한 곳:
<input type="text" id="witnessPetName" name="witnessPetName" required>
</label>
<label for="witnessAnimalType">동물 이름/종류:
<input type="text" id="witnessAnimalType" name="witnessAnimalType" required>
</label>
<label for="witnessOwnerName">연락처:
<input type="text" id="witnessOwnerName" name="witnessOwnerName" required>
</label>
<label for="witnessContactNumber">특징:
<textarea id="witnessContactNumber" name="witnessContactNumber" rows="4" required></textarea>
</label>
<label for="witnessPhoto">사진 첨부:
<input type="file" id="witnessPhoto" name="witnessPhoto" accept="image/*">
</label>
<button type="button" onclick="registerWitness()">목격 정보 등록</button>
</form>
</div>
<ul id="witnessPetsList"></ul>
<div id="witnessConfirmationWindow">
<p id="witnessConfirmationMessage" style="color: #fff;">목격 정보가 정상적으로 등록되었습니다.</p>
<button onclick="closeWitnessConfirmationWindow()">확인</button>
</div>
<script>
async function registerWitness() {
const witnessForm = document.getElementById('witnessForm');
const witnessPetName = witnessForm.elements['witnessPetName'].value;
const witnessAnimalType = witnessForm.elements['witnessAnimalType'].value;
const witnessOwnerName = witnessForm.elements['witnessOwnerName'].value;
const witnessContactNumber = witnessForm.elements['witnessContactNumber'].value;
const response = await fetch('/api/registerWitness', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ witnessPetName, witnessAnimalType, witnessOwnerName, witnessContactNumber }),
});
const result = await response.json();
alert(result.message); // 등록 결과 메시지 표시
witnessForm.reset();
fetchWitnessPets(); // 목격 정보 갱신
}
function closeWitnessConfirmationWindow() {
const witnessConfirmationWindow = document.getElementById('witnessConfirmationWindow');
witnessConfirmationWindow.style.display = 'none';
}
async function fetchWitnessPets() {
const response = await fetch('/api/getWitnessPets');
const witnessPets = await response.json();
const witnessPetsList = document.getElementById('witnessPetsList');
witnessPetsList.innerHTML = '';
witnessPets.forEach(pet => {
const listItem = document.createElement('li');
listItem.textContent = `${pet.witnessPetName} (${pet.witnessAnimalType}) - ${pet.witnessOwnerName} (${pet.witnessContactNumber})`;
witnessPetsList.appendChild(listItem);
});
witnessPetsList.style.display = 'block';
}
</script>
</body>
</html>