-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessage.html
More file actions
206 lines (185 loc) · 5.71 KB
/
Copy pathMessage.html
File metadata and controls
206 lines (185 loc) · 5.71 KB
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
<!doctype html>
<html ng-app="messageApp">
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.5/angular.min.js"></script>
<script>
var accessToken = "03ad46c2f59d466aa2b02311ce3d6303";
var baseUrl = "https://api.api.ai/v1/";
function send(text, c) {
$.ajax({
type: "POST",
url: baseUrl + "query?v=20150910",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
headers: {
"Authorization": "Bearer " + accessToken
},
data: JSON.stringify({
query: text,
lang: "en",
sessionId: "<any random string>"
}),
success: function(data) {
//(data.result.fulfillment.speech.toString());
var api_response = data.result.fulfillment.speech.toString();
var d_obj = {};
d_obj.user = 'doctor';
d_obj.text = api_response;
d_obj.date = new Date();
c.data.messages.push(d_obj);
},
error: function() {
alert("Internal Server Error");
}
});
//alert("Loading...");
}
angular.module('messageApp', [])
.controller('MessageController', function() {
var c = this;
c.data = [];
c.back = function() {
window.location = 'Home_Patient.html';
}
c.data.messages = [];
send('hello,', c);
send('who are you?', c);
c.send = function() {
var text_string = c.message;
var m_obj = {};
m_obj.user = 'me';
m_obj.text = text_string;
m_obj.date = new Date();
c.data.messages.push(m_obj);
c.message = '';
setTimeout(send(text_string, c), 5000);
}
});
</script>
<style>
body {
background-color: #F1F1F1;
font-size: 14px;
width: 400px;
height:100vh;
margin: auto;
}
.title_div {
display: flex;
flex-direction: row;
align-items: center;
background-color: white;
padding: 10px;
width: 100% !important;
margin: auto;
bottom: 0px;
}
.cancel_text {
right: 10px;
}
.title_text {
display: flex;
margin: 0 auto;
align-self: center;
}
.message_card {
display: flex;
align-items: center;
}
.right_direction {
flex-direction: row;
}
.reverse_direction {
flex-direction: row-reverse;
}
.image_header {
padding: 5px;
}
.circle_div {
width: 40px;
height: 40px;
border-radius: 50%;
color: white;
background-color: #41B2AA;
text-align: center;
line-height: 40px;
align-self: center;
}
.message_div {
width: 400px;
margin: auto;
}
.text_dialog {
background-color: white;
padding: 10px;
border-radius: 5px;
margin: 5px;
}
.darker {
background-color: #E4E4E4 !important;
}
.smaller_text {
font-size: 10px;
margin: 5px;
}
.submit_area {
position:absolute;
display: flex;
flex-direction: row-reverse;
background-color: white;
bottom: 0px;
padding: 5px;
width: 400px;
}
input {
width: 100%;
border-style: none;
}
.btn {
background-color: #41B2AA !important;
color: white !important;
}
</style>
</head>
<body>
<div ng-controller="MessageController as c" style = "height:100vh;">
<div class="title_div">
<div class="title_text"><b>Messages</b>
</div>
<div class="cancel_text" ng-click="c.back()"><img src = "images/home_mobile.png"/>
</div>
</div>
<div ng-repeat="message in c.data.messages">
<div ng-if="message.user == 'doctor'" class="message_card right_direction">
<div class="image_header">
<div class="circle_div">D</div>
</div>
<div class="message_div">
<div class="smaller_text">{{message.user}}</div>
<div class="text_dialog">{{message.text}}</div>
<div class="smaller_text">{{message.date}}</div>
</div>
</div>
<div ng-if="message.user == 'me'" class="message_card reverse_direction">
<div class="image_header">
<div class="circle_div">P</div>
</div>
<div class="message_div">
<div class="smaller_text">{{message.user}}</div>
<div class="text_dialog darker">{{message.text}}</div>
<div class="smaller_text">{{message.date}}</div>
</div>
</div>
</div><br/><br/><br/>
<div class="submit_area">
<label ng-click="c.send()" class="btn">send</label>
<input type="text" placeholder="messaging..." ng-model="c.message" id = "pmessage">
</div>
</div>
</body>
</html>