-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsummary.js
More file actions
50 lines (44 loc) · 1.32 KB
/
summary.js
File metadata and controls
50 lines (44 loc) · 1.32 KB
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
let login_btn = document.getElementById('login_btn');
let write;
login_btn.addEventListener("click", login);
if(sessionStorage.getItem('id') == null) {
login_btn.innerText = "로그인";
} else if (sessionStorage.getItem('id') != "") {
login_btn.innerText = sessionStorage.getItem("name") + "님";
}
load();
function login() {
if (sessionStorage.getItem('id') == "" || sessionStorage.getItem('id') == null) {
location.href = "login.html";
} else {
alert("로그아웃 되었습니다.");
sessionStorage.id = "";
sessionStorage.name = "";
login_btn.innerText = "로그인";
}
}
function load() {
$.ajax({
url: 'summary.php',
type: 'POST',
success: function (data) {
$("#main").html(data);
write = document.getElementById('write');
write.addEventListener('click', callNewPost);
},
error: function (e) {
alert(e.reponseText);
}
});
}
function toBuy(e) {
let w_id = e.target.className;
window.open(`./buying.html?${w_id}`);
}
function callNewPost() {
if(sessionStorage.id != "" && sessionStorage.id != null){
location.href = "newPost.html";
} else {
alert("로그인 후 이용해주세요.");
}
}