test_result.ejs
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
<!DOCTYPE html>
<html>
<head>
<title>추천 카트</title>
<link rel="stylesheet" type="text/css" href="test_result.css" />
</head>
<script>
var item = '<%- body %>';
var url = '<%- url %>';
var stritem = item.split(".");
function load() {
return fetch("metadata/kart.json")
.then((response) => response.json())
.then((json) => json.kart);
}
load().then((kart) => {
const div_target = document.querySelector("#total");
var obj = document.createElement('text');
var obj2 = document.createElement('text');
for (var i = 0; i < kart.length; i++) {
if (kart[i]['id'] == stritem[0]) {
obj.id = "text1";
obj2.id = "text2";
obj.innerText = "나에게 맞는 카트는 ";
obj2.innerText = kart[i]['name'];
break;
}
}
div_target.append(obj);
div_target.append(obj2);
});
function Img() {
return url + item;
}
</script>
<body>
<div id="total">
<div id="words">
<img id="imgkey" src="metadata/image/keyword.png">
</div>
<div id="rkart">
<img id="imgId" src="">
<script>document.getElementById("imgId").src = Img()</script>
</div>
<button id="reset" onClick="location.href='/test'">다시하기</button>
<button id="home" onClick="location.href='/'">HOME</button>
</div>
</body>
<script>
var keyword = "<%- keyword %>";
var keyarr = keyword.split(',');
const div_target = document.querySelector("#words");
var i = 0, index = 0;
while (index < 7) {
if (keyarr[index] != "empty") {
var obj = document.createElement('button');
obj.id = "word" + (i + 1);
obj.innerText = '#' + keyarr[index];
div_target.append(obj);
i++;
}
index++;
}
</script>
</html>