-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestJs.js
More file actions
71 lines (66 loc) · 2.33 KB
/
testJs.js
File metadata and controls
71 lines (66 loc) · 2.33 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
$("#question").hide();
$("#result").hide();
var num =1;
console.log(num)
var q = {
1: {"title": "첫 번째 질문", "type": "EI", "A": "E", "B": "I"},
2: {"title": "두 번째 질문", "type": "SN", "A": "S", "B": "N"},
3: {"title": "세 번째 질문", "type": "FT", "A": 'F', "B": "T"},
}
var result = {
"ESF":{"mbti":"esf"},
"EST":{"mbti":"est"},
"ENF":{"mbti":"enf"},
"ENT":{"mbti":"est"},
"ISF":{"mbti":"isf"},
"IST":{"mbti":"ist"},
"INF":{"mbti":"inf"},
"INT":{"mbti":"ist"},
}
function start() {
$("#start").hide();
$("#question").show();
next();
}
$("#A").click(function(){
var type=$("#type").val();
var preValue =$("#"+type).val();
$("#"+type).val(parseInt(preValue)+1);
console.log($("#"+type).val(parseInt(preValue)+1));
next();
});
$("#B").click(function(){
next();
});
function next(){
if(num==4){
$("#question").hide();
$("#result").show();
var str="";
($("#EI").val()<1) ? str+="I" : str+="E";
($("#SN").val()<1) ? str+="N" : str+="S";
($("#FT").val()<1) ? str+="T" : str+="F";
$("#mbti").html(result[str]["mbti"]);
}
else{
$(".progress-bar").attr('style',' width: calc(100/3*'+num+'%)');
$("#pgrNum").html(num+'/3');
$("#title").html(q[num]["title"]);
$("#type").val(q[num]["type"]);
$("#A").html(q[num]["A"]);
$("#B").html(q[num]["B"]);
num++;
}
}
// 링크 복사하는 함수
function copy(){
var url = '';
var textarea = document.createElement("textarea");
document.body.appendChild(textarea);
url = window.document.location.href;
textarea.value = url;
textarea.select();
document.execCommand("copy");
document.body.removeChild(textarea);
alert("링크가 복사되었습니다.")
}