-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
228 lines (185 loc) · 7.2 KB
/
script.js
File metadata and controls
228 lines (185 loc) · 7.2 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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
document.addEventListener("DOMContentLoaded", function(event) {
let body = document.querySelector('body');
let result = document.querySelector('#result');
let dark_mode_btn = document.querySelector('.dark_mode_btn');
let clear = document.querySelector('#clear');
let history = document.querySelector('#history');
let equalTo = document.querySelector('#equalTo');
let delete_single_num = document.querySelector('#delete_single_num');
let Normal_btn = document.querySelectorAll('#Normal_btn');
let initial_value = "";
document.addEventListener('DOMContentLoaded', function() {
const resultElement = document.getElementById('result');
function adjustFontSize() {
if (resultElement.scrollHeight > resultElement.clientHeight || resultElement.scrollWidth > resultElement.clientWidth) {
resultElement.classList.add('shrink-font');
} else {
resultElement.classList.remove('shrink-font');
}
}
adjustFontSize(); // Initially adjust font size
// Check font size on window resize
window.addEventListener('resize', function() {
adjustFontSize();
});
});
Normal_btn.forEach((Normal_btn, index) => {
Normal_btn.addEventListener('click', function() {
let text = this.innerHTML;
initial_value += text;
result.innerHTML = initial_value;
});
});
/*equal to button action*/
equalTo.addEventListener('click', function() {
if (result.innerHTML != "") {
history.innerHTML = result.innerHTML;
// history.innerHTML = `${result.innerHTML} = ${eval(result.innerHTML)}`;
result.innerHTML = eval(result.innerHTML);
initial_value = eval(result.innerHTML);
} else {
alert('please enter any Number');
}
});
/*dark_mode*/
let dark_mode_status = false;
dark_mode_btn.addEventListener('click', function() {
body.classList.toggle('dark_mode_active');
if (dark_mode_status == false) {
this.innerHTML = '<i class="fa fa-sun-o" aria-hidden="true"></i>';
dark_mode_status = true;
} else {
this.innerHTML = '<i class="fa fa-moon-o" aria-hidden="true"></i>';
dark_mode_status = false;
}
});
/*clear all number*/
clear.addEventListener('click', function() {
result.innerHTML = "";
initial_value = "";
});
/*delete single number*/
delete_single_num.addEventListener('click', function() {
result.innerHTML = result.innerHTML.substring(0, result.innerHTML.length - 1);
initial_value = result.innerHTML;
});
});
// JavaScript to add animation when images are in viewport
// Function to handle the intersection observer
function handleIntersection(entries, observer) {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('fade-in');
observer.unobserve(entry.target);
}
});
}
document.addEventListener('DOMContentLoaded', function() {
const images = document.querySelectorAll('.animated-image');
// Create an intersection observer instance
const observer = new IntersectionObserver(handleIntersection, {
root: null,
rootMargin: '0px',
threshold: 0.3 // Adjust this threshold value as needed
});
// Observe each image
images.forEach(image => {
observer.observe(image);
});
});
$(window).scroll(function() {
$('.animated-image').each(function() {
var imagePos = $(this).offset().top;
var windowHeight = $(window).height();
var topOfWindow = $(window).scrollTop();
if (imagePos < topOfWindow + windowHeight - 100) {
$(this).addClass('fade-in');
}
});
});
(function($) {
"use strict";
// Spinner
var spinner = function() {
setTimeout(function() {
if ($('#spinner').length > 0) {
$('#spinner').removeClass('show');
}
}, 1);
};
spinner();
// $(document).ready(function() {
// // Define an array of image paths
// // var imagePaths = ["./img/undraw_mobile_web_-2-g8b.svg", "./img/undraw_website_pl4v.svg", "./img/undraw_website_setup_re_d4y9.svg"];
// var imagePaths = ["./img/img1.png", "./img/img2.png", "./img/img3.png"];
// var currentIndex = 0; // Current index of the image being displayed
// // Function to change the image with fade animation
// function changeImage() {
// // Fade out the current image
// $("#myImage").fadeOut("slow", function() {
// // Change the source attribute of the image to the next image
// $(this).attr("src", imagePaths[currentIndex]);
// // Fade in the new image
// $(this).fadeIn("slow");
// });
// // Increment the index to display the next image in the array
// currentIndex++;
// // If currentIndex exceeds the array length, reset it to 0
// if (currentIndex >= imagePaths.length) {
// currentIndex = 0;
// }
// }
// // Call the changeImage function initially
// changeImage();
// // Set an interval to change the image every 5 seconds (5000 milliseconds)
// setInterval(changeImage, 5000);
// });
// Initiate the wowjs animation library
$(document).ready(function() {
// Show back-to-top button when scrolling down
$(window).scroll(function() {
if ($(this).scrollTop() > 100) {
$('.back-to-top').css('opacity', '1').css('visibility', 'visible');
} else {
$('.back-to-top').css('opacity', '0').css('visibility', 'hidden');
}
});
// Smooth scroll to top when button is clicked
$('.back-to-top').click(function(e) {
e.preventDefault();
$('html, body').animate({
scrollTop: 0
}, 'slow');
});
});
})(jQuery);
document.addEventListener('DOMContentLoaded', function() {
const backToTopButton = document.querySelector('.back-to-top');
// Function to smoothly scroll to the top of the page
function scrollToTop() {
const scrollDuration = 1000; // milliseconds
const scrollStep = -window.scrollY / (scrollDuration / 15);
const scrollInterval = setInterval(function() {
if (window.scrollY !== 0) {
window.scrollBy(0, scrollStep);
} else {
clearInterval(scrollInterval);
}
}, 15);
}
// Add fade-in animation
window.addEventListener('scroll', function() {
if (window.scrollY > 100) {
backToTopButton.style.opacity = '1';
backToTopButton.style.visibility = 'visible';
} else {
backToTopButton.style.opacity = '0';
backToTopButton.style.visibility = 'hidden';
}
});
// Smooth scroll to top when button is clicked
backToTopButton.addEventListener('click', function(e) {
e.preventDefault();
scrollToTop();
});
});