forked from arpit456jain/Amazing-Js-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculatorspage.js
46 lines (41 loc) · 1.23 KB
/
calculatorspage.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
//NavBar
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
//NavBar ends
// scroll to top starts
var scrolltop = $('#scroll-top');
$(window).scroll(function() {
if ($(window).scrollTop() > 80) {
scrolltop.addClass('active');
} else {
scrolltop.removeClass('active');
}
});
scrolltop.on('click', function(e) {
e.preventDefault();
$('html, body').animate({scrollTop:0}, '200');
});
// scroll to top ends
fetch('calculatorspage.json')
.then(response => response.json())
.then(data => {
let links = data;
for (let i = 0; i < links.length; i++) {
console.log(links.length);
let StyleBoxDiv = document.createElement('div');
StyleBoxDiv.innerHTML = `<div class="stylebox">
<div class="image">
<img src="Calculators/${links[i].name}/preview.png" alt="">
</div>
<p>${links[i].name}</p>
<a target="_blank" href="${links[i].link}">View</a>
</div>`;
document.getElementById('styles').appendChild(StyleBoxDiv);
};
});