-
Notifications
You must be signed in to change notification settings - Fork 46
/
index.php
270 lines (162 loc) · 4.6 KB
/
index.php
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
<!DOCTYPE html>
<html>
<head>
<title>RUET ChatBot</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/font-awesome.min.css">
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/main.css">
<link rel="icon" type="image/png" href="img/ruet.png">
<script src="js/vendor/modernizr-2.8.3.min.js"></script>
<script src="js/vendor/jquery-1.12.0.min.js"></script>
</head>
<style>
.chat
{
position:fixed;
bottom:0;
right:0;
margin-right: 20px;
max-width:300px;
z-index:999;
box-shadow: 4px 4px 4px 4px;
border: : 2px solid rgb(22,118,134);
}
#sc
{
background-color: rgb(22,118,134);
padding:15px;
color:white;
font-size: 16px;
width:300px;
height: 45px;
}
#panel
{
background-color: white;
display: none;
margin:0;
width:300px;
height: 300px;
}
#div
{
padding:10px;
height: 240px;
position: relative;
overflow-y: auto;
}
input[type=text]
{
width: 100%;
padding: 12px 20px;
margin: 8px 0;
box-sizing: border-box;
}
.ou
{
background-color:rgb(241,240,240);
color:black;
padding:10px;
left:5;
width:130px;
text-align: center;
height:auto;
border-radius: 15px;
}
.stt
{
margin-top:5px;
}
</style>
<body>
<div class="container">
<div class="row">
<div class="col-sm-5">
</div>
<div class="col-sm-7">
<div class="chat">
<a style="text-decoration:none;" href="#"><div id="sc"><center ><img style="float:left;" src="img/ruet.png" width="20px" height="20px"/><b>Chat With RUET</b></center></div></a>
<div id="panel">
<script>
$(document).ready(function(){
var i=0;
var st;
$("#sc").click(function(){
i++;
$("#panel").slideToggle();
if(i==1)
{
$('#div').html("<div class=\"ou\"> Hello Guest. Welcome To Ruet Chat</div><br>");
}
});
});
</script>
<script type="text/javascript">
$(document).ready(function(){
$("#st").click(function(){
var str=$("#tt").val();
$("#div").html(str);
});
});
</script>
<script>
//wait for page load to initialize script
$(document).ready(function(){
window.alreadySubmit = false;
$('#tt').keypress(function(f){
if(f.which == 13 && !alreadySubmit) {
window.alreadySubmit = true;
//listen for form submission
$('form').on('submit', function(e){
//prevent form from submitting and leaving page
e.preventDefault();
// AJAX
$.ajax({
type: "POST", //type of submit
cache: false, //important or else you might get wrong data returned to you
url: "process.php", //destination
datatype: "html", //expected data format from process.php
data: $('form').serialize(), //target your form's data and serialize for a POST
success: function(result) { // data is the var which holds the output of your process.php
// locate the div with #result and fill it with returned data from process.php
$('#div').append("<div class=\"stt\""+result+"</div>");
$('#tt').val("");
}
});
});
}
});
});
</script>
<div id='div' name="output" >
<div id="div1"></div>
</div>
<br>
<!--<script>
"use strict";
function submitForm(oFormElement)
{
var xhr = new XMLHttpRequest();
var display=document.getElementById('div');
xhr.onload = function(){ display.innerHTML=xhr.responseText; }
xhr.open (oFormElement.method, oFormElement.action, true);
xhr.send (new FormData (oFormElement));
return false;
}
</script>-->
<!--<label for="out">Output</label>
<textarea id='div' class="form-control" name="output" rows="10" cols="50"></textarea><br><br>-->
<div class="form-group">
<form action="process.php" id="form" name="f2" method="POST" >
<input type="textarea" id="tt" name="input" placeholder="Type Your Message" style="position:absolute; bottom:0; height:30px; width:100%; height:50px;" required />
</form>
</div>
</div></div>
</div>
</div>
</div>
</body>
</html>