-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathguest_comment.html
186 lines (174 loc) · 6.8 KB
/
guest_comment.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Guest Inauguration Comment</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css"
/>
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="./style.css" />
</head>
<body>
<section class="" id="mainscreen">
<div class="swiper">
<div class="swiper-wrapper">
<div class="swiper-slide">
<div class="gradient"></div>
<div class="form-container">
<form class="form-content " id="guessCommentID">
<div class="flex-container">
<div class="form-group textinaugrh">
<h1 class="head">Hello,</h1>
<h1 class="head" id="nameid"></h1>
<label for="inaugurationComment">Please inaugrate the event with your comments</label>
<br />
<textarea
id="inaugurationComment"
name="inaugurationComment"
placeholder="Inauguration Comment" rows="4" cols="50"></textarea>
<div id="charCount" class="counter">0/150 characters</div>
<!-- <input
type="text"
id="inaugurationComment"
name="inaugurationComment"
placeholder="Inauguration Comment"
required
/> -->
</div>
<div class="inaugbtn">
<button
type="button"
class="gradient-button"
id="submitbtn"
onclick="guestComment()"
>
Inaugurate the Event
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</section>
<div class="successscreen hide" id="successscreen">
<div class="container">
<div class="diya">
<div class="diya__base base">
<div class="base__part base__part--bottom">
<div class="base__decoration base__decoration--left"></div>
<div class="base__decoration base__decoration--right"></div>
</div>
<div class="base__part base__part--top"></div>
</div>
<div class="diya__flame flame" id="flame2">
<div class="flame__shadow flame__shadow--big"></div>
<div class="flame__shadow flame__shadow--sm1"></div>
<div class="flame__shadow flame__shadow--sm2"></div>
<div class="flame__shadow flame__shadow--sm3"></div>
<div class="flame__fire flame__fire--outer"></div>
<div class="flame__fire flame__fire--inner"></div>
</div>
<div class="diya__shadow shadow">
<div class="shadow__flame"></div>
<div class="shadow__diya"></div>
</div>
</div>
</div>
<h2 class="headsuccess">Successful</h2>
</div>
<script src="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js"></script>
<script>
const textarea = document.getElementById('inaugurationComment');
const charCountDiv = document.getElementById('charCount');
const maxChars = 150;
let namedata;
textarea.addEventListener('input', function() {
const charCount = this.value.length;
if (charCount > maxChars) {
this.value = this.value.substring(0, maxChars);
}
charCountDiv.innerText = `${this.value.length}/${maxChars} characters`;
})
function getQueryName() {
const hashdata = window.location.hash.substring(1)
const params = new URLSearchParams(hashdata)
const name = params.get('name');
const namediv = document.getElementById("nameid");
namediv.innerText = name;
namedata = name;
}
window.onload = getQueryName;
function getHashParams() {
const hash = window.location.hash.substring(1)
const params = new URLSearchParams(hash)
return {
email: params.get("email"),
identifier: params.get("identifier"),
document_hash: params.get("document_hash"),
name: params.get("name"),
}
}
function guestComment() {
document.getElementById("submitbtn").innerText = "Inaugurating";
document.getElementById("submitbtn").disabled = true;
const hashParams = getHashParams()
console.log(hashParams)
const comment = document.getElementById("inaugurationComment").value
const hash1 = window.location.hash.substring(1)
const params2 = new URLSearchParams(hash1)
console.log(comment)
console.log("Email:", hashParams.email)
console.log("Identifier:", hashParams.identifier)
console.log("Document Hash:", hashParams.document_hash)
console.log("Name:", hashParams.name)
console.log("Input Field:", comment)
let datacmnt = comment + " - " + params2.get("name");
if(comment===''){
datacmnt = params2.get("name") + "-"
}
const data = {
email: hashParams.email,
identifier: hashParams.identifier,
document_hash: hashParams.document_hash,
comment: datacmnt,
}
console.log("here data sent",data);
fetch("https://api.demo.dhiway.com/api/v1/dmp/witness", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
})
.then((response) => {
document.getElementById("submitbtn").innerText = "Inaugurate the Event";
document.getElementById("submitbtn").disabled = false;
console.log("here",response);
// if (!response.ok) {
// throw new Error("Network response was not ok")
// }
// alert("Inaugrated successfully!")
const mainscreen= document.getElementById("mainscreen");
const successscreen = document.getElementById("successscreen");
if (successscreen.classList.contains("hide")) {
successscreen.classList.remove("hide");
mainscreen.classList.add("hide");
}
// form.reset() // Reset the form after successful submission
})
.catch((error) => {
document.getElementById("submitbtn").innerText = "Inaugurate the Event";
document.getElementById("submitbtn").disabled = false;
console.error(
"There was a problem with your fetch operation:",
error
)
})
}
</script>
</body>
</html>