
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로
FIREBASE에서 구성 코드 따오고, 기본 골격 다 넣었는데 안되네요. 제가 뭘 잘못 건드린건지 모르겠어요
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>나의 추억앨범</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-4bw+/aepP/YC94hEpVNVgiZdgIC5+VKNBQNGCHeKRQN+PtmoHDEXuppvnDJzQIu9" crossorigin="anonymous">
<style>
@import url('https://fonts.googleapis.com/css2?family=Sunflower:wght@500&display=swap');
* {
font-family: 'Sunflower', sans-serif;
}
.title {
background-image: url(https://images.unsplash.com/photo-1511992243105-2992b3fd0410?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1470&q=80);
background-position: center;
background-size: cover;
height: 250px;
color: white;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.title>button {
margin-top: 20px;
font-weight: bold;
background-color: transparent;
}
.mypostingbox {
width: 500px;
height: 370px;
box-shadow: 0px 0px 3px gray;
border: 1px solid blue;
margin: 20px auto 20px auto;
padding: 20px;
}
.mybtn {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
.mybtn>button {
margin-right: 10px;
}
.mycards {
width: 1200px;
}
</style>
<script type="module">
// Firebase SDK 라이브러리 가져오기
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.22.0/firebase-app.js";
import { getFirestore } from "https://www.gstatic.com/firebasejs/9.22.0/firebase-firestore.js";
import { collection, addDoc } from "https://www.gstatic.com/firebasejs/9.22.0/firebase-firestore.js";
import { getDocs } from "https://www.gstatic.com/firebasejs/9.22.0/firebase-firestore.js";
// Firebase 구성 정보 설정
const firebaseConfig = {
apiKey: "AIzaSyBsEQfd5AOMflyWE9XE2wYb_bjcmk9j0pA",
authDomain: "second-ggantong.firebaseapp.com",
projectId: "second-ggantong",
storageBucket: "second-ggantong.appspot.com",
messagingSenderId: "123858014031",
appId: "1:123858014031:web:719b71c499e6a1a41d3f3a",
measurementId: "G-XGFEGKEMVR"
};
// Firebase 인스턴스 초기화
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
$("#writingpostcard").click(async function () {
let image = $('#image').val();
let title = $('#title').val();
let content = $('#content').val();
let date = $('#date').val();
let doc = {
'image': image,
'title': title,
'content': content,
'date': date
};
await addDoc(collection(db, "albums"), doc);
})
$(document).ready(function () {
let url = "http://spartacodingclub.shop/sparta_api/seoulair";
fetch(url)
.then(res => res.json())
.then(data => {
let temperature = data["RealtimeCityAir"]["row"][0]["IDEX_NM"];
$('#msg').text("오늘의 미세먼지 : " + temperature);
})
})
function openclose() {
$('#postbox').toggle()
}
function writingpostcard() {
let image = $('#image').val();
let title = $('#title').val();
let comment = $('#comment').val();
let date = $('#date').val();
let temp_html = `
<div class="col">
<div class="card">
<img src=${image}
class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">${title}</h5>
<p class="card-text">${comment}</p>
<p class="card-text">${date}</p>
</div>
</div>
</div>
`
$('#mygreatcards').append(temp_html);
}
</script>
</head>
<body>
<div class="title">
<h1>나만의 추억앨범</h1>
<p id="msg">
<button onclick="openclose()" type="button" class="btn btn-outline-light">추억 저장하기</button>
</div>
<div id="postbox" class="mypostingbox">
<div class="form-floating mb-3">
<input type="email" class="form-control" id="image" placeholder="name@example.com">
<label for="floatingInput">앨범 이미지</label>
</div>
<div class="form-floating mb-3">
<input type="email" class="form-control" id="title" placeholder="name@example.com">
<label for="floatingInput">앨범 제목</label>
</div>
<div class="form-floating mb-3">
<input type="email" class="form-control" id="comment" placeholder="name@example.com">
<label for="floatingInput">앨범 내용</label>
</div>
<div class="form-floating mb-3">
<input type="email" class="form-control" id="date" placeholder="name@example.com">
<label for="floatingInput">앨범 날짜</label>
</div>
<div class="mybtn">
<button type="button" class="btn btn-primary" id="writingpostcard">기록하기</button>
<button type="button" class="btn btn-outline-primary">닫기</button>
</div>
</div> 함께 알려주세요.
