-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
139 lines (127 loc) Β· 3.58 KB
/
script.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
function playVideo() {
var userInput = document.getElementById("search-input").value;
var total = calculateTotal(userInput);
var div = calculateDiv(userInput);
var sub = calculateSub(userInput);
var count = countLetters(userInput);
var videoSeven = document.getElementById("videoSeven");
var videoNotSeven = document.getElementById("videoNotSeven");
if (
total === 7 ||
div === 7 ||
sub === 7 ||
count === 7 ||
userInput.toLowerCase() === "thala" ||
userInput.toLowerCase() === "mahi" ||
userInput.toLowerCase() === "dhoni" ||
userInput.toLowerCase() === "msd"
) {
videoNotSeven.currentTime = 0;
videoNotSeven.pause();
videoSeven.style.display = "block";
videoNotSeven.style.display = "none";
videoSeven.play();
videoSeven.currentTime = 0;
if (count === 7) {
showInputWithPlus();
} else {
numText();
}
} else {
videoSeven.currentTime = 0;
videoSeven.pause();
videoSeven.style.display = "none";
videoNotSeven.style.display = "block";
videoNotSeven.play();
aukaat();
videoSeven.currentTime = 0;
}
}
function calculateTotal(input) {
var total = 0;
for (var i = 0; i < input.length; i++) {
if (!isNaN(input[i])) {
total += parseInt(input[i]);
} else {
total += input[i].toLowerCase().charCodeAt(0) - 96;
}
}
return total;
}
function calculateDiv(input) {
var total = 0;
for (var i = 0; i < input.length; i++) {
if (!isNaN(input[i])) {
total /= parseInt(input[i]);
} else {
total /= input[i].toLowerCase().charCodeAt(0) - 96;
}
}
return total;
}
function calculateSub(input) {
var total = 0;
for (var i = 0; i < input.length; i++) {
if (!isNaN(input[i])) {
total -= parseInt(input[i]);
} else {
total -= input[i].toLowerCase().charCodeAt(0) - 96;
}
}
return total;
}
function countLetters(input) {
var lettersOnly = input.replace(/[^a-zA-Z]/g, "");
var numberOfLetters = lettersOnly.length;
return numberOfLetters;
}
function showInputWithPlus() {
var userInput = document.getElementById("search-input").value;
var result = userInput.split("").join("+");
var total = calculateTotal(userInput);
document.getElementById("output").innerText =
result + " = 7 \nTHALA FOR A REASON π";
playVideo(total);
}
function aukaat() {
var userInput = document.getElementById("search-input").value;
var result = userInput.split("").join("+");
var total = calculateTotal(userInput);
document.getElementById("output").innerText =
result + " β 7 \n Aukaat dikha di bhai tumne bhi π";
playVideo(total);
}
function numText() {
var userInput = document.getElementById("search-input").value;
var total = calculateTotal(userInput);
var result = userInput.split("").join("+");
document.getElementById("output").innerText =
result + " = 7\n THALA FOR A REASON π";
playVideo(total);
}
function shareOnWhatsApp() {
window.open(
"https://wa.me/?text=" +
"Check out this amazing fun website!\n" +
encodeURIComponent(document.URL)
);
}
function shareOnFacebook() {
window.open(
"https://www.facebook.com/sharer/sharer.php?u=" +
"Check out this amazing fun website!\n" +
encodeURIComponent(document.URL)
);
}
function shareOnTwitter() {
var currentURL = encodeURIComponent(window.location.href);
window.open(
"https://twitter.com/intent/tweet?url=" +
"Check out this amazing fun website!" +
currentURL
);
}
function shareOnInstagram() {
var instagramDMUrl = "https://www.instagram.com/direct/inbox/";
window.open(instagramDMUrl, "_blank");
}