Gitlab@Informatics
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
project-melon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
65160381
project-melon
Commits
a7f9072a
Commit
a7f9072a
authored
2 months ago
by
65160381
Browse files
Options
Downloads
Patches
Plain Diff
9.8
parent
803b0bdf
No related branches found
No related tags found
No related merge requests found
Pipeline
#624
passed with warnings
2 months ago
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
public/index.html
+18
-0
18 additions, 0 deletions
public/index.html
with
18 additions
and
0 deletions
public/index.html
+
18
−
0
View file @
a7f9072a
...
@@ -99,6 +99,24 @@
...
@@ -99,6 +99,24 @@
alert
(
`
${
productName
}
added to cart!`
);
alert
(
`
${
productName
}
added to cart!`
);
}
}
async
function
displayUsername
()
{
try
{
const
response
=
await
fetch
(
'
/api/getUser
'
);
// Endpoint to get the user's email
if
(
response
.
status
===
401
)
{
console
.
log
(
'
User not logged in
'
);
document
.
getElementById
(
'
welcome-message
'
).
innerText
=
'
Please log in
'
;
}
else
{
const
user
=
await
response
.
json
();
document
.
getElementById
(
'
welcome-message
'
).
innerText
=
`Welcome,
${
user
.
email
}
`
;
// Display email here
}
}
catch
(
error
)
{
console
.
log
(
'
Error fetching user info:
'
,
error
);
}
}
// เรียกใช้ฟังก์ชันเมื่อหน้าเว็บโหลดเสร็จ
window
.
onload
=
displayUsername
;
// ฟังก์ชันอัปเดตจำนวนสินค้าที่อยู่ในตะกร้า
// ฟังก์ชันอัปเดตจำนวนสินค้าที่อยู่ในตะกร้า
function
updateCart
()
{
function
updateCart
()
{
let
cart
=
JSON
.
parse
(
localStorage
.
getItem
(
'
cart
'
))
||
[];
let
cart
=
JSON
.
parse
(
localStorage
.
getItem
(
'
cart
'
))
||
[];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment