-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbucket.js
More file actions
74 lines (67 loc) · 1.72 KB
/
bucket.js
File metadata and controls
74 lines (67 loc) · 1.72 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
let login_btn = document.getElementById('login_btn');
let buy_btn = document.getElementById('buy_btn');
let cancel_btn;
login_btn.addEventListener("click", login);
buy_btn.addEventListener("click", buy);
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: 'bucket.php',
type: 'POST',
data: {
user: sessionStorage.getItem("id")
},
success: function (data) {
$("#main").html(data);
cancel_btn = document.getElementById("cancel");
cancel_btn.addEventListener("click", cancel);
},
error: function (e) {
alert(e.reponseText);
}
});
}
function cancel() {
let arr = [];
let str = "";
let check = document.getElementsByName("check");
for (let i = 0; i < check.length; i++) {
if (check[i].checked == true) {
arr.push(check[i].value);
str = str+check[i].value+" ";
}
}
$.ajax({
url: 'bucket_cancel.php',
type: 'POST',
data: {
user: sessionStorage.getItem("id"),
arr: arr
},
success: function (data) {
alert("삭제되었습니다.");
load();
},
error: function (e) {
alert(e.reponseText);
}
});
}
function buy() {
window.open("bucket_buy.html");
}