forked from jaiyankargupta/OCD-Website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
119 lines (94 loc) · 3.45 KB
/
index.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
document.addEventListener('DOMContentLoaded', function () {
const contactForm = document.getElementById('contactForm');
const messageSubmit = document.getElementById('messageSubmit');
const submitButton = contactForm.querySelector('button[type="submit"]');
contactForm.addEventListener('submit', function (event) {
event.preventDefault();
submitButton.style.display = 'none';
messageSubmit.style.display = 'block';
setTimeout(() => {
contactForm.reset();
submitButton.style.display = 'block';
messageSubmit.style.display = 'none';
}, 2000);
});
});
// JS code for valid contact number
var contactNumber = document.getElementById('contactNumber').value;
if (!/^\d{10}$/.test(contactNumber)) {
alert('Please enter a valid 10-digit contact number.');
}
// JS code for Pop-up section
document.addEventListener('DOMContentLoaded', function() {
var popupBanner = document.getElementById('popup-banner');
var closeBtn = document.getElementById('close-btn');
// Function to show the popup banner
function showPopup() {
popupBanner.style.display = 'block';
}
// Function to close the popup banner
window.addEventListener('click', function() {
popupBanner.style.display = 'none';
});
setTimeout(showPopup, 1000);
});
// JS for dark mode toggle button
document.addEventListener('DOMContentLoaded', () => {
const toggleButton = document.getElementById('dark-mode-toggle');
let Count = 0;
toggleButton.addEventListener('click', () => {
Count++;
if (Count % 2 === 0) {
document.body.className = 'light-mode';
toggleButton.textContent = 'Dark Mode';
} else {
document.body.className = 'dark-mode';
toggleButton.textContent = 'Light Mode';
}
});
});
const storebtn=document.getElementById("formbtn");
storebtn.addEventListener("click",()=>{
const name=document.getElementById("name").value;
const email=document.getElementById("email").value;
const message=document.getElementById("message").value;
const contactnumber=document.getElementById("contact").value;
localStorage.setItem("name",name);
localStorage.setItem("email",email);
localStorage.setItem("message",message);
localStorage.setItem("contact",contactnumber);
})
// JS for option to choose between programms
document.addEventListener('DOMContentLoaded', function() {
const popup = document.getElementById('popup');
const closeBtn = document.querySelector('.close');
// Show the popup after a delay (e.g., 1 second)
setTimeout(() => {
popup.style.display = 'block';
}, 1000);
// Close the popup when the user clicks the close button
closeBtn.onclick = function() {
popup.style.display = 'none';
};
// Close the popup when the user clicks anywhere outside of the popup content
window.onclick = function(event) {
if (event.target == popup) {
popup.style.display = 'none';
}
};
});
function selectOption(option) {
let url = '';
switch(option) {
case 'DSA':
url = 'https://example.com/dsa-demo';
break;
case 'CP':
url = 'https://example.com/cp-demo';
break;
case 'JavaScript':
url = 'https://example.com/javascript-demo';
break;
}
window.location.href = url;
}