diff --git a/express-server/public/javascripts/test.js b/express-server/public/javascripts/test.js
index 86cc2fc5..928d4ede 100644
--- a/express-server/public/javascripts/test.js
+++ b/express-server/public/javascripts/test.js
@@ -1,6 +1,8 @@
$(document).ready(function() {
refresh();
+ userinfo();
+
$(document).on("click", ".btn_detail", function() {
window.location.replace("/shoppinglist_json/" + $(this).closest("tr").attr("id"));
});
@@ -29,32 +31,44 @@ $(document).ready(function() {
}
});
});
+});
- function refresh() {
+function refresh() {
- $("tbody").empty();
+ $("tbody").empty();
- $.ajax({
- type: "GET",
- url: "/myshoppinglists",
- success(data) {
- for(let item of data) {
- $(".tb_myshoppinglists").append("
" + item.name + " | " + item.description +
- " | forward | "
- + "clear |
");
- }
+ $.ajax({
+ type: "GET",
+ url: "/myshoppinglists",
+ success(data) {
+ for(let item of data) {
+ $(".tb_myshoppinglists").append("" + item.name + " | " + item.description +
+ " | forward | "
+ + "clear |
");
}
- });
-
- $.ajax({
- type: "GET",
- url: "/sharedshoppinglists",
- success(data) {
- for(let item of data) {
- $(".tb_sharedshoppinglists").append("" + item.name + " | " + item.description +
- " | forward |
");
- }
+ }
+ });
+
+ $.ajax({
+ type: "GET",
+ url: "/sharedshoppinglists",
+ success(data) {
+ for(let item of data) {
+ $(".tb_sharedshoppinglists").append("" + item.name + " | " + item.description +
+ " | forward |
");
}
- });
- }
-});
\ No newline at end of file
+ }
+ });
+}
+
+function userinfo() {
+ $.ajax({
+ type: "GET",
+ url: "/userinfo_json",
+ success(data) {
+ $(".userinfo").empty();
+ $(".userinfo").append("Logged in as: " + data.profile.displayName);
+ $(".user_img").attr("src", data.profile.photos[0].value);
+ }
+ });
+}
\ No newline at end of file
diff --git a/express-server/routes/index.js b/express-server/routes/index.js
index aa66e5e1..71a7909b 100644
--- a/express-server/routes/index.js
+++ b/express-server/routes/index.js
@@ -134,4 +134,8 @@ router.get("/test1", (req, res) => {
res.render("index1");
});
+router.get("/userinfo_json", (req, res) => {
+ res.send(req.session.passport.user);
+});
+
module.exports = router;
diff --git a/express-server/views/index1.ejs b/express-server/views/index1.ejs
index 1a7d89b6..7c72bc34 100644
--- a/express-server/views/index1.ejs
+++ b/express-server/views/index1.ejs
@@ -12,7 +12,8 @@
-
Logged in as: testuser1
+
Logged in as: testuser1
+