This repository has been archived by the owner on Oct 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
second.html
178 lines (163 loc) · 6.5 KB
/
second.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script src="https://www.gstatic.com/firebasejs/5.8.1/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyAnvb9PaAro6Di5OZxmtObb-LxBtxEjQEU",
authDomain: "hospital-management-18f97.firebaseapp.com",
databaseURL: "https://hospital-management-18f97.firebaseio.com",
projectId: "hospital-management-18f97",
storageBucket: "hospital-management-18f97.appspot.com",
messagingSenderId: "224580189703"
};
firebase.initializeApp(config);
const db=firebase.database();
</script>
<style>
.cont{
display: none;
}
.cont{
max-width: 600px;
margin: 20px auto;
background: #eee;
}
</style>
<script type="text/javascript">
var displayName,email,emailVerified,photoURL,uid,phoneNumber,providerData;
initApp = function() {
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
// User is signed in.
displayName = user.displayName;
email = user.email;
emailVerified = user.emailVerified;
photoURL = user.photoURL;
uid = user.uid;
phoneNumber = user.phoneNumber;
providerData = user.providerData;
user.getIdToken().then(function(accessToken) {
document.getElementById('account-details').textContent="Name: "+displayName;
});
}
else {
// User is signed out.
document.getElementById('account-details').textContent = 'null';
}
}, function(error) {
console.log(error);
});
};
window.addEventListener('load', function() {
initApp()
});
$(document).ready(function(){
firebase.database().ref('users/').on('value',function(snapshot){
var data=snapshot.child(uid).val();
if(snapshot.child(uid).val()!=null){
if(data.identity=="Doctor")
{
var id=data.email;
window.location = 'doc.html?info='+id;
}
if(data.identity=="Patient")
{
var id=data.email;
window.location = 'pat.html?info='+id;
}
}
else{
$('.cont').css('display','block');
}
});
$('form').on('submit',function(e){
e.preventDefault();
var usertype=$('select').val();
var user = firebase.auth().currentUser;
var uid=user.uid;
firebase.database().ref('users/').child(uid).set({
firstName: displayName,
identity: usertype,
lastName: displayName,
email: email
});
})
$('.butn').on('click',function(e){
e.preventDefault();
var usertype=$('select').val();
if(usertype=="Doctor"){
console.log(displayName+email);
$.ajax({
method: 'POST',
url: 'http://192.168.43.94:3000/api/Doctor',
data: {
"$class": "org.ehr.hackathon.Doctor",
"doctorId": email,
"firstName": displayName,
"lastName": ""
},
success: function(){
console.log('successfulll');
}
});
}
});
})
</script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<style>
.navbar{
background: #5b0cf0;
color: #fff;
}
.navbar li a,.navbar .navbar-brand{
color: #fff;
}
.cont{
padding: 20px;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg">
<div class="container">
<a class="navbar-brand" href="#">EHR System</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#mainNavbar">
<span class="navbar-toggler-icon" style="color: #fff">Menu</span>
</button>
<div class="collapse navbar-collapse" id="mainNavbar">
<ul class="navbar-nav ml-auto">
<li class="nav-item"><a class="nav-link" href="first.html">Home</a></li>
<li class="nav-item"><a class="nav-link" href="first.html">Logout</a></li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="cont">
<h3 class="text-center">User details:</h3>
<div id="account-details">
</div>
<p>Are you doctor or patient?</p>
<form>
<select name="usertype">
<option value="Select">Select</option>
<option value="Doctor">Doctor</option>
<option value="Patient">Patient</option>
</select>
<br><br>
<button class="btn btn-success">Submit</button>
</form>
<button class="butn">Ajax</button>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script type="text/javascript">
</script>
</body>
</html>