Skip to content
This repository was archived by the owner on Mar 5, 2024. It is now read-only.

Commit 30d7d7a

Browse files
committed
Updated
1 parent 0557755 commit 30d7d7a

File tree

4 files changed

+129
-1
lines changed

4 files changed

+129
-1
lines changed

index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<?php
2-
header('Location: /test');
2+
header('Location: /site');
33
?>
File renamed without changes.

site/index.html

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta name="viewport" content="width=device-width, initial-scale=1">
5+
<style>
6+
body {
7+
font-family: Arial, Helvetica, sans-serif;
8+
background-color: white;
9+
}
10+
* {
11+
box-sizing: border-box;
12+
}
13+
/* Add padding to containers */
14+
.container {
15+
padding: 16px;
16+
background-color: white;
17+
}
18+
/* Full-width input fields */
19+
input[type=text], input[type=password] {
20+
width: 100%;
21+
padding: 15px;
22+
margin: 5px 0 22px 0;
23+
display: inline-block;
24+
border: none;
25+
background: #f1f1f1;
26+
}
27+
input[type=text]:focus, input[type=password]:focus {
28+
background-color: #ddd;
29+
outline: none;
30+
}
31+
/* Overwrite default styles of hr */
32+
hr {
33+
border: 1px solid #f1f1f1;
34+
margin-bottom: 25px;
35+
}
36+
/* Set a style for the submit button */
37+
.registerbtn {
38+
background-color: #04AA6D;
39+
color: white;
40+
padding: 16px 20px;
41+
margin: 8px 0;
42+
border: none;
43+
cursor: pointer;
44+
width: 100%;
45+
opacity: 0.9;
46+
}
47+
.registerbtn:hover {
48+
opacity: 1;
49+
}
50+
/* Add a blue text color to links */
51+
a {
52+
color: dodgerblue;
53+
}
54+
/* Set a grey background color and center the text of the "sign in" section */
55+
.signin {
56+
background-color: #f1f1f1;
57+
text-align: center;
58+
}
59+
</style>
60+
</head>
61+
<body id="body">
62+
<div class="container">
63+
<h1 style="color:orange; text-align:center;">Dialogflow - PHP</h1>
64+
<p>
65+
<label for="sid"><b>Session ID</b></label>
66+
<input type="text" placeholder="Session ID" name="sid" id="sid" required>
67+
<label for="message"><b>Message</b></label>
68+
<input type="text" placeholder="Enter Message" name="message" id="message" required>
69+
<button type="submit" class="registerbtn" onclick="sendJSON()" >Send Message</button>
70+
<p class="result"></p>
71+
</p>
72+
<script src="js/index.js"></script>
73+
</div>
74+
</body>
75+
</html>

test/index.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
Apache License
3+
Version 2.0, January 2004
4+
http://www.apache.org/licenses/
5+
6+
Copyright 2021 sumithemmadi
7+
8+
Licensed under the Apache License, Version 2.0 (the "License");
9+
you may not use this file except in compliance with the License.
10+
You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing, software
15+
distributed under the License is distributed on an "AS IS" BASIS,
16+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
See the License for the specific language governing permissions and
18+
limitations under the License.
19+
20+
21+
*/
22+
function sendJSON() {
23+
let result = document.querySelector('.result');
24+
let sid = document.querySelector('#sid');
25+
let message = document.querySelector('#message');
26+
let xhr = new XMLHttpRequest();
27+
let url = "/dialogflow.php";
28+
29+
xhr.open("POST", url, true);
30+
xhr.setRequestHeader("Content-Type", "application/json");
31+
32+
xhr.onreadystatechange = function () {
33+
if (xhr.readyState === 4 && xhr.status === 200) {
34+
35+
result.innerHTML = this.responseText;
36+
}
37+
};
38+
39+
var data = JSON.stringify({
40+
"sid": sid.value,
41+
"message": message.value
42+
});
43+
xhr.send(data);
44+
}
45+
function validate_json(data) {
46+
try {
47+
JSON.parse(data);
48+
} catch (e) {
49+
return false;
50+
}
51+
return true;
52+
}
53+

0 commit comments

Comments
 (0)