forked from jiepengwong/ESDT4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
423 lines (368 loc) · 15.6 KB
/
index.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
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="./asset/HenesysSmallLogo.png">
<title>Henesys Market Place</title>
<!--bootstrap css-->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" crossorigin="anonymous">
<!--axios-->
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<!--Vue-->
<script src="https://unpkg.com/vue@next"></script>
<!-- Google Auth0 -->
<script async defer src="https://apis.google.com/js/api.js"
onload="this.onload=function(){};handleClientLoad()"
onreadystatechange="if (this.readyState === 'complete') this.onload()">
</script>
<meta name="google-signin-client_id" content="616186403576-ofsdqf0tp3r19t60rmflus3l3h9p25vo.apps.googleusercontent.com">
<style>
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800;900&display=swap');
body {
background-color: lightgreen;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif
}
.container {
margin: 50px auto
}
.body {
position: relative;
width: 720px;
height: 440px;
margin: 20px auto;
border: 1px solid #dddd;
border-radius: 18px;
overflow: hidden;
box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
}
.box-1 img {
width: 100%;
height: 100%;
object-fit: cover
}
.box-2 {
padding: 10px
}
.box-1,
.box-2 {
width: 50%
}
.h-1 {
font-size: 24px;
font-weight: 700
}
.text-muted {
font-size: 14px
}
.container .box {
width: 100px;
height: 100px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
border: 2px solid transparent;
text-decoration: none;
color: #615f5fdd
}
.box:active,
.box:visited {
border: 2px solid #124821
}
.box:hover {
border: 2px solid #124821
}
.btn.btn-primary {
background-color: transparent;
color: #124821;
border: 0px;
padding: 0;
font-size: 14px
}
.btn.btn-primary .fas.fa-chevron-right {
font-size: 12px
}
.footer .p-color {
color: #124821
}
.footer.text-muted {
font-size: 10px
}
.fas.fa-times {
position: absolute;
top: 20px;
right: 20px;
height: 20px;
width: 20px;
background-color: #f3cff379;
font-size: 18px;
display: flex;
align-items: center;
justify-content: center
}
.fas.fa-times:hover {
color: #ff0000
}
@media (max-width:767px) {
body {
padding: 10px
}
.body {
width: 100%;
height: 100%
}
.box-1 {
width: 100%
}
.box-2 {
width: 100%;
height: 440px
}
}
</style>
</head>
<body onload="loginStatus()">
<div id="app">
<div class="container" >
<div class="body d-md-flex align-items-center justify-content-between" style="background-color:white;">
<div class="box-1 mt-md-0 mt-5" > <img src="./asset/Marketplace.PNG" style="width: 481; height:721 "class="" alt=""> </div>
<div class=" box-2 d-flex flex-column h-100">
<div class="mt-5">
<p class="mb-1 h-1">Login to Henesys Marketplace.</p>
<p class="text-muted mb-2">Buy. Sell. In our Marketplace.</p>
<div class="d-flex flex-column ">
<p class="text-muted mb-2">Continue with:</p>
<div class="d-flex align-items-center">
<button @click="googleAuthtry()" type="button" class="btn btn-success btn-floating mx-1" >
Google
</button>
</div>
<div class="mt-3">
<p class="mb-0 text-muted">Powered by Google Auth.</p>
</div>
</div>
</div>
<div class="mt-auto">
<p class="footer text-muted mb-0 mt-md-0 mt-4">By registering, you will agree with our <span class="p-color me-1">terms and conditions</span>and <span class="p-color ms-1">privacy policy</span> </p>
</div>
</div>
</div>
</div>
<!-- TESTING -->
<!-- <div class="container-fluid h-custom">
<div class="row d-flex justify-content-center align-items-center h-100">
<div class="col-md-9 col-lg-6 col-xl-6 my-lg-5 py-lg-5">
<img src="./asset/HenesysHome.png" class="img-fluid"alt="Sample image">
</div>
<div class="col-md-8 col-lg-6 col-xl-5 offset-xl-1 my-lg-5 py-lg-5">
<div class="d-flex flex-row align-items-center justify-content-center justify-content-lg-start">
<h2>Welcome to Henesys Grocery Place!</h2>
</div>
<hr>
<div style="margin-top:30px"></div>
<div class="d-flex flex-row align-items-center justify-content-center justify-content-lg-start">
<p class="lead fw-normal mb-0 me-3 text-centre">Sign in with</p>
<button @click="googleAuthtry()" type="button" class="btn btn-success btn-floating mx-1" >
Google
</button>
</div> -->
<!-- {{id}}
{{isSignedIn}} -->
</div>
</div>
</div>
</div>
</body>
<script src="./narbar.js"></script>
<script>
function loginStatus() {
// If the login variable is initalised, then we will redirect them to
if (localStorage.getItem("id")){
// redirect them to login page
window.location.replace("./cataloguenew.php");
}
}
const app = Vue.createApp({
data() {
return {
id:null,
name: null,
email:null,
password: null,
googleUserProfile: undefined,
token: undefined,
isSignedIn: null,
databaseSign: null,
registered: null,
GoogleUser: null,
googleAuth: null,
}
},
computed : {
},
methods: {
GoogleSignIn() {
let gapi = window.gapi;
let clientId ="616186403576-ofsdqf0tp3r19t60rmflus3l3h9p25vo.apps.googleusercontent.com";
let apiKey ="AIzaSyC0WtHoYqLnGKgaqLWX6RGkiL0X2C7dll8";
let secretClientId = "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";
let discoveryDocs =["https://www.googleapis.com/discovery/v1/apis/oauth2/v2/rest"];
let scope ="https://www.googleapis.com/auth/userinfo.profile";
gapi.load("client:auth2", () => {
gapi.client.init({
apiKey,
clientId,
discoveryDocs,
scope,
secretClientId,
})
.then(() => {
gapi.auth2.getAuthInstance().signIn().then(() => {
var hehe = gapi.auth2.getAuthInstance();
var GoogleUser = hehe.currentUser.get();
var BasicProfile = GoogleUser.getBasicProfile()
this.id = BasicProfile.getId();
this.name = BasicProfile.getName();
this.email = BasicProfile.getEmail();
this.isSignedIn = GoogleUser.isSignedIn();
let jsondata = JSON.stringify({
"name": this.name,
"email": this.email,
"mobile": "",
"ratings": 0,
"counts": 0
})
if (this.isSignedIn && this.id != null) {
var database_url = "http://127.0.0.1:5000/profile/" + this.id;
console.log(database_url);
fetch(database_url)
.then(response => response.json())
.then(data => {
console.log(data.code)
console.log(data.code == 404)
if (data.code == 404) {
console.log("There is no such data in the database")
this.registered = false;
console.log(this.registered)
console.log(this.id)
var registered_url = "http://127.0.0.1:5000/profile/register/" + this.id
console.log(registered_url)
console.log(jsondata)
console.log(typeof jsondata)
console.log(this.registered)
if (this.registered==false){
fetch(registered_url,{
method: "POST",
headers: {
"Content-type": "application/json"
},
body: jsondata
})
.then(response => response.json())
.then(data => {console.log(data)})
.catch(error=> {console.log(error)})
localStorage.login = jsondata
localStorage.id = this.id
this.show = true
this.localStorage= localStorage.id
newjsondata = JSON.parse(jsondata)
mobile = newjsondata['mobile']
console.log(newjsondata)
console.log(mobile)
if (mobile == "") {
window.location.replace("./insertmobile.php");
}
else{
window.location.replace("./cataloguenew.php");
}
}
}
else {
console.log("There is already data in the database")
this.registered = true;
console.log(this.registered)
localStorage.login = jsondata
localStorage.id = this.id
window.location.replace("./cataloguenew.php");
}
})
}
else {
// if isSignedIn and id is null means we dont route them to anything
alert("There is an error in the Sign In process.")
}
})
})
})
},
googleAuthtry() {
let gapi = window.gapi;
let clientId ="616186403576-ofsdqf0tp3r19t60rmflus3l3h9p25vo.apps.googleusercontent.com";
let apiKey ="AIzaSyC0WtHoYqLnGKgaqLWX6RGkiL0X2C7dll8";
let secretClientId = "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";
let discoveryDocs =["https://www.googleapis.com/discovery/v1/apis/oauth2/v2/rest"];
let scope ="https://www.googleapis.com/auth/userinfo.profile";
gapi.load("client:auth2", () => {
gapi.client.init({
apiKey,
clientId,
discoveryDocs,
scope,
secretClientId,
})
.then(() => {
gapi.auth2.getAuthInstance().signIn().then(() => {
var googleAuth = gapi.auth2.getAuthInstance();
googleAuth.isSignedIn.listen(this.GoogleSignIn())
})
})
})
},
}
})
app.component("navbar",{
template: template1,
data() {
return{
links: links1,
isSignedIn: localStorage.getItem("id"),
}
},
methods:{
signOut() {
let gapi = window.gapi;
let clientId ="616186403576-ofsdqf0tp3r19t60rmflus3l3h9p25vo.apps.googleusercontent.com";
let apiKey ="AIzaSyC0WtHoYqLnGKgaqLWX6RGkiL0X2C7dll8";
let secretClientId = "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";
let discoveryDocs =["https://www.googleapis.com/discovery/v1/apis/oauth2/v2/rest"];
let scope ="https://www.googleapis.com/auth/userinfo.profile";
gapi.load("client:auth2", () => {
gapi.client.init({
apiKey,
clientId,
discoveryDocs,
scope,
secretClientId,})
.then(() => {
var GoogleAuthObj = gapi.auth2.getAuthInstance();
this.GoogleAuth = GoogleAuthObj.signOut();
this.isSignedIn = false;
})
})
localStorage.removeItem("login")
localStorage.removeItem("id")
alert("You have been logged out!")
location.reload()
},
}
})
const vm = app.mount('#app');
</script>
</html>