From 79649b897d82da935d09734cd795d14122269ea2 Mon Sep 17 00:00:00 2001 From: Diana Seo Date: Fri, 18 Aug 2023 21:10:00 +0900 Subject: [PATCH 1/5] worked on the JS assignment --- .firebaserc | 5 ++ .gitignore | 66 ++++++++++++++++ firebase.json | 13 ++++ public/404.html | 33 ++++++++ public/index.html | 92 ++++++++++++++++++++++ public/main.css | 28 +++++++ public/picture.html | 181 ++++++++++++++++++++++++++++++++++++++++++++ public/script.js | 165 ++++++++++++++++++++++++++++++++++++++++ public/upload.html | 126 ++++++++++++++++++++++++++++++ script.js | 0 storage.rules | 8 ++ styles.css | 0 12 files changed, 717 insertions(+) create mode 100644 .firebaserc create mode 100644 .gitignore create mode 100644 firebase.json create mode 100644 public/404.html create mode 100644 public/index.html create mode 100644 public/main.css create mode 100644 public/picture.html create mode 100644 public/script.js create mode 100644 public/upload.html create mode 100644 script.js create mode 100644 storage.rules create mode 100644 styles.css diff --git a/.firebaserc b/.firebaserc new file mode 100644 index 000000000..53247c5ac --- /dev/null +++ b/.firebaserc @@ -0,0 +1,5 @@ +{ + "projects": { + "default": "kakaojs-7b84e" + } +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..dbb58ffbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,66 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +firebase-debug.log* +firebase-debug.*.log* + +# Firebase cache +.firebase/ + +# Firebase config + +# Uncomment this if you'd like others to create their own Firebase project. +# For a team working on the same Firebase project(s), it is recommended to leave +# it commented so all members can deploy to the same project(s) in .firebaserc. +# .firebaserc + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env diff --git a/firebase.json b/firebase.json new file mode 100644 index 000000000..534922c8d --- /dev/null +++ b/firebase.json @@ -0,0 +1,13 @@ +{ + "hosting": { + "public": "public", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ] + }, + "storage": { + "rules": "storage.rules" + } +} diff --git a/public/404.html b/public/404.html new file mode 100644 index 000000000..829eda8fd --- /dev/null +++ b/public/404.html @@ -0,0 +1,33 @@ + + + + + + Page Not Found + + + + +
+

404

+

Page Not Found

+

The specified file was not found on this website. Please check the URL for mistakes and try again.

+

Why am I seeing this?

+

This page was generated by the Firebase Command-Line Interface. To modify it, edit the 404.html file in your project's configured public directory.

+
+ + diff --git a/public/index.html b/public/index.html new file mode 100644 index 000000000..72bf3ac69 --- /dev/null +++ b/public/index.html @@ -0,0 +1,92 @@ + + + + + + Document + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/main.css b/public/main.css new file mode 100644 index 000000000..80ddd1327 --- /dev/null +++ b/public/main.css @@ -0,0 +1,28 @@ +.product { + display: flex; + padding: 10px; +} + +.btn:hover { + color: green; + } + +.thumbnail { + max-width: 200px; + width: 100%; + border-radius: 10px; + background-size: cover; + background-position: center; + } + .product .price { + font-size: 16px; + font-weight: 600; + } + .product .title { + font-size: 17px; + font-weight: 600; + } + .product .date { + color: grey; + font-size: 13px; + } diff --git a/public/picture.html b/public/picture.html new file mode 100644 index 000000000..c04a24185 --- /dev/null +++ b/public/picture.html @@ -0,0 +1,181 @@ + + + + + + Document + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/script.js b/public/script.js new file mode 100644 index 000000000..b73711a27 --- /dev/null +++ b/public/script.js @@ -0,0 +1,165 @@ +function script(uid){ + const id = document.getElementById(uid); + const url = "http://localhost:5005/picture.html?"; + console.log(uid); + + const firebaseConfig = { + apiKey: "AIzaSyBLJjgAJr-CPkOMvQ5cXo_7XxRB457ClOY", + authDomain: "kakaojs-7b84e.firebaseapp.com", + projectId: "kakaojs-7b84e", + storageBucket: "kakaojs-7b84e.appspot.com", + messagingSenderId: "225584743925", + appId: "1:225584743925:web:7800682de75fbae054ccbc", + measurementId: "G-NCXB18TBVK" + }; + + // Initialize Firebase + const db = firebase.firestore(); + const storage = firebase.storage(); + + + /*$('#send').click(function(){ + + var file = document.querySelector('#image').files[0]; + var storageRef = storage.ref(); + var route = storageRef.child('image/'+ file.name); + var uploadFile = route.put(file); + + uploadFile.on( 'state_changed', + // 변화시 동작하는 함수 + null, + //에러시 동작하는 함수 + (error) => { + console.error('실패사유는', error); + }, + // 성공시 동작하는 함수 + () => { + uploadFile.snapshot.ref.getDownloadURL().then((url) => { + console.log('업로드된 경로는', url); + var toSave = { + name : $('#name').val(), + email : $('#email').val(), + phonenumber : $('#phonenumber').val(), + image : url + } + db.collection('friends').add(toSave).then((result)=>{ + console.log(result); + window.location.href = '/index.html'; + }).catch((error)=>{ + console.log(error) + }) + }); + } + ); + + + });*/ + //const docRef = doc(db, "cities", "SF"); + console.log(db.collection('friends').get()) + //console.log($('.container').length); + + //$('.container').remove(); + + db.collection('friends').get().then((res) => { + res.forEach((doc) => { + console.log(doc.id, uid); + if (doc.id === uid){ + console.log("inside if") + var template = `

밑에 뜨는 프로필을 수정해주세요! 새로운 이미지를 클릭하고 몇초 뒤에 창이 뜨니 클릭은 꼭! 한번만 해주세요.

+
+ +
+ + `; + /*for (var i = 0; i < $('.container').length; i++){ + console.log("inside for loop"); + $('.container').remove($('.container')[i]); + }*/ + $('.container').append(template); + $('#update').click(function(){ + + var file = document.querySelector('#image').files[0]; + var storageRef = storage.ref(); + var route = storageRef.child('image/'+ file.name); + var uploadFile = route.put(file); + + uploadFile.on( 'state_changed', + // 변화시 동작하는 함수 + null, + //에러시 동작하는 함수 + (error) => { + console.error('실패사유는', error); + }, + // 성공시 동작하는 함수 + () => { + uploadFile.snapshot.ref.getDownloadURL().then((url) => { + console.log('업로드된 경로는', url); + var toSave = { + name : doc.data().name, + email : doc.data().email, + phonenumber : doc.data().phonenumber, + image : url + } + db.collection('friends').doc(doc.id).update(toSave).then((result)=>{ + console.log(result); + window.location.href = '/index.html'; + }).catch((error)=>{ + console.log(error) + }) + }); + } + ); }) + + //console.log("inside update"); + //db.collection('friends').where('email', '==', doc.data().email).delete(); + //route.put(document.querySelector('#image').files[0]) + //firestore.collection("friends").document(doc.id).update("image", imageUri.toString()) + + console.log($('.container')); + } else { + //$('.container').remove(template); + }}) + + + /* var file = document.querySelector('#image').files[0]; + var storageRef = storage.ref(); + var route = storageRef.child('image/'+ file.name); + var uploadFile = route.put(file); + + uploadFile.on( 'state_changed', + // 변화시 동작하는 함수 + null, + //에러시 동작하는 함수 + (error) => { + console.error('실패사유는', error); + }, + // 성공시 동작하는 함수 + () => { + uploadFile.snapshot.ref.getDownloadURL().then((url) => { + console.log('업로드된 경로는', url); + var toSave = { + name : $('#name').val(), + email : $('#email').val(), + phonenumber : $('#phonenumber').val(), + image : url + } + db.collection('friends').add(toSave).then((result)=>{ + console.log(result); + window.location.href = '/index.html'; + }).catch((error)=>{ + console.log(error) + }) + }); + }) + });*/ + }); + + console.log($('.container').length); +}; \ No newline at end of file diff --git a/public/upload.html b/public/upload.html new file mode 100644 index 000000000..61152692f --- /dev/null +++ b/public/upload.html @@ -0,0 +1,126 @@ + + + + + + Document + + + + + + + +
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/script.js b/script.js new file mode 100644 index 000000000..e69de29bb diff --git a/storage.rules b/storage.rules new file mode 100644 index 000000000..4eda34fdf --- /dev/null +++ b/storage.rules @@ -0,0 +1,8 @@ +rules_version = '2'; +service firebase.storage { + match /b/{bucket}/o { + match /{allPaths=**} { + allow read, write: if request.auth!=null; + } + } +} diff --git a/styles.css b/styles.css new file mode 100644 index 000000000..e69de29bb From 3aaa56bfecebb8760def606cb21784cf82ec9a95 Mon Sep 17 00:00:00 2001 From: Diana Seo Date: Fri, 18 Aug 2023 21:31:30 +0900 Subject: [PATCH 2/5] cloned remote repo --- Y_FE_JAVASCRIPT_PICTURE | 1 + 1 file changed, 1 insertion(+) create mode 160000 Y_FE_JAVASCRIPT_PICTURE diff --git a/Y_FE_JAVASCRIPT_PICTURE b/Y_FE_JAVASCRIPT_PICTURE new file mode 160000 index 000000000..914986c97 --- /dev/null +++ b/Y_FE_JAVASCRIPT_PICTURE @@ -0,0 +1 @@ +Subproject commit 914986c97082eb19b6062e2cecbb3d6327860fe7 From 985fcd596659b28c25bdc9864c535cc3e4c96b9d Mon Sep 17 00:00:00 2001 From: Diana Seo Date: Fri, 18 Aug 2023 23:39:22 +0900 Subject: [PATCH 3/5] finished --- public/index.html | 6 ++---- public/main.css | 29 +++++++++++++++++++++-------- public/script.js | 2 +- public/upload.html | 6 ++---- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/public/index.html b/public/index.html index 72bf3ac69..465dc731c 100644 --- a/public/index.html +++ b/public/index.html @@ -17,10 +17,8 @@ diff --git a/public/main.css b/public/main.css index 80ddd1327..057c6c11a 100644 --- a/public/main.css +++ b/public/main.css @@ -3,8 +3,24 @@ padding: 10px; } -.btn:hover { - color: green; +#update { + border-radius: 4px; + background-color: skyblue; + border: none; + color: #FFFFFF; + text-align: center; + font-size: 28px; + padding: 20px; + width: 200px; + transition: all 0.5s; + cursor: pointer; + margin: 5px; + } + + #update:hover { + background-image: linear-gradient(to right, #25aae1, #40e495, #30dd8a, #2bb673); + box-shadow: 0 10px 25px 0 rgba(49, 196, 190, 0.75); + transition: all 1s ease-in-out; } .thumbnail { @@ -14,15 +30,12 @@ background-size: cover; background-position: center; } - .product .price { - font-size: 16px; - font-weight: 600; - } + .product .title { - font-size: 17px; + font-size: 0.7em; font-weight: 600; } .product .date { color: grey; - font-size: 13px; + font-size: 0.5em; } diff --git a/public/script.js b/public/script.js index b73711a27..bc3a1ab9e 100644 --- a/public/script.js +++ b/public/script.js @@ -74,7 +74,7 @@ function script(uid){

${doc.data().phonenumber}

- + `; diff --git a/public/upload.html b/public/upload.html index 61152692f..38065e73f 100644 --- a/public/upload.html +++ b/public/upload.html @@ -17,10 +17,8 @@ From 2f8d70b34762a630b78631ca3fef4c87dbc8cd14 Mon Sep 17 00:00:00 2001 From: Diana Seo Date: Sat, 19 Aug 2023 00:47:23 +0900 Subject: [PATCH 4/5] inside Kakao --- Y_FE_JAVASCRIPT_PICTURE | 1 - public/index.html | 1 - 2 files changed, 2 deletions(-) delete mode 160000 Y_FE_JAVASCRIPT_PICTURE diff --git a/Y_FE_JAVASCRIPT_PICTURE b/Y_FE_JAVASCRIPT_PICTURE deleted file mode 160000 index 914986c97..000000000 --- a/Y_FE_JAVASCRIPT_PICTURE +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 914986c97082eb19b6062e2cecbb3d6327860fe7 diff --git a/public/index.html b/public/index.html index 465dc731c..4ba12957f 100644 --- a/public/index.html +++ b/public/index.html @@ -85,6 +85,5 @@
${doc.data().name}
}) - \ No newline at end of file From 6837399ecd424ef7fc1eb256555efbedb5c46cbd Mon Sep 17 00:00:00 2001 From: Diana Seo Date: Sat, 19 Aug 2023 00:53:10 +0900 Subject: [PATCH 5/5] 1 edit --- public/index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/public/index.html b/public/index.html index 4ba12957f..1b0c31d5d 100644 --- a/public/index.html +++ b/public/index.html @@ -29,7 +29,6 @@ -