This repository has been archived by the owner on Apr 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
160 lines (155 loc) · 5.24 KB
/
app.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
/*=============================
Made With ♥ By Al Nahian
============================*/
// Start Code
// 05 Sep July 2020
// Al Nahian | https://alnahian2003.github.io
// global variables
var yourName = document.getElementById("yourname"),
theirName = document.getElementById("theirname"),
calcBtn = document.querySelector("button"),
yourlovescoreis = document.getElementById("yourlovescoreis"),
loveScore = Math.random() * 100,
loveInfo = document.getElementById("loveinfo"),
reloadBtn = document.getElementById("reload");
loveScore = Math.floor(loveScore) + 1;
//capitalize input values
function capitalize_Words(str) {
return str.replace(/\w\S*/g, function (txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
}
// Love Score Counter
function love() {
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
(async function () {
var i = 0;
while (i < loveScore) {
document.getElementById("score").innerHTML = i + "%";
await sleep(20);
i++;
}
})();
}
// Add eventlistener to button
calcBtn.addEventListener("click", function (e) {
loveScore = Math.random() * 100; //delete this line if you want to keep the same value in the same session.
e.preventDefault();
if (yourName.value == "" && theirName.value == "") {
alert("You can't leave fields empty");
}
if (yourName.value == "") {
alert("Please Enter Your Name");
}
if (theirName.value == "") {
alert("Please Enter His/Her Name");
}
//lovescore conditions
else if (loveScore <= 10) {
yourlovescoreis.innerHTML = "Your Love Score is";
love();
reloadBtn.style.display = "block";
loveInfo.innerHTML =
"<b>You</b> and " +
"<b>" +
capitalize_Words(theirName.value) +
"</b>" +
" love each other like Oil & Water. I'm sorry, but this is not enough for a perfect relationship.";
} else if (loveScore <= 20) {
yourlovescoreis.innerHTML = "Your Love Score is";
love();
reloadBtn.style.display = "block";
loveInfo.innerHTML =
"<b>You</b> and " +
"<b>" +
capitalize_Words(theirName.value) +
"</b>" +
" love each other like Bird & Sky. But need to put a little concentration on your love.";
} else if (loveScore <= 30) {
yourlovescoreis.innerHTML = "Your Love Score is";
love();
reloadBtn.style.display = "block";
loveInfo.innerHTML =
"<b>You</b> and " +
"<b>" +
capitalize_Words(theirName.value) +
"</b>" +
" love each other like Soil & Seed. You should take care of your love more! ";
} else if (loveScore <= 40) {
yourlovescoreis.innerHTML = "Your Love Score is";
love();
reloadBtn.style.display = "block";
loveInfo.innerHTML =
"<b>You</b> and " +
"<b>" +
capitalize_Words(theirName.value) +
"</b>" +
" love each other like Romeo & Juliet. There is no fake things in your love. Go Ahead!";
} else if (loveScore <= 50) {
yourlovescoreis.innerHTML = "Your Love Score is";
love();
reloadBtn.style.display = "block";
loveInfo.innerHTML =
"<b>You</b> and " +
"<b>" +
capitalize_Words(theirName.value) +
"</b>" +
" love each other like Marie & Pierre Curie. That's a good combination. You are a good example of true love.";
} else if (loveScore <= 60) {
yourlovescoreis.innerHTML = "Your Love Score is";
love();
reloadBtn.style.display = "block";
loveInfo.innerHTML =
"<b>You</b> and " +
"<b>" +
capitalize_Words(theirName.value) +
"</b>" +
" love each other like The Earth & The Moon. You cannot live without each other.";
} else if (loveScore <= 70) {
yourlovescoreis.innerHTML = "Your Love Score is";
love();
reloadBtn.style.display = "block";
loveInfo.innerHTML =
"<b>You</b> and " +
"<b>" +
capitalize_Words(theirName.value) +
"</b>" +
" love each other like River & Sea. Spread Love, not Hate.";
} else if (loveScore <= 80) {
yourlovescoreis.innerHTML = "Your Love Score is";
love();
reloadBtn.style.display = "block";
loveInfo.innerHTML =
"<b>You</b> and " +
"<b>" +
capitalize_Words(theirName.value) +
"</b>" +
" love each other like glue. Nothing can seperate you from each other. Love is Forever.";
} else if (loveScore <= 90) {
yourlovescoreis.innerHTML = "Your Love Score is";
love();
reloadBtn.style.display = "block";
loveInfo.innerHTML =
"<b>You</b> and " +
"<b>" +
capitalize_Words(theirName.value) +
"</b>" +
" love each other more than anything in the world! You are the best example of true love.";
} else if (loveScore <= 100) {
yourlovescoreis.innerHTML = "Your Love Score is";
love();
reloadBtn.style.display = "block";
loveInfo.innerHTML =
"<b>You</b> and " +
"<b>" +
capitalize_Words(theirName.value) +
"</b>" +
" love each other like Ertuğrul Gazi & Halime Sultan. You should get married with " +
"<b>" +
capitalize_Words(theirName.value) +
"</b>" +
" very soon. Best of Luck!";
}
});