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

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
sumithemmadi committed Oct 11, 2021
1 parent 0557755 commit 30d7d7a
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php
header('Location: /test');
header('Location: /site');
?>
File renamed without changes.
75 changes: 75 additions & 0 deletions site/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
font-family: Arial, Helvetica, sans-serif;
background-color: white;
}
* {
box-sizing: border-box;
}
/* Add padding to containers */
.container {
padding: 16px;
background-color: white;
}
/* Full-width input fields */
input[type=text], input[type=password] {
width: 100%;
padding: 15px;
margin: 5px 0 22px 0;
display: inline-block;
border: none;
background: #f1f1f1;
}
input[type=text]:focus, input[type=password]:focus {
background-color: #ddd;
outline: none;
}
/* Overwrite default styles of hr */
hr {
border: 1px solid #f1f1f1;
margin-bottom: 25px;
}
/* Set a style for the submit button */
.registerbtn {
background-color: #04AA6D;
color: white;
padding: 16px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
opacity: 0.9;
}
.registerbtn:hover {
opacity: 1;
}
/* Add a blue text color to links */
a {
color: dodgerblue;
}
/* Set a grey background color and center the text of the "sign in" section */
.signin {
background-color: #f1f1f1;
text-align: center;
}
</style>
</head>
<body id="body">
<div class="container">
<h1 style="color:orange; text-align:center;">Dialogflow - PHP</h1>
<p>
<label for="sid"><b>Session ID</b></label>
<input type="text" placeholder="Session ID" name="sid" id="sid" required>
<label for="message"><b>Message</b></label>
<input type="text" placeholder="Enter Message" name="message" id="message" required>
<button type="submit" class="registerbtn" onclick="sendJSON()" >Send Message</button>
<p class="result"></p>
</p>
<script src="js/index.js"></script>
</div>
</body>
</html>
53 changes: 53 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Copyright 2021 sumithemmadi
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
function sendJSON() {
let result = document.querySelector('.result');
let sid = document.querySelector('#sid');
let message = document.querySelector('#message');
let xhr = new XMLHttpRequest();
let url = "/dialogflow.php";

xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/json");

xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {

result.innerHTML = this.responseText;
}
};

var data = JSON.stringify({
"sid": sid.value,
"message": message.value
});
xhr.send(data);
}
function validate_json(data) {
try {
JSON.parse(data);
} catch (e) {
return false;
}
return true;
}

0 comments on commit 30d7d7a

Please sign in to comment.