-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathencore.js
161 lines (140 loc) · 4.88 KB
/
encore.js
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
//step02
let obj1 = {name:"김수경", age:30};
console.log(obj1.name);
let obj2 = {};
obj2.name = "김혜경";
console.log(obj2.name);
console.log(typeof(obj1));
console.log(typeof(obj2));
console.log(obj1);
console.log(obj1.toString());
console.log(obj1.valueOf());
let obj3 = new Object();
obj3.id = "tester";
console.log(obj3.id);
console.log("-----step03-----");
function client(id){
this.id = id;
this.setId = function(id){
this.id = id;
};
this.getId = function(){
return this.id;
};
}
let obj4 = new client("tester");
console.log(obj4.id);
console.log(obj4.getId());
obj4.setId("me");
console.log(obj4.getId());
obj4.address = "서초";
console.log(obj4.address);
obj4.setAddress = function(address){
this.address = address;
};
obj4.getAddress = function(){
return this.address;
};
console.log(obj4.address);
console.log(obj4.getAddress());
obj4.setAddress("부천");
console.log(obj4.getAddress());
console.log(obj4["address"]);
console.log("---반복문---");
for (let data in obj4){
console.log(data + " : " + obj4[data]);
}
delete obj4.address;
console.log(obj4.address);
//민웅 형님코드 에러 160개박멸
let selectedIndex1 = "";
let selectedIndex2 = "";
let select_text2 = "";
let select_value1 = "";
let select_value2 = "";
let arrSelect = [];
let selectHtml;
function select_form1(){
selectedIndex1 = document.custom.customSelect1.options.selectedIndex;
select_value1 = document.custom.customSelect1.options[selectedIndex1].value;
if (select_value1 != ""){
document.custom.customSelect2.style.display = "inline";
selectDivision(select_value1);
} else if (select_value1 == ""){
document.custom.customSelect2.style.display = "none";
}
}
select_form1();
function select_form2(){
selectedIndex2 = document.custom.customSelect2.options.selectedIndex;
select_text2 = document.custom.customSelect2.options[selectedIndex2].text;
select_value2 = document.custom.customSelect2.options[selectedIndex2].value;
if (select_text2 != ""){
document.custom.customSelect3.style.display = "inline";
selectArea(select_value1, select_value2);
} else if (select_text2 == ""){
document.custom.customSelect3.style.display = "none";
}
}
select_form2();
function selectDivision(guNm) {
let xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
alert(this.responseText);
selectHtml = "<option selected value=\"\">상권형태</option>";
arrSelect = eval(this.responseText);
for (let i = 0; i < arrSelect.length; i++){
selectHtml += "<option value=\"" + arrSelect[i] + "\">" + arrSelect[i] + "</option>";
}
document.getElementById("customSelect2").innerHTML = selectHtml;
}
};
xhttp.open("POST", "CommertialController?command=getSelectDivision&guNm=" + guNm, true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send();
}
function selectArea(guNm, divisionNm) {
let xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
selectHtml = "<option selected value=\"\">상권명</option>";
arrSelect = eval(this.responseText);
for (let i = 0; i < arrSelect.length; i++){
selectHtml += "<option value=\"" + arrSelect[i] + "\">" + arrSelect[i] + "</option>";
}
document.getElementById("customSelect3").innerHTML = selectHtml;
}
};
xhttp.open("POST", "CommertialController?command=getSelectArea&guNm=" + guNm + "&divisionNm=" + divisionNm, true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send();
}
//step 05
let plusNum = (val1, val2) => val1 + val2;
console.log(plusNum(10, 20));
let minusNum = (val1, val2) => val1 - val2;
console.log(minusNum(20, 10));
let numArray = [1, 4, 7, 2, 6, 9, 4, 5, 7, 8, 2];
let charArray = ["ab", "bf", "agh", "fdgr", "avr"];
let devide = numArray.map((v) => {
if (v > 5){
return v = v + "는(은) 5보다 큰 수입니다.";
} else {
return v = v + "는(은) 5보다 작은 수입니다.";
}
});
let b = 0;
let v = 0;
let calculate = numArray.reduce((q, a) => {
if (a > 5){
v += 1;
} else {
b += 1;
}
return "numArray의 숫자들 중 5보다 큰 숫자의 수는" + v + "개이고, 5보다 작은숫자의 수는" + b + "개입니다.";
});
let search = charArray.filter(word => word.includes("a"));
console.log(devide);
console.log(calculate);
console.log("charArray의 a가 포함된 문자열의 개수는" + search.length + "개 입니다.");