/
app.js
222 lines (193 loc) · 5.64 KB
/
app.js
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
const express = require("express");
const bodyParser = require("body-parser");
// const express = require("express");
const app = express()
const mongoose = require("mongoose");
app.set('view engine', 'ejs');
app.use(bodyParser.urlencoded({extended:true}))
app.use(express.static("public"));
mongoose.connect("mongodb+srv://akash:akash@cluster0.trdd6ez.mongodb.net/todolistDB");
const Registeration = {
name:String,
City:String,
email:String,
password:String
}
const bookingSchema = {
turfName:String,
location:String,
check_in_date:String,
timeSlot:String,
members:String
}
const Registers = mongoose.model("Register",Registeration);
const Booking = mongoose.model("Booking",bookingSchema);
const t1 = new Registers({
name:"Enter your Name here",
city:"Enter your city name here",
email:"Enter your email here",
password:"Enter your password here"
})
const b1 = new Booking({
turfName:"Enter the new Turf name",
location:"New Turf Location",
check_in_date:"New Turf Check in date",
timeSlot:"Timeslot of the turf",
members:"Number of members in the turf"
})
app.get("/",function(req,res){
res.sendFile(__dirname+"/Registeration.html");
})
app.post("/",function(req,res){
var inputName = req.body.name;
var inputCity = req.body.city;
var inputEmail = req.body.email;
var inputPassword = req.body.psw;
// console.log(req.body);
const t2 = new Registers({
name:inputName,
city:inputCity,
email:inputEmail,
password:inputPassword
});
t2.save();
res.redirect("/booking.ejs");
})
app.get("/SignIn.html",function(req,res){
res.sendFile(__dirname+"/SignIn.html");
})
app.post("/SignIn.html",function(req,res){
var inputEmail = req.body.email;
var inputPassword = req.body.psw;
Registers.find({ email: inputEmail, password: inputPassword}, function (err,docs) {
if(err){
console.log(err);
}else{
if(docs.length == 0){
res.redirect("/");
}else{
res.redirect("/dicee.html");
}
}
});
})
app.get("/dicee.html",function(req,res){
res.sendFile(__dirname+"/dicee.html");
})
app.get("/explore.html",function(req,res){
res.sendFile(__dirname+"/explore.html");
})
app.get("/dicee.html",function(req,res){
res.sendFile(__dirname+"/dicee.html");
})
app.listen(3000,function(){
console.log("Server is running on port 3000");
})
var item1 = {
_id:1,
name:"St. Mary's High School, 4 Bungalows, Near Versova Telephone Exchange,Andheri West",
location:"Mumbai",
map_url:"https://goo.gl/maps/uiHg68cVjXM2",
image_icon:"https://www.sporloc.com/image/cache/catalog/911158FINALLOGO-286x180.jpg"
}
var item2 = {
_id:2,
name:"Rajasthani Sammelan Education Trust, SV Road, Malad West, Mumbai 400064",
location:"Mumbai",
map_url:"https://maps.app.goo.gl/5rFCzCkY3JTL3LT68",
image_icon:"https://www.sporloc.com/image/cache/catalog/632721lOGO30-286x180.jpg"
}
var item3 = {
_id:3,
name:"FS Turf, Churchgate - by SPORLOC",
location:"Mumbai",
map_url:"https://goo.gl/maps/VJqHp2xzv7tKDRjd7",
image_icon:"https://www.sporloc.com/image/cache/catalog/754285FinalLogo20-286x180.jpg"
}
var item4 = {
_id:4,
name:"Trickshot, Mulund - by SPORLOC",
location:"Mumbai",
map_url:"https://goo.gl/maps/axTihBSDg5mrPBwTA",
image_icon:"https://www.sporloc.com/image/cache/catalog/714786FINALLOGO-286x180.jpg"
}
var item5 = {
_id:5,
name:"Play The Turf, Malad - by SPORLOC",
location:"Mumbai",
map_url:"https://goo.gl/maps/eD8sQWppNkSQMfDt9",
image_icon:"https://www.sporloc.com/image/cache/catalog/805106LOGO30-286x180.jpg"
}
var item6 = {
_id:6,
name:"UMRB Turf, Azad Nagar - by SPORLOC",
location:"Mumbai",
map_url:"https://goo.gl/maps/t3D9j6AwDAgVFd6A7",
image_icon:"https://www.sporloc.com/image/cache/catalog/506061Logo20-286x180.jpg"
}
var turfs = [item1,item2,item3,item4,item5,item6];
var id = 0;
app.get("/booking.ejs",function(req,res){
// console.log(turfs[0].image_icon);
res.render('booking', {turfImage:turfs});
})
app.post("/booking.ejs",function(req,res){
id = Number(req.body.turf);
console.log(id);
// turfs.forEach(function(turf){
// if(id===turf._id){
// var array = turf;
// }
// res.render('booking1',{oneturf:array});
res.redirect("/booking1");
// })
})
// app.get("/booking1",function(req,res){
// res.render('/booking1',{oneturf:turf});
// })
var bool = false;
app.get("/booking1",function(req,res){
turfs.forEach(function(turf){
if(id===turf._id){
var array = turf;
bool = true;
if(bool){
// console.log(turf.image_icon);
res.render('booking1',{oneturf:array});
}
}
});
})
app.get("/book_now.ejs",function(req,res){
turfs.forEach(function(turf){
if(id===turf._id){
var array = turf;
res.render('book_now',{oneturf:array});
}
});
})
app.post("/book_now",function(req,res){
var turfName = req.body.turfname;
var location = req.body.location;
var check_in_date = req.body.check_in_date;
var check_out_date = req.body.check_out_date;
var timeSlot = req.body.timeslot;
var members = req.body.members;
var email = req.body.email;
var phone = req.body.phone;
const b2 = new Booking({
turfName:turfName,
location:location,
check_in_date:check_in_date,
timeSlot:timeSlot,
members:members
})
b2.save();
res.redirect("/successful.html");
})
// app.get("/book_now.ejs",function(req,res){
// res.render('book_now',{oneturf:array});
// });
app.get("/successful.html",function(req,res){
res.sendFile(__dirname+"/successful.html");
})